]> git.ipfire.org Git - ipfire.org.git/blobdiff - src/backend/fireinfo.py
people: Show pending registrations
[ipfire.org.git] / src / backend / fireinfo.py
index b14edd919a9efc8ec173a665e4ec7dcaa4aa18e2..a295ca6c9479622724b41ef7be58548fa7b7d5ba 100644 (file)
@@ -1,12 +1,12 @@
 #!/usr/bin/python
 
 import datetime
-import hwdata
 import iso3166
 import logging
 import re
 
 from . import database
+from . import hwdata
 from . import util
 from .misc import Object
 
@@ -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)