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

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Fri Jun 18 16:52:57 CEST 2010


Revision: 10253
          http://gar.svn.sourceforge.net/gar/?rev=10253&view=rev
Author:   wahwah
Date:     2010-06-18 14:52:57 +0000 (Fri, 18 Jun 2010)

Log Message:
-----------
mGAR v2: submitpkg, clean old files before uploading new ones.

Modified Paths:
--------------
    csw/mgar/gar/v2/lib/python/opencsw.py
    csw/mgar/gar/v2/lib/python/submit_to_newpkgs.py

Modified: csw/mgar/gar/v2/lib/python/opencsw.py
===================================================================
--- csw/mgar/gar/v2/lib/python/opencsw.py	2010-06-18 00:18:52 UTC (rev 10252)
+++ csw/mgar/gar/v2/lib/python/opencsw.py	2010-06-18 14:52:57 UTC (rev 10253)
@@ -281,6 +281,7 @@
 
   def __repr__(self):
     return u"StagingDir(%s)" % repr(self.dir_path)
+
   def GetLatest(self, software, architectures=ARCHITECTURES):
     files = os.listdir(self.dir_path)
     package_files = []

Modified: csw/mgar/gar/v2/lib/python/submit_to_newpkgs.py
===================================================================
--- csw/mgar/gar/v2/lib/python/submit_to_newpkgs.py	2010-06-18 00:18:52 UTC (rev 10252)
+++ csw/mgar/gar/v2/lib/python/submit_to_newpkgs.py	2010-06-18 14:52:57 UTC (rev 10253)
@@ -76,6 +76,16 @@
   pass
 
 
+def RemoveOldFiles(basename_list, host, directory):
+  basename_str = " ".join(["%s/%s*" % (directory, x) for x in basename_list])
+  args = ["ssh", host, "rm -f %s" % basename_str]
+  logging.debug("Running: %s" % args)
+  ret = subprocess.call(args)
+  if ret:
+    msg = ("Removing % failed." % basename_str)
+    raise PackageSubmissionError(msg)
+
+
 def main():
   try:
     config = ConfigParser.SafeConfigParser()
@@ -100,6 +110,10 @@
                       dest="debug", default=False,
                       action="store_true",
                       help="Print debugging messages")
+    parser.add_option("--no-clean",
+                      dest="clean", default=True,
+                      action="store_false",
+                      help="Prevent submitpkg from deleting old files from newpkgs")
     (options, args) = parser.parse_args()
     file_names = args
     level = logging.INFO
@@ -156,14 +170,16 @@
   remote_package_files = []
   remote_package_references = []
   files_to_rsync = []
+  target_host = config.get(CONFIG_RELEASE_SECTION, "target host")
+  target_dir = config.get(CONFIG_RELEASE_SECTION, "target dir")
+  dst_arg = ("%s:%s" % (target_host, target_dir))
   for p in package_files:
-    dst_arg = ("%s:%s" % (config.get(CONFIG_RELEASE_SECTION, "target host"),
-                          config.get(CONFIG_RELEASE_SECTION, "target dir")))
     files_to_rsync.append(p)
     remote_package_files.append(dst_arg)
     package_base_file_name = os.path.split(p)[1]
     remote_package_references.append(dst_arg + "/" + package_base_file_name)
-  # TODO(maciej): rsync only once
+  if options.clean:
+    RemoveOldFiles(catalognames, target_host, target_dir)
   args = ["rsync", "-v"] + files_to_rsync + [dst_arg]
   logging.debug(args)
   try:


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