Exemple #1
0
def run(name: str):
    logging.debug('Running ' + name)
    if osinfo.is_win():
        subprocess.Popen([os.path.dirname(sys.executable) + '/' + name + '.exe'])
    elif osinfo.is_linux():
        subprocess.Popen([os.path.dirname(sys.executable) + '/' + name ])
    else:
        raise OSError(platform.system() + 'is not supported!')
Exemple #2
0
def remove_old_installation():
    """Remove old files."""

    logging.info('Removing old updater installation')

    if osinfo.is_win():
        os.remove('updater.exe')
    else:
        os.remove('updater')
Exemple #3
0
def main():
    app = QtWidgets.QApplication(sys.argv)
    if not (osinfo.is_linux() or osinfo.is_mac_os() or osinfo.is_win()):
        not_valid_os()
        exit(1)
    test_for_update()
    thr = update_updater()
    window = SiteMonster()
    window.show()
    if thr is not None:
        thr.join()
    sys.exit(app.exec_())
def send_notification(message):
    """Send push notification to your PC."""

    logging.info('Sending notification')

    if osinfo.is_win():
        send_windows_notification(message)
    elif osinfo.is_linux():
        send_linux_notification(message)
    elif osinfo.is_mac_os():
        send_mac_os_notification(message)
    else:
        raise OSError("Unknown OS: " + platform.system())
def send_windows_notification(message: str):
    """Send windows 10 toast notification."""

    logging.debug('Sending windows 10 toast notification')

    if not osinfo.is_win():
        logging.error('Trying to send win10 notification not from win10!')
        raise OSError(
            'Windows toast notifications can be sent only from Windows 10!')

    import win10toast

    toaster = win10toast.ToastNotifier()
    toaster.show_toast(appinfo.APP_NAME,
                       message,
                       icon_path=appinfo.APP_ICON,
                       duration=5,
                       threaded=True)
Exemple #6
0
def get_and_create_data_folder() -> str:
    """Gets data folder.

    For more information see docs for  functions `get_data_folder_windows`,
    `get_data_folder_macos` and `get_data_folder_linux`.

    """

    folder = None

    if is_win():
        folder = get_data_folder_windows()
    elif is_linux():
        folder = get_data_folder_linux()
    elif is_mac_os():
        folder = get_data_folder_macos()
    else:
        raise OSError("Unknown OS: " + platform.system())

    if not os.path.exists(folder):
        os.makedirs(folder)

    return folder