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

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Sat Feb 27 16:21:08 CET 2010


Revision: 8864
          http://gar.svn.sourceforge.net/gar/?rev=8864&view=rev
Author:   wahwah
Date:     2010-02-27 15:21:04 +0000 (Sat, 27 Feb 2010)

Log Message:
-----------
mGAR v2: submitpkg, accept also filenames as arguments

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-02-27 15:08:15 UTC (rev 8863)
+++ csw/mgar/gar/v2/lib/python/opencsw.py	2010-02-27 15:21:04 UTC (rev 8864)
@@ -257,6 +257,8 @@
   def __init__(self, dir_path):
     self.dir_path = dir_path
 
+  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 = []
@@ -268,7 +270,8 @@
       if relevant_pkgs:
         package_files.append(relevant_pkgs[-1])
     if not package_files:
-      raise PackageError("Could not find %s in %s" % (software, self.dir_path))
+      raise PackageError("Could not find %s in %s"
+                         % (repr(software), repr(self.dir_path)))
     logging.debug("The latest packages %s in %s are %s",
                   repr(software),
                   repr(self.dir_path),

Modified: csw/mgar/gar/v2/lib/python/submit_to_newpkgs.py
===================================================================
--- csw/mgar/gar/v2/lib/python/submit_to_newpkgs.py	2010-02-27 15:08:15 UTC (rev 8863)
+++ csw/mgar/gar/v2/lib/python/submit_to_newpkgs.py	2010-02-27 15:21:04 UTC (rev 8864)
@@ -87,7 +87,8 @@
                 repr(opt_name))
         raise ConfigurationError("Option %s is missing from the configuration."
                            % repr(opt_name))
-    parser = optparse.OptionParser()
+    usage = """%s [options] [file1 file2 ...]""" % sys.argv[0]
+    parser = optparse.OptionParser(usage)
     parser.add_option("-p",
                       dest="pkgnames",
                       help="A deprecated options. Please use --catalognames.")
@@ -100,7 +101,8 @@
                       action="store_true",
                       help="Print debugging messages")
     (options, args) = parser.parse_args()
-    level = logging.WARN
+    file_names = args
+    level = logging.INFO
     if options.debug:
       level = logging.DEBUG
     logging.basicConfig(level=level)
@@ -112,9 +114,6 @@
                                          options.pkgnames])
       else:
         options.catalognames = options.pkgnames
-    if not options.catalognames:
-      parser.print_help()
-      raise ConfigurationError("You need to specify a package name or names.")
     if config.has_option(CONFIG_RELEASE_SECTION, "release cc"):
       release_cc = config.get(CONFIG_RELEASE_SECTION, "release cc")
     else:
@@ -124,10 +123,28 @@
     print CONFIG_INFO
     print e
     sys.exit(1)
-  catalognames = options.catalognames.split(",")
-  package_files = []
   staging_dir = opencsw.StagingDir(config.get(CONFIG_RELEASE_SECTION,
                                                   "package dir"))
+  if options.catalognames:
+    catalognames = options.catalognames.split(",")
+  else:
+    catalognames = []
+  if file_names:
+    for file_name in file_names:
+      base_name = os.path.basename(file_name)
+      if base_name != file_name:
+        logging.warn("Removing %s, using only %s"
+                     % (repr(os.path.dirname(file_name)), repr(base_name)))
+        logging.warn("Only %s will be searched for packages."
+                     % repr(staging_dir))
+      parsed_file_name = opencsw.ParsePackageFileName(base_name)
+      catalognames.append(parsed_file_name["catalogname"])
+  catalognames = sorted(set(catalognames))
+  if not catalognames:
+    parser.print_help()
+    raise ConfigurationError("You need to specify a package name or names.")
+
+  package_files = []
   for p in catalognames:
     package_files.extend(staging_dir.GetLatest(p))
   logging.debug("Copying files to the target host:dir")


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