示例#1
0
文件: LBRYApp.py 项目: awesome/lbry
    def finishLaunching(self):
        self.connection = False
        statusbar = AppKit.NSStatusBar.systemStatusBar()
        self.statusitem = statusbar.statusItemWithLength_(AppKit.NSVariableStatusItemLength)
        self.icon = AppKit.NSImage.alloc().initByReferencingFile_(ICON_PATH)
        self.icon.setScalesWhenResized_(True)
        self.icon.setSize_((20, 20))
        self.statusitem.setImage_(self.icon)
        self.menubarMenu = AppKit.NSMenu.alloc().init()
        self.open = AppKit.NSMenuItem.alloc().initWithTitle_action_keyEquivalent_("Open", "openui:", "")
        self.menubarMenu.addItem_(self.open)
        self.quit = AppKit.NSMenuItem.alloc().initWithTitle_action_keyEquivalent_("Quit", "replyToApplicationShouldTerminate:", "")
        self.menubarMenu.addItem_(self.quit)
        self.statusitem.setMenu_(self.menubarMenu)
        self.statusitem.setToolTip_(APP_NAME)


        if test_internet_connection():
            if platform.mac_ver()[0] >= "10.10":
                LBRYNotify("Starting LBRY")
        else:
            if platform.mac_ver()[0] >= "10.10":
                LBRYNotify("LBRY needs an internet connection to start, try again when one is available")
            sys.exit(0)

        # if not subprocess.check_output("git ls-remote https://github.com/lbryio/lbry-web-ui.git | grep HEAD | cut -f 1",
        #                                shell=True):
        #     LBRYNotify(
        #         "You should have been prompted to install xcode command line tools, please do so and then start LBRY")
        #     sys.exit(0)

        lbry = LBRYDaemonServer()
        d = lbry.start()
        d.addCallback(lambda _: webbrowser.open(UI_ADDRESS))
        reactor.listenTCP(API_PORT, server.Site(lbry.root), interface=API_INTERFACE)
示例#2
0
def start():
    parser = argparse.ArgumentParser(description="Launch lbrynet-daemon")
    parser.add_argument("--wallet", help="lbrycrd or lbryum, default lbryum", type=str, default="")
    parser.add_argument("--ui", help="path to custom UI folder", default=None)
    parser.add_argument("--branch", help="Branch of lbry-web-ui repo to use, defaults on master")
    parser.add_argument("--no-launch", dest="launchui", action="store_false")
    parser.add_argument("--log-to-console", dest="logtoconsole", action="store_true")
    parser.add_argument("--quiet", dest="quiet", action="store_true")
    parser.set_defaults(branch=False, launchui=True, logtoconsole=False, quiet=False)
    args = parser.parse_args()

    if args.logtoconsole:
        logging.basicConfig(level=logging.INFO)

    args = parser.parse_args()

    try:
        JSONRPCProxy.from_url(API_CONNECTION_STRING).is_running()
        log.info("lbrynet-daemon is already running")
        if not args.logtoconsole:
            print "lbrynet-daemon is already running"
        if args.launchui:
            webbrowser.open(UI_ADDRESS)
        return
    except:
        pass

    log.info("Starting lbrynet-daemon from command line")

    if not args.logtoconsole and not args.quiet:
        print "Starting lbrynet-daemon from command line"
        print "To view activity, view the log file here: " + lbrynet_log
        print "Web UI is available at http://%s:%i" % (API_INTERFACE, API_PORT)
        print "JSONRPC API is available at " + API_CONNECTION_STRING
        print "To quit press ctrl-c or call 'stop' via the API"

    if test_internet_connection():
        lbry = LBRYDaemonServer()

        d = lbry.start(
            branch=args.branch if args.branch else DEFAULT_UI_BRANCH,
            user_specified=args.ui,
            wallet=args.wallet,
            branch_specified=True if args.branch else False,
        )
        if args.launchui:
            d.addCallback(lambda _: webbrowser.open(UI_ADDRESS))

        reactor.listenTCP(API_PORT, server.Site(lbry.root), interface=API_INTERFACE)
        reactor.run()

        if not args.logtoconsole and not args.quiet:
            print "\nClosing lbrynet-daemon"
    else:
        log.info("Not connected to internet, unable to start")
        if not args.logtoconsole:
            print "Not connected to internet, unable to start"
        return
