How to use download_image method in avocado

Best Python code snippet using avocado_python

download_image.py

Source:download_image.py Github

copy

Full Screen

...67 for key in sign_list:68 request_url = request_url + urllib.urlencode({key: sign_dict[key]}) + "&"69 request_url = DOMAIN + path + "?" + request_url + "sign=" + sign70 return request_url71def download_image(img_url, path, filename):72 try:73 sock = urllib.urlopen(img_url)74 htmlcode = sock.read()75 sock.close()76 filedir = open(os.path.join(path, filename), "wb")77 filedir.write(htmlcode)78 filedir.close()79 except Exception as err:80 logging.info('open url image error: %s', err)81 # abnormal_log.info('open url image error: %s', err)82def main():83 for line in src_file.readlines():84 line = line.strip('\n').split('\t')85 url = line[7]86 filename = url.split('/')[-1]87 request_url = DOMAIN + url88 print(url)89 # request_url = get_sign(url, EXP)90 rejectcodes = line[2]91 if rejectcodes == '230001001': #非3Dhome户型图92 download_image(request_url, './230001001', filename)93 if rejectcodes == '230001002': #标注简称94 download_image(request_url, './230001002', filename)95 if rejectcodes == '230001003': #功能间名称错误96 download_image(request_url, './230001003', filename)97 if rejectcodes == '230001004': #颜色错误98 download_image(request_url, './230001004', filename)99 if rejectcodes == '230001005': #方向标错误100 download_image(request_url, './230001005', filename)101 if rejectcodes == '230001006': #封闭空间102 download_image(request_url, './230001006', filename)103 if rejectcodes=='230001007': #显示不全104 download_image(request_url, './230001007', filename)105 if rejectcodes=='230001008': #户型图修饰106 download_image(request_url, './230001008', filename)107 if rejectcodes=='230001009': #未绘制楼梯108 download_image(request_url, './230001009', filename)109 if rejectcodes=='230001010': #字体大小不一致110 download_image(request_url, './230001010', filename)111 if rejectcodes=='230001011': #双重水印112 download_image(request_url, './230001011', filename)113 if rejectcodes=='230001012': #少绘制功能间114 download_image(request_url, './230001012', filename)115 if rejectcodes=='230001013': #入户门错误116 download_image(request_url, './230001013', filename)117 if rejectcodes=='230001014': #楼层错误118 download_image(request_url, './230001014', filename)119 if rejectcodes=='230001015': #虚线绘制错误120 download_image(request_url, './230001015', filename)121 if rejectcodes=='230001016': #门窗未按实际绘制122 download_image(request_url, './230001016', filename)123 if rejectcodes=='230001017': #格局绘制错误124 download_image(request_url, './230001017', filename)125 if rejectcodes=='230002001': #标准图与测绘图不符126 download_image(request_url, './230002001', filename)127 if rejectcodes=='230002002': #门或窗缺失128 download_image(request_url, './230002002', filename)129 if rejectcodes=='230003001': #门或窗缺失130 download_image(request_url, './230003001', filename)131 if rejectcodes=='230003002': #门窗位置错误132 download_image(request_url, './230003002', filename)133 if rejectcodes=='230003003': #功能间名称错误或缺失134 download_image(request_url, './230003003', filename)135 if rejectcodes=='230003004': #墙体尺寸,位置错误136 download_image(request_url, './230003004', filename)137 if rejectcodes=='230003005': #户型镜像138 download_image(request_url, './230003005', filename)139 if rejectcodes=='230003006': #多余门或窗140 download_image(request_url, './230003006', filename)141 if rejectcodes=='230003007': #缺失墙体142 download_image(request_url, './230003007', filename)143 if rejectcodes=='230003008': #未绘制楼梯144 download_image(request_url, './230003008', filename)145 if rejectcodes=='230003009': #楼梯位置错误146 download_image(request_url, './230003009', filename)147 if rejectcodes=='230003010': #楼层标注缺失或错误148 download_image(request_url, './230003010', filename)149 if rejectcodes=='230003011': #缺失功能间150 download_image(request_url, './230003011', filename)151 if rejectcodes=='230003012': #其它类问题152 download_image(request_url, './230003012', filename)153 if rejectcodes=='230002003': #门窗位置错误154 download_image(request_url, './230002003', filename)155 if rejectcodes=='230002004': #功能间名称错误或缺失156 download_image(request_url, './230002004', filename)157 if rejectcodes=='230002005': #墙体尺寸,位置错误158 download_image(request_url, './230002005', filename)159 if rejectcodes=='230002006': #户型镜像160 download_image(request_url, './230002006', filename)161 if rejectcodes=='230002007': #多余门或窗162 download_image(request_url, './230002007', filename)163 if rejectcodes=='230002008': #缺失墙体164 download_image(request_url, './230002008', filename)165 if rejectcodes=='230002009': #未绘制楼梯166 download_image(request_url, './230002009', filename)167 if rejectcodes=='230002010': #楼梯位置错误168 download_image(request_url, './230002010', filename)169 if rejectcodes=='230002011': #楼层标注缺失或错误170 download_image(request_url, './230002011', filename)171 if rejectcodes=='230002012': #缺失功能间172 download_image(request_url, './230002012', filename)173 if rejectcodes == '230002013': #其他类问题174 download_image(request_url, './230002013', filename)175 if rejectcodes=='230001018': #隐私空间标注错误176 download_image(request_url, './230001018', filename)177 if rejectcodes=='230001019': #门大小不一(90度)178 download_image(request_url, './230001019', filename)179 if rejectcodes=='230001020': #功能间数量与照片不符180 download_image(request_url, './230001020', filename)181 if rejectcodes=='230001021': #墙体不符182 download_image(request_url, './230001021', filename)183 if rejectcodes=='230001022': #其它类问题184 download_image(request_url, './230001022', filename)185 if rejectcodes=='220123': #圈点图与参考图建立关系错误186 download_image(request_url, './220123', filename)187 if rejectcodes=='220124': #开放厨房绘制错误188 download_image(request_url, './220124', filename)189 if rejectcodes=='220125': #层高缺失190 download_image(request_url, './220125', filename)191 if rejectcodes=='220126': #户型结构错误192 download_image(request_url, './220126', filename)193 if rejectcodes=='220127': #户型描述缺失194 download_image(request_url, './220127', filename)195 if rejectcodes=='240001': #画质问题196 download_image(request_url, './240001', filename)197 if rejectcodes=='240002': #空间问题198 download_image(request_url, './240002', filename)199 if rejectcodes=='240003': #隐私问题200 download_image(request_url, './240003', filename)201 if rejectcodes == '240004': #数量、设置问题202 download_image(request_url, './240004', filename)203 if rejectcodes=='240005': #人物问题204 download_image(request_url, './240005', filename)205 if rejectcodes=='240006': #失真问题206 download_image(request_url, './240006', filename)207 if rejectcodes=='240007': #水印208 download_image(request_url, './240007', filename)209 if rejectcodes=='240008': #真实性210 download_image(request_url, './240008', filename)211 if rejectcodes=='240001001': #模糊212 download_image(request_url, './240001001', filename)213 if rejectcodes=='240001002': #黑暗214 download_image(request_url, './240001002', filename)215 if rejectcodes=='240001003': #曝光216 download_image(request_url, './240001003', filename)217 if rejectcodes=='240001004': #噪点218 download_image(request_url, './240001004', filename)219 if rejectcodes == '240002001': #无三面墙220 download_image(request_url, './240002001', filename)221 if rejectcodes == '240002002': #地面过大222 download_image(request_url, './240002002', filename)223 if rejectcodes == '240002003': #地面过小224 download_image(request_url, './240002003', filename)225 if rejectcodes == '240002004': #单一物品226 download_image(request_url, './240002004', filename)227 if rejectcodes == '240002005': #不能隔门隔墙拍摄228 download_image(request_url, './240002005', filename)229 if rejectcodes == '240003001': #隐私衣物230 download_image(request_url, './240003001', filename)231 if rejectcodes == '240003002': #马桶盖232 download_image(request_url, './240003002', filename)233 if rejectcodes == '240004001': #角度重复234 download_image(request_url, './240004001', filename)235 if rejectcodes == '240004002': #数量不符236 download_image(request_url, './240004002', filename)237 if rejectcodes == '240004003': #传错位置238 download_image(request_url, './240004003', filename)239 if rejectcodes == '240004004':240 download_image(request_url, './240004004', filename)241 if rejectcodes == '240005001':242 download_image(request_url, './240005001', filename)243 if rejectcodes == '240005002':244 download_image(request_url, './240005002', filename)245 if rejectcodes == '240005003':246 download_image(request_url, './240005003', filename)247 if rejectcodes == '240005004':248 download_image(request_url, './240005004', filename)249 if rejectcodes == '240006001':250 download_image(request_url, './240006001', filename)251 if rejectcodes == '240006002':252 download_image(request_url, './240006002', filename)253 if rejectcodes == '240007001':254 download_image(request_url, './240007001', filename)255 if rejectcodes == '240007002':256 download_image(request_url, './240007002', filename)257 if rejectcodes == '240008001':258 download_image(request_url, './240008001', filename)259 if rejectcodes == '240008002':260 download_image(request_url, './240008002', filename)261 if rejectcodes == '240009001':262 download_image(request_url, './240009001', filename)263 if rejectcodes == '240010001':264 download_image(request_url, './240010001', filename)265 if rejectcodes == '440001001':266 download_image(request_url, './440001001', filename)267 if rejectcodes == '440001009':268 download_image(request_url, './440001009', filename)269 if rejectcodes == '440001011':270 download_image(request_url, './440001011', filename)271 if rejectcodes == '440001013':272 download_image(request_url, './440001013', filename)273if __name__ == "__main__":...

