20
|
1 import os
|
|
2 import subprocess
|
|
3 import sys
|
|
4
|
|
5
|
|
6 def find_packages(prefix="package_r_"):
|
|
7 """
|
|
8 """
|
|
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
|
|
14 eprefix = prefix
|
|
15 if prefix.find('/') <> -1:
|
|
16 eprefix = prefix.replace('/','\/') # for grep
|
|
17 path = '.'
|
|
18 # fails on nitesh's recent mac - locate not working
|
|
19 # 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)
|
|
22 out, err = p.communicate()
|
|
23 fpaths = out.split('\n')
|
|
24 fpaths = [x for x in fpaths if len(x) > 1]
|
|
25 fver = [x.split(os.path.sep)[-4:-1] for x in fpaths]
|
|
26 # >>> foo.split(os.path.sep)[-4:-1]
|
|
27 # ['fubar', 'package_r_3_1_1', '63cdb9b2234c']
|
|
28 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.insert(0,['Use default (system) interpreter','system',False])
|
|
31 else:
|
|
32 res = [['Use default (system) interpreter','system',False],
|
21
|
33 ['**WARNING** NO package env.sh files found - is the "find" system command working? Are any interpreters installed?','system',True]]
|
20
|
34 if len(res) > 2:
|
|
35 res[1][2] = True # selected if more than one
|
|
36 # return a triplet - user_sees,value,selected - all unselected if False
|
|
37 return res
|
|
38
|
|
39 def testapi():
|
|
40 host_url = 'http://localhost:8080'
|
|
41 new_path = [ os.path.join( os.getcwd(), "lib" ) ]
|
|
42 new_path.extend( sys.path[1:] ) # remove scripts/ from the path
|
|
43 sys.path = new_path
|
|
44 from galaxy import config
|
|
45 aconfig = config.Configuration( )
|
|
46 M_A_K = aconfig.master_api_key
|
|
47 tooldeps = aconfig.tool_dependency_dir
|
|
48 gi = GalaxyInstance(url=host_url, key=M_A_K)
|
|
49
|
|
50
|
|
51 if __name__ == "__main__":
|
|
52 print find_packages()
|
|
53
|