00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 import smolt
00021 import json, urllib
00022 from i18n import _
00023 from smolt_config import get_config_attr
00024
00025 def rating(profile, smoonURL, gate):
00026 print ""
00027 print _("Current rating for vendor/model.")
00028 print ""
00029 scanURL='%s/client/host_rating?vendor=%s&system=%s' % (smoonURL, urllib.quote(profile.host.systemVendor), urllib.quote(profile.host.systemModel))
00030 r = json.load(urllib.urlopen(scanURL))['ratings']
00031 rating_system = { '0' : _('Unrated/Unknown'),
00032 '1' : _('Non-working'),
00033 '2' : _('Partially-working'),
00034 '3' : _('Requires 3rd party drivers'),
00035 '4' : _('Works, needs additional configuration'),
00036 '5' : _('Works out of the box')
00037 }
00038 print "\tCount\tRating"
00039 print "\t-----------------"
00040 for rate in r:
00041 print "\t%s\t%s" % (r[rate], rating_system[rate])
00042
00043 def scan(profile, smoonURL, gate):
00044 print _("Scanning %s for known errata.\n" % smoonURL)
00045 devices = []
00046 for VendorID, DeviceID, SubsysVendorID, SubsysDeviceID, Bus, Driver, Type, Description in profile.deviceIter():
00047 if VendorID:
00048 devices.append('%s/%04x/%04x/%04x/%04x' % (Bus,
00049 int(VendorID or 0),
00050 int(DeviceID or 0),
00051 int(SubsysVendorID or 0),
00052 int(SubsysDeviceID or 0)) )
00053 searchDevices = 'NULLPAGE'
00054 devices.append('System/%s/%s' % ( urllib.quote(profile.host.systemVendor), urllib.quote(profile.host.systemModel) ))
00055 for dev in devices:
00056 searchDevices = "%s|%s" % (searchDevices, dev)
00057 scanURL='%s/smolt-w/api.php' % smoonURL
00058 scanData = 'action=query&titles=%s&format=json' % searchDevices
00059 try:
00060 r = json.load(urllib.urlopen(scanURL, scanData))
00061 except ValueError:
00062 print "Could not wiki for errata!"
00063 return
00064 found = []
00065
00066 for page in r['query']['pages']:
00067 try:
00068 if int(page) > 0:
00069 found.append('\t%swiki/%s' % (smoonURL, r['query']['pages'][page]['title']))
00070 except KeyError:
00071 pass
00072
00073 if found:
00074 print _("\tErrata Found!")
00075 for f in found: print "\t%s" % f
00076 else:
00077 print _("\tNo errata found, if this machine is having issues please go to")
00078 print _("\tyour profile and create a wiki page for the device so others can")
00079 print _("\tbenefit")
00080
00081 if __name__ == "__main__":
00082 from gate import create_passing_gate
00083 gate = create_passing_gate()
00084 smoonURL = get_config_attr("SMOON_URL", "http://smolts.org/")
00085 profile = smolt.create_profile(gate, smolt.read_uuid())
00086 scan(profile, smoonURL, gate)
00087 rating(profile, smoonURL, gate)