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