From 9f72f2479a008ce5afc050858fbe92193697ec7c Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Tue, 4 Jun 2013 14:25:40 +0300 Subject: Make sure we flush stdout when logging, refactor for that. --- utils/new-publish/propagate.py | 14 +++++++++----- utils/new-publish/publish | 19 +++++++++++-------- 2 files changed, 20 insertions(+), 13 deletions(-) (limited to 'utils') diff --git a/utils/new-publish/propagate.py b/utils/new-publish/propagate.py index 349a7a7..aa12d33 100755 --- a/utils/new-publish/propagate.py +++ b/utils/new-publish/propagate.py @@ -19,6 +19,10 @@ TRIGGER_KEY_FILE = "/home/ubuntu/snapshots-sync2.new/linaro-android-build-publis LOCAL_UPLOAD_DIR = "/mnt/publish/uploads" REMOTE_UPLOAD_DIR = "/uploads/android" +def log(msg): + print msg + sys.stdout.flush() + if __name__ == "__main__": optparser = optparse.OptionParser(usage="%prog ") @@ -54,22 +58,22 @@ if __name__ == "__main__": dir_list = publib.make_dir_struct(file_list, REMOTE_UPLOAD_DIR, strip=strip) print "Dirs:", dir_list if not options.dry_run: - print "Creating dir structure on upload server" + log("Creating dir structure on upload server") publib.create_dir_struct(dir_list, remote_host, PUBLISH_USER_NAME, options.identity_publish) - print "Done creating dir structure on upload server" + log("Done creating dir structure on upload server") upload_script = publib.make_upload_script(file_list, REMOTE_UPLOAD_DIR, strip=strip) - print "Uploading files to upload server" + log("Uploading files to upload server") publib.upload_files(upload_script, remote_host, PUBLISH_USER_NAME, options.identity_publish, options) - print "Done uploading files to upload server" + log("Done uploading files to upload server") if options.step in ("all", "2"): job, build = args[0].split("/") client = paramiko.SSHClient() client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) client.connect(remote_host, username=TRIGGER_USER_NAME, key_filename=TRIGGER_KEY_FILE) - print "Triggering moving of files from upload to download area" + log("Triggering moving of files from upload to download area") stdin, stdout, stderr = client.exec_command("reshuffle-files -t android -j %s -n %s -m %s" % (job, build, opt_staging)) stdin.close() rc = stdout.channel.recv_exit_status() diff --git a/utils/new-publish/publish b/utils/new-publish/publish index 48912ad..b18e351 100755 --- a/utils/new-publish/publish +++ b/utils/new-publish/publish @@ -14,6 +14,10 @@ UPLOAD_DIR = "/uploads" COPY_KEY_FILE = "/var/run/lava/publish-copy" TRIGGER_KEY_FILE = "/var/run/lava/publish-trigger" +def log(msg): + print msg + sys.stdout.flush() + if __name__ == "__main__": optparser = optparse.OptionParser(usage="%prog ...") optparser.add_option("-t", "--type", help="Build type") @@ -46,23 +50,22 @@ if __name__ == "__main__": print "File list:", file_list dir_list = publib.make_dir_struct(file_list, UPLOAD_DIR, build_id, options.strip) print "Dir list:", dir_list - print "Creating dir structure on intermediate server" + log("Creating dir structure on intermediate server") publib.create_dir_struct(dir_list, REMOTE_HOST, COPY_USER_NAME, options.identity_copy) - print "Done creating dir structure on intermediate server" + log("Done creating dir structure on intermediate server") upload_script = publib.make_upload_script(file_list, UPLOAD_DIR, build_id, options.strip) - print "Uploading files to intermediate server" + log("Uploading files to intermediate server") publib.upload_files(upload_script, REMOTE_HOST, COPY_USER_NAME, options.identity_copy, options) - print "Done uploading files to intermediate server" + log("Done uploading files to intermediate server") - print "Triggering propagation of files to downloads server" - sys.stdout.flush() + log("Triggering propagation of files to downloads server") rc = os.system("ssh -i %s %s@%s propagate.py %s %s %s" % (options.identity_trigger, TRIGGER_USER_NAME, REMOTE_HOST, "-s" if options.staging else "", "--host=%s" % options.host if options.host else "", build_id)) if rc != 0: - print "Publishing failed" + log("Publishing failed") sys.exit(1) - print "Publishing successful" + log("Publishing successful") -- cgit v1.2.3