update logs for the mobile driver

This commit is contained in:
piair 2021-12-28 11:31:35 +01:00
parent 6c3efee69a
commit 4094081c33

19
V4.py
View File

@ -106,15 +106,20 @@ def CustomSleep(temps):
else : else :
sleep(temps) sleep(temps)
def ListTabs(): def ListTabs(Mdriver = None ):
tabs = [] tabs = []
if Mdriver :
driver = Mdriver
for i in driver.window_handles : for i in driver.window_handles :
driver.switch_to.window(i) driver.switch_to.window(i)
tabs.append(driver.current_url) tabs.append(driver.current_url)
return(tabs) return(tabs)
def LogError(message,log = Log): def LogError(message,log = Log, Mdriver = None):
if Mdriver :
driver = Mdriver
if not IsLinux : if not IsLinux :
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
print(f'\033[93m Erreur : {str(message)} \033[0m') print(f'\033[93m Erreur : {str(message)} \033[0m')
@ -135,7 +140,7 @@ def LogError(message,log = Log):
channel = client.get_channel(833275838837030912) #channel de log channel = client.get_channel(833275838837030912) #channel de log
await channel.send("------------------------------------\n" + _mail) await channel.send("------------------------------------\n" + _mail)
await channel.send(ListTabs()) await channel.send(ListTabs(Mdriver=Mdriver))
await channel.send(str(message)) await channel.send(str(message))
CustomSleep(1) CustomSleep(1)
await channel.send(file=discord.File('screenshot.png')) await channel.send(file=discord.File('screenshot.png'))
@ -494,8 +499,8 @@ def BingMobileSearch(override = randint(20,25)):
CustomSleep(uniform(5,10)) CustomSleep(uniform(5,10))
Mlogin(echec) Mlogin(echec)
else : else :
LogError('recherche sur mobile impossible. On skip \n\n\n\n\n\n\n\n') LogError('recherche sur mobile impossible. On skip \n\n\n\n\n\n\n\n', Mdriver=MobileDriver)
printf(f"login impossible 3 fois de suite. {e}") LogError(f"login impossible 3 fois de suite. {e}",Mdriver=MobileDriver)
MobileDriver.quit() MobileDriver.quit()
return(True) return(True)
@ -518,7 +523,7 @@ def BingMobileSearch(override = randint(20,25)):
except exceptions.NoAlertPresentException as e : except exceptions.NoAlertPresentException as e :
pass pass
except Exception as e: except Exception as e:
LogError(f"error sur une alerte dans le driver mobile. {e}") LogError(f"error sur une alerte dans le driver mobile. {e}",Mdriver=MobileDriver)
if not Mlogin(echec) : if not Mlogin(echec) :
@ -546,7 +551,7 @@ def BingMobileSearch(override = randint(20,25)):
except Exception as e: except Exception as e:
LogError("BingMobileSearch" + str(e)) LogError("BingMobileSearch" + str(e),Mdriver=MobileDriver)
try : try :
MobileDriver.quit() MobileDriver.quit()
except Exception as e: except Exception as e: