]> git.ipfire.org Git - thirdparty/suricata-update.git/commitdiff
Supress progress meter when not on a tty.
authorJason Ish <ish@unx.ca>
Fri, 14 Dec 2018 15:33:04 +0000 (09:33 -0600)
committerJason Ish <ish@unx.ca>
Fri, 14 Dec 2018 17:33:25 +0000 (11:33 -0600)
Fixes Redmine issue:
https://redmine.openinfosecfoundation.org/issues/2743

suricata/update/main.py

index de25993e33ae3253cc77db05456d9ff85429bbaa..fe6e3332ae2c22ae1ceda9fd78b9717aa7dbb507 100644 (file)
@@ -304,6 +304,9 @@ class DropRuleFilter(object):
 
 class Fetch:
 
+    def __init__(self):
+        self.istty = os.isatty(sys.stdout.fileno())
+
     def check_checksum(self, tmp_filename, url):
         try:
             checksum_url = url + ".md5"
@@ -323,7 +326,7 @@ class Fetch:
         return False
 
     def progress_hook(self, content_length, bytes_read):
-        if config.args().quiet:
+        if config.args().quiet or not self.istty:
             return
         if not content_length or content_length == 0:
             percent = 0
@@ -336,6 +339,8 @@ class Fetch:
         sys.stdout.write("\b" * 38)
 
     def progress_hook_finish(self):
+        if config.args().quiet or not self.istty:
+            return
         sys.stdout.write("\n")
         sys.stdout.flush()
 
@@ -382,8 +387,7 @@ class Fetch:
             raise err
         except Exception as err:
             raise err
-        if not config.args().quiet:
-            self.progress_hook_finish()
+        self.progress_hook_finish()
         logger.info("Done.")
         return self.extract_files(tmp_filename)