projects
/
snf-image-creator
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Rename README.rst to README
[snf-image-creator]
/
image_creator
/
rsync.py
diff --git
a/image_creator/rsync.py
b/image_creator/rsync.py
index
81476f2
..
08bc27a
100644
(file)
--- a/
image_creator/rsync.py
+++ b/
image_creator/rsync.py
@@
-82,7
+82,7
@@
class Rsync:
self._exclude = []
self._options = ['-v']
self._exclude = []
self._options = ['-v']
- def run(self, src, dest):
+ def run(self, src, dest, slabel='source', dlabel='destination'):
"""Run the actual command"""
cmd = []
cmd.append('rsync')
"""Run the actual command"""
cmd = []
cmd.append('rsync')
@@
-90,7
+90,8
@@
class Rsync:
for i in self._exclude:
cmd.extend(['--exclude', i])
for i in self._exclude:
cmd.extend(['--exclude', i])
- self._out.output("Calculating total number of host files ...", False)
+ self._out.output("Calculating total number of %s files ..." % slabel,
+ False)
# If you don't specify a destination, rsync will list the source files.
dry_run = subprocess.Popen(cmd + [src], shell=False,
# If you don't specify a destination, rsync will list the source files.
dry_run = subprocess.Popen(cmd + [src], shell=False,
@@
-106,8
+107,7
@@
class Rsync:
self._out.success("%d" % total)
self._out.success("%d" % total)
- progress = self._out.Progress(total,
- "Copying host files into the image ... ")
+ progress = self._out.Progress(total, "Copying files to %s" % dlabel)
run = subprocess.Popen(cmd + [src, dest], shell=False,
stdout=subprocess.PIPE, bufsize=0)
try:
run = subprocess.Popen(cmd + [src, dest], shell=False,
stdout=subprocess.PIPE, bufsize=0)
try:
@@
-123,12
+123,19
@@
class Rsync:
progress.success('done')
finally:
progress.success('done')
finally:
- run.poll()
- if run.returncode is None:
- run.send_signal(signal.SIGHUP)
+ def handler(signum, frame):
+ run.terminate()
+ time.sleep(1)
+ run.poll()
+ if run.returncode is None:
+ run.kill()
+ run.wait()
+
+ signal.signal(signal.SIGALRM, handler)
+ signal.alarm(2)
run.communicate()
run.communicate()
+ signal.alarm(0)
if run.returncode != 0:
raise FatalError("rsync failed")
if run.returncode != 0:
raise FatalError("rsync failed")
-
# vim: set sta sts=4 shiftwidth=4 sw=4 et ai :
# vim: set sta sts=4 shiftwidth=4 sw=4 et ai :