Exemple #1
0
 def _requestPageErr(self, err, uri=False, method='GET', postdata=None, nolocation=False, second=False):
    if err.getErrorMessage().split()[0] == '401' and not second:
       log.info('Board '+str(self.host)+' doesn\'t appears to support SETOTP command for uri '+str(uri))
       return wu.getPage(uri, http_user=self.user, http_password=self.pwd, 
          method=method, postdata=postdata).addErrback(self._requestPageErr, uri, nolocation=nolocation, second=True)
    log.error("Page "+str(uri)+"can't be accessed! ("+err.getErrorMessage()+")")
    raise error.Error(err.getErrorMessage().split()[0], err.getErrorMessage())
Exemple #2
0
 def _getReport(self):
    log.debug("Weather get report")
    if self.usecity:
       page="http://api.openweathermap.org/data/2.5/weather?q="+str(self.city)+"&units=metric"
    else:
       page="http://api.openweathermap.org/data/2.5/weather?lat="+str(self.lat)+"&lon="+str(self.lon)+"&mode=json&units=metric"
    cb=wu.getPage(page, headers={'x-api-key': str(self.owmid)}).addCallbacks(self.onData, self.onError)
Exemple #3
0
 def _webRequest(self):
    args="?xjerr=1&client=chromium&pfilter=0&lang="+self.lang+"&lm="+self.grammar+"&maxresults="+str(self.maxresults)
    headers={"Content-Type": "audio/x-flac; rate=8000"}
    f=open(self.flacname,'rb')
    audio=f.read()
    f.close()
    url=SPEECHURL+args
    return web.getPage(url, method='POST', postdata=audio, headers=headers, agent=self.agent)
Exemple #4
0
 def _requestOTPPage(self, uri, pwd, method='GET', postdata=None, nolocation=False):
    log.info("Send OTP Request for "+str(uri)+" with pwd "+str(pwd))
    return wu.getPage(uri, http_user='******', http_password=str(pwd), method=method, postdata=postdata, nolocation=nolocation
       ).addCallback(self._requestPageOk, uri
       ).addErrback(self._requestPageErr, uri, method, postdata, nolocation)
Exemple #5
0
 def check_device(self, device):
    log.info("DETECTED DEVICE: "+str(device))
    location=device.get_location()
    wu.getPage(location).addCallback(self.parseXML, device)
Exemple #6
0
 def getPage(self, page):
    self.started=False
    self.connector, cb = wu.getPage(page,  progress=self.progress, stream=True, headerscb=self.gotHeaders) #, stream=pagePart)
    reactor.callLater(1, self.checkStarted, page)
Exemple #7
0
 def getAudio(self):
    print "get", self.audiourl
    return web.getPage(self.audiourl, agent=self.agent)
Exemple #8
0
 def getSitecomName(self, res):
    wu.getPage("http://"+self.host+'/util/query.cgi',
       http_user="******", http_password=self.adminpwd).addCallback(
          self.saveSitecom, res)
Exemple #9
0
 def __init__(self, uri, method, req):
    self.method = method
    self.uri = uri
    self.req = req
    wu.getPage(uri).addCallbacks(self.onOk, self.onError)