Full Screen

Full Screen

routes.py

Source:routes.py Github

copy

Full Screen

...87 app.config["UPLOADED_IMAGES"], file_name), file_name)88 return redirect(url_for('download_image', filename=file_name))89 return render_template("index.html")90@app.route("/uploads/<filename>")91def download_image(filename):...

Full Screen

Full Screen

lpl-thumbnails-downloader.py

Source:lpl-thumbnails-downloader.py Github

copy

Full Screen

...28 console = os.path.splitext(os.path.basename(console))[0]29 if 'MAME' in console:30 return 'MAME'31 return console32def download_image(folder, console, game, retry, realname=""):33 repo = "https://raw.githubusercontent.com/libretro-thumbnails/" + urllib.parse.quote(console.replace(' ','_')) + "/master/"34 clean_game = game35 if realname == '':36 realname = game37 original_game = realname.replace('/', '_').replace(':', '_') + '.png'38 game = urllib.parse.quote(game.replace('&', '_').replace(':', '_').replace('/', '_') + '.png')39 thumbnail = 040 if not os.path.exists(folder + '/Named_Boxarts/' + original_game):41 try:42 urllib.request.urlretrieve(repo + 'Named_Boxarts/' + game, folder + '/Named_Boxarts/' + original_game)43 thumbnail += 144 except:45 pass46 else:47 thumbnail += 148 if not os.path.exists(folder + '/Named_Snaps/' + original_game):49 try:50 urllib.request.urlretrieve(repo + 'Named_Snaps/' + game, folder + '/Named_Snaps/' + original_game)51 thumbnail += 152 except:53 pass54 else:55 thumbnail += 156 if not os.path.exists(folder + '/Named_Titles/' + original_game):57 try:58 urllib.request.urlretrieve(repo + 'Named_Titles/' + game, folder + '/Named_Titles/' + original_game)59 thumbnail += 160 except:61 pass62 else:63 thumbnail += 164 if thumbnail == 0:65 print("Not found " + clean_game + ' at ' + repo + 'Named_Boxarts/' + game)66 if retry is False:67 try:68 if clean_game.count(',') > 1:69 # Try with switching stuff inside parenthesis because the game can have different filenames70 s = re.findall('\((.*?)\)', clean_game)71 s = s[0].split(', ')72 try_game_name = s[1] + ', ' + s[0].replace(', ', '')73 clean_game = clean_game.replace(s[0] + ', ' + s[1], try_game_name)74 download_image(folder, console, clean_game, True, realname)75 download_image(folder, console, clean_game.replace(',', ''), True, realname)76 except:77 pass78 if '(Euro)' in clean_game:79 # Try with bootleg80 clean_game = clean_game.replace('(Euro)', '(bootleg)')81 download_image(folder, console, clean_game, True, realname)82 if '(' not in clean_game:83 # Try with adding a country84 download_image(folder, console, clean_game + " (Japan)", True, realname)85 download_image(folder, console, clean_game + " (USA)", True, realname)86 download_image(folder, console, clean_game + " (Europe)", True, realname)87 if '(Europe)' in clean_game:88 # Try with replacing a country89 clean_game = clean_game.replace('(Europe)', '(USA)')90 download_image(folder, console, clean_game, True, realname)91 else:92 print(' Downloaded ' + realname + ' ' + str(thumbnail) + ' thumbnails')93console = get_console_name(args.playlist)94folder = create_folders(console)95print('Downloading ' + console + ' thumbnails')96with open(args.playlist, "r") as read_file:97 data = json.load(read_file)98 if len(data['items']) > 0:99 for item in data['items']:100 download_image(folder, console, item['label'], False)101 else:102 print('Empty playlist.')...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful