fio2gnuplot: fix TabErrors when running with Python 3
[fio.git] / tools / plot / fio2gnuplot
index 5d31f13..cc4ea4c 100755 (executable)
@@ -1,4 +1,5 @@
 #!/usr/bin/python2.7
+# Note: this script is python2 and python3 compatible.
 #
 #  Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
 #  Author: Erwan Velu  <erwan@enovance.com>
@@ -19,6 +20,8 @@
 #  along with this program; if not, write to the Free Software
 #  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
+from __future__ import absolute_import
+from __future__ import print_function
 import os
 import fnmatch
 import sys
@@ -26,27 +29,29 @@ import getopt
 import re
 import math
 import shutil
+from six.moves import map
+from six.moves import range
 
 def find_file(path, pattern):
        fio_data_file=[]
        # For all the local files
        for file in os.listdir(path):
-           # If the file matches the glob
-           if fnmatch.fnmatch(file, pattern):
-               # Let's consider this file
-               fio_data_file.append(file)
+               # If the file matches the glob
+               if fnmatch.fnmatch(file, pattern):
+                       # Let's consider this file
+                       fio_data_file.append(file)
 
        return fio_data_file
 
 def generate_gnuplot_script(fio_data_file,title,gnuplot_output_filename,gnuplot_output_dir,mode,disk_perf,gpm_dir):
-       if verbose: print "Generating rendering scripts"
+       if verbose: print("Generating rendering scripts")
        filename=gnuplot_output_dir+'mygraph'
        temporary_files.append(filename)
        f=open(filename,'w')
 
        # Plotting 3D or comparing graphs doesn't have a meaning unless if there is at least 2 traces
        if len(fio_data_file) > 1:
-               f.write("call \'%s/graph3D.gpm\' \'%s' \'%s\' \'\' \'%s\' \'%s\'\n" % (gpm_dir,title,gnuplot_output_filename,gnuplot_output_filename,mode))
+               f.write("call \'%s/graph3D.gpm\' \'%s' \'%s\' \'\' \'%s\' \'%s\'\n" % (gpm_dir,title,gnuplot_output_filename,gnuplot_output_filename,mode))
 
                # Setting up the compare files that will be plot later
                compare=open(gnuplot_output_dir + 'compare.gnuplot','w')
@@ -88,10 +93,10 @@ set style line 1 lt 1 lw 3 pt 3 linecolor rgb "green"
                compare_smooth.write("plot %s w l ls 1 ti 'Global average value (%.2f)'" % (global_avg,global_avg));
                compare_trend.write("plot %s w l ls 1 ti 'Global average value (%.2f)'" % (global_avg,global_avg));
 
-        pos=0
-        # Let's create a temporary file for each selected fio file
-        for file in fio_data_file:
-                tmp_filename = "gnuplot_temp_file.%d" % pos
+               pos=0
+               # Let's create a temporary file for each selected fio file
+               for file in fio_data_file:
+                       tmp_filename = "gnuplot_temp_file.%d" % pos
 
                # Plotting comparing graphs doesn't have a meaning unless if there is at least 2 traces
                if len(fio_data_file) > 1:
@@ -101,12 +106,12 @@ set style line 1 lt 1 lw 3 pt 3 linecolor rgb "green"
                        compare_trend.write(",\\\n'%s' using 2:3 smooth bezier title '%s'" % (tmp_filename,fio_data_file[pos]))
 
                png_file=file.replace('.log','')
-                raw_filename = "%s-2Draw" % (png_file)
-                smooth_filename = "%s-2Dsmooth" % (png_file)
-                trend_filename = "%s-2Dtrend" % (png_file)
-                avg  = average(disk_perf[pos])
-                f.write("call \'%s/graph2D.gpm\' \'%s' \'%s\' \'%s\' \'%s\' \'%s\' \'%s\' \'%s\' \'%f\'\n" % (gpm_dir,title,tmp_filename,fio_data_file[pos],raw_filename,mode,smooth_filename,trend_filename,avg))
-                pos = pos +1
+               raw_filename = "%s-2Draw" % (png_file)
+               smooth_filename = "%s-2Dsmooth" % (png_file)
+               trend_filename = "%s-2Dtrend" % (png_file)
+               avg  = average(disk_perf[pos])
+               f.write("call \'%s/graph2D.gpm\' \'%s' \'%s\' \'%s\' \'%s\' \'%s\' \'%s\' \'%s\' \'%f\'\n" % (gpm_dir,title,tmp_filename,fio_data_file[pos],raw_filename,mode,smooth_filename,trend_filename,avg))
+               pos = pos +1
 
        # Plotting comparing graphs doesn't have a meaning unless if there is at least 2 traces
        if len(fio_data_file) > 1:
