def start(apptype, exec_dir):
    if apptype == 'torrentstream':
        appname = 'Torrent Stream'
    elif apptype == 'acestream':
        appname = 'ACE Stream HD'
    else:
        raise Exception, 'Bad app type'
    single_instance_checker = wx.SingleInstanceChecker(appname + '-' + wx.GetUserId())
    if single_instance_checker.IsAnotherRunning():
        print >> sys.stderr, 'appwrapper: already running, exit'
        if get_default_api_version(apptype, exec_dir) < 2:
            send_startup_event()
        os._exit(0)
    globalConfig.set_value('apptype', apptype)
    globalConfig.set_mode('client_wx')
    wrapper = AppWrapper()
    try:
        bgapp = run_bgapp(wrapper, appname, VERSION)
    except Exception as e:
        print >> sys.stderr, 'Fatal error while starting:', str(e)
        print_exc()
        os._exit(0)

    wrapper.set_bgapp(bgapp)
    bgapp.debug_systray = bgapp.debug_level & 1024 != 0
    ACEStream.Player.systray.DEBUG = bgapp.debug_systray
    ACEStream.Player.systray.SHOW_DEBUG_LEVEL = bgapp.debug_systray
    ACEStream.Player.systray.DEBUG_PIECES = bgapp.debug_level & 128 != 0
    ACEStream.Player.systray.DEBUG_VIDEOSTATUS = bgapp.debug_level & 2048 != 0
    ACEStream.Player.systray.DEBUG_PROXY_BUF = bgapp.debug_level & 4096 != 0
    wrapper.MainLoop()
    if not ALLOW_MULTIPLE:
        del single_instance_checker
    stop_bgapp(bgapp)
def start(apptype, current_dir):
    try:
        config, fileargs = parseargs.parseargs(sys.argv, argsdef, presets={})
    except Exception as e:
        print >> sys.stderr, e
        os._exit(1)

    if config['name'] == '':
        print >> sys.stderr, 'Usage:  ', get_usage(argsdef)
        os._exit(0)
    debug_level = config['debug']
    ACEStream.Core.BitTornado.SocketHandler.DEBUG = debug_level & 8 != 0
    ACEStream.Core.BitTornado.BT1.Choker.DEBUG = debug_level & 8 != 0
    ACEStream.Core.BitTornado.BT1.Connecter.DEBUG = debug_level & 8 != 0
    ACEStream.Core.BitTornado.BT1.Downloader.DEBUG = debug_level & 8 != 0
    ACEStream.Core.BitTornado.BT1.Encrypter.DEBUG = debug_level & 8 != 0
    ACEStream.Core.BitTornado.BT1.Encrypter.DEBUG_CLOSE = debug_level & 8 != 0
    ACEStream.Core.BitTornado.BT1.Rerequester.DEBUG = debug_level & 8 != 0
    ACEStream.Core.BitTornado.BT1.Rerequester.DEBUG_DHT = debug_level & 8 != 0
    ACEStream.Core.BitTornado.BT1.Rerequester.DEBUG_CHECK_NETWORK_CONNECTION = debug_level & 8 != 0
    ACEStream.Core.BitTornado.BT1.track.DEBUG = debug_level & 8 != 0
    ACEStream.Core.BitTornado.BT1.StorageWrapper.DEBUG_LIVE = debug_level == -1 or debug_level & 16 != 0
    ACEStream.Core.Video.VideoSource.DEBUG = debug_level == -1 or debug_level & 16 != 0
    ACEStream.Core.NATFirewall.NatCheck.DEBUG = debug_level & 64 != 0
    ACEStream.Core.NATFirewall.UPnPThread.DEBUG = debug_level & 64 != 0
    ACEStream.Core.NATFirewall.UDPPuncture.DEBUG = debug_level & 64 != 0
    ACEStream.Core.NATFirewall.upnp.DEBUG = debug_level & 64 != 0
    ACEStream.Core.NATFirewall.ConnectionCheck.DEBUG = debug_level & 64 != 0
    ACEStream.Core.BitTornado.RawServer.DEBUG = debug_level & 512 != 0
    ACEStream.Core.BitTornado.RawServer.DEBUG2 = debug_level & 512 != 0
    ACEStream.Core.BitTornado.ServerPortHandler.DEBUG = debug_level & 512 != 0
    ACEStream.Core.BitTornado.ServerPortHandler.DEBUG2 = debug_level & 512 != 0
    ACEStream.Core.BitTornado.HTTPHandler.DEBUG = debug_level & 512 != 0
    ACEStream.Core.BitTornado.HTTPHandler.DEBUG2 = debug_level & 512 != 0
    ACEStream.Core.BitTornado.SocketHandler.DEBUG = debug_level & 512 != 0
    ACEStream.Core.BitTornado.SocketHandler.DEBUG2 = debug_level & 512 != 0
    globalConfig.set_value('apptype', apptype)
    if apptype == 'torrentstream':
        appname = 'Torrent Stream'
    else:
        appname = 'ACE Stream HD'
    app = StreamApp(appname, current_dir)
    iconpath = os.path.join(current_dir, 'data', 'images', 'stream.ico')
    wrapper = AppWrapper()
    wrapper.set_bgapp(app)
    wrapper.set_icon(iconpath)
    app.set_wrapper(wrapper)
    webui_server = WebUIServer(6879, app)
    webui_server.background_serve()
    app.start_stream(config)
    wrapper.MainLoop()
    app.OnExit()
    os._exit(0)
