9
|
1 import os
|
|
2 import subprocess
|
|
3
|
|
4 def find_packages(prefix="package_r_"):
|
|
5 """
|
|
6 """
|
|
7 #locate env.sh | grep -i package_r_
|
|
8 #/data/extended/galaxyJune14_2014/tool_dependency/readline/6.2/devteam/package_r_2_15_0/8ab0d08a3da1/env.sh
|
|
9 #/data/home/rlazarus/galaxy/tool_dependency_dir/R_3_1_1/3.1.1/fubar/package_r_3_1_1/5f1b8d22140a/env.sh
|
|
10 #/data/home/rlazarus/galaxy/tool_dependency_dir/R_3_1_1/3.1.1/fubar/package_r_3_1_1/d9964efbfbe3/env.sh
|
|
11 #/data/home/rlazarus/galtest/tool_dependency_dir/R_3_1_1/3.1.1/fubar/package_r_3_1_1/63cdb9b2234c/env.sh
|
|
12 eprefix = prefix
|
|
13 if prefix.find('/') <> -1:
|
|
14 eprefix = prefix.replace('/','\/') # for grep
|
|
15 cl = ['locate env.sh | grep -i %s' % eprefix,]
|
|
16 p = subprocess.Popen(cl, stdout=subprocess.PIPE, stderr=subprocess.PIPE,shell=True)
|
|
17 out, err = p.communicate()
|
|
18 fpaths = out.split('\n')
|
|
19 fpaths = [x for x in fpaths if len(x) > 1]
|
|
20 fver = [x.split(os.path.sep)[-4:-1] for x in fpaths]
|
|
21 # >>> foo.split(os.path.sep)[-4:-1]
|
|
22 # ['fubar', 'package_r_3_1_1', '63cdb9b2234c']
|
|
23 res = [['%s rev %s owner %s' % (x[1],x[2],x[0]),fpaths[i],False] for i,x in enumerate(fver)]
|
|
24 res.insert(0,['Use default (system) interpreter','system',False])
|
|
25 if len(res) > 1:
|
|
26 res[1][2] = True # selected if more than one
|
|
27 # return a triplet - user_sees,value,selected - all unselected if False
|
|
28 return res
|
|
29
|
|
30 if __name__ == "__main__":
|
|
31 print find_packages()
|