SysPaths.py revision 2931
12221SN/A# Copyright (c) 2006 The Regents of The University of Michigan 22221SN/A# All rights reserved. 32221SN/A# 42221SN/A# Redistribution and use in source and binary forms, with or without 52221SN/A# modification, are permitted provided that the following conditions are 62221SN/A# met: redistributions of source code must retain the above copyright 72221SN/A# notice, this list of conditions and the following disclaimer; 82221SN/A# redistributions in binary form must reproduce the above copyright 92221SN/A# notice, this list of conditions and the following disclaimer in the 102221SN/A# documentation and/or other materials provided with the distribution; 112221SN/A# neither the name of the copyright holders nor the names of its 122221SN/A# contributors may be used to endorse or promote products derived from 132221SN/A# this software without specific prior written permission. 142221SN/A# 152221SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 162221SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 172221SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 182221SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 192221SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 202221SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 212221SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 222221SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 232221SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 242221SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 252221SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 262221SN/A# 272665Ssaidi@eecs.umich.edu# Authors: Ali Saidi 282665Ssaidi@eecs.umich.edu 292665Ssaidi@eecs.umich.eduimport os, sys 302221SN/Afrom os.path import isdir, join as joinpath 312221SN/Afrom os import environ as env 323415Sgblack@eecs.umich.edu 333415Sgblack@eecs.umich.edudef disk(file): 342223SN/A system() 353415Sgblack@eecs.umich.edu return joinpath(disk.dir, file) 368778Sgblack@eecs.umich.edu 373578Sgblack@eecs.umich.edudef binary(file): 383415Sgblack@eecs.umich.edu system() 393415Sgblack@eecs.umich.edu return joinpath(binary.dir, file) 408750Sgblack@eecs.umich.edu 413415Sgblack@eecs.umich.edudef script(file): 422680Sktlim@umich.edu system() 433415Sgblack@eecs.umich.edu return joinpath(script.dir, file) 442800Ssaidi@eecs.umich.edu 458750Sgblack@eecs.umich.edudef system(): 462221SN/A if not system.dir: 473415Sgblack@eecs.umich.edu try: 483415Sgblack@eecs.umich.edu path = env['M5_PATH'].split(':') 492223SN/A except KeyError: 502221SN/A path = [ '/dist/m5/system', '/n/poolfs/z/dist/m5/system' ] 512221SN/A 523573Sgblack@eecs.umich.edu for system.dir in path: 533576Sgblack@eecs.umich.edu if os.path.isdir(system.dir): 543576Sgblack@eecs.umich.edu break 552221SN/A else: 563573Sgblack@eecs.umich.edu raise ImportError, "Can't find a path to system files." 573576Sgblack@eecs.umich.edu 583576Sgblack@eecs.umich.edu if not binary.dir: 592221SN/A binary.dir = joinpath(system.dir, 'binaries') 603573Sgblack@eecs.umich.edu if not disk.dir: 613576Sgblack@eecs.umich.edu disk.dir = joinpath(system.dir, 'disks') 623576Sgblack@eecs.umich.edu if not script.dir: 632221SN/A script.dir = joinpath(system.dir, 'boot') 643573Sgblack@eecs.umich.edu 653576Sgblack@eecs.umich.edusystem.dir = None 663576Sgblack@eecs.umich.edubinary.dir = None 672221SN/Adisk.dir = None 683573Sgblack@eecs.umich.eduscript.dir = None 693576Sgblack@eecs.umich.edu