MattL920 / pyp

Automatically exported from code.google.com/p/pyp
0 stars 0 forks source link

Leading slashes in temp file paths for "rerun" #19

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
pyp v2.12 (svn rev 238) cannot be run at all on Windows (native Python, not a 
cygwin port) because the temporary files  '/%s/pyp_rerun_%d.txt' for "rerun" 
functionality of pyp are created with an unnecessary leading forward slash in 
the file path. 

I think there is no reason to use '/%s/pyp_rerun_%d.txt' instead of 
'%s/pyp_rerun_%d.txt'.

Python's tempfile.gettempdir() always returns an absolute path from the root of 
the filesystem on all platforms (see Python module source at 
http://hg.python.org/cpython/file/tip/Lib/tempfile.py#l130 ). 

Patch is attached. I have tested that everything works on Linux, and everything 
except "rerun" works on Windows (will post the complete fix for rerun on 
Windows later).

Index: pyp
===================================================================
--- pyp (revision 238)
+++ pyp (working copy)
@@ -1397,12 +1397,12 @@
             print Docs.unmodified_config
             sys.exit()

-        rerun_path = '/%s/pyp_rerun_%d.txt' 
%(tempfile.gettempdir(),os.getppid())        
+        rerun_path = '%s/pyp_rerun_%d.txt' 
%(tempfile.gettempdir(),os.getppid())        

         if options.rerun: #deals with rerunning script with -r flag
             if not os.path.exists(rerun_path):
                 gpid = int(os.popen("ps -p %d -oppid=" % os.getppid()).read().strip())
-                rerun_gpid_path = '/%s/pyp_rerun_%d.txt' 
%(tempfile.gettempdir() ,gpid)
+                rerun_gpid_path = '%s/pyp_rerun_%d.txt' 
%(tempfile.gettempdir() ,gpid)
                 if os.path.exists(rerun_gpid_path):
                     rerun_path = rerun_gpid_path
                 else:

Original issue reported on code.google.com by niki...@gmail.com on 26 Jan 2013 at 4:10

Attachments:

GoogleCodeExporter commented 9 years ago
Hi,

Thanks for checking this out.  This should be fixed in the beta version of pyp. 
 Please let me know if that doesn't work.  This is a stable release, and will 
be migrated to the main tree soon.

Original comment by tobyro...@gmail.com on 1 Feb 2013 at 5:37