示例#3
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()
示例#4
0
    def finishLaunching(self):
        self.connection = False
        statusbar = AppKit.NSStatusBar.systemStatusBar()
        self.statusitem = statusbar.statusItemWithLength_(
            AppKit.NSVariableStatusItemLength)
        self.icon = AppKit.NSImage.alloc().initByReferencingFile_(ICON_PATH)
        self.icon.setScalesWhenResized_(True)
        self.icon.setSize_((20, 20))
        self.statusitem.setImage_(self.icon)
        self.menubarMenu = AppKit.NSMenu.alloc().init()
        self.open = AppKit.NSMenuItem.alloc(
        ).initWithTitle_action_keyEquivalent_("Open", "openui:", "")
        self.menubarMenu.addItem_(self.open)
        self.quit = AppKit.NSMenuItem.alloc(
        ).initWithTitle_action_keyEquivalent_(
            "Quit", "replyToApplicationShouldTerminate:", "")
        self.menubarMenu.addItem_(self.quit)
        self.statusitem.setMenu_(self.menubarMenu)
        self.statusitem.setToolTip_(APP_NAME)

        if test_internet_connection():
            if platform.mac_ver()[0] >= "10.10":
                LBRYNotify("Starting LBRY")
        else:
            if platform.mac_ver()[0] >= "10.10":
                LBRYNotify(
                    "LBRY needs an internet connection to start, try again when one is available"
                )
            sys.exit(0)

        lbry = LBRYDaemonServer()
        d = lbry.start()
        d.addCallback(lambda _: webbrowser.open(UI_ADDRESS))
        lbrynet_server = server.Site(lbry.root)
        lbrynet_server.requestFactory = LBRYDaemonRequest
        reactor.listenTCP(API_PORT, lbrynet_server, interface=API_INTERFACE)
示例#5
0
def start():
    parser = argparse.ArgumentParser(description="Launch lbrynet-daemon")
    parser.add_argument("--wallet",
                        help="lbrycrd or lbryum, default lbryum",
                        type=str,
                        default='')
    parser.add_argument("--ui", help="path to custom UI folder", default=None)
    parser.add_argument(
        "--branch",
        help="Branch of lbry-web-ui repo to use, defaults on master")
    parser.add_argument('--no-launch', dest='launchui', action="store_false")
    parser.add_argument('--log-to-console',
                        dest='logtoconsole',
                        action="store_true")
    parser.add_argument('--quiet', dest='quiet', action="store_true")
    parser.set_defaults(branch=False,
                        launchui=True,
                        logtoconsole=False,
                        quiet=False)
    args = parser.parse_args()

    log_support.configure_file_handler(lbrynet_log)
    log_support.configure_loggly_handler()
    if args.logtoconsole:
        log_support.configure_console(level='DEBUG')
    log_support.disable_third_party_loggers()
    log_support.disable_noisy_loggers()

    try:
        JSONRPCProxy.from_url(API_CONNECTION_STRING).is_running()
        log.info("lbrynet-daemon is already running")
        if not args.logtoconsole:
            print "lbrynet-daemon is already running"
        if args.launchui:
            webbrowser.open(UI_ADDRESS)
        return
    except:
        pass

    log.info("Starting lbrynet-daemon from command line")

    if not args.logtoconsole and not args.quiet:
        print "Starting lbrynet-daemon from command line"
        print "To view activity, view the log file here: " + lbrynet_log
        print "Web UI is available at http://%s:%i" % (API_INTERFACE, API_PORT)
        print "JSONRPC API is available at " + API_CONNECTION_STRING
        print "To quit press ctrl-c or call 'stop' via the API"

    if test_internet_connection():
        lbry = LBRYDaemonServer()

        d = lbry.start(
            branch=args.branch if args.branch else DEFAULT_UI_BRANCH,
            user_specified=args.ui,
            wallet=args.wallet,
            branch_specified=True if args.branch else False)
        if args.launchui:
            d.addCallback(lambda _: webbrowser.open(UI_ADDRESS))

        lbrynet_server = server.Site(lbry.root)
        lbrynet_server.requestFactory = LBRYDaemonRequest
        reactor.listenTCP(API_PORT, lbrynet_server, interface=API_INTERFACE)
        reactor.run()

        if not args.logtoconsole and not args.quiet:
            print "\nClosing lbrynet-daemon"
    else:
        log.info("Not connected to internet, unable to start")
        if not args.logtoconsole:
            print "Not connected to internet, unable to start"
        return