Пример #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!')
Пример #2
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_())
Пример #3
0
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())
Пример #4
0
def send_linux_notification(message: str):
    """Send linux libnotify notification."""

    logging.debug('Sending linux libnotify notification')

    if not osinfo.is_linux():
        logging.error('Trying to send linux notification not from linux!')
        raise OSError(
            'Linux libnotify notifications can be sent only from linux-based OS!'
        )
    if appinfo.APP_ICON is not None:
        os.system(
            'notify-send "{}" "{}" --icon="{}" --expire-time=30000'.format(
                appinfo.APP_NAME, message, os.path.abspath(appinfo.APP_ICON)))
    else:
        os.system('notify-send "{}" "{}" --expire-time=30000'.format(
            appinfo.APP_NAME, message))
Пример #5
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
Пример #6
0
        exit(1)
    test_for_update()
    thr = update_updater()
    window = SiteMonster()
    window.show()
    if thr is not None:
        thr.join()
    sys.exit(app.exec_())


def add_in_startup():
    if getattr(sys, 'frozen', False):
        path = os.getenv('HOME') + '/.config/autostart/'
        if not os.path.exists(path):
            os.makedirs(path)
        shutil.copyfile('/usr/share/applications/daemon.desktop', path + '/Site Monster Daemon.desktop')


def not_valid_os():
    QtWidgets.QMessageBox.information(QtWidgets.QMessageBox(), "Can't start",
                                                  "This app don't support this os",
                                                  QtWidgets.QMessageBox.Ok)


if __name__ == '__main__':
    if osinfo.is_linux():
        add_in_startup()
    logging.info('Starting app')
    run_daemon_if_it_is_not_running()
    main()