From feaffd3f4b135d17f09c327161bc66ac6228f7bc Mon Sep 17 00:00:00 2001 From: Leonardo Robol Date: Sat, 17 Apr 2010 12:16:33 +0200 Subject: [PATCH] Aggiunto controllo delle eccezioni. --- phcstats.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/phcstats.py b/phcstats.py index 6525948..651fefc 100755 --- a/phcstats.py +++ b/phcstats.py @@ -17,10 +17,14 @@ def LoadClients(group = 'all'): gruppo group di dsh. Il default รจ 'all' """ clients = [] - for client in open('/etc/dsh/group/' + group, 'r'): - client = client.strip() - if client.strip != '' and client[0] != '#': - clients.append (client) + try: + for client in open('/etc/dsh/group/' + group, 'r'): + client = client.strip() + if client.strip != '' and client[0] != '#': + clients.append (client) + except IOError: + raise IOError('Il gruppo dsh \'%s\' non esiste, nessun client trovato!' % + group) return clients def IsAlive(client): @@ -112,5 +116,8 @@ if __name__ == "__main__": UpdateClientsData(client, IsAlive(client)) if options.stats: - for client in LoadClients(): - PrintStats(client) + try: + for client in LoadClients(): + PrintStats(client) + except Exception, e: + print "Errore durante l'esecuzione!\n ==> %s" % e -- 2.1.4