20 from __future__
import print_function
25 from urllib2
import urlopen
27 from urllib.request
import urlopen
30 import urlparse
as parse
32 from urllib
import parse
35 from smolt_config
import get_config_attr
39 print(
_(
"Current rating for vendor/model."))
41 scanURL=
'%s/client/host_rating?vendor=%s&system=%s' % (smoonURL, parse.quote(profile.host.systemVendor), parse.quote(profile.host.systemModel))
42 r = json.load(urlopen(scanURL))[
'ratings']
43 rating_system = {
'0' :
_(
'Unrated/Unknown'),
44 '1' :
_(
'Non-working'),
45 '2' :
_(
'Partially-working'),
46 '3' :
_(
'Requires 3rd party drivers'),
47 '4' :
_(
'Works, needs additional configuration'),
48 '5' :
_(
'Works out of the box')
50 print(
"\tCount\tRating")
51 print(
"\t-----------------")
53 print(
"\t%s\t%s" % (r[rate], rating_system[rate]))
55 def scan(profile, smoonURL, gate):
56 print(
_(
"Scanning %s for known errata.\n" % smoonURL))
58 for VendorID, DeviceID, SubsysVendorID, SubsysDeviceID, Bus, Driver, Type, Description
in profile.deviceIter():
60 devices.append(
'%s/%04x/%04x/%04x/%04x' % (Bus,
63 int(SubsysVendorID
or 0),
64 int(SubsysDeviceID
or 0)) )
65 searchDevices =
'NULLPAGE'
66 devices.append(
'System/%s/%s' % ( parse.quote(profile.host.systemVendor), parse.quote(profile.host.systemModel) ))
68 searchDevices =
"%s|%s" % (searchDevices, dev)
69 scanURL=
'%ssmolt-w/api.php' % smoonURL
70 scanData =
'action=query&titles=%s&format=json' % searchDevices
72 r = json.load(urlopen(scanURL,
bytes(scanData,
'latin1')))
74 print(
"Could not wiki for errata!")
78 for page
in r[
'query'][
'pages']:
81 found.append(
'\t%swiki/%s' % (smoonURL, r[
'query'][
'pages'][page][
'title']))
86 print(
_(
"\tErrata Found!"))
87 for f
in found:
print(
"\t%s" % f)
89 print(
_(
"\tNo errata found, if this machine is having issues please go to"))
90 print(
_(
"\tyour profile and create a wiki page for the device so others can"))
93 if __name__ ==
"__main__":
94 from gate
import create_passing_gate
97 profile = smolt.create_profile(gate, smolt.read_uuid())
98 scan(profile, smoonURL, gate)
99 rating(profile, smoonURL, gate)