autorun: fixed out,err redirect in BitTorrentClientRun
authorAdriana Draghici <adriana008@gmail.com>
Thu, 29 Apr 2010 14:19:12 +0000 (14:19 +0000)
committerAdriana Draghici <adriana008@gmail.com>
Thu, 29 Apr 2010 14:19:12 +0000 (14:19 +0000)
autorun/server/BitTorrentClientRun.py
autorun/server/TriblerRun.py

index 5687ceb..8d22d38 100644 (file)
@@ -78,8 +78,8 @@ class BitTorrentClientRun:
             print "log redirect to file ", (self.log_dir+"/"+self.log_file)
         
         p=subprocess.Popen(args, shell=False, #does not create sh process
-                            stdout=log_redirect,
-                            stderr=output_redirect)
+                            stdout=output_redirect,
+                            stderr=log_redirect)
         pid = p.pid
         if(DEBUG):
             print "BitTorrentClientRun: pid =", pid
index 8e62760..dc06fce 100644 (file)
@@ -6,10 +6,11 @@
 """
 
 import sys
+import os
 import os.path
 from BitTorrentClientRun import BitTorrentClientRun
 
-DEBUG = False
+DEBUG = True
 
 
 class TriblerRun(BitTorrentClientRun):
@@ -33,15 +34,15 @@ class TriblerRun(BitTorrentClientRun):
         f = open(filename, "r");
         f_copy = open(tmp_filename, "w");
         import_line = "import sys" 
-        instr_line = "\nsys.path.append('"+base_path+"')\n"
+        instr_line = "sys.path.append('"+base_path+"')\n"
         exists = False
         position = -1
         exists = False
         for line in f:
-            if line.find("import")>=0 and line.find("sys")>=0 and (not line.find("sys."))>=0:
+            if line.find("import")>=0 and line.find("sys")>=0 and (not (line.find("sys.")>=0)):
                 #position = f.tell() + len(line) + 1
                 f_copy.write(line)
-                f_copy.write(instr_line)
+                f_copy.write("\n" + instr_line)
                 continue
             if line == instr_line:
                 exists = True