Example #1
0
    def getResContent(self):
        if self.RES_CACHE != None:
            return self.RES_CACHE
        gz_res = get_content_from_url(self.CONFIG_RCD_GZ_URL)
        tfile = file("/home/wjj/"+self.RES_DIR+"/config.ini.gz",'wb')
        #tfile = tempfile.NamedTemporaryFile(delete= False)
        tfile.write(gz_res)
        tfile.close()
        plain_res = util.readGzip(tfile.name)
        #os.unlink(tfile.name)

        self.RES_CACHE =  json.loads(unicode(plain_res,'iso-8859-1').replace('\r\n', '\\r\\n'))

        return self.RES_CACHE
Example #2
0
 def downloadImageAndSave(self, imageUrl):
     #imageUrl = 'http://imgstore.cdn.sogou.com/app/a/11220002/349351_s_90_2.webp'
     print imageUrl
     temp = imageUrl.split("/")
     temp.reverse()
     fileName= temp[0]
     filePath = get_absoulte_dir(self.WALLPAPER_DIR+'/'+fileName)
     print 'filePath', filePath
     new_file_path = filePath + '.png'
     #png_file = file(new_file_path,'r')
     if os.path.isfile(new_file_path):
         print 'exist ,skip download \n'
     else:
         img_res = get_content_from_url(imageUrl)
         f = file(filePath,'wb').write(img_res)
         util.convert_webp_to_png(filePath, new_file_path)
     return new_file_path
Example #3
0
 def downloadLargeImg(self, imgId, width, height):
     img_url = self.DOWNLOAD_URL % (imgId, width, height)
     img_res = get_content_from_url(img_url)
     large_img_save_dir =  util.get_absoulte_dir(self.LARGE_DIR+'/%s' % imgId)
     f = file(large_img_save_dir,'wb').write(img_res)
     return large_img_save_dir