mailr17603 - in /trunk: auto_analyses/stereochem_analysis.py generic_fns/dasha.py generic_fns/palmer.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on September 28, 2012 - 17:28:
Author: bugman
Date: Fri Sep 28 17:28:11 2012
New Revision: 17603

URL: http://svn.gna.org/viewcvs/relax?rev=17603&view=rev
Log:
Python 3 preparations - all os.popen3() instances in relax have been replaced 
by the subprocess module.


Modified:
    trunk/auto_analyses/stereochem_analysis.py
    trunk/generic_fns/dasha.py
    trunk/generic_fns/palmer.py

Modified: trunk/auto_analyses/stereochem_analysis.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/auto_analyses/stereochem_analysis.py?rev=17603&r1=17602&r2=17603&view=diff
==============================================================================
--- trunk/auto_analyses/stereochem_analysis.py (original)
+++ trunk/auto_analyses/stereochem_analysis.py Fri Sep 28 17:28:11 2012
@@ -57,10 +57,11 @@
 
 # Python module imports.
 from math import pi, sqrt
-from os import F_OK, access, getcwd, popen3, sep
+from os import F_OK, access, getcwd, sep
 from random import randint
 from re import search
 from string import split
+from subprocess import PIPE, Popen
 import sys
 
 # relax module imports.
@@ -768,32 +769,32 @@
                     continue
 
                 # Open the Molmol pipe.
-                stdin, stdout, stderr = popen3("molmol -t -f -", 'w', 0)
+                pipe = Popen("molmol -t -f -", shell=True, stdin=PIPE, 
stdout=PIPE, stderr=PIPE, close_fds=False)
 
                 # Init all.
-                stdin.write("InitAll yes\n")
+                pipe.stdin.write("InitAll yes\n")
 
                 # Read the PDB.
-                stdin.write("ReadPdb " + self.results_dir+sep+file_in + "\n")
+                pipe.stdin.write("ReadPdb " + self.results_dir+sep+file_in + 
"\n")
 
                 # Fitting to mean.
-                stdin.write("Fit to_first 'selected'\n")
-                stdin.write("Fit to_mean 'selected'\n")
+                pipe.stdin.write("Fit to_first 'selected'\n")
+                pipe.stdin.write("Fit to_mean 'selected'\n")
 
                 # Write the result.
-                stdin.write("WritePdb " + self.results_dir+sep+file_out + 
"\n")
+                pipe.stdin.write("WritePdb " + self.results_dir+sep+file_out 
+ "\n")
 
                 # End Molmol.
-                stdin.close()
+                pipe.stdin.close()
 
                 # Get STDOUT and STDERR.
-                sys.stdout.write(stdout.read())
+                sys.stdout.write(pipe.stdout.read())
                 if self.log:
-                    log.write(stderr.read())
+                    log.write(pipe.stderr.read())
 
                 # Close the pipe.
-                stdout.close()
-                stderr.close()
+                pipe.stdout.close()
+                pipe.stderr.close()
 
                 # Open the superimposed file in relax.
                 self.interpreter.reset()

Modified: trunk/generic_fns/dasha.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/generic_fns/dasha.py?rev=17603&r1=17602&r2=17603&view=diff
==============================================================================
--- trunk/generic_fns/dasha.py (original)
+++ trunk/generic_fns/dasha.py Fri Sep 28 17:28:11 2012
@@ -24,8 +24,9 @@
 
 # Python module imports.
 from math import pi
-from os import F_OK, access, chdir, getcwd, popen3, sep
+from os import F_OK, access, chdir, getcwd, sep
 from string import lower
+from subprocess import PIPE, Popen
 import sys
 
 # relax module imports.
@@ -414,22 +415,22 @@
             raise RelaxFileError('dasha script', 'dasha_script')
 
         # Execute Dasha.
-        stdin, stdout, stderr = popen3(binary)
+        pipe = Popen(binary, shell=True, stdin=PIPE, stdout=PIPE, 
stderr=PIPE, close_fds=False)
 
         # Get the contents of the script and pump it into Dasha.
         script = open('dasha_script')
         lines = script.readlines()
         script.close()
         for line in lines:
-            stdin.write(line)
+            pipe.stdin.write(line)
 
         # Close the pipe.
-        stdin.close()
+        pipe.stdin.close()
 
         # Write to stdout and stderr.
-        for line in stdout.readlines():
+        for line in pipe.stdout.readlines():
             sys.stdout.write(line)
-        for line in stderr.readlines():
+        for line in pipe.stderr.readlines():
             sys.stderr.write(line)
 
     # Failure.

Modified: trunk/generic_fns/palmer.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/generic_fns/palmer.py?rev=17603&r1=17602&r2=17603&view=diff
==============================================================================
--- trunk/generic_fns/palmer.py (original)
+++ trunk/generic_fns/palmer.py Fri Sep 28 17:28:11 2012
@@ -25,9 +25,10 @@
 
 # Python module imports.
 from math import pi
-from os import F_OK, access, chdir, chmod, getcwd, listdir, popen3, remove, 
sep, system
+from os import F_OK, access, chdir, chmod, getcwd, listdir, remove, sep, 
system
 from re import match, search
 from string import count, find, split
+from subprocess import PIPE, Popen
 import sys
 
 # relax module imports.
@@ -591,15 +592,15 @@
             cmd = binary + ' -i mfin -d mfdata -p mfpar -m mfmodel -o mfout 
-e out -s ' + pdb
         else:
             cmd = binary + ' -i mfin -d mfdata -p mfpar -m mfmodel -o mfout 
-e out'
-        stdin, stdout, stderr = popen3(cmd)
+        pipe = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, 
close_fds=False)
 
         # Close the pipe.
-        stdin.close()
+        pipe.stdin.close()
 
         # Write to stdout and stderr.
-        for line in stdout.readlines():
+        for line in pipe.stdout.readlines():
             sys.stdout.write(line)
-        for line in stderr.readlines():
+        for line in pipe.stderr.readlines():
             sys.stderr.write(line)
 
     # Failure.




Related Messages


Powered by MHonArc, Updated Fri Sep 28 17:40:01 2012