From 27b89b4fe58a9e9dc8681414f456fc2b15887abd Mon Sep 17 00:00:00 2001 From: Marcel Eggert Date: Wed, 23 Feb 2022 17:44:54 +0100 Subject: [PATCH] [Change] bugFix checkUrl --- main-azraelis.py | 58 ++++++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/main-azraelis.py b/main-azraelis.py index 1dc63a8..b816c8a 100644 --- a/main-azraelis.py +++ b/main-azraelis.py @@ -701,30 +701,6 @@ def uploadPictureToGDrive(daten): def checkBaseUrl(daten): - if not 'baseUrl' in daten['bannerInfos']: - daten['bannerInfos']['baseUrl'] = "Bitte Url nachtragen" - import pygsheets - - gc = pygsheets.authorize(service_file='gdrive.json') - - #open the google spreadsheet (where 'PY to Gsheet Test' is the name of my sheet) - sh = gc.open('Banner Liste') - - #select the first sheet - wks = sh[0] - - i = 1 - - cells = wks.get_all_values(include_tailing_empty_rows=False, include_tailing_empty=False, returnas='matrix') - - not_in = True - banner_name = daten['bannerInfos']['filename'].split("_") - - for cell in cells: - if banner_name[1] == cell[1]: - daten['bannerInfos']['baseUrl'] = cell[2] - break - if 'baseUrl' in daten['bannerInfos']: import os import pickle @@ -755,7 +731,7 @@ def checkBaseUrl(daten): from pprint import pprint # from init_photo_service import service import pandas as pd - + import time """ list method @@ -787,8 +763,9 @@ def checkBaseUrl(daten): wks = sh[0] i = 1 + for item in lst_medias: - print(i) + print(f"{i}/{len(lst_medias)}") cells = wks.get_all_values(include_tailing_empty_rows=False, include_tailing_empty=False, returnas='matrix') not_in = True @@ -802,7 +779,34 @@ def checkBaseUrl(daten): last_row = len(cells) new_row = [ last_row, banner_name[1], item['baseUrl']] worksheet = wks.insert_rows(last_row, values=new_row, inherit=True) - + time.sleep(1) + i += 1 + + + if not 'baseUrl' in daten['bannerInfos']: + daten['bannerInfos']['baseUrl'] = "Bitte Url nachtragen" + import pygsheets + + gc = pygsheets.authorize(service_file='gdrive.json') + + #open the google spreadsheet (where 'PY to Gsheet Test' is the name of my sheet) + sh = gc.open('Banner Liste') + + #select the first sheet + wks = sh[0] + + i = 1 + + cells = wks.get_all_values(include_tailing_empty_rows=False, include_tailing_empty=False, returnas='matrix') + + not_in = True + banner_name = daten['bannerInfos']['filename'].split("_") + + for cell in cells: + if banner_name[1] == cell[1]: + daten['bannerInfos']['baseUrl'] = cell[2] + break + return daten def writeDataToGSheet(daten):