From d157dc78b723fae8b55e3d2a6f25ff9417afb051 Mon Sep 17 00:00:00 2001
From: Markus Scheidgen <markus.scheidgen@gmail.com>
Date: Thu, 8 Aug 2019 13:25:50 +0200
Subject: [PATCH] Fixed non published uploads handling in mirror cli command.
 [skip ci]

---
 nomad/cli/client/mirror.py | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/nomad/cli/client/mirror.py b/nomad/cli/client/mirror.py
index 5dd9653f9c..78b2f091a9 100644
--- a/nomad/cli/client/mirror.py
+++ b/nomad/cli/client/mirror.py
@@ -97,7 +97,7 @@ def mirror(
             print('Cannot parse the given query %s: %s' % (query, str(e)))
             sys.exit(1)
     else:
-        query = {}
+        query = dict(published=True)
 
     utils.configure_logging()
 
@@ -123,9 +123,14 @@ def mirror(
                 continue
             except KeyError:
                 pass
-
-            upload_data = client.mirror.get_upload_mirror(upload_id=upload_id).response().result
-            n_calcs = len(upload_data.calcs)
+            
+            try:
+                upload_data = client.mirror.get_upload_mirror(upload_id=upload_id).response().result
+                n_calcs = len(upload_data.calcs)
+            except HTTPBadRequest:
+                print('Could not mirror %s, it is probably not published.' % upload_id)
+                n_calcs = 0
+                continue
 
             if __in_test:
                 # In tests, we mirror from our selves, remove it so it is not there for import
-- 
GitLab