24 from urllib2
import urlopen
26 from urllib.request
import urlopen
29 import urlparse
as parse
31 from urllib
import parse
34 from smolt_config
import get_config_attr
38 print(
_(
"Current rating for vendor/model."))
40 scanURL=
'%s/client/host_rating?vendor=%s&system=%s' % (smoonURL, parse.quote(profile.host.systemVendor), parse.quote(profile.host.systemModel))
41 r = json.load(urlopen(scanURL))[
'ratings']
42 rating_system = {
'0' :
_(
'Unrated/Unknown'),
43 '1' :
_(
'Non-working'),
44 '2' :
_(
'Partially-working'),
45 '3' :
_(
'Requires 3rd party drivers'),
46 '4' :
_(
'Works, needs additional configuration'),
47 '5' :
_(
'Works out of the box')
49 print(
"\tCount\tRating")
50 print(
"\t-----------------")
52 print(
"\t%s\t%s" % (r[rate], rating_system[rate]))
54 def scan(profile, smoonURL, gate):
55 print(
_(
"Scanning %s for known errata.\n" % smoonURL))
57 for VendorID, DeviceID, SubsysVendorID, SubsysDeviceID, Bus, Driver, Type, Description
in profile.deviceIter():
59 devices.append(
'%s/%04x/%04x/%04x/%04x' % (Bus,
62 int(SubsysVendorID
or 0),
63 int(SubsysDeviceID
or 0)) )
64 searchDevices =
'NULLPAGE'
65 devices.append(
'System/%s/%s' % ( parse.quote(profile.host.systemVendor), parse.quote(profile.host.systemModel) ))
67 searchDevices =
"%s|%s" % (searchDevices, dev)
68 scanURL=
'%ssmolt-w/api.php' % smoonURL
69 scanData =
'action=query&titles=%s&format=json' % searchDevices
71 r = json.load(urlopen(scanURL,
bytes(scanData,
'latin1')))
73 print(
"Could not wiki for errata!")
77 for page
in r[
'query'][
'pages']:
80 found.append(
'\t%swiki/%s' % (smoonURL, r[
'query'][
'pages'][page][
'title']))
85 print(
_(
"\tErrata Found!"))
86 for f
in found:
print(
"\t%s" % f)
88 print(
_(
"\tNo errata found, if this machine is having issues please go to"))
89 print(
_(
"\tyour profile and create a wiki page for the device so others can"))
92 if __name__ ==
"__main__":
93 from gate
import create_passing_gate
96 profile = smolt.create_profile(gate, smolt.read_uuid())
97 scan(profile, smoonURL, gate)
98 rating(profile, smoonURL, gate)