]> git.ipfire.org Git - ipfire.org.git/commitdiff
fireinfo: Allow importing profiles for aarch64
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 28 Oct 2019 21:32:31 +0000 (21:32 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 28 Oct 2019 21:32:31 +0000 (21:32 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/backend/fireinfo.py
src/web/fireinfo.py

index 4ca5c935e115647669913825b745b6710103d909..a295ca6c9479622724b41ef7be58548fa7b7d5ba 100644 (file)
@@ -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)
index 60fe3c638c4bbdbf3e65c200861ec3165eb40237..47bc9258b1141c14f16b88296a5e2c0131fe97ca 100644 (file)
@@ -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.")