SysPaths.py revision 2931
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
332902SN/Adef disk(file):
342902SN/A    system()
352902SN/A    return joinpath(disk.dir, file)
362566SN/A
372902SN/Adef binary(file):
382902SN/A    system()
392902SN/A    return joinpath(binary.dir, file)
402902SN/A
412902SN/Adef script(file):
422902SN/A    system()
432902SN/A    return joinpath(script.dir, file)
442902SN/A
452902SN/Adef system():
462902SN/A    if not system.dir:
472774SN/A        try:
482774SN/A                path = env['M5_PATH'].split(':')
492774SN/A        except KeyError:
502784SN/A                path = [ '/dist/m5/system', '/n/poolfs/z/dist/m5/system' ]
512566SN/A
522902SN/A        for system.dir in path:
532902SN/A            if os.path.isdir(system.dir):
542774SN/A                break
552774SN/A        else:
562774SN/A            raise ImportError, "Can't find a path to system files."
572566SN/A
582902SN/A    if not binary.dir:
592902SN/A        binary.dir = joinpath(system.dir, 'binaries')
602902SN/A    if not disk.dir:
612902SN/A        disk.dir = joinpath(system.dir, 'disks')
622902SN/A    if not script.dir:
632902SN/A        script.dir = joinpath(system.dir, 'boot')
642566SN/A
652902SN/Asystem.dir = None
662902SN/Abinary.dir = None
672902SN/Adisk.dir = None
682902SN/Ascript.dir = None
69