Commits

WebBreacher committed 654bca6

Modified the padding to be more effecient.

Comments (0)

Files changed (1)

     db = {'targets': []}
     cnt = 0
     tot = len(targets) * 2
+    previouslen = 0
     try:
         for target in targets:
             # Displays the target name to the right of the progress bar
             if opts.verbose:
-                printProgress(cnt, tot, target)
+                printProgress(cnt, tot, target, previouslen)
             else:
                 printProgress(cnt, tot)
             filename = '%s.png' % re.sub('\W','',target)
             filepath = '%s/%s' % (directory, filename)
             getCapture(target, filepath, timeout)
             cnt += 1
-            # Overwrites the target information from the right of the progress bar
-            printProgress(cnt, tot)
+            previouslen = len(target)
             target_data = {}
             target_data['url'] = target
             target_data['path'] = filename
     if stderr: response += str(stderr)
     return proc.returncode, response.strip()
 
-def printProgress(cnt, tot, target=' '*60):
+def printProgress(cnt, tot, target='', previouslen=0):
     percent = 100 * float(cnt) / float(tot)
+    if target and previouslen > len(target): 
+        target = target + ' ' * (previouslen - len(target))
     sys.stdout.write('[%-40s] %d%%   %s\r' % ('='*int(float(percent)/100*40), percent, target))
     sys.stdout.flush()
     return ''