def check_for_high_battery(self, high_level: int = 80) -> None: """ Checking of low battery percentage. By default it check for 80 Args: high_level: battery percentage number """ high_battery_flag = False notifier = Notifier(self._app_name, self._high_battery_summary, self._high_battery_message, self._high_battery_icon) try: while True: percentage = self._battery.get_percentage() plugged = self._battery.is_plugged() if percentage >= high_level: if plugged is False and high_battery_flag: notifier.close() high_battery_flag = False if plugged and high_battery_flag is False: notifier.show(URGENCY_CRITICAL) high_battery_flag = True else: high_battery_flag = False time.sleep(3) except KeyboardInterrupt: print("User interrupted!")
try: notif = feed.get_notification() feed.last_checked = time.strftime("%H:%M:%S", time.localtime()) # feed obj might have changed, update config CONFIG.write() if notif: NOTIFIER.notify(*notif) except Exception as e: print("error on {}: {}".format(feed, e)) while True: for th in THREADS: th.join() THREADS = [] print("\r", end="") for feed in FEEDS: print(feed.feed['provider'], feed.last_checked, end=" ") t = Thread(target=handle_feed, args=(feed,)) t.start() THREADS.append(t) time.sleep(SLEEP_TIME) if __name__ == '__main__': try: main() except KeyboardInterrupt: print("\nGood Bye!") NOTIFIER.close() exit(0)