Exemple #1
0
    def bildirim(self, baslik=None, icerik=None, gorsel=None) -> None:
        if platform.machine(
        ) == "aarch64" or self.kullanici_adi == "gitpod" or self.bellenim_surumu.split(
                '-')[-1] == 'aws':
            return

        dizin = os.getcwd()
        konum = dizin.split(
            "\\") if self.isletim_sistemi == "Windows" else dizin.split("/")
        dosya_adi = f"~/../{konum[-2]}/{konum[-1]}/{sys.argv[0]}"

        ayrac = "/" if self.isletim_sistemi != "Windows" else "\\"

        kutuphane_dizin = Path(__file__).parent.resolve()

        _bildirim = Notify()
        _bildirim._notification_audio = f"{kutuphane_dizin}{ayrac}bildirim.wav"
        _bildirim._notification_application_name = dosya_adi

        if gorsel:
            if not gorsel.startswith("http"):
                _bildirim._notification_icon = f"{dizin}{ayrac}{gorsel}"
            else:
                foto_istek = requests.get(gorsel, stream=True)
                foto_istek.raw.decode_content = True
                with open(f"{kutuphane_dizin}{ayrac}gorsel.png",
                          "wb") as dosya:
                    copyfileobj(foto_istek.raw, dosya)
                _bildirim._notification_icon = f"{kutuphane_dizin}{ayrac}gorsel.png"

        _bildirim.title = baslik or self.pencere_basligi
        _bildirim.message = icerik or self.bildirim_metni
        _bildirim.send(block=False)
Exemple #2
0
    def notify(self, block=True, **kwargs):
        from notifypy import Notify
        notification = Notify()
        for key, value in kwargs.items():
            setattr(notification, key, value)

        notification.send(block=block)
Exemple #3
0
class App():
    def __init__(self, api, crypto_coin):
        self.coingecko = api
        self.notification = Notify()
        self.crypto_coin = crypto_coin
        self.currency = 'usd'
        self.crypto = self.coingecko.get_price(ids=self.crypto_coin,
                                               vs_currencies=self.currency)
        self.title = f"{self.crypto_coin.title()} Current Price"
        self.message = f"The Current Price of {self.crypto_coin.title()} is {self.Price()}"
        self.notification.icon = icon
        self.notification.audio = sound

    def notifyMe(self):
        self.notification.title = self.title
        self.notification.message = self.message
        self.notification.send()

    def Price(self):
        coin_price = 0
        for price in self.crypto:
            coin_price = self.crypto[price]
        return locale.currency(coin_price[self.currency], grouping=True)

    def getCoinList(self):
        coins_list = self.coingecko.get_coins_list()
        return coins_list

    def getCurrencies(self):
        currencies = self.coingecko.get_supported_vs_currencies()
        return currencies
Exemple #4
0
	def __init__(self, db: DB, notification_title: str):
		self._db = db
		self._cancel_event = Event()
		self._thread = Thread(target=self._notification_loop)
		self._filter = TaskFilter(self.SLEEP_TIME)
		self._notification = Notify()
		self._notification.title = notification_title
Exemple #5
0
def shutdown_notify(minutes):
    """
    Sends a notification if there is a pending shutdown in N minutes
    from now.
    """
    systemd_shutdown_file = "/run/systemd/shutdown/scheduled"
    if not os.path.exists(systemd_shutdown_file):
        click.secho("No shutdown scheduled ✔️", fg="green")
        return

    with open(systemd_shutdown_file, "r") as f:
        content = f.read()
        usec_str = re.search(
            r"USEC=(\d+)",
            content,
        ).group(1)
        now_seconds = time.time()
        time_left_seconds = int(usec_str) / 10**6 - now_seconds
        time_left = timedelta(seconds=int(time_left_seconds))

        if timedelta(minutes=minutes) >= time_left:
            notification = Notify(
                default_notification_title="Pending shutdown",
                default_notification_message=(
                    "The system is scheduled for "
                    f"automatic shutdown in {time_left}.\n"
                    "Use shutdown -c to cancel."),
            )
            notification.send()
Exemple #6
0
 def __init__(self):
     Helper.valid_arguments_compression = ["low", "medium", "high"]
     Helper.valid_arguments_type = ["mp4", "webm", "ogv"]
     Helper.marker = "--"
     Helper.os = os.name
     self.notification = Notify(
         default_notification_icon=Path("./doc/logo.png"))
Exemple #7
0
 def __init__(self, my_dir, allow_renaming=False):
     self.dir = my_dir
     self.allow_renaming = allow_renaming
     self._db = Database(my_dir, observer=self)
     self._allowed_renames = []
     self._allowed_modifications = []
     self._notify = Notify(default_notification_application_name="RefMan")