@@ -120,11 +125,11 @@ def generate_gnuplot_math_script(title,gnuplot_output_filename,mode,average,gnup
        filename=gnuplot_output_dir+'mymath';
        temporary_files.append(filename)
        f=open(filename,'a')
-        f.write("call \'%s/math.gpm\' \'%s' \'%s\' \'\' \'%s\' \'%s\' %s\n" % (gpm_dir,title,gnuplot_output_filename,gnuplot_output_filename,mode,average))
+       f.write("call \'%s/math.gpm\' \'%s' \'%s\' \'\' \'%s\' \'%s\' %s\n" % (gpm_dir,title,gnuplot_output_filename,gnuplot_output_filename,mode,average))
        f.close()
 
 def compute_aggregated_file(fio_data_file, gnuplot_output_filename, gnuplot_output_dir):
-       if verbose: print "Processing data file 2/2"
+       if verbose: print("Processing data file 2/2")
        temp_files=[]
        pos=0
 
@@ -152,7 +157,7 @@ def compute_temp_file(fio_data_file,disk_perf,gnuplot_output_dir, min_time, max_
        end_time=max_time
        if end_time == -1:
                end_time="infinite"
-       if verbose: print "Processing data file 1/2 with %s<time<%s" % (min_time,end_time)
+       if verbose: print("Processing data file 1/2 with %s<time<%s" % (min_time,end_time))
        files=[]
        temp_outfile=[]
        blk_size=0
@@ -198,8 +203,8 @@ def compute_temp_file(fio_data_file,disk_perf,gnuplot_output_dir, min_time, max_
                                try:
                                        blk_size=int(block_size)
                                except:
-                                       print "Error while reading the following line :"
-                                       print line
+                                       print("Error while reading the following line :")
+                                       print(line)
                                        sys.exit(1);
 
                        # We ignore the first 500msec as it doesn't seems to be part of the real benchmark
@@ -225,7 +230,7 @@ def compute_temp_file(fio_data_file,disk_perf,gnuplot_output_dir, min_time, max_
        return blk_size
 
 def compute_math(fio_data_file, title,gnuplot_output_filename,gnuplot_output_dir,mode,disk_perf,gpm_dir):
-       if verbose: print "Computing Maths"
+       if verbose: print("Computing Maths")
        global_min=[]
        global_max=[]
        average_file=open(gnuplot_output_dir+gnuplot_output_filename+'.average', 'w')
@@ -243,14 +248,14 @@ def compute_math(fio_data_file, title,gnuplot_output_filename,gnuplot_output_dir
        max_file.write('DiskName %s\n'% mode)
        average_file.write('DiskName %s\n'% mode)
        stddev_file.write('DiskName %s\n'% mode )
-       for disk in xrange(len(fio_data_file)):
+       for disk in range(len(fio_data_file)):
 #              print disk_perf[disk]
-               min_file.write("# Disk%d was coming from %s\n" % (disk,fio_data_file[disk]))
-               max_file.write("# Disk%d was coming from %s\n" % (disk,fio_data_file[disk]))
-               average_file.write("# Disk%d was coming from %s\n" % (disk,fio_data_file[disk]))
-               stddev_file.write("# Disk%d was coming from %s\n" % (disk,fio_data_file[disk]))
+               min_file.write("# Disk%d was coming from %s\n" % (disk,fio_data_file[disk]))
+               max_file.write("# Disk%d was coming from %s\n" % (disk,fio_data_file[disk]))
+               average_file.write("# Disk%d was coming from %s\n" % (disk,fio_data_file[disk]))
+               stddev_file.write("# Disk%d was coming from %s\n" % (disk,fio_data_file[disk]))
                avg  = average(disk_perf[disk])
-               variance = map(lambda x: (x - avg)**2, disk_perf[disk])
+               variance = [(x - avg)**2 for x in disk_perf[disk]]
                standard_deviation = math.sqrt(average(variance))
 #              print "Disk%d [ min=%.2f max=%.2f avg=%.2f stddev=%.2f \n" % (disk,min(disk_perf[disk]),max(disk_perf[disk]),avg, standard_deviation)
                average_file.write('%d %d\n' % (disk, avg))
@@ -264,7 +269,7 @@ def compute_math(fio_data_file, title,gnuplot_output_filename,gnuplot_output_dir
 
        global_disk_perf = sum(disk_perf, [])
        avg  = average(global_disk_perf)
-       variance = map(lambda x: (x - avg)**2, global_disk_perf)
+       variance = [(x - avg)**2 for x in global_disk_perf]
        standard_deviation = math.sqrt(average(variance))
 
        global_file.write('min=%.2f\n' % min(global_disk_perf))
@@ -331,52 +336,52 @@ def parse_global_files(fio_data_file, global_search):
                                        max_file=file
        # Let's print the avg output
        if global_search == "avg":
-               print "Biggest aggregated value of %s was %2.f in file %s\n" % (global_search, max_result, max_file)
+               print("Biggest aggregated value of %s was %2.f in file %s\n" % (global_search, max_result, max_file))
        else:
-               print "Global search %s is not yet implemented\n" % global_search
+               print("Global search %s is not yet implemented\n" % global_search)
 
 def render_gnuplot(fio_data_file, gnuplot_output_dir):
-       print "Running gnuplot Rendering"
+       print("Running gnuplot Rendering")
        try:
                # Let's render all the compared files if some
                if len(fio_data_file) > 1:
-                       if verbose: print " |-> Rendering comparing traces"
+                       if verbose: print(" |-> Rendering comparing traces")
                        os.system("cd %s; for i in *.gnuplot; do gnuplot $i; done" % gnuplot_output_dir)
-               if verbose: print " |-> Rendering math traces"
+               if verbose: print(" |-> Rendering math traces")
                os.system("cd %s; gnuplot mymath" % gnuplot_output_dir)
-               if verbose: print " |-> Rendering 2D & 3D traces"
+               if verbose: print(" |-> Rendering 2D & 3D traces")
                os.system("cd %s; gnuplot mygraph" % gnuplot_output_dir)
 
                name_of_directory="the current"
                if gnuplot_output_dir != "./":
                        name_of_directory=gnuplot_output_dir
-               print "\nRendering traces are available in %s directory" % name_of_directory
+               print("\nRendering traces are available in %s directory" % name_of_directory)
                global keep_temp_files
                keep_temp_files=False
        except:
-               print "Could not run gnuplot on mymath or mygraph !\n"
+               print("Could not run gnuplot on mymath or mygraph !\n")
                sys.exit(1);
 
 def print_help():
-    print 'fio2gnuplot -ghbiodvk -t <title> -o <outputfile> -p <pattern> -G <type> -m <time> -M <time>'
-    print
-    print '-h --help                           : Print this help'
-    print '-p <pattern> or --pattern <pattern> : A glob pattern to select fio input files'
-    print '-b           or --bandwidth         : A predefined pattern for selecting *_bw.log files'
-    print '-i           or --iops              : A predefined pattern for selecting *_iops.log files'
-    print '-g           or --gnuplot           : Render gnuplot traces before exiting'
-    print '-o           or --outputfile <file> : The basename for gnuplot traces'
-    print '                                       - Basename is set with the pattern if defined'
-    print '-d           or --outputdir <dir>   : The directory where gnuplot shall render files'
-    print '-t           or --title <title>     : The title of the gnuplot traces'
-    print '                                       - Title is set with the block size detected in fio traces'
-    print '-G           or --Global <type>     : Search for <type> in .global files match by a pattern'
-    print '                                       - Available types are : min, max, avg, stddev'
-    print '                                       - The .global extension is added automatically to the pattern'
-    print '-m           or --min_time <time>   : Only consider data starting from <time> seconds (default is 0)'
-    print '-M           or --max_time <time>   : Only consider data ending before <time> seconds (default is -1 aka nolimit)'
-    print '-v           or --verbose           : Increasing verbosity'
-    print '-k           or --keep              : Keep all temporary files from gnuplot\'s output dir'
+    print('fio2gnuplot -ghbiodvk -t <title> -o <outputfile> -p <pattern> -G <type> -m <time> -M <time>')
+    print()
+    print('-h --help                           : Print this help')
+    print('-p <pattern> or --pattern <pattern> : A glob pattern to select fio input files')
+    print('-b           or --bandwidth         : A predefined pattern for selecting *_bw.log files')
+    print('-i           or --iops              : A predefined pattern for selecting *_iops.log files')
+    print('-g           or --gnuplot           : Render gnuplot traces before exiting')
+    print('-o           or --outputfile <file> : The basename for gnuplot traces')
+    print('                                       - Basename is set with the pattern if defined')
+    print('-d           or --outputdir <dir>   : The directory where gnuplot shall render files')
+    print('-t           or --title <title>     : The title of the gnuplot traces')
+    print('                                       - Title is set with the block size detected in fio traces')
+    print('-G           or --Global <type>     : Search for <type> in .global files match by a pattern')
+    print('                                       - Available types are : min, max, avg, stddev')
+    print('                                       - The .global extension is added automatically to the pattern')
+    print('-m           or --min_time <time>   : Only consider data starting from <time> seconds (default is 0)')
+    print('-M           or --max_time <time>   : Only consider data ending before <time> seconds (default is -1 aka nolimit)')
+    print('-v           or --verbose           : Increasing verbosity')
+    print('-k           or --keep              : Keep all temporary files from gnuplot\'s output dir')
 
 def main(argv):
     mode='unknown'
@@ -401,126 +406,126 @@ def main(argv):
     force_keep_temp_files=False
 
     if not os.path.isfile(gpm_dir+'math.gpm'):
-           gpm_dir="/usr/local/share/fio/"
-           if not os.path.isfile(gpm_dir+'math.gpm'):
-                   print "Looks like fio didn't get installed properly as no gpm files found in '/usr/share/fio' or '/usr/local/share/fio'\n"
-                   sys.exit(3)
+        gpm_dir="/usr/local/share/fio/"
+        if not os.path.isfile(gpm_dir+'math.gpm'):
+            print("Looks like fio didn't get installed properly as no gpm files found in '/usr/share/fio' or '/usr/local/share/fio'\n")
+            sys.exit(3)
 
     try:
-           opts, args = getopt.getopt(argv[1:],"ghkbivo:d:t:p:G:m:M:",['bandwidth', 'iops', 'pattern', 'outputfile', 'outputdir', 'title', 'min_time', 'max_time', 'gnuplot', 'Global', 'help', 'verbose','keep'])
+        opts, args = getopt.getopt(argv[1:],"ghkbivo:d:t:p:G:m:M:",['bandwidth', 'iops', 'pattern', 'outputfile', 'outputdir', 'title', 'min_time', 'max_time', 'gnuplot', 'Global', 'help', 'verbose','keep'])
     except getopt.GetoptError:
-        print "Error: One of the options passed to the cmdline was not supported"
-        print "Please fix your command line or read the help (-h option)"
-         sys.exit(2)
+        print("Error: One of the options passed to the cmdline was not supported")
+        print("Please fix your command line or read the help (-h option)")
+        sys.exit(2)
 
     for opt, arg in opts:
-      if opt in ("-b", "--bandwidth"):
-         pattern='*_bw.log'
-      elif opt in ("-i", "--iops"):
-         pattern='*_iops.log'
-      elif opt in ("-v", "--verbose"):
-        verbose=True
-      elif opt in ("-k", "--keep"):
-        #User really wants to keep the temporary files
-        force_keep_temp_files=True
-      elif opt in ("-p", "--pattern"):
-         pattern_set_by_user=True
-        pattern=arg
-        pattern=pattern.replace('\\','')
-      elif opt in ("-o", "--outputfile"):
-         gnuplot_output_filename=arg
-      elif opt in ("-d", "--outputdir"):
-         gnuplot_output_dir=arg
-        if not gnuplot_output_dir.endswith('/'):
-               gnuplot_output_dir=gnuplot_output_dir+'/'
-        if not os.path.exists(gnuplot_output_dir):
-               os.makedirs(gnuplot_output_dir)
-      elif opt in ("-t", "--title"):
-         title=arg
-      elif opt in ("-m", "--min_time"):
-        min_time=arg
-      elif opt in ("-M", "--max_time"):
-        max_time=arg
-      elif opt in ("-g", "--gnuplot"):
-        run_gnuplot=True
-      elif opt in ("-G", "--Global"):
-        parse_global=True
-        global_search=arg
-      elif opt in ("-h", "--help"):
-         print_help()
-         sys.exit(1)
+        if opt in ("-b", "--bandwidth"):
+            pattern='*_bw.log'
+        elif opt in ("-i", "--iops"):
+            pattern='*_iops.log'
+        elif opt in ("-v", "--verbose"):
+            verbose=True
+        elif opt in ("-k", "--keep"):
+            #User really wants to keep the temporary files
+            force_keep_temp_files=True
+        elif opt in ("-p", "--pattern"):
+            pattern_set_by_user=True
+            pattern=arg
+            pattern=pattern.replace('\\','')
+        elif opt in ("-o", "--outputfile"):
+            gnuplot_output_filename=arg
+        elif opt in ("-d", "--outputdir"):
+            gnuplot_output_dir=arg
+            if not gnuplot_output_dir.endswith('/'):
+                gnuplot_output_dir=gnuplot_output_dir+'/'
+            if not os.path.exists(gnuplot_output_dir):
+                os.makedirs(gnuplot_output_dir)
+        elif opt in ("-t", "--title"):
+            title=arg
+        elif opt in ("-m", "--min_time"):
+            min_time=arg
+        elif opt in ("-M", "--max_time"):
+            max_time=arg
+        elif opt in ("-g", "--gnuplot"):
+            run_gnuplot=True
+        elif opt in ("-G", "--Global"):
+            parse_global=True
+            global_search=arg
+        elif opt in ("-h", "--help"):
+            print_help()
+            sys.exit(1)
 
     # Adding .global extension to the file
     if parse_global==True:
-           if not gnuplot_output_filename.endswith('.global'):
-               pattern = pattern+'.global'
+        if not gnuplot_output_filename.endswith('.global'):
+            pattern = pattern+'.global'
 
     fio_data_file=find_file('.',pattern)
     if len(fio_data_file) == 0:
-           print "No log file found with pattern %s!" % pattern
-           # Try numjob log file format if per_numjob_logs=1
-            if (pattern == '*_bw.log'):
-                fio_data_file=find_file('.','*_bw.*.log')
-            if (pattern == '*_iops.log'):
-                fio_data_file=find_file('.','*_iops.*.log')
-            if len(fio_data_file) == 0:
-                sys.exit(1)
-            else:
-                print "Using log file per job format instead"
+        print("No log file found with pattern %s!" % pattern)
+        # Try numjob log file format if per_numjob_logs=1
+        if (pattern == '*_bw.log'):
+            fio_data_file=find_file('.','*_bw.*.log')
+        if (pattern == '*_iops.log'):
+            fio_data_file=find_file('.','*_iops.*.log')
+        if len(fio_data_file) == 0:
+            sys.exit(1)
+        else:
+            print("Using log file per job format instead")
     else:
-           print "%d files Selected with pattern '%s'" % (len(fio_data_file), pattern)
+        print("%d files Selected with pattern '%s'" % (len(fio_data_file), pattern))
 
     fio_data_file=sorted(fio_data_file, key=str.lower)
     for file in fio_data_file:
-       print ' |-> %s' % file
-       if "_bw.log" in file :
-               mode="Bandwidth (KB/sec)"
-       if "_iops.log" in file :
-               mode="IO per Seconds (IO/sec)"
+        print(' |-> %s' % file)
+        if "_bw.log" in file :
+            mode="Bandwidth (KB/sec)"
+        if "_iops.log" in file :
+            mode="IO per Seconds (IO/sec)"
     if (title == 'No title') and (mode != 'unknown'):
-           if "Bandwidth" in mode:
-                   title='Bandwidth benchmark with %d fio results' % len(fio_data_file)
-           if "IO" in mode:
-                   title='IO benchmark with %d fio results' % len(fio_data_file)
+        if "Bandwidth" in mode:
+            title='Bandwidth benchmark with %d fio results' % len(fio_data_file)
+        if "IO" in mode:
+            title='IO benchmark with %d fio results' % len(fio_data_file)
 
-    print
+    print()
     #We need to adjust the output filename regarding the pattern required by the user
     if (pattern_set_by_user == True):
-           gnuplot_output_filename=pattern
-           # As we do have some glob in the pattern, let's make this simpliest
-           # We do remove the simpliest parts of the expression to get a clear file name
-           gnuplot_output_filename=gnuplot_output_filename.replace('-*-','-')
-           gnuplot_output_filename=gnuplot_output_filename.replace('*','-')
-           gnuplot_output_filename=gnuplot_output_filename.replace('--','-')
-           gnuplot_output_filename=gnuplot_output_filename.replace('.log','')
-           # Insure that we don't have any starting or trailing dash to the filename
-           gnuplot_output_filename = gnuplot_output_filename[:-1] if gnuplot_output_filename.endswith('-') else gnuplot_output_filename
-           gnuplot_output_filename = gnuplot_output_filename[1:] if gnuplot_output_filename.startswith('-') else gnuplot_output_filename
-           if (gnuplot_output_filename == ''):
-               gnuplot_output_filename='default'       
+        gnuplot_output_filename=pattern
+        # As we do have some glob in the pattern, let's make this simpliest
+        # We do remove the simpliest parts of the expression to get a clear file name
+        gnuplot_output_filename=gnuplot_output_filename.replace('-*-','-')
+        gnuplot_output_filename=gnuplot_output_filename.replace('*','-')
+        gnuplot_output_filename=gnuplot_output_filename.replace('--','-')
+        gnuplot_output_filename=gnuplot_output_filename.replace('.log','')
+        # Insure that we don't have any starting or trailing dash to the filename
+        gnuplot_output_filename = gnuplot_output_filename[:-1] if gnuplot_output_filename.endswith('-') else gnuplot_output_filename
+        gnuplot_output_filename = gnuplot_output_filename[1:] if gnuplot_output_filename.startswith('-') else gnuplot_output_filename
+        if (gnuplot_output_filename == ''):
+            gnuplot_output_filename='default'
 
     if parse_global==True:
-       parse_global_files(fio_data_file, global_search)
+        parse_global_files(fio_data_file, global_search)
     else:
-       blk_size=compute_temp_file(fio_data_file,disk_perf,gnuplot_output_dir,min_time,max_time)
-       title="%s @ Blocksize = %dK" % (title,blk_size/1024)
-       compute_aggregated_file(fio_data_file, gnuplot_output_filename, gnuplot_output_dir)
-       compute_math(fio_data_file,title,gnuplot_output_filename,gnuplot_output_dir,mode,disk_perf,gpm_dir)
-       generate_gnuplot_script(fio_data_file,title,gnuplot_output_filename,gnuplot_output_dir,mode,disk_perf,gpm_dir)
-
-       if (run_gnuplot==True):
-               render_gnuplot(fio_data_file, gnuplot_output_dir)
-
-       # Shall we clean the temporary files ?
-       if keep_temp_files==False and force_keep_temp_files==False:
-               # Cleaning temporary files
-               if verbose: print "Cleaning temporary files"
-               for f in enumerate(temporary_files):
-                       if verbose: print " -> %s"%f[1]
-                       try:
-                           os.remove(f[1])
-                       except:
-                           True
+        blk_size=compute_temp_file(fio_data_file,disk_perf,gnuplot_output_dir,min_time,max_time)
+        title="%s @ Blocksize = %dK" % (title,blk_size/1024)
+        compute_aggregated_file(fio_data_file, gnuplot_output_filename, gnuplot_output_dir)
+        compute_math(fio_data_file,title,gnuplot_output_filename,gnuplot_output_dir,mode,disk_perf,gpm_dir)
+        generate_gnuplot_script(fio_data_file,title,gnuplot_output_filename,gnuplot_output_dir,mode,disk_perf,gpm_dir)
+
+        if (run_gnuplot==True):
+            render_gnuplot(fio_data_file, gnuplot_output_dir)
+
+        # Shall we clean the temporary files ?
+        if keep_temp_files==False and force_keep_temp_files==False:
+            # Cleaning temporary files
+            if verbose: print("Cleaning temporary files")
+            for f in enumerate(temporary_files):
+                if verbose: print(" -> %s"%f[1])
+                try:
+                    os.remove(f[1])
+                except:
+                    True
 
 #Main
 if __name__ == "__main__":