Bugs on use of exception.

This commit is contained in:
Davi Vercillo C. Garcia 2009-07-21 23:31:20 -03:00
parent d72c7682d5
commit b8bcf519c7

View file

@ -72,8 +72,9 @@ class CheckMirrors:
"""Method that verify, for each mirror, if its repomd.xml is equal of that on main. """Method that verify, for each mirror, if its repomd.xml is equal of that on main.
""" """
print "\nChecking the repositories repodata !\n\nUsing:", self.main_mirror % (self.directory, self.version, self.architecture) print "\nChecking the repositories repodata !\n\nUsing:", self.main_mirror % (self.directory, self.version, self.architecture)
counter = 0
for url in self.mirrors: for url in self.mirrors:
print "\rTesting: %d/%d" % (self.good_mirrors[1] , self.number_total_mirrors), print "\rTesting: %d/%d" % (counter , self.number_total_mirrors),
sys.stdout.flush() sys.stdout.flush()
try: try:
if urllib.urlopen(url + self.xml_filename).read() == self.repodata: if urllib.urlopen(url + self.xml_filename).read() == self.repodata:
@ -82,9 +83,10 @@ class CheckMirrors:
else: else:
self.bad_mirrors[0].append(url) self.bad_mirrors[0].append(url)
self.bad_mirrors[1] += 1 self.bad_mirrors[1] += 1
except Exception, err: except Exception, error.msg:
self.error_mirrors[0].append(url + "\n[" + err + "]") self.error_mirrors[0].append(url + "\n[" + error.msg + "]")
self.error_mirrors[1] += 1 self.error_mirrors[1] += 1
counter += 1
def print_results(self): def print_results(self):
"""Method that put the results on STDOUT. """Method that put the results on STDOUT.
@ -121,9 +123,6 @@ class CheckMirrors:
if __name__ == "__main__": if __name__ == "__main__":
"""Main Function.
If the programs was called as a script, this will be executed.
"""
signal(2, SIG_DFL) signal(2, SIG_DFL)
if len(sys.argv) == 4: if len(sys.argv) == 4:
CheckMirrors(sys.argv[1], sys.argv[2], sys.argv[3], ).run() CheckMirrors(sys.argv[1], sys.argv[2], sys.argv[3], ).run()