|
1 | 1 | import os |
2 | 2 | import subprocess |
3 | | -import sys |
4 | 3 |
|
5 | 4 |
|
6 | 5 | def find_packages(prefix="package_r_"): |
7 | 6 | """ |
8 | 7 | """ |
9 | | - #locate env.sh | grep -i package_r_ |
10 | | - #/data/extended/galaxyJune14_2014/tool_dependency/readline/6.2/devteam/package_r_2_15_0/8ab0d08a3da1/env.sh |
11 | | - #/data/home/rlazarus/galaxy/tool_dependency_dir/R_3_1_1/3.1.1/fubar/package_r_3_1_1/5f1b8d22140a/env.sh |
12 | | - #/data/home/rlazarus/galaxy/tool_dependency_dir/R_3_1_1/3.1.1/fubar/package_r_3_1_1/d9964efbfbe3/env.sh |
13 | | - #/data/home/rlazarus/galtest/tool_dependency_dir/R_3_1_1/3.1.1/fubar/package_r_3_1_1/63cdb9b2234c/env.sh |
| 8 | + # locate env.sh | grep -i package_r_ |
| 9 | + # /data/extended/galaxyJune14_2014/tool_dependency/readline/6.2/devteam/package_r_2_15_0/8ab0d08a3da1/env.sh |
| 10 | + # /data/home/rlazarus/galaxy/tool_dependency_dir/R_3_1_1/3.1.1/fubar/package_r_3_1_1/5f1b8d22140a/env.sh |
| 11 | + # /data/home/rlazarus/galaxy/tool_dependency_dir/R_3_1_1/3.1.1/fubar/package_r_3_1_1/d9964efbfbe3/env.sh |
| 12 | + # /data/home/rlazarus/galtest/tool_dependency_dir/R_3_1_1/3.1.1/fubar/package_r_3_1_1/63cdb9b2234c/env.sh |
14 | 13 | eprefix = prefix |
15 | 14 | if prefix.find('/') != -1: |
16 | | - eprefix = prefix.replace('/','\/') # for grep |
| 15 | + eprefix = prefix.replace('/', '\/') # for grep |
17 | 16 | path = '.' |
18 | | - # fails on nitesh's recent mac - locate not working |
| 17 | + # fails on nitesh's recent mac - locate not working |
19 | 18 | # cl = ['locate env.sh | grep -i %s' % eprefix,] |
20 | | - cl = ['find %s -iname "env.sh" | grep -i %s' % (path,eprefix),] |
21 | | - p = subprocess.Popen(cl, stdout=subprocess.PIPE, stderr=subprocess.PIPE,shell=True) |
| 19 | + cl = ['find %s -iname "env.sh" | grep -i %s' % (path, eprefix), ] |
| 20 | + p = subprocess.Popen(cl, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) |
22 | 21 | out, err = p.communicate() |
23 | 22 | fpaths = out.split('\n') |
24 | 23 | fpaths = [x for x in fpaths if len(x) > 1] |
25 | 24 | fver = [x.split(os.path.sep)[-4:-1] for x in fpaths] |
26 | 25 | # >>> foo.split(os.path.sep)[-4:-1] |
27 | 26 | # ['fubar', 'package_r_3_1_1', '63cdb9b2234c'] |
28 | 27 | if len(fpaths) > 0: |
29 | | - res = [['%s rev %s owner %s' % (x[1],x[2],x[0]),fpaths[i],False] for i,x in enumerate(fver)] |
30 | | - res[0][2] = True # selected if more than one |
31 | | - res.insert(0,['Use default (system) interpreter','system',False]) |
| 28 | + res = [['%s rev %s owner %s' % (x[1], x[2], x[0]), fpaths[i], False] for i, x in enumerate(fver)] |
| 29 | + res[0][2] = True # selected if more than one |
| 30 | + res.insert(0, ['Use default (system) interpreter', 'system', False]) |
32 | 31 | else: |
33 | | - res = [['Use default (system) interpreter','system',True], |
34 | | - ['**WARNING** NO package env.sh files found - is the "find" system command working? Are any interpreters installed?','system',False]] |
| 32 | + res = [['Use default (system) interpreter', 'system', True], |
| 33 | + ['**WARNING** NO package env.sh files found - is the "find" system command working? Are any interpreters installed?', 'system', False]] |
35 | 34 | # return a triplet - user_sees,value,selected - all unselected if False |
36 | 35 | return res |
37 | 36 |
|
38 | | -def testapi(): |
39 | | - host_url = 'http://localhost:8080' |
40 | | - new_path = [ os.path.join( os.getcwd(), "lib" ) ] |
41 | | - new_path.extend( sys.path[1:] ) # remove scripts/ from the path |
42 | | - sys.path = new_path |
43 | | - from galaxy import config |
44 | | - aconfig = config.Configuration( ) |
45 | | - M_A_K = aconfig.master_api_key |
46 | | - tooldeps = aconfig.tool_dependency_dir |
47 | | - gi = GalaxyInstance(url=host_url, key=M_A_K) |
48 | | - |
49 | 37 |
|
50 | 38 | if __name__ == "__main__": |
51 | 39 | print(find_packages()) |
52 | | - |
0 commit comments