From e3d45f22bf1943bcba5b09a7e78254ebaacf9f95 Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Thu, 30 Apr 2020 11:53:15 -0400 Subject: Handle running in a container with no username Arvados-DCO-1.1-Signed-off-by: Peter Amstutz --- bh20sequploader/main.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'bh20sequploader/main.py') diff --git a/bh20sequploader/main.py b/bh20sequploader/main.py index 4c4711d..10d1029 100644 --- a/bh20sequploader/main.py +++ b/bh20sequploader/main.py @@ -62,11 +62,16 @@ def main(): external_ip = urllib.request.urlopen('https://ident.me').read().decode('utf8') + try: + username = getpass.getuser() + except KeyError: + username = "unknown" + properties = { "sequence_label": seqlabel, "upload_app": "bh20-seq-uploader", "upload_ip": external_ip, - "upload_user": "%s@%s" % (getpass.getuser(), socket.gethostname()) + "upload_user": "%s@%s" % (username, socket.gethostname()) } col.save_new(owner_uuid=UPLOAD_PROJECT, name="%s uploaded by %s from %s" % -- cgit v1.2.3