- now = time.time()
- if (now - checkpoint) > 20:
- bps = (float(count)/float(now - start))
- logger.info("%2.1f%% complete, %3.2f MiB/s, %1.0f seconds left",
- float(count * 100) / float(properties[url]["Content-Length"]),
- bps/(1024*1024),
- (int(properties[url]["Content-Length"])-count)/bps)
- checkpoint = now
-
- c.save_new(name="Downloaded from %s" % url, owner_uuid=project_uuid, ensure_unique_name=True)
+ loopnow = time.time()
+ if (loopnow - checkpoint) > 20:
+ bps = count / (loopnow - start)
+ if cl is not None:
+ logger.info("%2.1f%% complete, %3.2f MiB/s, %1.0f seconds left",
+ ((count * 100) / cl),
+ (bps // (1024*1024)),
+ ((cl-count) // bps))
+ else:
+ logger.info("%d downloaded, %3.2f MiB/s", count, (bps / (1024*1024)))
+ checkpoint = loopnow
+
+ logger.info("Download complete")
+
+ collectionname = "Downloaded from %s" % urllib.parse.quote(url, safe='')
+
+ # max length - space to add a timestamp used by ensure_unique_name
+ max_name_len = 254 - 28
+
+ if len(collectionname) > max_name_len:
+ over = len(collectionname) - max_name_len
+ split = int(max_name_len/2)
+ collectionname = collectionname[0:split] + "…" + collectionname[split+over:]
+
+ c.save_new(name=collectionname, owner_uuid=project_uuid, ensure_unique_name=True)