summaryrefslogtreecommitdiff
path: root/gear/worker.py
diff options
context:
space:
mode:
Diffstat (limited to 'gear/worker.py')
-rw-r--r--gear/worker.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/gear/worker.py b/gear/worker.py
index 55b4fa4c..222a5297 100644
--- a/gear/worker.py
+++ b/gear/worker.py
@@ -45,19 +45,25 @@ def upload_files(cache_key, suffixes):
print "DEBUG: start upload_files"
cache_dir = '/src/cache/artifacts'
remote_cache_dir = '/src/cache_server/'
- files_to_upload = [os.path.join(cache_dir, cache_key + '.' + suffix) for suffix in suffixes]
- with ssh_manager('127.0.0.1', 22, 'root', '/root/gerritbot/gerritbot_rsa') as client:
+ files_to_upload = [os.path.join(cache_dir,
+ cache_key + '.' + suffix)
+ for suffix in suffixes]
+ with ssh_manager('127.0.0.1', 22, 'root',
+ '/root/gerritbot/gerritbot_rsa') as client:
sftp = client.open_sftp()
for single_file in files_to_upload:
- remote_dest = os.path.join(remote_cache_dir, os.path.basename(single_file))
- remote_dest_tmp = os.path.join(remote_cache_dir, os.path.basename(single_file) + '.tmp')
+ remote_dest = os.path.join(remote_cache_dir,
+ os.path.basename(single_file))
+ remote_dest_tmp = os.path.join(remote_cache_dir,
+ os.path.basename(single_file)
+ + '.tmp')
print "DEBUG: going to upload %s" % single_file
print "DEBUG: upload destination %s" % remote_dest
try:
sftp.stat(remote_dest)
print "DEBUG: file already exists"
return
- except:
+ except IOError:
print "DEBUG: file not found in cache, uploading"
sftp.put(single_file, remote_dest_tmp)
sftp.rename(remote_dest_tmp, remote_dest)
@@ -78,10 +84,12 @@ while True:
bg_request['ref'],
bg_request['system'])
# TODO: There should be another way of doing this.
- cmd = ['morph', 'calculate-build-graph', '--quiet', bg_request['repo'], bg_request['ref'], bg_request['system']]
+ cmd = ['morph', 'calculate-build-graph', '--quiet',
+ bg_request['repo'], bg_request['ref'], bg_request['system']]
p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
output = p.stdout.read()
- # TODO: catch errors calculating build-graph here instead of sending the error as build-graph :)
+ # TODO: catch errors calculating build-graph here instead of sending
+ # the error as build-graph :)
print "DEBUG: finished computing build graph"
job.sendWorkComplete(output)
elif job.name == "build-artifact":