From: Michael Tremer Date: Mon, 28 Oct 2019 21:32:31 +0000 (+0000) Subject: fireinfo: Allow importing profiles for aarch64 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=240e9253c7ac611dd7a356ac9bcfe1dad82ab580;p=ipfire.org.git fireinfo: Allow importing profiles for aarch64 Signed-off-by: Michael Tremer --- diff --git a/src/backend/fireinfo.py b/src/backend/fireinfo.py index 4ca5c935..a295ca6c 100644 --- a/src/backend/fireinfo.py +++ b/src/backend/fireinfo.py @@ -147,11 +147,11 @@ class Processor(Object): def __str__(self): s = [] - if not self.model_string.startswith(self.vendor): + if self.model_string and not self.model_string.startswith(self.vendor): s.append(self.vendor) s.append("-") - s.append(self.model_string) + s.append(self.model_string or "Generic") if self.core_count > 1: s.append("x%s" % self.core_count) @@ -187,9 +187,10 @@ class Processor(Object): @property def model_string(self): - s = self.data.model_string.split() + if self.data.model_string: + s = self.data.model_string.split() - return " ".join((e for e in s if e)) + return " ".join((e for e in s if e)) @property def flags(self): @@ -252,7 +253,7 @@ class Processor(Object): return caps def format_model(self): - s = self.model_string + s = self.model_string or "" # Remove everything after the @: Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz s, sep, rest = s.partition("@") @@ -288,7 +289,8 @@ class Processor(Object): s = [] model = self.format_model() - s.append(model) + if model: + s.append(model) clock_speed = self.format_clock_speed() if clock_speed: @@ -1034,7 +1036,6 @@ class Profile(Object): pairs = ( ("-beta", " - Beta "), ("-rc", " - Release Candidate "), - ("rc", "Release Candidate "), ("core", "Core Update "), ("beta", "Beta "), ) @@ -1216,11 +1217,6 @@ class ProfileParser(Object): "flags", ) - __processor_args_mandatory = ( - "vendor", - "model_string", - ) - def __init__(self, backend, public_id, blob=None): Object.__init__(self, backend) @@ -1396,10 +1392,6 @@ class ProfileParser(Object): args[arg] = _processor.get(_arg, None) - for arg in self.__processor_args_mandatory: - if not args.get(arg, None): - raise ProfileParserError("Mandatory argument missing: %s" % arg) - self.processor = self.fireinfo.get_processor(**args) if not self.processor: self.processor = self.fireinfo.create_processor(**args) @@ -1613,7 +1605,7 @@ class Fireinfo(Object): def create_processor(self, vendor, model_string, family, model, stepping, core_count, flags=None): res = self.db.get("INSERT INTO fireinfo_processors(vendor, model_string, \ family, model, stepping, core_count, flags) VALUES(%s, %s, %s, %s, %s, %s, %s) \ - RETURNING id", vendor, model_string, family, model, stepping, core_count, flags) + RETURNING id", vendor or None, model_string or None, family, model, stepping, core_count, flags) if res: return Processor(self.backend, res.id) @@ -1630,11 +1622,11 @@ class Fireinfo(Object): flags = [] res = self.db.get("SELECT * FROM fireinfo_processors \ - WHERE vendor = %s AND model_string = %s \ + WHERE vendor IS NOT DISTINCT FROM %s AND model_string IS NOT DISTINCT FROM %s \ AND family IS NOT DISTINCT FROM %s AND model IS NOT DISTINCT FROM %s \ AND stepping IS NOT DISTINCT FROM %s AND core_count = %s \ - AND flags <@ %s AND flags @> %s", vendor, model_string, family, model, - stepping, core_count, flags, flags) + AND flags <@ %s AND flags @> %s", vendor or None, model_string or None, + family, model, stepping, core_count, flags, flags) if res: return Processor(self.backend, res.id, res) diff --git a/src/web/fireinfo.py b/src/web/fireinfo.py index 60fe3c63..47bc9258 100644 --- a/src/web/fireinfo.py +++ b/src/web/fireinfo.py @@ -145,8 +145,8 @@ class ProfileSendHandler(BaseHandler): try: self.fireinfo.handle_profile(public_id, profile_blob, location=location) - except fireinfo.ProfileParserError: - raise tornado.web.HTTPError(400) + except fireinfo.ProfileParserError as e: + raise tornado.web.HTTPError(400, "Could not parse profile: %s" % e) self.finish("Your profile was successfully saved to the database.")