Skip to content

Commit

Permalink
bugfix : Add exception handling for lost internet connection
Browse files Browse the repository at this point in the history
see #12 for more details
  • Loading branch information
wolfrust committed Sep 22, 2021
1 parent bed6e78 commit e11ec2a
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions bannoti.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from sys import argv
from colorama import Fore, Style, init
init()
import requests


def show_help() -> None:
Expand Down Expand Up @@ -101,22 +102,35 @@ def removeFromStartup(Name) -> None:

while True:

for i in range(len(accounts)):
try:

for i in range(len(accounts)):

pending_now = ban.account_balance(accounts[i])['pending']
pending_then = balances['balances'][accounts[i]]['pending']

pending_now = ban.account_balance(accounts[i])['pending']
pending_then = balances['balances'][accounts[i]]['pending']
if ( pending_now != pending_then ):

if ( pending_now != pending_then ):
if ( not is_negative(pending_now - pending_then)):

if ( not is_negative(pending_now - pending_then)):
print(f'Recieved {str(ban.ban_from_raw(str(pending_now - pending_then)))[0:4]}BAN at account {Fore.YELLOW}{accounts[i][0:7]}{Style.RESET_ALL}{accounts[i][7:61]}{Fore.GREEN}{accounts[i][60:65]}{Style.RESET_ALL}')

print(f'Recieved {str(ban.ban_from_raw(str(pending_now - pending_then)))[0:4]}BAN at account {Fore.YELLOW}{accounts[i][0:7]}{Style.RESET_ALL}{accounts[i][7:61]}{Fore.GREEN}{accounts[i][60:65]}{Style.RESET_ALL}')
if (getOS() == 'Windows'):
exec(r'assets\notify.exe ' + f'"Recieved {str(ban.ban_from_raw(str(pending_now - pending_then)))[0:4]}BAN" "at account {accounts[i]}"')
else:
exec(f'assets/notify "Recieved {str(ban.ban_from_raw(str(pending_now - pending_then)))[0:4]}BAN" "at account {accounts[i]}"')

if (getOS() == 'Windows'):
exec(r'assets\notify.exe ' + f'"Recieved {str(ban.ban_from_raw(str(pending_now - pending_then)))[0:4]}BAN" "at account {accounts[i]}"')
else:
exec(f'assets/notify "Recieved {str(ban.ban_from_raw(str(pending_now - pending_then)))[0:4]}BAN" "at account {accounts[i]}"')
balances['balances'][accounts[i]]['pending'] = pending_now

balances['balances'][accounts[i]]['pending'] = pending_now
sleep(5)

sleep(5)
except (requests.exceptions.ConnectionError, requests.exceptions.ConnectionError) :
print(f"{Fore.RED}Internet connection lost.. {Style.RESET_ALL}", end="")
while True:
sleep(5)
try:
requests.get('https://google.com')
break
except:
pass
print(f"{Fore.GREEN} Restored {Style.RESET_ALL}")

0 comments on commit e11ec2a

Please sign in to comment.