Esempio n. 1
0
 def _url_file_save(self, url, fp, o=True):
     try:
         uo = urllib.URLopener()
         ufo = uo.open(url)
         data = ufo.read()
         ufo.close()
         fo = open(fp, 'w+b')
         fo.write(data)
         fo.close()
     except:
         loger.warning('not able to save data to file.')
         return None
     return fp
Esempio n. 2
0
 def expost(self, json=True, posturl='', postdata=None):
     if not postdata:
         self.postdata = dict()
         self.postdata[self.ext] = dict()
     elif self.ext not in postdata:
         tmpd = dict()
         tmpd[self.ext] = self.postdata
         self.postdata = tmpd
     else:
         self.postdata = postdata
     td = self.postdata[self.ext]
     for k in self.keys:
         if k not in td:
             loger.warning('may be ignore key: %s' % k)
     self.posturl = posturl
     return self.post(json=json)