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, 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)