[Treepkg-commits] r364 - in branches/treepkg-status: bin treepkg
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Jul 13 14:24:14 CEST 2010
Author: bricks
Date: 2010-07-13 14:24:14 +0200 (Tue, 13 Jul 2010)
New Revision: 364
Added:
branches/treepkg-status/treepkg/publish.py
Modified:
branches/treepkg-status/bin/publishpackages.py
Log:
moved common publish functions to a seperate module
Modified: branches/treepkg-status/bin/publishpackages.py
===================================================================
--- branches/treepkg-status/bin/publishpackages.py 2010-07-13 12:23:28 UTC (rev 363)
+++ branches/treepkg-status/bin/publishpackages.py 2010-07-13 12:24:14 UTC (rev 364)
@@ -20,17 +20,9 @@
from treepkg.run import call, capture_output
from treepkg.cmdexpand import cmdexpand
from treepkg.util import ensure_directory, listdir_abs
+from treepkg.publish import remove_trailing_slashes, expand_filename,
+ prefix_for_remote_command, copy_to_publishdir
-
-def remove_trailing_slashes(s):
- return s.rstrip("/")
-
-def expand_filename(filename):
- """
- Applies os.path.expanduser and os.path.expandvars to filename
- """
- return os.path.expandvars(os.path.expanduser(filename))
-
config_desc = ["distribution", "section", "num_newest",
"build_user", "build_host", "build_listpackages",
"publish_user", "publish_host",
@@ -74,18 +66,6 @@
" informational output"))
return parser.parse_args()
-def prefix_for_remote_command(user, host):
- """Returns the ssh call needed to run a command on a remote host.
- If host is empty, the function assumes the command is to be run on
- the local host as the same user that exectutes this function, so
- that no ssh or other call is needed.
- """
- prefix = []
- if host:
- prefix.extend(["ssh", "%s@%s" % (user, host)])
- return prefix
-
-
def copy_to_cache(variables, track, revision, arch, quiet):
listpackages_vars = variables.copy()
@@ -126,29 +106,6 @@
call(cmdexpand("scp -p @scp_flags @files $cachedir/", files=files,
scp_flags=scp_flags, **variables))
-
-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"]:
- remote_destdir = (("%(publish_user)s@%(publish_host)s:" % variables)
- + remote_destdir)
- runremote = prefix_for_remote_command(variables["publish_user"],
- variables["publish_host"])
-
- call(cmdexpand("@runremote mkdir --parents $destdir",
- runremote=runremote, destdir=destdir, **variables))
- rsync_flags = []
- if variables["publish_remove_old_packages"]:
- rsync_flags.append("--delete")
- if quiet:
- rsync_flags.append("--quiet")
- call(cmdexpand("rsync @rsync_flags -r --perms --times --omit-dir-times"
- " $cachedir/ $remote_destdir/",
- rsync_flags=rsync_flags, remote_destdir=remote_destdir,
- **variables))
-
-
def publish_packages_arch(variables, track, revision, dist, section, arch,
quiet):
copy_to_cache(variables, track, revision, arch, quiet)
Added: branches/treepkg-status/treepkg/publish.py
===================================================================
--- branches/treepkg-status/treepkg/publish.py 2010-07-13 12:23:28 UTC (rev 363)
+++ branches/treepkg-status/treepkg/publish.py 2010-07-13 12:24:14 UTC (rev 364)
@@ -0,0 +1,56 @@
+#! /usr/bin/python
+# Copyright (C) 2007 - 2010 by Intevation GmbH
+# Authors:
+# Bernhard Herzog <bh at intevation.de>
+# Bjoern Ricks <bjoern.ricks at intevation.de>
+#
+# This program is free software under the GPL (>=v2)
+# Read the file COPYING coming with the software for details.
+
+import os.path
+
+from treepkg.run import call, capture_output
+from treepkg.cmdexpand import cmdexpand
+
+def remove_trailing_slashes(s):
+ return s.rstrip("/")
+
+def expand_filename(filename):
+ """
+ Applies os.path.expanduser and os.path.expandvars to filename
+ """
+ return os.path.expandvars(os.path.expanduser(filename))
+
+def prefix_for_remote_command(user, host):
+ """Returns the ssh call needed to run a command on a remote host.
+ If host is empty, the function assumes the command is to be run on
+ the local host as the same user that exectutes this function, so
+ that no ssh or other call is needed.
+ """
+ prefix = []
+ if host:
+ prefix.extend(["ssh", "%s@%s" % (user, host)])
+ return prefix
+
+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"]:
+ remote_destdir = (("%(publish_user)s@%(publish_host)s:" % variables)
+ + remote_destdir)
+ runremote = prefix_for_remote_command(variables["publish_user"],
+ variables["publish_host"])
+
+ call(cmdexpand("@runremote mkdir --parents $destdir",
+ runremote=runremote, destdir=destdir, **variables))
+ rsync_flags = []
+ if variables["publish_remove_old_packages"]:
+ rsync_flags.append("--delete")
+ if quiet:
+ rsync_flags.append("--quiet")
+ call(cmdexpand("rsync @rsync_flags -r --perms --times --omit-dir-times"
+ " $cachedir/ $remote_destdir/",
+ rsync_flags=rsync_flags, remote_destdir=remote_destdir,
+ **variables))
+
+
More information about the Treepkg-commits
mailing list