SysPaths.py revision 3510
12931Sktlim@umich.edu# Copyright (c) 2006 The Regents of The University of Michigan 22931Sktlim@umich.edu# All rights reserved. 32931Sktlim@umich.edu# 42931Sktlim@umich.edu# Redistribution and use in source and binary forms, with or without 52931Sktlim@umich.edu# modification, are permitted provided that the following conditions are 62931Sktlim@umich.edu# met: redistributions of source code must retain the above copyright 72931Sktlim@umich.edu# notice, this list of conditions and the following disclaimer; 82931Sktlim@umich.edu# redistributions in binary form must reproduce the above copyright 92931Sktlim@umich.edu# notice, this list of conditions and the following disclaimer in the 102931Sktlim@umich.edu# documentation and/or other materials provided with the distribution; 112931Sktlim@umich.edu# neither the name of the copyright holders nor the names of its 122931Sktlim@umich.edu# contributors may be used to endorse or promote products derived from 132931Sktlim@umich.edu# this software without specific prior written permission. 142931Sktlim@umich.edu# 152931Sktlim@umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 162931Sktlim@umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 172931Sktlim@umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 182931Sktlim@umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 192931Sktlim@umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 202931Sktlim@umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 212931Sktlim@umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 222931Sktlim@umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 232931Sktlim@umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 242931Sktlim@umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 252931Sktlim@umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 262931Sktlim@umich.edu# 272931Sktlim@umich.edu# Authors: Ali Saidi 282931Sktlim@umich.edu 292774SN/Aimport os, sys 302774SN/Afrom os.path import isdir, join as joinpath 312774SN/Afrom os import environ as env 322566SN/A 333510Shsul@eecs.umich.educonfig_path = os.path.dirname(os.path.abspath(__file__)) 343510Shsul@eecs.umich.educonfig_root = os.path.dirname(config_path) 353510Shsul@eecs.umich.edu 362902SN/Adef disk(file): 372902SN/A system() 382902SN/A return joinpath(disk.dir, file) 392566SN/A 402902SN/Adef binary(file): 412902SN/A system() 422902SN/A return joinpath(binary.dir, file) 432902SN/A 442902SN/Adef script(file): 452902SN/A system() 462902SN/A return joinpath(script.dir, file) 472902SN/A 482902SN/Adef system(): 492902SN/A if not system.dir: 502774SN/A try: 512774SN/A path = env['M5_PATH'].split(':') 522774SN/A except KeyError: 532784SN/A path = [ '/dist/m5/system', '/n/poolfs/z/dist/m5/system' ] 542566SN/A 552902SN/A for system.dir in path: 562902SN/A if os.path.isdir(system.dir): 572774SN/A break 582774SN/A else: 592774SN/A raise ImportError, "Can't find a path to system files." 602566SN/A 612902SN/A if not binary.dir: 622902SN/A binary.dir = joinpath(system.dir, 'binaries') 632902SN/A if not disk.dir: 642902SN/A disk.dir = joinpath(system.dir, 'disks') 652902SN/A if not script.dir: 663510Shsul@eecs.umich.edu script.dir = joinpath(config_root, 'boot') 672566SN/A 682902SN/Asystem.dir = None 692902SN/Abinary.dir = None 702902SN/Adisk.dir = None 712902SN/Ascript.dir = None 72