Improving error handling and removing unused var
Signed-off-by: Jiri Podivin <jpodivin@redhat.com>
This commit is contained in:
parent
69309d5531
commit
a2b5468164
1 changed files with 4 additions and 6 deletions
|
@ -397,11 +397,9 @@ def breakoutdate(givendate):
|
||||||
'Dec' : '12',
|
'Dec' : '12',
|
||||||
}
|
}
|
||||||
|
|
||||||
date_part = givendate.split()
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
[day, month, year] = givendate.split(":")[0].split('/')
|
[day, month, year] = givendate.split(":")[0].split('/')
|
||||||
except:
|
except IndexError:
|
||||||
# string out of index because date corrupted?
|
# string out of index because date corrupted?
|
||||||
[day, month, year ] = ['01', 'Jan', '1970'] # epoch
|
[day, month, year ] = ['01', 'Jan', '1970'] # epoch
|
||||||
ret_str = "%s-%s-%s" % (year, Apache_Months[month], day)
|
ret_str = "%s-%s-%s" % (year, Apache_Months[month], day)
|
||||||
|
@ -418,7 +416,7 @@ def breakoutrepo(request):
|
||||||
if 'arch=' in i:
|
if 'arch=' in i:
|
||||||
arch = i.split('=')[1]
|
arch = i.split('=')[1]
|
||||||
return (repo,arch)
|
return (repo,arch)
|
||||||
except:
|
except IndexError:
|
||||||
return ("unknown_repo","unknown_arch")
|
return ("unknown_repo","unknown_arch")
|
||||||
|
|
||||||
|
|
||||||
|
@ -570,7 +568,7 @@ def parselog(our_file, out_file):
|
||||||
output_file = out_file
|
output_file = out_file
|
||||||
try:
|
try:
|
||||||
data = open(our_file, "r")
|
data = open(our_file, "r")
|
||||||
except:
|
except PermissionError or FileNotFoundError:
|
||||||
sys.stderr.write("Unable to open %s\n" % our_file )
|
sys.stderr.write("Unable to open %s\n" % our_file )
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
|
@ -589,7 +587,7 @@ def parselog(our_file, out_file):
|
||||||
try:
|
try:
|
||||||
output = open(output_file,"a")
|
output = open(output_file,"a")
|
||||||
sys.stdout.write("Outputting data: %s\n" % our_file)
|
sys.stdout.write("Outputting data: %s\n" % our_file)
|
||||||
except:
|
except PermissionError or FileNotFoundError:
|
||||||
sys.stderr.write("Unable to open outputfile: %s\n" % our_file)
|
sys.stderr.write("Unable to open outputfile: %s\n" % our_file)
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue