root/galaxy-central/eggs/GeneTrack-2.0.0_beta_1_dev_48da9e998f0caf01c5be731e926f4b0481f658f0-py2.6.egg/genetrack/conf.py @ 3

リビジョン 3, 2.9 KB (コミッタ: kohda, 14 年 前)

Install Unix tools  http://hannonlab.cshl.edu/galaxy_unix_tools/galaxy.html

行番号 
1"""
2Configuration namespace.
3
4
5"""
6import sys, os, shutil
7import logger
8
9# Python version check
10if sys.version_info < (2, 5):
11    logger.error( 'genetrack requires python 2.5 or higher' )
12    sys.exit()
13
14def path_join(*args):
15    "Builds absolute path"
16    return os.path.abspath(os.path.join(*args))
17
18# set up paths relative to the location of this file
19curr_dir = os.path.dirname( __file__ )
20BASE_DIR = path_join( curr_dir, '..' )
21TEST_DIR = path_join( BASE_DIR, 'tests' )
22TEST_DATA_DIR = path_join( TEST_DIR, 'testdata' )
23TEMP_DATA_DIR = path_join( TEST_DIR, 'tempdir' )
24COVERAGE_DIR = path_join( TEST_DIR, 'coverage' )
25
26
27def module_check(names, loglevel, exit=True):
28    "Verifies that required modules are present"
29
30    # required modules
31    errflag = False
32   
33
34    loglevel = loglevel
35    for name in names:
36        try:
37            __import__(name)
38        except ImportError, exc:
39            if not errflag:
40                loglevel('Software requirements not met!')
41                loglevel('See http://genetrack.bx.psu.edu for installation instructions')
42                loglevel('-' * 20)
43                errflag = True
44            loglevel('missing module: %s' % name)
45   
46    # missing dependecies
47    if exit and errflag:
48        sys.exit()
49
50
51def version_check():
52    # verify some of the versions
53    module_versions = [ ('tables', '2.0'), ('numpy', '1.1') ]
54    for name, version in module_versions:
55        try:
56            mod = __import__(name)
57            if mod.__version__ < version:
58                raise Exception('%s of version %s or higher is required' % (name, version))
59        except Exception, exc:
60            logger.error( str(exc) )
61            sys.exit()
62
63#perform the module check   
64required = ( 'numpy', 'tables', )
65module_check( required, loglevel=logger.error )
66version_check()
67
68def check_server():
69    "Checks for modules that are required to run the server"
70    optional = ( 'django', 'pychartdir', 'Image' )
71    module_check( optional, loglevel=logger.error )
72
73try:
74    # monkeypath pytables to disable the Natural Name warning
75    import re
76    from tables import path
77    path._pythonIdRE = re.compile('.')
78except:
79    logger.warn( 'could not patch the Natural Name warning' )
80
81def reset_dir(path):
82    "Resets a directory path"
83    if os.path.isdir( path ):
84        shutil.rmtree( path)
85        os.mkdir( path )
86
87# create the temporary data directory if not present
88if not os.path.isdir( TEMP_DATA_DIR ):
89    os.mkdir( TEMP_DATA_DIR )
90
91def testdata(*args, **kwds):
92    "Generates paths to test data"
93    path = path_join(TEST_DATA_DIR, *args)
94    if 'verify' in kwds:
95        if not os.path.isfile(path):
96            raise IOError("file '%s' not found" % path )
97    return path
98
99def tempdata(*args):
100    "Generates paths to temporary data"
101    return path_join(TEMP_DATA_DIR, *args)
102
103def test(verbose=0):
104    "Performs module level testing"
105    import doctest
106    doctest.testmod( verbose=verbose )
107
108if __name__ == "__main__":
109    test()
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。