def start(apptype, current_dir):
    try:
        config, fileargs = parseargs.parseargs(sys.argv, argsdef, presets={})
    except Exception as e:
        print >> sys.stderr, e
        os._exit(1)

    if config['name'] == '':
        print >> sys.stderr, 'Usage:  ', get_usage(argsdef)
        os._exit(0)
    debug_level = config['debug']
    ACEStream.Core.BitTornado.SocketHandler.DEBUG = debug_level & 8 != 0
    ACEStream.Core.BitTornado.BT1.Choker.DEBUG = debug_level & 8 != 0
    ACEStream.Core.BitTornado.BT1.Connecter.DEBUG = debug_level & 8 != 0
    ACEStream.Core.BitTornado.BT1.Downloader.DEBUG = debug_level & 8 != 0
    ACEStream.Core.BitTornado.BT1.Encrypter.DEBUG = debug_level & 8 != 0
    ACEStream.Core.BitTornado.BT1.Encrypter.DEBUG_CLOSE = debug_level & 8 != 0
    ACEStream.Core.BitTornado.BT1.Rerequester.DEBUG = debug_level & 8 != 0
    ACEStream.Core.BitTornado.BT1.Rerequester.DEBUG_DHT = debug_level & 8 != 0
    ACEStream.Core.BitTornado.BT1.Rerequester.DEBUG_CHECK_NETWORK_CONNECTION = debug_level & 8 != 0
    ACEStream.Core.BitTornado.BT1.track.DEBUG = debug_level & 8 != 0
    ACEStream.Core.BitTornado.BT1.StorageWrapper.DEBUG_LIVE = debug_level == -1 or debug_level & 16 != 0
    ACEStream.Core.Video.VideoSource.DEBUG = debug_level == -1 or debug_level & 16 != 0
    ACEStream.Core.NATFirewall.NatCheck.DEBUG = debug_level & 64 != 0
    ACEStream.Core.NATFirewall.UPnPThread.DEBUG = debug_level & 64 != 0
    ACEStream.Core.NATFirewall.UDPPuncture.DEBUG = debug_level & 64 != 0
    ACEStream.Core.NATFirewall.upnp.DEBUG = debug_level & 64 != 0
    ACEStream.Core.NATFirewall.ConnectionCheck.DEBUG = debug_level & 64 != 0
    ACEStream.Core.BitTornado.RawServer.DEBUG = debug_level & 512 != 0
    ACEStream.Core.BitTornado.RawServer.DEBUG2 = debug_level & 512 != 0
    ACEStream.Core.BitTornado.ServerPortHandler.DEBUG = debug_level & 512 != 0
    ACEStream.Core.BitTornado.ServerPortHandler.DEBUG2 = debug_level & 512 != 0
    ACEStream.Core.BitTornado.HTTPHandler.DEBUG = debug_level & 512 != 0
    ACEStream.Core.BitTornado.HTTPHandler.DEBUG2 = debug_level & 512 != 0
    ACEStream.Core.BitTornado.SocketHandler.DEBUG = debug_level & 512 != 0
    ACEStream.Core.BitTornado.SocketHandler.DEBUG2 = debug_level & 512 != 0
    globalConfig.set_value('apptype', apptype)
    if apptype == 'torrentstream':
        appname = 'Torrent Stream'
    else:
        appname = 'ACE Stream HD'
    app = StreamApp(appname, current_dir)
    iconpath = os.path.join(current_dir, 'data', 'images', 'stream.ico')
    wrapper = AppWrapper()
    wrapper.set_bgapp(app)
    wrapper.set_icon(iconpath)
    app.set_wrapper(wrapper)
    webui_server = WebUIServer(6879, app)
    webui_server.background_serve()
    app.start_stream(config)
    wrapper.MainLoop()
    app.OnExit()
    os._exit(0)
def start(apptype, exec_dir):
    if apptype == 'torrentstream':
        appname = 'Torrent Stream'
    elif apptype == 'acestream':
        appname = 'ACE Stream HD'
    else:
        raise Exception, 'Bad app type'
    globalConfig.set_value('apptype', apptype)
    globalConfig.set_mode('client_console')
    wrapper = AppWrapper()
    bgapp = run_bgapp(wrapper, appname, VERSION)
    wrapper.set_bgapp(bgapp)
    wrapper.MainLoop()
    stop_bgapp(bgapp)
def start(apptype, exec_dir):
    if apptype == 'torrentstream':
        appname = 'Torrent Stream'
    elif apptype == 'acestream':
        appname = 'ACE Stream HD'
    else:
        raise Exception, 'Bad app type'
    globalConfig.set_value('apptype', apptype)
    globalConfig.set_mode('client_console')
    wrapper = AppWrapper()
    bgapp = run_bgapp(wrapper, appname, VERSION)
    wrapper.set_bgapp(bgapp)
    wrapper.MainLoop()
    stop_bgapp(bgapp)