Exemple #8
0
def Notificacion(opciones):
    """
    Muestra una notificacion de Escritorio

    texto -> str
        Texto de la notificacion
    titulo -> str
        Titulo de la notificacion
    icono -> str
        direcion del icono
    icono_relativo -> bool
        direcion del icono dentro de folder config
    """
    if "texto" in opciones:
        Texto = opciones["texto"]

        Noti = Notify()
        Noti.message = Texto
        Noti.application_name = "ElGatoALSW"

        if "titulo" in opciones:
            Noti.title = opciones["titulo"]
        else:
            Noti.title = "ElGatoALSW"

        # TODO: Iconos relativo
        if "icono" in opciones:
            DirecionIcono = opciones["icono"]
            if "icono_relativo" in opciones:
                if opciones["icono_relativo"]:
                    DirecionIcono = UnirPath(ObtenerFolderConfig,
                                             DirecionIcono)

            Noti.icon = DirecionIcono
        Noti.send()
Exemple #9
0
def errorNotify(title, body):
    if thePlatform == "Linux" or thePlatform == "Darwin":
        from notifypy import Notify

        notif = Notify()
        notif.title = title
        notif.message = body
        notif.icon = "./icons/png/robloxnotif.png"
        notif.audio = path.realpath("./sounds/error.wav")
        notif.application_name = "robloxnotif"
        notif.send(block=True)

    elif thePlatform == "Windows":
        import win10toast
        from playsound import playsound

        toast = win10toast.ToastNotifier()
        toast.show_toast(
            title,
            body,
            duration=5,
            icon_path="./icons/robloxnotif.ico",
            threaded=True,
            sound=False,
        )
        try:
            playsound(path.realpath("./sounds/error.wav"))
        except UnicodeDecodeError:
            pass
        while toast.notification_active():
            sleep(0.1)
def notify_popout(title=None,
                  message=None,
                  icon=sg.DEFAULT_BASE64_ICON,
                  app_name=None):
    """
    Show a notification popout window

    :param title: Title shown in the notification
    :param message: Message shown in the notification
    :param icon: Icon shown in the notification - defaults to PySimpleGUI icon. Should be a PNG file
    :param app_name: Application name shown in the notification
    """
    if not hasattr(notify_popout, 'temp_files'):
        notify_popout.temp_files = []

    notification = Notify()
    notification.title = title
    notification.message = message
    tmp = None
    if isinstance(icon, bytes):
        with tempfile.TemporaryFile(suffix='.png', delete=False) as tmp:
            tmp.write(base64.b64decode(icon))
            tmp.close()
        notification.icon = tmp.name
    elif icon is not None:
        notification.icon = icon
    if app_name is not None:
        notification.application_name = app_name
    notification.send(block=False)
    if tmp is not None:
        notify_popout.temp_files.append(tmp.name)
Exemple #11
0
 def __init__(self, api, crypto_coin):
     self.coingecko = api
     self.notification = Notify()
     self.crypto_coin = crypto_coin
     self.currency = 'usd'
     self.crypto = self.coingecko.get_price(ids=self.crypto_coin,
                                            vs_currencies=self.currency)
     self.title = f"{self.crypto_coin.title()} Current Price"
     self.message = f"The Current Price of {self.crypto_coin.title()} is {self.Price()}"
     self.notification.icon = icon
     self.notification.audio = sound
Exemple #12
0
def notify(message: str):
    """Notify with a given message."""
    notification = Notify(
        default_notification_title="Remember",
        default_application_name="name",
        default_notification_icon=s.config.http_path,
        # default_notification_audio=""
    )

    notification.message = message
    notification.send()
def Birthday_Today_Notification(First, Last, Age):
    notification = Notify()
    notification.title = f"{First} {Last}'s Birthday!!!"
    notification.message = f"{First} is turning {Age} today! Make sure to wish them a happy birthday!"
    notification.icon = "Images\BirthdayCakeIcon.png"
    notification.application_name = "Birthday Tracker"
    notification.audio = r"Images\NotificationSound.wav"
    notification.send()
Exemple #14
0
def _notify(title: str, body: str, image: str = None) -> None:
    notification = Notify()
    notification.title = title
    notification.message = body
    notification.icon = image if image and os.path.exists(image) else app_icon
    notification.application_name = APP_NAME
    notification.send(block=False)
Exemple #15
0
 def notify(self, title, description, duration=5):
     notification = Notify()
     notification.title = title
     notification.message = description
     notification.icon = "./assets/image/icon.png"
     notification.audio = "./assets/audio/notification.wav"
     notification.send()
