示例#1
0
def lenovo_internal(self, model):
    self.response.out.write("Cron: Lenovo FUS ({0})\n".format(model))
    conn = httplib.HTTPConnection("fus.lenovomm.com")
    conn.request("GET", "/firmware/3.0/updateservlet?action=querynewfirmware&devicemodel={0}&locale=".format(model))
    resp = conn.getresponse()
    if resp.status == 200:
        try:
            xml = etree.fromstring(resp.read())
            pr = PollResult(deviceid=model,
                otaname=xml.xpath("/firmwareupdate/firmware/name")[0].text,
                otadesc=lenovo_getdesc(xml)[0:500],
                otachecksum=xml.xpath("/firmwareupdate/firmware/md5")[0].text,
                otaurl=xml.xpath("/firmwareupdate/firmware/downloadurl")[0].text)
            pr.put()
            lastchange = DBAL.get_latest_change(model)
            if lastchange is None or lastchange.otachecksum != pr.otachecksum or lastchange.otaname != pr.otaname or lastchange.otaurl != pr.otaurl:
                ArchivedPollResult(deviceid=model,
                    otaname=xml.xpath("/firmwareupdate/firmware/name")[0].text,
                    otadesc=lenovo_getdesc(xml)[0:500],
                    otachecksum=xml.xpath("/firmwareupdate/firmware/md5")[0].text,
                    otaurl=xml.xpath("/firmwareupdate/firmware/downloadurl")[0].text).put()
            return
        except:
            PollResult(deviceid=model,error="{0} {1}".format(sys.exc_info()[0], sys.exc_info()[1])).put()
    else:
        PollResult(deviceid=model,error="{0} {1}".format(resp.status, resp.reason)).put()
    lastchange = DBAL.get_latest_change(model)
    if lastchange is None:
        ArchivedPollResult(deviceid=model, error="No successful polls yet.").put()
示例#2
0
 def get(self):
     template = je.get_template('overview.html')
     pagedevices = []
     for id, name in devices.items():
         pagedevices.append({"name": name, "id": id, "change": DBAL.get_latest_change(id), "poll": DBAL.get_latest_poll(id)})
     
     self.response.out.write(template.render({'devices': pagedevices, 'uri_for':self.uri_for}))