[csw-devel] SF.net SVN: gar:[20905] csw/mgar/gar/v2/lib/python

chninkel at users.sourceforge.net chninkel at users.sourceforge.net
Tue Apr 30 00:31:27 CEST 2013


Revision: 20905
          http://gar.svn.sourceforge.net/gar/?rev=20905&view=rev
Author:   chninkel
Date:     2013-04-29 22:31:26 +0000 (Mon, 29 Apr 2013)
Log Message:
-----------
gar: checkpkg: remove the package copy step by directly gunzipping the compressed package

Modified Paths:
--------------
    csw/mgar/gar/v2/lib/python/package.py
    csw/mgar/gar/v2/lib/python/shell.py

Modified: csw/mgar/gar/v2/lib/python/package.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package.py	2013-04-29 22:28:33 UTC (rev 20904)
+++ csw/mgar/gar/v2/lib/python/package.py	2013-04-29 22:31:26 UTC (rev 20905)
@@ -91,12 +91,11 @@
         # result, but the result will be cached as a object member.
         self.GetMtime()
         self.GetMd5sum()
-        base_name_gz = os.path.split(self.pkg_path)[1]
-        shutil.copy(self.pkg_path, self.GetWorkDir())
-        self.pkg_path = os.path.join(self.GetWorkDir(), base_name_gz)
-        args = ["gunzip", "-f", self.pkg_path]
-        unused_retcode = self.ShellCommand(args)
-        self.gunzipped_path = self.pkg_path[:(-len(gzip_suffix))]
+        base_name = os.path.split(self.pkg_path)[1][:(-len(gzip_suffix))]
+        self.gunzipped_path = os.path.join(self.GetWorkDir(), base_name)
+        with open(self.gunzipped_path, 'w') as gunzipped_file:
+          args = ["gunzip", "-f", "-c", self.pkg_path]
+          unused_retcode = shell.ShellCommand(args, stdout=gunzipped_file)
       elif self.pkg_path.endswith(pkg_suffix):
         self.gunzipped_path = self.pkg_path
       else:

Modified: csw/mgar/gar/v2/lib/python/shell.py
===================================================================
--- csw/mgar/gar/v2/lib/python/shell.py	2013-04-29 22:28:33 UTC (rev 20904)
+++ csw/mgar/gar/v2/lib/python/shell.py	2013-04-29 22:31:26 UTC (rev 20905)
@@ -34,11 +34,13 @@
       raise Error("Running %s has failed." % repr(args))
     return retcode
 
-def ShellCommand(args, env=None, timeout=None):
+def ShellCommand(args, env=None, timeout=None,
+                 stdout=subprocess.PIPE,
+                 stderr=subprocess.PIPE):
   logging.debug("Running: %s", args)
   proc = subprocess.Popen(args,
-                          stdout=subprocess.PIPE,
-                          stderr=subprocess.PIPE,
+                          stdout=stdout,
+                          stderr=stderr,
                           env=env,
                           preexec_fn=os.setsid,
                           close_fds=True)

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the devel mailing list