Exemple #16
0
 def notification_send(title, message, config_dict, b_sound):
     notification = Notify()
     notification.title = title
     notification.message = message
     notification.icon = config_dict['PATH_NOTIF_ICON']
     if b_sound:
         notification.audio = config_dict['PATH_NOTIF_SOUND']
     notification.send()
Exemple #17
0
    def find_product_match(self, wishlist_file=None):
        """If a match is found with the wishlist, a notification is created"""
        wish_list = WishList(wishlist_file).items
        notification = None
        product = self.get_product()
        for item in wish_list:
            if item.lower() in product['productName'].lower() or item.lower() in product['offerName'].lower():

                notification = Notify()
                timeend = re.search("(\d\d:\d\d:\d\d)", product['dealEndDateTime']).group(1)
                message = f"Price:  {product['price']} EUR \nDiscount: {product.get('discount','-')}% \nEnds: {timeend}"
                notification.title = product['productName']
                notification.message = message

        return product, notification
Exemple #18
0
def opm_notify_main():
    """Main function for Sending Notification Message to the Host Desktop

    The function is used in OPMRUN background scripts to send a status notification message to the host desktop, based
    on the augments supplied to the function, there are no parameters for this function. The function is used on a
    standalone basis and thus does not use the OPMRUN system variable directory.

    Augments
    --------
    --title= : str
        The title to be used in the notification. If default with '' then 'OPMRUN Background Processing", will be used.
    --message= : dict
        The message to be displayed in the notification, should normally the job number and job name.
    --status= : int
        Status code used to display the icon in the notification set to one of the following:
            ''   : for the default icon opmrun.png
            "0"  : for pass and the opm_notify_pass.png icon
            "0"  : for fail and the opm_notify_fail.png icon.

    Parameters
    ----------
    None

    Returns
    -------
    Issues notification message to the desktop.
    """

    #
    # Read Arguments
    #
    title    = ''
    message  = ''
    pathdir  = os.path.dirname(os.path.abspath(__file__))
    icon     = Path(pathdir) / 'opmrun.png'
    iconpass = Path(pathdir) / 'opmrun-pass.png'
    iconfail = Path(pathdir) / 'opmrun-fail.png'
    for cmd in sys.argv:
        if '--title=' in cmd:
            title = cmd.replace('--title=', '')
            if title is None:
                title = 'OPMRUN Background Processing'
        elif '--message=' in cmd:
            message = cmd.replace('--message=', '')
        elif '--status=' in cmd:
            status = cmd.replace('--status=', '')
            if status == '0':
                icon = iconpass
            elif status == '1':
                icon = iconfail

    notification                  = Notify()
    notification.application_name = 'OPMRUN Background Processing',
    notification.title            = str(title)
    notification.message          = str(message)
    notification.icon             = icon
    notification.send(block=False)
Exemple #19
0
 def send_notification(self, title, message):
     if self.config.ENABLE_NOTIFICATIONS and sys.platform == 'win32':
         from notifypy import Notify
         notification = Notify()
         notification.title = title
         notification.message = message
         notification.application_name = "AzurLaneAutoScript"
         notification.icon = "assets/gooey/icon.ico"
         notification.send(block=False)
Exemple #20
0
def notify(title="Event", message=None, location=None):
    """Send a system notification"""
    notification = Notify()
    notification.title = title
    notification.message = message
    if location:
        message += f"\nLocation: {location}"
    notification.icon = "./schedule.png"
    notification.audio = "./Polite.wav"
    notification.send()
Exemple #21
0
def EnviarNotificacion(mensaje, audio):
    NotigicacionBase = Notify()
    NotigicacionBase.title = "Titulo"
    NotigicacionBase.message = mensaje
    if audio is not None:
        NotigicacionBase.audio = path.join(direcion, audio)
    NotigicacionBase.send()
Exemple #22
0
def standard_message(lecture, time_left, logo):

    notification = Notify()
    notification.title = lecture
    notification.message = f'ლექციამდე დარჩენილია {time_left} საათი, არ დაგავიწყდეს BTU-სა და Google ქლასრუმებზე დავალების ნახვა.'
    notification.icon = logo
    notification.send()
Exemple #23
0
def set_timer(time: Union[str, int, float], message: str = "Timer finished") -> None:
    if type(time) is str:
        match = pattern.match(time)

        if match is None:
            raise SyntaxError(f"Incorrect time format: {time}")

        amount = float(match.group(1))
        unit = match.group(2) or "s"
    elif type(time) in (int, float):
        amount = time
        unit = "s"

    notification = Notify()
    notification.title = "Timer"
    notification.message = message

    Timer(amount * units[unit], notification.send).start()
