diff options
author | Colin Walters <walters@verbum.org> | 2010-10-07 13:39:59 -0400 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2010-10-07 13:42:09 -0400 |
commit | 1365aadb0242dd7635f37911d7afa57093b6ce87 (patch) | |
tree | 2eb3225584c493787b589a64a7d01ad26db88560 /rpmci/rpmci_vcs_mirror_main.py | |
parent | 0e0fdb80e434d6fc379871d35571ba121be53cf7 (diff) | |
download | rpmci-1365aadb0242dd7635f37911d7afa57093b6ce87.tar.gz rpmci-1365aadb0242dd7635f37911d7afa57093b6ce87.tar.xz rpmci-1365aadb0242dd7635f37911d7afa57093b6ce87.zip |
subtask: New wrapper for logging subprocess output consistently
Assign taskids, rotating old logs.
Diffstat (limited to 'rpmci/rpmci_vcs_mirror_main.py')
-rw-r--r-- | rpmci/rpmci_vcs_mirror_main.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/rpmci/rpmci_vcs_mirror_main.py b/rpmci/rpmci_vcs_mirror_main.py index 51c706b..db24e58 100644 --- a/rpmci/rpmci_vcs_mirror_main.py +++ b/rpmci/rpmci_vcs_mirror_main.py @@ -21,6 +21,7 @@ import gobject import gio from . import msgqueue +from . import subtask from . import lame_vcs_abstraction class VCSMirror(object): @@ -31,9 +32,6 @@ class VCSMirror(object): self._options = options self._dir = config.get('VCS', 'mirror_dir') - self._process_dir = config.get('VCS', 'process_logdir') - if not os.path.isdir(self._process_dir): - os.makedirs(self._process_dir) self._timeout_seconds = int(config.get('VCS', 'poll_seconds')) self._max_host_concurrency = int(config.get('VCS', 'max_host_concurrency')) self._max_concurrency = int(config.get('VCS', 'max_concurrency')) @@ -180,16 +178,16 @@ class VCSMirror(object): % (host_job_count, host)) vcsdir = self._cachedir_for_vcs(vcs) - job_logname = '%s-update-%s-%d.log' % (vcs.vcstype, self._escape_vcs_url(vcs), - int(time.time()), ) - job_logpath = os.path.join(self._process_dir, job_logname) + escaped_url = self._escape_vcs_url(vcs) + taskid = 'vcs-update-%s' % (escaped_url, ) + task_logpath = subtask.prepare_task_logfile(taskid) if not os.path.isdir(vcsdir): previous_id = None logging.info("Doing initial checkout for %r" % (vcs.get_base_url_string(), )) vcs_tempdir = vcsdir + '.tmp' if os.path.isdir(vcs_tempdir): shutil.rmtree(vcs_tempdir) - process = vcs.checkout_async(vcs_tempdir, job_logpath, self._on_job_exited) + process = vcs.checkout_async(vcs_tempdir, task_logpath, self._on_job_exited) elif self._options.clone_then_exit: logging.info("Already have clone directory %s" % (vcsdir, )) processed.append(vcs) @@ -198,7 +196,7 @@ class VCSMirror(object): vcs.set_directory(vcsdir) previous_id = vcs.get_id() logging.info("Doing update for %r (starting from commit id %s)" % (vcs.get_base_url_string(), previous_id)) - process = vcs.update_async(job_logpath, self._on_job_exited) + process = vcs.update_async(task_logpath, self._on_job_exited) process.__vcs = vcs self._jobs_by_host[host].append((process, previous_id)) processed.append(vcs) @@ -249,6 +247,8 @@ def main(): level = logging.DEBUG if options.debug else logging.INFO logging.basicConfig(stream=sys.stderr, level=level) + subtask.global_configure(config) + mirrordir = config.get('VCS', 'mirror_dir') vcslist_path = os.path.join(mirrordir, 'vcs.txt') |