diff toolRPViz.py @ 29:d854b21ada0c draft

planemo upload commit c56eddc745b70354680c2a2b605840ed72bb98ef
author pablocarb
date Wed, 07 Aug 2019 05:13:27 -0400
parents b30e3e5ee8f8
children
line wrap: on
line diff
--- a/toolRPViz.py	Fri Aug 02 05:27:32 2019 -0400
+++ b/toolRPViz.py	Wed Aug 07 05:13:27 2019 -0400
@@ -13,6 +13,7 @@
 import os
 import json
 import tarfile
+import shutil
 
 def arguments():
     parser = argparse.ArgumentParser(description='toolRPViz: Pathway visualizer. Pablo Carbonell, SYNBIOCHEM, 2019')
@@ -39,13 +40,13 @@
     print( res )
     
 def pathwayUpload( arg ):
-    files = { 'file': open(arg.infile, 'rb' ) }
+    # Post request
     data = {'selenzyme_table': arg.selenzyme_table, 'input_format': arg.input_format}
+    files = { 'file': open(arg.infile, 'rb' ), 'data': ('data.json', json.dumps(data)) }
     print('Sending query to '+arg.server)
-    r=requests.post( arg.server+'/Query',files=files,data=data )
-    if arg.outfolder is None:
-        arg.outfolder = os.path.dirname( arg.outfile )
-    if not os.path.exists(outfolder):
+    r=requests.post(arg.server+'/Query',files=files)
+    # Read response
+    if not os.path.exists(arg.outfolder):
         os.mkdir(arg.outfolder)
     outtar = os.path.join( arg.outfolder, 'out.tar' )
     open(outtar,'wb').write( r.content )
@@ -53,7 +54,7 @@
     tar = tarfile.open(outtar)
     tar.extractall(path=arg.outfolder)
     html = os.path.join( arg.outfolder, 'index.html' )
-    shutil.cp( html, arg.outfile )  
+    shutil.copy( html, arg.outfile )  
     print( 'Files extracted' )