#!/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
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)
@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):
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("@")
s = []
model = self.format_model()
- s.append(model)
+ if model:
+ s.append(model)
clock_speed = self.format_clock_speed()
if clock_speed:
pairs = (
("-beta", " - Beta "),
("-rc", " - Release Candidate "),
- ("rc", "Release Candidate "),
("core", "Core Update "),
("beta", "Beta "),
)
"flags",
)
- __processor_args_mandatory = (
- "vendor",
- "model_string",
- )
-
def __init__(self, backend, public_id, blob=None):
Object.__init__(self, backend)
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)
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)
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)