def _connect(self): if self.connected: return self._reset() self._debug(u"Sending GoogleLogin request for service=%s, user= %s to endpoint %s" %(self.serviceName, self.username, ZGDataLogin.LOGIN_ENDPOINT)) #$NON-NLS-1$ params = {} params[u"Email"] = self.username #$NON-NLS-1$ params[u"Passwd"] = self.password #$NON-NLS-1$ params[u"service"] = self.serviceName #$NON-NLS-1$ params[u"source"] = ZGDataLogin.SOURCE #$NON-NLS-1$ if self.captchaToken and self.loginCaptcha: params[u"logintoken"] = self.captchaToken #$NON-NLS-1$ params[u"logincaptcha"] = self.loginCaptcha #$NON-NLS-1$ self._debug(u"Sending GoogleLogin logintoken: %s" %self.captchaToken) #$NON-NLS-1$ self._debug(u"Sending GoogleLogin logincaptcha: %s" %self.loginCaptcha) #$NON-NLS-1$ conn = ZSimpleHTTPRequest(ZGDataLogin.LOGIN_ENDPOINT) #$NON-NLS-1$ self.connected = True conn.send(params) self.httpCode = conn.getHttpStatusCode() self.httpMessage = conn.getHttpStatusMessage() self._debug(u"GoogleLogin response code: %d, %s" % (self.httpCode, self.httpMessage)) #$NON-NLS-1$ self.ok = self.httpCode == 200 if self.httpCode == 200 or self.httpCode == 403: data = conn.getResponse() self._parseData(data)
def _fetchContent(self, url): u"""Retrieves the text content from the url.""" #$NON-NLS-1$ request = ZSimpleHTTPRequest(url) content = None if request.send(): content = request.getResponse() content = convertToUnicode(content) return content