Public Member Functions | |
| def | __init__ |
| getIPUtils constructor | |
| def | getLastUpdateTime |
| Retrieves the last time the the GEO IP database was installed. | |
| def | isGEOIPDatabaseInstalled |
| Returns True if any database is installed. | |
| def | updateGEOIPDatabase |
| Copies a new database file to EyeSpy's GEO IP Database folder. | |
| def | installGeoIPIfNecessary |
| Checks EyeSpy's GEO IP Database folder to see which database files need to updated. | |
Public Attributes | |
| path | |
Static Public Attributes | |
| tuple | installGeoIPIfNecessary = staticmethod(installGeoIPIfNecessary) |
Definition at line 30 of file geoIPUtils.py.
| def objects.geoip.geoIPUtils.geoIPUtils.__init__ | ( | self, | ||
| path | ||||
| ) |
| def objects.geoip.geoIPUtils.geoIPUtils.getLastUpdateTime | ( | self | ) |
Retrieves the last time the the GEO IP database was installed.
This method works by extracting a time stamp from a small text file (located in the same folder as the database). This file is created each time a new database is imported into the application.
Definition at line 40 of file geoIPUtils.py.
00040 : 00041 infoFile = None 00042 00043 try: 00044 infoFile = open(globalStrings.geoIPInfoPath(),"r") 00045 infoString = infoFile.read(512); 00046 return infoString 00047 00048 except Exception, e: 00049 logger.log(__name__ + ": There was an error opening GEO IP info file: " + str(e)) 00050 logger.log(__name__ + ": Could not determine when the last time the GEO IP Database was updated") 00051 return ""; 00052 00053 finally: 00054 if infoFile != None: 00055 infoFile.close() 00056 00057 ## Returns True if any database is installed. The method simply checks to see
Checks EyeSpy's GEO IP Database folder to see which database files need to updated.
Note that calling updateGEOIPDatabase does not update the database file directly, since the the database file may be locked. This method should be called when the application is starting up, before the database is initialized.
Definition at line 99 of file geoIPUtils.py.
00099 : 00100 if os.path.isfile(globalStrings.tempIPInfoPath()): 00101 try: 00102 shutil.copyfile(globalStrings.tempIPInfoPath(), globalStrings.geoIPInfoPath()) 00103 shutil.copyfile(globalStrings.tempIPLocPath(), globalStrings.geoIPLocPath()) 00104 00105 os.remove(globalStrings.tempIPInfoPath()) 00106 os.remove(globalStrings.tempIPLocPath()) 00107 except Exception, ex: 00108 strErr = "There was an error updating database files: %s" % str(ex) 00109 logger.log(__name__ + ": " + strErr) 00110 00111 raise Exception, strErr 00112 00113 # the next are optional, so do not raise an exception back to the user 00114 try: 00115 shutil.copyfile(globalStrings.tempIPIspInfoPath(), globalStrings.geoIPIspPath()) 00116 shutil.copyfile(globalStrings.tempIPOrgInfoPath(), globalStrings.geoIPOrgPath()) 00117 00118 os.remove(globalStrings.tempIPIspInfoPath()) 00119 os.remove(globalStrings.tempIPOrgInfoPath()) 00120 00121 except Exception, ex: 00122 00123 strErr = "There was an error updating optional database files: %s" % str(ex) 00124 logger.log(__name__ + ": " + strErr) 00125 00126 installGeoIPIfNecessary = staticmethod(installGeoIPIfNecessary)
| def objects.geoip.geoIPUtils.geoIPUtils.isGEOIPDatabaseInstalled | ( | self | ) |
Returns True if any database is installed.
The method simply checks to see whether the database file exists at the expected location
Definition at line 61 of file geoIPUtils.py.
00061 : 00062 return os.path.exists( globalStrings.geoIPLocPath() ) 00063 ## Copies a new database file to EyeSpy's GEO IP Database folder.
| def objects.geoip.geoIPUtils.geoIPUtils.updateGEOIPDatabase | ( | self, | ||
| path | ||||
| ) |
Copies a new database file to EyeSpy's GEO IP Database folder.
Typically this is set to: objects/logic/entity/res/geoIP/
| path | Source path of the database (full path + file name) |
Definition at line 67 of file geoIPUtils.py.
00067 : 00068 try: 00069 infoFile = None 00070 00071 #make sure these folders exist, don't complain if the mkdir fails 00072 try: 00073 os.mkdir(globalStrings.geoIPResPath) 00074 os.mkdir(globalStrings.geoIPPath) 00075 except Exception, ex: 00076 logger.log(__name__ + "GEO IP Database folder already exists. This is not necessarily an error.") 00077 00078 00079 shutil.copyfile(path, globalStrings.tempIPLocPath()) 00080 00081 # now create file containing the time stamp of the last update. 00082 infoFile = open(globalStrings.tempIPInfoPath(),"w") 00083 00084 infoFile.write(timeUtil.formatDateTime(time.time())); 00085 00086 except Exception, ex: 00087 strErr = "There was an error updating database files: %s" % str(ex) 00088 logger.log(__name__ + ": " + strErr) 00089 00090 raise Exception, strErr 00091 finally: 00092 if infoFile != None: 00093 infoFile.close() 00094
tuple objects.geoip.geoIPUtils.geoIPUtils.installGeoIPIfNecessary = staticmethod(installGeoIPIfNecessary) [static] |
Definition at line 127 of file geoIPUtils.py.
Definition at line 34 of file geoIPUtils.py.
1.5.8