Merge branch '15521-keepstore-logging'
[arvados.git] / sdk / python / arvados / commands / arv_copy.py
index c5d74efe550a152a1e1f96e97d440084cbebd63f..0ba3f0a483fac785a6d080adf5ea494c480d02b3 100755 (executable)
@@ -1,4 +1,6 @@
-#! /usr/bin/env python
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: Apache-2.0
 
 # arv-copy [--recursive] [--no-recursive] object-uuid src dst
 #
 
 from __future__ import division
 from future import standard_library
+from future.utils import listvalues
 standard_library.install_aliases()
 from past.builtins import basestring
 from builtins import object
-from past.utils import old_div
 import argparse
 import contextlib
 import getpass
@@ -158,7 +160,7 @@ def main():
         abort("cannot copy object {} of type {}".format(args.object_uuid, t))
 
     # Clean up any outstanding temp git repositories.
-    for d in list(local_repo_dir.values()):
+    for d in listvalues(local_repo_dir):
         shutil.rmtree(d, ignore_errors=True)
 
     # If no exception was thrown and the response does not have an
@@ -640,10 +642,11 @@ def create_collection_from(c, src, dst, args):
 #
 def copy_collection(obj_uuid, src, dst, args):
     if arvados.util.keep_locator_pattern.match(obj_uuid):
-        # If the obj_uuid is a portable data hash, it might not be uniquely
-        # identified with a particular collection.  As a result, it is
-        # ambigious as to what name to use for the copy.  Apply some heuristics
-        # to pick which collection to get the name from.
+        # If the obj_uuid is a portable data hash, it might not be
+        # uniquely identified with a particular collection.  As a
+        # result, it is ambiguous as to what name to use for the copy.
+        # Apply some heuristics to pick which collection to get the
+        # name from.
         srccol = src.collections().list(
             filters=[['portable_data_hash', '=', obj_uuid]],
             order="created_at asc"
@@ -805,7 +808,7 @@ def select_git_url(api, repo_name, retries, allow_insecure_http, allow_insecure_
 
     if git_url.startswith("http:"):
         if allow_insecure_http:
-            logger.warn("Using insecure git url %s but will allow this because %s", git_url, allow_insecure_http_opt)
+            logger.warning("Using insecure git url %s but will allow this because %s", git_url, allow_insecure_http_opt)
         else:
             raise Exception("Refusing to use insecure git url %s, use %s if you really want this." % (git_url, allow_insecure_http_opt))
 
@@ -954,7 +957,7 @@ def human_progress(obj_uuid, bytes_written, bytes_expected):
         return "\r{}: {}M / {}M {:.1%} ".format(
             obj_uuid,
             bytes_written >> 20, bytes_expected >> 20,
-            old_div(float(bytes_written), bytes_expected))
+            float(bytes_written) / bytes_expected)
     else:
         return "\r{}: {} ".format(obj_uuid, bytes_written)