annotate getlocalrpackages.py @ 9:ce5ec1d989fd draft

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