import logging
import re
+from . import countries
from . import database
from . import hwdata
from . import util
"11" : N_("Signal processing controller"),
"ff" : N_("Unassigned class"),
},
-
+
"usb" : {
"00" : N_("Unclassified"),
"01" : N_("Multimedia"),
def time_updated(self):
return self.data.time_updated
- def updated(self, profile_parser=None, location=None, when=None):
+ def updated(self, profile_parser=None, country_code=None, when=None):
valid = self.settings.get_int("fireinfo_profile_days_valid", 14)
self.db.execute("UPDATE fireinfo_profiles \
profile_parser.processor_bogomips,
)
- if location:
- self.set_location(location)
+ if country_code:
+ self.set_country_code(country_code)
self.log_profile_update()
# Location
- def get_location(self):
+ @property
+ def location(self):
if not hasattr(self, "_location"):
res = self.db.get("SELECT location FROM fireinfo_profiles_locations \
WHERE profile_id = %s", self.id)
return self._location
- def set_location(self, location):
- if self.location == location:
+ def set_country_code(self, country_code):
+ if self.location == country_code:
return
self.db.execute("DELETE FROM fireinfo_profiles_locations \
WHERE profile_id = %s", self.id)
self.db.execute("INSERT INTO fireinfo_profiles_locations(profile_id, location) \
- VALUES(%s, %s)", self.id, location)
+ VALUES(%s, %s)", self.id, country_code)
- self._location = location
-
- location = property(get_location, set_location)
+ self._location = country_code
@property
def location_string(self):
- return self.geoip.get_country_name(self.location)
+ return countries.get_name(self.location)
# Devices
self._kernel_id = None
return self._kernel_id
-
+
def set_kernel_id(self, kernel_id):
if self.kernel_id == kernel_id:
return
else:
self.db.execute("COMMIT")
- def _handle_profile(self, public_id, profile_blob, location=None, when=None):
+ def _handle_profile(self, public_id, profile_blob, country_code=None, when=None):
private_id = profile_blob.get("private_id", None)
assert private_id
if profile:
# Check if the profile has changed. If so, update the data.
if profile_parser.equals(profile):
- profile.updated(profile_parser, location=location, when=when)
+ profile.updated(profile_parser, country_code=country_code, when=when)
return
# If it does not match, we assume that it is expired and
profile = self.fireinfo.create_profile(public_id, private_id, when=when)
profile.parse(profile_parser)
- if location:
- profile.set_location(location)
+ if country_code:
+ profile.set_country_code(country_code)
return profile