Fa qualcosa e gestice la non presenza dei file.

Leonardo [2010-04-17 08:30]
Fa qualcosa e gestice la non presenza dei file.
Filename
phcstats.py
diff --git a/phcstats.py b/phcstats.py
old mode 100644
new mode 100755
index 8c5db69..4793897
--- a/phcstats.py
+++ b/phcstats.py
@@ -34,7 +34,10 @@ def LoadClientData(client):
     Valori True o False
     """
     data = {}
-    f = open(database_directory + client, 'r')
+    try:
+        f = open(database_directory + client, 'r')
+    except IOError:
+        return data
     for line in f:
         (time, alive) = line.split(":")
         data[time] = alive
@@ -62,3 +65,8 @@ def UpdateClientsData(client, alive):
     data[time.time()] = alive
     DumpClientData(client, data)

+
+
+if __name__ == "__main__":
+    for client in LoadClients():
+        UpdateClientsData(client, IsAlive(client))
ViewGit