diff bin/publishpackages.py @ 263:acf6c0ce2014

Add --quiet option so that publishpackages.py can be run without any output. Usefule for cron-jobs
author Bernhard Herzog <bh@intevation.de>
date Tue, 28 Apr 2009 10:23:08 +0000
parents 8052aabada8b
children 1fcdffbeb9de
line wrap: on
line diff
--- a/bin/publishpackages.py	Fri Apr 24 18:33:12 2009 +0000
+++ b/bin/publishpackages.py	Tue Apr 28 10:23:08 2009 +0000
@@ -48,7 +48,8 @@
 def parse_commandline():
     parser = OptionParser()
     parser.set_defaults(config_file=os.path.join(treepkgcmd.topdir,
-                                                 "publishpackages.cfg"))
+                                                 "publishpackages.cfg"),
+                        quiet=False)
     parser.add_option("--config-file",
                       help=("The configuration file."
                             " Default is publishpackages.cfg"))
@@ -68,6 +69,9 @@
                       help=("The package track whose files are to be"
                             " published. If not given, files of all tracks"
                             " will be published"))
+    parser.add_option("--quiet", action="store_true",
+                      help=("Do not print progress meters or other"
+                            " informational output"))
     return parser.parse_args()
 
 def prefix_for_remote_command(user, host):
@@ -82,7 +86,7 @@
     return prefix
 
 
-def copy_to_cache(variables, track, revision, arch):
+def copy_to_cache(variables, track, revision, arch, quiet):
     listpackages_vars = variables.copy()
 
     if arch == "source":
@@ -115,10 +119,14 @@
     if variables["build_host"]:
         userhost = "%(build_user)s@%(build_host)s:" % variables
         files = [userhost + filename for filename in files]
-    call(cmdexpand("scp -p @files $cachedir/", files = files, **variables))
+    scp_flags = []
+    if quiet:
+        scp_flags.append("-q")
+    call(cmdexpand("scp -p @scp_flags @files $cachedir/", files=files,
+                   scp_flags=scp_flags, **variables))
 
 
-def copy_to_publishdir(variables, dist, section, arch):
+def copy_to_publishdir(variables, dist, section, arch, quiet):
     destdir = os.path.join(variables["publish_dir"], dist, section, arch)
     remote_destdir = destdir
     if variables["publish_host"]:
@@ -132,17 +140,20 @@
     rsync_flags = []
     if variables["publish_remove_old_packages"]:
         rsync_flags.append("--delete")
+    if quiet:
+        rsync_flags.append("--quiet")
     call(cmdexpand("rsync @rsync_flags -rpt $cachedir/ $remote_destdir/",
                    rsync_flags=rsync_flags, remote_destdir=remote_destdir,
                    **variables))
 
 
-def publish_packages_arch(variables, track, revision, dist, section, arch):
-    copy_to_cache(variables, track, revision, arch)
-    copy_to_publishdir(variables, dist, section, arch)
+def publish_packages_arch(variables, track, revision, dist, section, arch,
+                          quiet):
+    copy_to_cache(variables, track, revision, arch, quiet)
+    copy_to_publishdir(variables, dist, section, arch, quiet)
 
 
-def publish_packages(config_filename, track, revision, dist, section):
+def publish_packages(config_filename, track, revision, dist, section, quiet):
     config = read_config(config_filename)
 
     if dist is None:
@@ -151,7 +162,8 @@
         section = config["section"]
 
     for arch in ["binary-i386", "source"]:
-        publish_packages_arch(config, track, revision, dist, section, arch)
+        publish_packages_arch(config, track, revision, dist, section, arch,
+                              quiet)
 
     # update apt archive
     call(config["after_upload_hook"])
@@ -159,6 +171,6 @@
 def main():
     options, args = parse_commandline()
     publish_packages(options.config_file, options.track, options.revision,
-                     options.dist, options.section)
+                     options.dist, options.section, options.quiet)
 
 main()
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)