Exemple #24
0
class Helper():
    '''
        cc2 Helper
        ----------
        This class loads the "settings.json", defines global variables 
        and manages notifications
    '''

    global valid_arguments_compression
    global valid_arguments_type
    global path
    global marker
    global settings_data

    def __init__(self):
        Helper.valid_arguments_compression = ["low", "medium", "high"]
        Helper.valid_arguments_type = ["mp4", "webm", "ogv"]
        Helper.marker = "--"
        Helper.os = os.name
        self.notification = Notify(
            default_notification_icon=Path("./doc/logo.png"))

    def load_settings(self):
        Helper.settings_data = []
        Helper.path = ""
        Helper.notification = 0
        try:
            file_path = Path("./settings.json")
            with open(file_path) as f:
                data = json.load(f)

            Helper.settings_data = data
            Helper.path = data['settings'][0]['cc2_folder']
            Helper.notification = data['settings'][0]['notification']

            print("Settings-Loaded")
        except:
            print("Error @load_settings")

    def notification_message(self, title, message):
        if (Helper.notification):
            self.notification.title = title
            self.notification.message = message
            self.notification.send()
Exemple #25
0
 def __init__(self, remote_notifications=False):
     self._local_notifier = LocalNotify()
     if remote_notifications:
         self._remote_notifier = RemoteNotify()
         logger.info(
             "Registering a new Remote Push Notification (RPN) endpoint")
         remote_notify_info = self._remote_notifier.register()
         self._display_remote_notify_info(str(remote_notify_info))
     else:
         self._remote_notifier = None
Exemple #26
0
def notification_send(title="Empty", message="No message", icon=""):
    notify = Notify()
    notify.title = title
    notify.message = message
    try:
        notify.icon = icon
        notify.send(block=False)
    except (exceptions.InvalidIconPath):
        pass
Exemple #27
0
def notifier():
    global timer_started, timer_running, clock_values
    timer_started = False
    timer_running = -1
    clock_values = ['00','00','00']
    
    n = Notify()
    n.title = "Timer"
    n.message = "Timer is over"
    n.audio = 'notification.wav'
    n.icon = 'timer.png'

    n.send()
Exemple #28
0
def this_will_run_when_alarm_rings(alarm):
    if alarm[2] == 0:
        pass
    else:
        alarm_ = Alarms()
        time = alarm_.convert_to_12_hour_clock(minutes_from_minight=alarm[4])
        notification = Notify()
        notification.title = alarm[1]
        notification.message = f"The time is {time[0]}:{time[1]} {time[2]}"
        notification.icon = "./Assets/Robert Logo.png"
        notification.audio = "./Assets/beep.wav"
        notification.send()
    alarm_.delete_alarm(alarm[0])
Exemple #29
0
def prompt_for_touch():
    try:
        click.echo('Touch your YubiKey...', err=True)
        notification = Notify()
        notification.title = "Touch your yubikey"
        notification.message = "Touch your yubikey"
        notification.audio = os.path.join(os.path.dirname(__file__),
                                          "notification_sound.wav")
        notification.icon = os.path.join(os.path.dirname(__file__),
                                         "yubikey.png")
        notification.send()
    except Exception:
        sys.stderr.write("Touch your YubiKey...\n")
Exemple #30
0
class Notifier(object):
    def __init__(self, remote_notifications=False):
        self._local_notifier = LocalNotify()
        if remote_notifications:
            self._remote_notifier = RemoteNotify()
            logger.info(
                "Registering a new Remote Push Notification (RPN) endpoint")
            remote_notify_info = self._remote_notifier.register()
            self._display_remote_notify_info(str(remote_notify_info))
        else:
            self._remote_notifier = None

    @classmethod
    def _display_remote_notify_info(cls, remote_notify_info):
        if os.name == 'nt':
            # Windows cmd/powershell does not display QR code properly - stripping it off
            remote_notify_info = remote_notify_info[:remote_notify_info.index(
                "Or scan this QR code")]

        logger.info(
            """\n\n****************** REMOTE PUSH NOTIFICATIONS ********************\n
            %s
            \nNOTE: iOS and Safari NOT supported
            \n*****************************************************************\n""",
            remote_notify_info
        )

    def notify(self, title, message, link):
        if self._remote_notifier:
            self._send_remote_notification(title, message, link)
        else:
            self._send_local_notification(title, message)

    def _send_local_notification(self, title, message):
        self._local_notifier.title = title
        self._local_notifier.message = message
        self._local_notifier.send()

    def _send_remote_notification(self, title, message, link):
        self._remote_notifier.send(
            "{title} - {message}".format(title=title, message=message), link)