Mercurial > repos > iuc > tool_factory_2
comparison getlocalrpackages.py @ 0:2ac21c27018a draft default tip
Uploaded
| author | iuc |
|---|---|
| date | Tue, 07 Apr 2015 10:29:55 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:2ac21c27018a |
|---|---|
| 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[0][2] = True # selected if more than one | |
| 31 res.insert(0,['Use default (system) interpreter','system',False]) | |
| 32 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]] | |
| 35 # return a triplet - user_sees,value,selected - all unselected if False | |
| 36 return res | |
| 37 | |
| 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 | |
| 50 if __name__ == "__main__": | |
| 51 print find_packages() | |
| 52 |
