示例#1
0
def main(lbry_name=None):
    def LBRYApp():
        return SysTrayIcon(icon, hover_text, menu_options, on_quit=stop)

    def openui_(sender):
        webbrowser.open(UI_ADDRESS)

    def replyToApplicationShouldTerminate_():
        try:
            reactor.stop()
        except error.ReactorNotRunning:
            log.debug('Reactor already stopped')

    def stop(sysTrayIcon):
        replyToApplicationShouldTerminate_()

    if getattr(sys, 'frozen', False) and os.name == "nt":
        icon = os.path.join(os.path.dirname(sys.executable), ICON_PATH,
                            'lbry16.ico')
    else:
        icon = os.path.join(ICON_PATH, 'lbry16.ico')

    hover_text = APP_NAME
    menu_options = (('Open', icon, openui_), )

    if not test_internet_connection():
        log.warn('No Internet Connection')
        sys.exit(1)

    systray_thread = threading.Thread(target=LBRYApp)
    systray_thread.daemon = True
    systray_thread.start()

    lbry = LBRYDaemonServer()
    d = lbry.start()
    d.addCallback(lambda _: LBRYURIHandler.open_address(lbry_name))
    lbrynet_server = server.Site(lbry.root)
    lbrynet_server.requestFactory = LBRYDaemonRequest
    try:
        reactor.listenTCP(API_PORT, lbrynet_server, interface=API_INTERFACE)
    except error.CannotListenError:
        log.info('Daemon already running, exiting app')
        sys.exit(1)
    reactor.run()
示例#2
0
def main(lbry_name=None):
    def LBRYApp():
        return SysTrayIcon(icon, hover_text, menu_options, on_quit=stop)

    def openui_(sender):
        webbrowser.open(UI_ADDRESS)

    def replyToApplicationShouldTerminate_():
        try:
            reactor.stop()
        except error.ReactorNotRunning:
            log.debug('Reactor already stopped')

    def stop(sysTrayIcon):
        replyToApplicationShouldTerminate_()

    if getattr(sys, 'frozen', False) and os.name == "nt":
        icon = os.path.join(os.path.dirname(sys.executable), ICON_PATH, 'lbry16.ico')
    else:
        icon = os.path.join(ICON_PATH, 'lbry16.ico')

    hover_text = APP_NAME
    menu_options = (('Open', icon, openui_),)

    if not test_internet_connection():
        log.warn('No Internet Connection')
        sys.exit(1)

    systray_thread = threading.Thread(target=LBRYApp)
    systray_thread.daemon = True
    systray_thread.start()

    lbry = DaemonServer()
    d = lbry.start()
    d.addCallback(lambda _: LBRYURIHandler.open_address(lbry_name))
    lbrynet_server = server.Site(lbry.root)
    lbrynet_server.requestFactory = DaemonRequest
    try:
        reactor.listenTCP(API_PORT, lbrynet_server, interface=API_INTERFACE)
    except error.CannotListenError:
        log.info('Daemon already running, exiting app')
        sys.exit(1)
    reactor.run()
示例#3
0
    lbry = DaemonServer()
    d = lbry.start()
    d.addCallback(lambda _: LBRYURIHandler.open_address(lbry_name))
    lbrynet_server = server.Site(lbry.root)
    lbrynet_server.requestFactory = DaemonRequest
    try:
        reactor.listenTCP(API_PORT, lbrynet_server, interface=API_INTERFACE)
    except error.CannotListenError:
        log.info('Daemon already running, exiting app')
        sys.exit(1)
    reactor.run()

if __name__ == '__main__':
    lbry_daemon = JSONRPCProxy.from_url(API_CONNECTION_STRING)

    try:
        daemon_running = lbry_daemon.is_running()
        start_daemon = False
    except:
        start_daemon = True

    try:
        lbry_name = LBRYURIHandler.parse_name(sys.argv[1])
    except IndexError:
        lbry_name = None
    start_daemon = True
    if start_daemon:
        main(lbry_name)
    else:
        LBRYURIHandler.open_address(lbry_name)
示例#4
0
        launchui=True,
        use_auth=False,
        analytics_manager=analytics.Manager.new_instance())
    reactor.run()


if __name__ == '__main__':
    utils.setup_certs_for_windows()
    conf.update_settings_from_file()

    log_file = settings.get_log_filename()
    log_support.configure_logging(log_file, console=True)

    lbry_daemon = JSONRPCProxy.from_url(settings.API_CONNECTION_STRING)

    try:
        daemon_running = lbry_daemon.is_running()
        start_daemon = False
    except:
        start_daemon = True

    try:
        lbry_name = LBRYURIHandler.parse_name(sys.argv[1])
    except IndexError:
        lbry_name = None
    start_daemon = True
    if start_daemon:
        main(lbry_name)
    else:
        LBRYURIHandler.open_address(lbry_name)