def notify(): battery = psutil.sensors_battery() old_bat = 0 while True: signal.signal(signal.SIGINT, signal_handler) # For Future Refrence # signal.pause() # time.sleep(900) percent = battery.percent if percent < old_bat: old_bat = percent - 10 if percent < 20: Notification("Battery Level Reached Critical", str(percent) + "% Percent Remaining, Please Provide Power.", duration=20).send() else: Notification("Battery Level Going Down", str(percent) + "% Percent Remaining", duration=10).send() if percent > old_bat: Notification("Battery Stable :)", str(percent) + "% Percent Remaining", duration=5).send() old_bat = percent time.sleep(900)
def pyNotifier(self): title = self.titulo.text() sms = self.mensagem.toPlainText() if (title or sms) is '': QMessageBox.critical(self.ferramentas, "Erro", "Defina um titulo e mensagem para a notificão..") else: self.labelIntro.setText("Botão [py-notifier] pressionado!") from pynotifier import Notification notificacao = Notification(title=f"{title}", description=f"{sms}", duration=5, urgency=Notification.URGENCY_NORMAL, icon_path="notification-message-im") notificacao.send()
def notify(hours): """ This Function notifies when it's an hour, two hours or more. """ present = it_is_time_for_notify() if hours == 1: Notification("It's an Hour!!", present).send() else: ptr = f"It's {hours} Hours" Notification(ptr, present).send() Timer(3600, function=lambda: notify(hours + 1)).start()
def print_notifications(self): def_ports, routine_ports, def_ports_names, routine_ports_names = self.extract_changed_ports( ) notification_text = '' if len(def_ports) != 0 and len(routine_ports) != 0: notification_text = "Closed ports: " for port in def_ports: notification_text += port if def_ports.index(port) != len(def_ports) - 1: notification_text += ', ' notification_text += " | Opened ports: " for port in routine_ports: notification_text += port if routine_ports.index(port) != len(routine_ports) - 1: notification_text += ', ' Notification( title='MapDiff Port Scanner', description=notification_text, icon_path= 'path/to/image/file/icon.png', # On Windows .ico is required, on Linux - .png duration=3, # Duration in seconds urgency=Notification.URGENCY_CRITICAL).send() elif len(def_ports) != 0 and len(routine_ports) == 0: for port in def_ports: notification_text += port if def_ports.index(port) != len(def_ports) - 1: notification_text += ', ' Notification( title='MapDiff Port Scanner', description='Some ports are closed: ' + notification_text, icon_path= 'path/to/image/file/icon.png', # On Windows .ico is required, on Linux - .png duration=3, # Duration in seconds urgency=Notification.URGENCY_CRITICAL).send() elif len(routine_ports) != 0 and len(def_ports) == 0: for port in routine_ports: notification_text += port if routine_ports.index(port) != len(routine_ports) - 1: notification_text += ', ' Notification( title='MapDiff Port Scanner', description='New ports are opened: ' + notification_text, icon_path= 'path/to/image/file/icon.png', # On Windows .ico is required, on Linux - .png duration=3, # Duration in seconds urgency=Notification.URGENCY_CRITICAL).send()
def notify(msg): Notification( title='Bitcoin Updater', description=msg, icon_path=path, # On Windows .ico is required, on Linux - .png duration=5, # Duration in seconds urgency=Notification.URGENCY_CRITICAL).send()
def notify( title="Python notification", message: str = "Your program has completed", duration: float = 10., sound: str = None ): if sys.platform != "darwin": # pynotifier is windows+linux from pynotifier import Notification Notification( title=title, description=message, icon_path=python_icon, duration=duration, urgency=Notification.URGENCY_CRITICAL ).send() else: from pync import Notifier Notifier.notify(message, title=title) Notifier.remove(os.getpid()) Notifier.list(os.getpid()) if sound is not None: if sound == "random": soundfile = get_random_soundfile() else: soundfile = get_soundfile(sound) playsound(soundfile)
def mainCheck(nose, ls, rs, toComp): global stop global strictness ndist = checkPose(nose, toComp.nose) lsdist = checkPose(ls, toComp.lshold) rsdist = checkPose(rs, toComp.rshold) # print(ndist,lsdist,rsdist) # print(time.time(),stop) currposture = None if ndist > 200/strictness or lsdist/strictness > 75 or rsdist/strictness > 75: currposture = "bad" elif ndist/strictness > 100 or lsdist/strictness > 50 or rsdist/strictness > 50: currposture = "alert" stop += 0.25 else: currposture = "good" stop = time.time()+t1 if stop > time.time()+t1: stop = time.time()+t1 # print("exceed") print(currposture) if time.time() >= stop: print("BAD") Notification( title='Check Your Posture', description='It seems like you are sitting recklessly.', duration=2, # Duration in seconds urgency='normal' ).send() stop = time.time() + t1
def main(): writeOnLCD("Edwin Project") lcd.cursor_pos = (1, 0) writeOnLCD("ELSYS @ 2021") time.sleep(5) Notification(title='Edwin', description='Едвин стартира', duration=5, urgency='normal').send() lcd.clear() while True: try: writeOnLCD("Edwin is waiting.") speech_input = speech_recognition() print("Ти каза : " + speech_input) lcd.clear() read_input(speech_input) except KeyboardInterrupt: writeOnLCD("Bye Bye!") time.sleep(2) lcd.clear() sys.exit()
def __loss(self): Notification(title="CCS Service", description="You lost points!", icon_path=self.notifIconPath, duration=5, urgency=Notification.URGENCY_NORMAL).send() playsound.playsound(self.lossPath)
def check_spam(self): if self.whitelisted: self._spam = 0 self.log_mail() return elif self.blacklisted: self._spam = 1 else: self.discover_url(self.urls) self.check_stored_xss() if self.threshold < self.spam_points: self._spam = 1 if self.get_spam() == 1: self.log.info("Mail moved to spam with id: " + str(self.mail_id)) if platform.system() == "Windows": notification.notify( title='Found spam mail by: ' + getaddresses(self.parsed_mail.get_all('from', []))[0][1], message=self.account, app_icon=None, timeout=10, ) else: Notification( title='Found spam mail by: ' + getaddresses(self.parsed_mail.get_all('from', []))[0][1], description=self.account, duration=10, urgency=Notification.URGENCY_CRITICAL).send() self.log_mail()
def run(self, **kwargs): from pynotifier import Notification title = kwargs.get("title") description = kwargs.get("description") duration = kwargs.get("duration") translate = kwargs.get("translate") if translate: translator = Translator(0) try: _title = translator.start({"text": title, "to_lang": ""}).join(30).get("result") _description = translator.start({"text": description, "to_lang": ""}).join(30).get("result") if type(_title) is str and type(_description) is str: title = _title description = _description else: del _title del _description except Exception: # noqa pass Notification( title=title, description=description, icon_path=None, duration=duration, urgency="critical" ).send()
def myNotify(myTitle, myMessage): Notification( title=myTitle, description=myMessage, icon_path= "abq_Batcher.png.ico", # On Windows .ico is required, on Linux - .png duration=DurationTime, # Duration in seconds urgency='normal').send()
def notify(title: str, msg: str) -> None: print(f"Sending notification: Title: '{title}' Message: '{msg}'") Notification( title=title, description=msg, # Duration in seconds duration=5, urgency=Notification.URGENCY_NORMAL).send()
def SendNotification(name): Notification( title="Birthday", description="Birthday Today \n" + name, icon_path= 'C:\\Users\\saba\\Documents\\personal\\birthdayReminder\\birthday.ico', # On Windows .ico is required, on Linux - .png duration=3, # Duration in seconds urgency=Notification.URGENCY_CRITICAL).send()
def notify(): if sys.platform.startswith('linux'): Notification(title="Download Finished", description="youtube downloader download finished", duration=6, icon_path='favicon.ico', urgency=Notification.URGENCY_NORMAL).send() elif sys.platform.startswith('win32'): toast = ToastNotifier() toast.show_toast(title="Download Finished", msg="youtube downloader download finished", duration=6, icon_path='favicon.ico')
def send_notify(title='Notification Title', description='Notification Description', urgency=Notification.URGENCY_NORMAL): Notification( title=title, description=description, icon_path='path/to/image/file/icon.png', duration=10, # czas powiadomienia w sekundach urgency=urgency ).send()
def resolve_conflict(path, base, local, remote, confirm=True, prefer='local', notifications=False): """ Attempt to resolve a conflict between local and remote files :param base: A string containing the previous contents of the file :param local: A string containing the local contents of the file :param remote: A string containing the remote contents of a file :param confirm: Whether to confirm overwriting a file :param prefer: The side to prefer when overwriting :param notifications: Send notifications """ results = None action = 's' if confirm: Notification(title='SN Sync: Conflict when syncing file', description=path, duration=5, urgency=Notification.URGENCY_CRITICAL).send() action = click.prompt( 'Overwrite/Merge/Skip', type=click.Choice(['o', 'overwrite', 'm', 'merge', 's', 'skip'], case_sensitive=False), show_choices=False, show_default=False, prompt_suffix=' [o/m/S]: ', default='s') action = action[0] if action == 'o': logger.debug("Overwriting with {} copy".format(prefer)) if prefer == 'local': results = local elif prefer == 'remote': results = remote elif action == 'm': had_conflict, contents = merge3_has_conflict(local.splitlines(True), base.splitlines(True), remote.splitlines(True)) contents = ''.join(contents) if had_conflict: logger.debug("File has a conflict") contents = click.edit(text=contents, require_save=True) return contents elif not confirm or action == 's': return None return results
def screenshot(): root.destroy() Notification( title='BitBizScreenShare', description= 'BitBiz ScreenShare is now running in your background, use f2 or f12 to make a screenshot', icon_path='icon.ico', duration=5, urgency=Notification.URGENCY_CRITICAL).send() from mss import mss import ftplib import string import random from pynput import keyboard read_keybind = open("key.txt", "r") COMBINATIONS = [{keyboard.Key.f2}, {keyboard.Key.f12}] current = set() def execute(): with mss() as sct: sct.shot() def id_generator(size=6, chars=string.ascii_uppercase + string.digits): return ''.join(random.choice(chars) for _ in range(size)) randomstring = id_generator() session = ftplib.FTP('', '', '') file = open('monitor-1.png', 'rb') # file to send session.storbinary('STOR ' + randomstring + ".png", file) # send the file file.close() # close file and FTP session.quit() # print("Your link: https://bitbiz.nl/screenshots/" + randomstring + ".png") import pyperclip pyperclip.copy("https://bitbiz.nl/screenshots/" + randomstring + ".png") spam = pyperclip.paste() def on_press(key): if any([key in COMBO for COMBO in COMBINATIONS]): current.add(key) if any(all(k in current for k in COMBO) for COMBO in COMBINATIONS): execute() def on_release(key): if any([key in COMBO for COMBO in COMBINATIONS]): current.remove(key) with keyboard.Listener(on_press=on_press, on_release=on_release) as Listener: Listener.join()
def notification_popup(main_title,quote): Notification( title=main_title, description=quote, icon_path=None, # On Windows .ico is required, on Linux - .png duration=10, # Duration in seconds urgency=Notification.URGENCY_CRITICAL ).send()
def notify_handler(self, text): print(f"sending {text} to client...") self.statusLabel.show() Notification( title=f'{self.timer().name}', description=f'{text}', #icon_path='path/to/image/file/icon.png', # On Windows .ico is required, on Linux - .png duration=5, # Duration in seconds urgency=Notification.URGENCY_CRITICAL).send()
def myNotify(myTitle, myMessage): if sys.platform == 'linux': Notification( title=myTitle, description=myMessage, # icon_path='Notify.ico', # On Windows .ico is required, on Linux - .png duration=DurationTime, # Duration in seconds urgency='normal', ).send() else: Notification( title=myTitle, description=myMessage, icon_path= 'Notify.ico', # On Windows .ico is required, on Linux - .png duration=DurationTime, # Duration in seconds urgency='normal', ).send()
def test_osx(mocker): """Tests pync is imported and called on OSX.""" pync = mocker.patch("pync.notify") Notification( title="OSX Title", description="OSX Description", ).send() pync.assert_called_with(message="OSX Description", title="OSX Title", appIcon=None)
def test_linux_fails_on_osx(mocker): """Tests linux fails on OSX because notify-send is not on the PATH.""" system = mocker.patch("platform.system") system.return_value = "Linux" with pytest.raises(SystemError): Notification( title="Notification Title", description="Notification Description", ).send()
def notifier(theme): title = "KDynamic" message = f"Current {data['wm']} theme changed to {theme}, Some application may need to restart to apply change" timeout = 50 from pynotifier import Notification Notification(title=title, description=message, icon_path='KDynamicLogo.png', duration=5, urgency='normal').send()
def notify( title: str, description: str = '', ): Notification( title = title, description = description, duration = 5, urgency = Notification.URGENCY_NORMAL, ).send()
def wrapper_function(*args, **kwargs): if urgency == 'low': urgency2 = Notification.URGENCY_LOW elif urgency == 'normal': urgency2 = Notification.URGENCY_NORMAL elif urgency == 'critial': urgency2 = Notification.URGENCY_CRITICAL else: urgency2 = Notification.URGENCY_NORMAL ico_result = SUCCESS_ICO isException = -1 extra = -1 result = None try: result = original_function(*args, **kwargs) extra = 'SUCCESFULLY - ' except Exception as e: ico_result = ERROR_ICO extra = 'ERROR - ' isException = e notification = Notification(extra + title, msg, duration, urgency2) try: notification.send() if email != -1: if isException == -1: subject = True else: subject = False requests.post('https://sender-msg.herokuapp.com/email/', json={ "email": email, "subject": subject }) except Exception as e: raise e if isException != -1: raise isException else: return result
def show_notification() -> None: while True: game_data: GameData = notification_queue.get() logging.debug(f"main.show_notification: Got {game_data}") cache.add(game_data) Notification(title=game_data.name, description=game_data.get_discounts(), duration=settings.notification_duration).send() time.sleep(settings.notification_duration + 1) notification_queue.task_done()
def main(min, rel): min *= 60 rel = 1 * 60 while True: work = min break_ = rel Notification("Time to work⚒", "Timer is starting now", 10).send() while work: mins, secs = divmod(work, 60) os.system("CLS") print(pyfiglet.figlet_format("{:02d}:{:02d}".format(mins, secs), justify='center', font='big')) time.sleep(1) work -= 1 Notification("You can relax now!🥞", "Ok your time is up, just relax☺", 10).send() while break_: mins, secs = divmod(break_, 60) os.system("CLS") print(pyfiglet.figlet_format("{:02d}:{:02d}".format(mins, secs), justify='center', font='big')) time.sleep(1) break_ -= 1
def notify(msg): try: Notification(title="TextShot", description=msg).send() except (SystemError, NameError): trayicon = QtWidgets.QSystemTrayIcon( QtGui.QIcon( QtGui.QPixmap.fromImage( QtGui.QImage(1, 1, QtGui.QImage.Format_Mono)))) trayicon.show() trayicon.showMessage("TextShot", msg, QtWidgets.QSystemTrayIcon.NoIcon) trayicon.hide()
def main(): """ This function initializes the Hour Timer and Break Timer. """ Notification("Started Timer...", " ").send() Timer(3600, function=lambda: notify(1)).start() while True: time.sleep(1200) App()