[PATCH] KVM test: cd_hash: remove -i command line option

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Following kvm_config example, changed the syntax
from

./cd_hash.py -i <iso filename>

to this:

./cd_hash.py <iso filenames>

So the script is more intuitive and useful.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@xxxxxxxxxx>
---
 client/tests/kvm/cd_hash.py |   53 +++++++++++++++++++++----------------------
 1 files changed, 26 insertions(+), 27 deletions(-)

diff --git a/client/tests/kvm/cd_hash.py b/client/tests/kvm/cd_hash.py
index fee20a3..bcd14dc 100755
--- a/client/tests/kvm/cd_hash.py
+++ b/client/tests/kvm/cd_hash.py
@@ -13,37 +13,36 @@ from autotest_lib.client.bin import utils
 
 
 if __name__ == "__main__":
-    parser = optparse.OptionParser()
-    parser.add_option('-i', '--iso', type="string", dest="filename",
-                      action='store',
-                      help='path to a ISO file whose hash string will be '
-                           'evaluated.')
-
+    parser = optparse.OptionParser("usage: %prog [options] [filenames]")
     options, args = parser.parse_args()
-    filename = options.filename
 
     logging_manager.configure_logging(kvm_utils.KvmLoggingConfig())
 
-    if not filename:
+    if args:
+        filenames = args
+    else:
         parser.print_help()
         sys.exit(1)
 
-    filename = os.path.abspath(filename)
-
-    file_exists = os.path.isfile(filename)
-    can_read_file = os.access(filename, os.R_OK)
-    if not file_exists:
-        logging.critical("File %s does not exist. Aborting...", filename)
-        sys.exit(1)
-    if not can_read_file:
-        logging.critical("File %s does not have read permissions. "
-                         "Aborting...", filename)
-        sys.exit(1)
-
-    logging.info("Hash values for file %s", os.path.basename(filename))
-    logging.info("md5    (1m): %s", utils.hash_file(filename, 1024*1024,
-                                                    method="md5"))
-    logging.info("sha1   (1m): %s", utils.hash_file(filename, 1024*1024,
-                                                    method="sha1"))
-    logging.info("md5  (full): %s", utils.hash_file(filename, method="md5"))
-    logging.info("sha1 (full): %s", utils.hash_file(filename, method="sha1"))
+    for filename in filenames:
+        filename = os.path.abspath(filename)
+
+        file_exists = os.path.isfile(filename)
+        can_read_file = os.access(filename, os.R_OK)
+        if not file_exists:
+            logging.critical("File %s does not exist!", filename)
+            continue
+        if not can_read_file:
+            logging.critical("File %s does not have read permissions!",
+                             filename)
+            continue
+
+        logging.info("Hash values for file %s", os.path.basename(filename))
+        logging.info("md5    (1m): %s", utils.hash_file(filename, 1024*1024,
+                                                        method="md5"))
+        logging.info("sha1   (1m): %s", utils.hash_file(filename, 1024*1024,
+                                                        method="sha1"))
+        logging.info("md5  (full): %s", utils.hash_file(filename, method="md5"))
+        logging.info("sha1 (full): %s", utils.hash_file(filename,
+                                                        method="sha1"))
+        logging.info("")
-- 
1.6.6.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux