1# Copyright (c) 2006 The Regents of The University of Michigan 2# All rights reserved. 3# 4# Redistribution and use in source and binary forms, with or without 5# modification, are permitted provided that the following conditions are 6# met: redistributions of source code must retain the above copyright 7# notice, this list of conditions and the following disclaimer; 8# redistributions in binary form must reproduce the above copyright --- 19 unchanged lines hidden (view full) --- 28 29import os, sys 30from os.path import isdir, join as joinpath 31from os import environ as env 32 33config_path = os.path.dirname(os.path.abspath(__file__)) 34config_root = os.path.dirname(config_path) 35 |
36def searchpath(path, file): 37 for p in path: 38 f = joinpath(p, file) 39 if os.path.exists(f): 40 return f 41 raise IOError, "Can't find file '%s' on path." % file 42 |
43def disk(file): 44 system() |
45 return searchpath(disk.path, file) |
46 47def binary(file): 48 system() |
49 return searchpath(binary.path, file) |
50 51def script(file): 52 system() |
53 return searchpath(script.path, file) |
54 55def system(): |
56 if not system.path: |
57 try: |
58 path = env['M5_PATH'].split(':') |
59 except KeyError: |
60 path = [ '/dist/m5/system', '/n/poolfs/z/dist/m5/system' ] |
61 |
62 # filter out non-existent directories 63 system.path = filter(os.path.isdir, path) |
64 |
65 if not system.path: 66 raise IOError, "Can't find a path to system files." |
67 |
68 if not binary.path: 69 binary.path = [joinpath(p, 'binaries') for p in system.path] 70 if not disk.path: 71 disk.path = [joinpath(p, 'disks') for p in system.path] 72 if not script.path: 73 script.path = [joinpath(config_root, 'boot')] 74 75system.path = None 76binary.path = None 77disk.path = None 78script.path = None |