Category : error-handling

I have a script that loops through some YouTube videos and adds them to a playlist: for page in pages: add_video_to_playlist(youtube,upsert_id,my_playlist) def add_video_to_playlist(youtube_obj,video_id,yt_pl_id): request = youtube_obj.playlistItems().insert( part="snippet", body={ "snippet": { "playlistId": yt_pl_id, #"position": 0, "resourceId": { "kind": "youtube#video", "videoId": video_id } } } ) try: response = request.execute() print(response[‘snippet’][‘title’]) except HttpError as err: return "Error: ..

Read more

I have some selenium code which is always throwing up this exception: Error: [(‘C:UsersuserAppDataRoamingMozillaFirefoxProfilestp3cz5dm.default-releasestoragedefaultmoz-extension+++81745d9e-096f-4b18-ad35-c2ef2dcf93e4^userContextId=4294967295idb3647222921wleabcEoxlt-eengsairo.sqlite-shm’, ‘C:UsersuserAppDataLocalTemptmp5h3p7xuzwebdriver-py-profilecopystoragedefaultmoz-extension+++81745d9e-096f-4b18-ad35-c2ef2dcf93e4^userContextId=4294967295idb3647222921wleabcEoxlt-eengsairo.sqlite-shm’, ‘[Errno 13] Permission denied’)] This error just seems to go away when I run the file again or the loop again. I do have an try and except statement to catch it: except (InvalidSessionIdException, Error): print("Restarting due to Exception InvalidSessionIdException") ..

Read more

I’m trying to iterate through a text file searching for matches to multiple regular expressions. ”’ loc_pattern_2_1 = re.compile(r"[a-zA-Z]+s[a-zA-Z]+,s[a-zA-Z]+") loc_pattern_2_2 = re.compile(r"[a-zA-Z]+s[a-zA-Z]+,s[a-zA-Z]+s[a-zA-Z]+") loc_pattern_1_1 = re.compile(r"[a-zA-Z]+,s[a-zA-Z]+") loc_pattern_1_2 = re.compile(r"[a-zA-Z]+,s[a-zA-Z]+s[a-zA-Z]+") date_pattern = re.compile(r"[a-zA-Z][a-zA-Z][a-zA-Z],s[0-9]+/[0-9]+/[0-9]+") ”’ ^These are the regular expressions. when I plug them all into the re.finditer() part of my code like this: import pdfplumber import os ..

Read more

is there any way to convert my current structure to something close to what I expected? This will help to reduce alot of duplicated code as there might be 401, 402, 403,… my current flask error handling’s structure @error.app_errorhandler(400) def error_400(error): message = error.description logger.info(‘post request fail : {}’.format(message)) return make_response(jsonify({}), 400) @error.app_errorhandler(429) def error_429(error): ..

Read more