root/galaxy-central/scripts/test_dist_egg.py

リビジョン 2, 1.6 KB (コミッタ: hatakeyama, 14 年 前)

import galaxy-central

行番号 
1#!/usr/bin/env python
2"""
3A crude script for minimal "testing" of dist eggs (require and import).  It may
4not work on all zipped eggs.  It may be easiest to just customize this script
5for whatever egg you want to test.
6
7usage: test_dist_egg.py <egg_name>
8"""
9import os, sys, logging, subprocess
10
11try:
12    assert sys.argv[1]
13except:
14    print __doc__
15    sys.exit( 1 )
16
17lib = os.path.abspath( os.path.join( os.path.dirname( __file__ ), '..', 'lib' ) )
18sys.path.insert( 0, lib )
19
20if sys.argv[1].endswith( '.egg' ):
21
22    egg = sys.argv[1]
23    egg_name = os.path.basename( egg ).split( '-' )[0]
24    sys.path.insert( 0, egg )
25
26    import pkg_resources
27    pkg_resources.require( egg_name )
28    provider = pkg_resources.get_provider( egg_name )
29    importables = provider.get_metadata('top_level.txt').splitlines()
30
31    for importable in importables:
32        mod = __import__( importable )
33        assert os.path.dirname( mod.__path__[0] ) == os.path.dirname( provider.module_path )
34        print "OK"
35
36    sys.exit( 0 )
37
38else:
39
40    build_dir = os.path.join( os.path.dirname( os.path.abspath( __file__ ) ), 'scramble', 'build' )
41    if os.path.exists( build_dir ):
42        raise Exception( 'Build dir must be removed before testing: %s' % build_dir )
43
44    name = sys.argv[1]
45
46    from galaxy.eggs.dist import DistScrambleCrate
47   
48    c = DistScrambleCrate()
49   
50    for egg in c[name]:
51        print 'Checking %s %s for %s on %s' % ( name, egg.version, egg.platform, egg.build_host )
52        p = subprocess.Popen( 'ssh %s %s %s %s %s' % ( egg.build_host, egg.python, os.path.abspath( __file__ ), egg.distribution.location, egg.platform ), shell=True )
53        p.wait()
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。