annotate getlocalrpackages.py @ 22:4e3aa95ed3ac draft

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