Example #1
0
    def OnInit(self):
        # have to manually set the Posix locale
        self._Locale = wx.Locale(wx.LANGUAGE_DEFAULT)

        appname = "NLV"
        self.SetAppName(appname)

        # currently, neither the theme files, nor the "channel" (pipe to VisualStudio)
        # can be shared between application instances; so prevent that here
        self._ApplicationLock = wx.SingleInstanceChecker()
        if self._ApplicationLock.IsAnotherRunning():
            wx.MessageBox(
                "Another instance of the program is already running. This instance will Quit", appname,
                wx.OK | wx.ICON_INFORMATION | wx.STAY_ON_TOP | wx.CENTRE )

            return False

        user_dir = self.SetupApplicationConfiguration()
        self.SetupLogging(user_dir)
        self.SetupMetaData(user_dir)
        self.SetupExtensions()

        # startup the GUI window
        frame = G_LogViewFrame(None, appname)

        with G_PerfTimerScope("G_LogViewFrame.Show"):
            frame.Show()

        return True
Example #2
0
 def OnInit(self):
     '''
     Provides the additional initalisation needed for the application.
     '''
     self.SetupTanslation()
     self.checker = wx.SingleInstanceChecker(".Geocacher_" + wx.GetUserId())
     if self.checker.IsAnotherRunning():
         dlg = wx.MessageDialog(
             None,
             message=
             _("Geocacher is already running, please switch to that instance."
               ),
             caption=_("Geocacher Already Running"),
             style=wx.CANCEL | wx.ICON_HAND)
         dlg.ShowModal()
         return False
     else:
         from geocacher.widgets.mainWindow import MainWindow
         dirName = os.path.dirname(os.path.abspath(__file__))
         imageName = os.path.join(dirName, 'gfx', 'splash.png')
         image = wx.Image(imageName, wx.BITMAP_TYPE_PNG)
         bmp = image.ConvertToBitmap()
         wx.SplashScreen(bmp,
                         wx.SPLASH_CENTER_ON_SCREEN | wx.SPLASH_TIMEOUT,
                         5000, None, wx.ID_ANY)
         wx.Yield()
         frame = MainWindow(None, -1)
         self.SetTopWindow(frame)
         frame.Show(True)
         return True
Example #3
0
    def OnInit(self):
        HOST, PORT = socket.gethostname(), 61955
        argvs = sys.argv

        instance_name = u"%s-%s" % (self.GetAppName(), wx.GetUserId())
        self.instance = wx.SingleInstanceChecker(instance_name)
        if self.instance.IsAnotherRunning():
            if len(argvs) >= 2:
                self.client(HOST, PORT, argvs)
            wx.Exit()
        else:
            server = self.start_server(HOST, PORT)

        # タスクトレイ
        self.tb_ico = wx.TaskBarIcon()
        self.tb_ico.Bind(wx.EVT_TASKBAR_LEFT_DCLICK, self.OnTbiLeftDClick)
        self.tb_ico.Bind(wx.EVT_TASKBAR_RIGHT_UP, self.OnTbiRightUp)
        self.ico = wx.Icon("homu.ico", wx.BITMAP_TYPE_ICO)
        self.tb_ico.SetIcon(self.ico, u"homuhomu")

        # タスクトレイ用メニューの作成
        self.menu = wx.Menu()
        self.menu.Append(1, u"Exit(&X)")
        wx.EVT_MENU(self.menu, 1, self.OnClose)

        self.Frm = wx.Frame(None,
                            -1,
                            "homuLauncher",
                            size=(400, 60),
                            pos=(400, 400))
        self.TxtCtr = wx.TextCtrl(self.Frm, -1)
        self.Frm.Show()
        return 1
Example #4
0
    def OnInit(self):
        print('Running wxPython ' + wx.version())
        # Set Current directory to the one containing this file
        os.chdir(os.path.dirname(os.path.abspath(__file__)))

        self.SetAppName('SettingsManager')

        s = SettingsManager()
        s.ReadSettings()
        self._snglInstChecker = wx.SingleInstanceChecker()
        self._snglInstChecker.CreateDefault()
        if self._snglInstChecker.IsAnotherRunning(
        ) and not s.MultipleInstancesAllowed:
            wx.MessageBox(
                'Another instance of this application is already running!',
                'Multiple instances not allowed',
                wx.OK | wx.ICON_EXCLAMATION | wx.CENTER)
            return False

        # Create the main window
        frm = MainFrame()
        self.SetTopWindow(frm)

        frm.Show()
        return True
Example #5
0
    def OnInit(self):

        self.SetAppName("PyggyBank")

        self.engine = Engine()

        sys.excepthook = ExceptionHook

        #control app istance
        self.instance = wx.SingleInstanceChecker('client_lock', os.getcwd())
        if self.instance.IsAnotherRunning():
            msg = "Okay, Houston, we've had a problem here.\nAnother instance is running"
            wx.MessageBox(msg,
                          wx.GetApp().GetAppName(),
                          style=wx.ICON_ERROR | wx.OK)
            return False

        try:
            obj = frames.main.MainFrame()
            self.SetTopWindow(obj)
            obj.OnOpen()
            obj.Show()
            return True
        except:
            print sys.exc_info()[0]
            print sys.exc_info()[1]
            print sys.exc_info()[2]
            return False
Example #6
0
 def __init__(self, *args, **kwargs):
     super(SingleInstApp, self).__init__(*args, **kwargs)
     self.splash = None
     
     # Setup (note this will happen after subclass OnInit)
     instid = u"%s-%s" % (self.GetAppName(), wx.GetUserId())
     print "instid", instid
     self._checker = wx.SingleInstanceChecker(instid)
     if self.IsOnlyInstance():
         # First instance so start IPC server
         try:
             self._ipc = IpcServer(self, instid, 27115)
             self._ipc.start()
         except socket.error:
             pass
         
         # Open a window
         self.ShowSplash()
         #self.DoOpenNewWindow()
     else:
         # Another instance so just send a message to
         # the instance that is already running.
         cmd = u"OpenWindow.%s.%s" % (instid, GetArgFile())
         if not SendMessage(cmd, port=27115):
             print u"Failed to send message!"
Example #7
0
def main():
    """Program entry point."""
    conf.init()

    if wx:
        name = urllib.quote_plus("-".join([conf.Title, conf.DbPath]))
        singlechecker = wx.SingleInstanceChecker(name)
        if singlechecker.IsAnotherRunning(): sys.exit()

        app = MainApp(redirect=True) # redirect stdout/stderr to wx popup
        locale = wx.Locale(wx.LANGUAGE_ENGLISH) # Avoid dialog buttons in native language
        app.MainLoop() # stdout/stderr directed to wx popup
    else:
        model = Model()
        if tk:
            widget = tk.Tk() # Use Tkinter instead to get screen size
            size = [0, 0, widget.winfo_screenwidth(), widget.winfo_screenheight()]
            model.log_resolution([size])
            widget.destroy()
        print("wxPython not available, using basic command line interface.")
        print("Web interface running at %s" % conf.WebUrl)
        try:
            model.run()
        except IOError as e:
            if e.errno != errno.EINTR: raise # Interrupted syscall, probably sleep
        except KeyboardInterrupt:
            model.stop()
Example #8
0
def main():
    """Program entry point."""
    if conf.Frozen: multiprocessing.freeze_support()
    conf.init(), db.init(conf.DbPath, conf.DbStatements)
    try:
        db.execute("PRAGMA journal_mode = WAL")
    except Exception:
        pass

    if wx:
        name = re.sub(r"\W", "__", "-".join([conf.Title, conf.DbPath]))
        singlechecker = wx.SingleInstanceChecker(name)
        if singlechecker.IsAnotherRunning(): sys.exit()

        MainApp(redirect=True).MainLoop()  # stdout/stderr directed to wx popup
    else:
        model = Model()
        if tk:
            widget = tk.Tk()  # Use Tkinter instead to get screen size
            size = [
                0, 0,
                widget.winfo_screenwidth(),
                widget.winfo_screenheight()
            ]
            model.log_resolution([size])
            widget.destroy()
        print("wxPython not available, using basic command line interface.")
        print("Web interface running at %s" % conf.WebUrl)
        try:
            model.run()
        except IOError as e:
            if e.errno != errno.EINTR:
                raise  # Interrupted syscall, probably sleep
        except KeyboardInterrupt:
            model.stop()
Example #9
0
def start(apptype, exec_dir):
    appname = "freestream"
    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
    freestream.Player.systray.DEBUG = bgapp.debug_systray
    freestream.Player.systray.SHOW_DEBUG_LEVEL = bgapp.debug_systray
    freestream.Player.systray.DEBUG_PIECES = bgapp.debug_level & 128 != 0
    freestream.Player.systray.DEBUG_VIDEOSTATUS = bgapp.debug_level & 2048 != 0
    freestream.Player.systray.DEBUG_PROXY_BUF = bgapp.debug_level & 4096 != 0
    wrapper.MainLoop()
    if not ALLOW_MULTIPLE:
        del single_instance_checker
    stop_bgapp(bgapp)
Example #10
0
class App(wx.App):

    # changeable properties
    version: str = 'v1.17.11'
    repoApiUrl: str = 'https://api.github.com/repos/Bridge-Core/Bridge./releases'
    installPath: Path = Path(
        '%userprofile%/appdata/Local/Programs/Bridge').resolve()
    # window properties
    title: str = f'Bridge. {version} installer'
    height: int = 178
    width: int = 440
    # do not change
    root: root
    updating: bool = installPath.exists()
    instanceChecker = wx.SingleInstanceChecker()

    def OnInit(self):
        if self.instanceChecker.IsAnotherRunning():
            return False
        if not self.installPath.exists():
            self.installPath.mkdir(exist_ok=True, parents=True)
        self.SetAppName('BridgeInstaller')
        self.root = root(self)
        self.root.Show(True)
        self.SetTopWindow(self.root)
        self.root.Raise()
        return True

    def OnExit(self):
        return True
Example #11
0
    def SingleInstance(self):
        self.name = 'TimeSync-%s' % wx.GetUserId()
        self.instance = wx.SingleInstanceChecker(self.name)

        if self.instance.IsAnotherRunning():
            wx.MessageBox('TimeSync is already running!',
                          'TimeSync already running')
            return True
Example #12
0
    def ensure_single_instance(self, name):
        """Check to see if this is the only instance."""

        self.name = "%s-%s" % (self.single_instance, wx.GetUserId())
        self.instance = wx.SingleInstanceChecker(self.name)
        if self.instance.IsAnotherRunning():
            # wx.MessageBox("Only one instance allowed!", "ERROR", wx.OK | wx.ICON_ERROR)
            return False
        return True
Example #13
0
 def OnInit(self):
     self.name = "Laser Timer"
     self.instance = wx.SingleInstanceChecker(self.name)
     if self.instance.IsAnotherRunning():
         wx.MessageBox("Another instance is running", "ERROR")
         return False
     frame = LaserWindow(None, "EnVision Laser Cutter")
     frame.Show()
     return True
Example #14
0
 def OnInit(self):
     self.name = "EnVision-LaserScheduling"
     self.instance = wx.SingleInstanceChecker(self.name)
     if self.instance.IsAnotherRunning():
         wx.MessageBox("Another instance is running", "ERROR")
         return False
     self.frame = MainWindow(None, "EnVision Laser Schedule")
     self.frame.Show()
     return True
Example #15
0
    def __init__(self, *args, **kargs):
        """Initialize that main app and its attributes
        @postcondition: application is created and ready to be run in mainloop

        """
        wx.App.__init__(self, *args, **kargs)
        events.AppEventHandlerMixin.__init__(self)

        self.SetAppName(ed_glob.PROG_NAME)

        # Attributes
        self.profile_updated = InitConfig()
        self._log = dev_tool.DEBUGP
        self._lock = False
        self._windows = dict()

        if ed_glob.SINGLE:
            # Setup the instance checker
            instance_name = u"%s-%s" % (self.GetAppName(), wx.GetUserId())
            self._instance = wx.SingleInstanceChecker(instance_name)
            if self._instance.IsAnotherRunning():
                try:
                    opts, args = getopt.getopt(sys.argv[1:], "dhv",
                                               ['debug', 'help', 'version'])
                except getopt.GetoptError, msg:
                    self._log("[app][err] %s" % str(msg))
                    args = list()

                if not len(args):
                    args.append(APP_CMD_OPEN_WINDOW)

                rval = ed_ipc.SendCommands(args,
                                           profiler.Profile_Get('SESSION_KEY'))
                # If sending the command failed then let the editor startup
                # a new instance
                if not rval:
                    self._isfirst = True
            else:
                self._log("[app][info] Starting Ipc server...")
                # Set the session key and save it to the users profile so
                # that other instances can access the server
                key = unicode(base64.b64encode(os.urandom(8), 'zZ'))
                key = wx.GetUserName() + key
                profiler.Profile_Set('SESSION_KEY', key)
                profiler.Profile_Set('ISBINARY', hasattr(sys, 'frozen'))
                path = profiler.Profile_Get('MYPROFILE')
                profiler.Profile().Write(path)
                try:
                    self._server = ed_ipc.EdIpcServer(
                        self, profiler.Profile_Get('SESSION_KEY'))
                    self._server.start()
                except Exception, msg:
                    self._log("[app][err] Failed to start ipc server")
                    self._log("[app][err] %s" % str(msg))
                    self._server = None
                self._isfirst = True
Example #16
0
    def __init__(self, basename):
        super(SingleInstanceChecker, self).__init__()

        self._logger = logging.getLogger(self.__class__.__name__)

        if sys.platform != 'linux2':
            self._wx_instance_name = "tribler-" + wx.GetUserId()
            self._wx_checker = wx.SingleInstanceChecker(self._wx_instance_name)

        self._basename = basename
Example #17
0
    def __init__(self, name, host, port, frame=None, func=None):
        self.name = name
        self.frame = frame
        self.port = port
        self.host = host
        self.logger = logging.getLogger("")
        if not func:
            self.func = lambda: wx.CallAfter(self.__raiseFrame)

        self.s_checker = wx.SingleInstanceChecker(self.name)
Example #18
0
    def ensure_single_instance(self, single_instance):
        """Check to see if this is the only instance."""

        if single_instance is not None and isinstance(single_instance, str):
            self.name = "%s-%s" % (self.single_instance, wx.GetUserId())
            self.instance = wx.SingleInstanceChecker(self.name)
            if self.instance.IsAnotherRunning():
                self.instance_okay = False

        return self.instance_okay
Example #19
0
    def OnInit(self):
        self.name = "TydApp-%s" % wx.GetUserId()
        self.instance = wx.SingleInstanceChecker(self.name)
        if self.instance.IsAnotherRunning():
            wx.MessageBox(u'已经运行一个程序啦', u'出错提示')
            return False

        frame = TydMainFrame(None, -1, u'统一桌面')
        frame.Show(True)
        frame.Centre()
        return True
Example #20
0
File: dtk.py Project: mitxi21/dtk
 def OnInit(self):
     """
     wx.App init function that returns False if the app is already running.
     """
     self.name = "SingleApp-%s".format(wx.GetUserId())
     self.instance = wx.SingleInstanceChecker(self.name)
     if self.instance.IsAnotherRunning():
         wx.MessageBox("An instance of the application is already running",
                       "Error", wx.OK | wx.ICON_WARNING)
         return False
     return True
Example #21
0
    def MainLoop(self):
        single_instance_name = 'fr0st-%s' % wx.GetUserId()
        single_instance = wx.SingleInstanceChecker(single_instance_name)

        if single_instance.IsAnotherRunning():
            ErrorMessage(None, "Another instance of fr0st is already running. "
                         "Multiple instances are not supported.")
            return

        self.MainWindow = MainWindow(None, wx.ID_ANY)
        wx.App.MainLoop(self)
Example #22
0
    def OnInit(self, *args, **kwargs):
        self.name = "TrayIcon-{}".format(wx.GetUserId())
        self.instance = wx.SingleInstanceChecker(self.name)

        if self.instance.IsAnotherRunning():
            wx.MessageBox('Another instance is running', 'ERROR')
            return False

        TaskBarIcon()

        return super(App, self).OnInit(*args, **kwargs)
Example #23
0
    def OnInit(self):
        """Initialize the Editor
        @note: this gets called before __init__
        @postcondition: custom artprovider and plugins are loaded

        """
        self.SetAppName(ed_glob.PROG_NAME)

        self._log = dev_tool.DEBUGP
        self._log("[app][info] Editra is Initializing")

        self._isfirst = False  # Is the first instance
        self._instance = None

        if ed_glob.SINGLE:
            # Setup the instance checker
            instance_name = u"%s-%s" % (self.GetAppName(), wx.GetUserId())
            self._instance = wx.SingleInstanceChecker(instance_name)
            if self._instance.IsAnotherRunning():
                try:
                    opts, args = getopt.getopt(sys.argv[1:], "dhv",
                                               ['debug', 'help', 'version'])
                except getopt.GetoptError, msg:
                    self._log("[app][err] %s" % str(msg))
                    args = list()

                if not len(args):
                    args.append(APP_CMD_OPEN_WINDOW)

                rval = ed_ipc.SendCommands(args,
                                           profiler.Profile_Get('SESSION_KEY'))
                # If sending the command failed then let the editor startup
                # a new instance
                if not rval:
                    self._isfirst = True
            else:
                self._log("[app][info] Starting Ipc server...")
                # Set the session key and save it to the users profile so
                # that other instances can access the server
                key = unicode(base64.b64encode(os.urandom(8), 'zZ'))
                key = wx.GetUserName() + key
                profiler.Profile_Set('SESSION_KEY', key)
                profiler.Profile_Set('ISBINARY', hasattr(sys, 'frozen'))
                path = profiler.Profile_Get('MYPROFILE')
                profiler.Profile().Write(path)
                try:
                    self._server = ed_ipc.EdIpcServer(
                        self, profiler.Profile_Get('SESSION_KEY'))
                    self._server.start()
                except Exception, msg:
                    self._log("[app][err] Failed to start ipc server")
                    self._log("[app][err] %s" % str(msg))
                    self._server = None
                self._isfirst = True
        def OnInit(self):
            self.name = "SingleApp-%s" % wx.GetUserId()
            self.instance = wx.SingleInstanceChecker(self.name)

            if self.instance.IsAnotherRunning():
                wx.MessageBox("已经有一个潮生活发票助手程序在运行了!", "Do not Panic")
                return False
            else:
                the_frame = ChaoShengHuo(None, -1)
                the_frame.Show(True)
                return True
Example #25
0
    def OnInit(self):
        #         self.locale = wx.Locale(locale)
        #         print("LOCALE_DECIMAL_POINT", self.locale.GetInfo(wx.LOCALE_DECIMAL_POINT, wx.LOCALE_CAT_NUMBER))
        self.locale = wx.Locale(
            wx.LANGUAGE_ENGLISH)  # !!! obligé pour certains PC ???
        #         print("LOCALE_DECIMAL_POINT", self.locale.GetInfo(wx.LOCALE_DECIMAL_POINT, wx.LOCALE_CAT_NUMBER))
        #         self.locale = wx.Locale(wx.LANGUAGE_FRENCH) # Sans ça, il y a des erreurs sur certains PC ...
        #         print("LOCALE_DECIMAL_POINT", self.locale.GetInfo(wx.LOCALE_DECIMAL_POINT, wx.LOCALE_CAT_NUMBER))

        # Problème avec les PNG ??? Suppression des warning
        #  --> bug dans la version wx4 : les warnings plantent : il faut changer self.locale
        # https://github.com/wxWidgets/Phoenix/issues/769
        wx.Log.SetLogLevel(
            0
        )  # ?? Pour éviter le plantage de wxpython 3.0 avec Win XP pro ???

        self.name = "pySéquence-%s" % wx.GetUserId()
        self.instance = wx.SingleInstanceChecker(self.name)

        if self.instance.IsAnotherRunning():
            # Another instance so just send a message to
            # the instance that is already running.
            _, fichier = GetArgs()
            #             wx.MessageBox(fichier, "Fichier")
            if os.path.isfile(fichier):
                cmd = "OpenWindow.%s.%s" % (self.name, fichier)
                #                 wx.MessageBox(cmd, "Message")
                if not SendMessage(cmd, port=self.PORT):
                    print("Failed to send message!")
#                     wx.MessageBox(fichier, "Failed to send message!")
            else:
                wx.MessageBox("pySéquence semble être déjà lancé !",
                              "pySéquence")

            return False

        else:
            # First instance so start IPC server
            try:
                self._ipc = IpcServer(self, self.name, self.PORT)
                self._ipc.start()
            except socket.error:
                print("Erreur création serveur")
            except:
                pass

            self.splash = MySplashScreen(self)
            self.splash.Show()

            AddRTCHandlers()

            #            frame = SingleAppFrame(None, "SingleApp")
            #            frame.Show()
            return True
Example #26
0
 def OnInit(self):
     ##获取实例名称
     self.name = "%s-%s" % (self.GetAppName(), wx.GetUserId())
     ##要检测的实例
     self.instance = wx.SingleInstanceChecker(self.name)
     ##查看实例是否已经运行,如果已经运行则初始化失败退出
     if self.instance.IsAnotherRunning():
         wx.MessageBox(u"Web Publisher,已经在运行了!", u"提示")
         return False
     MySplash = MySplashScreen()
     MySplash.Show()
     return True
Example #27
0
def main():
    app = BoaApp(0)
    
    m_check = wx.SingleInstanceChecker(app.GetAppName())
    if (m_check.IsAnotherRunning()):
        wx.MessageBox('Only one instance of this application can run at once.', app.GetAppName(), wx.ICON_INFORMATION)            
        del m_check
        app.Destroy()
        return False
    
    app.createWindow()
    app.MainLoop()
Example #28
0
    def OnInit(self):
        # Instancia de la app (issue#8)
        self.instance = wx.SingleInstanceChecker("huayra-tda")
        if self.instance.IsAnotherRunning():
            wx.MessageBox("Huayra TDA ya está ejecutándose", "Aviso")
            return False

        self.frame = MainFrame()
        self.frame.SetIcon(wx.Icon(os.path.dirname(os.path.realpath(__file__))+"/icono-tda.png", wx.BITMAP_TYPE_PNG))
        self.frame.Show()
        self.SetTopWindow(self.frame)

        return True
Example #29
0
def run_bgapp(appname, params=None):
    if params is None:
        params = [""]

    if len(sys.argv) > 1:
        params = sys.argv[1:]

    # Create single instance semaphore
    # Arno: On Linux and wxPython-2.8.1.1 the SingleInstanceChecker appears
    # to mess up stderr, i.e., I get IOErrors when writing to it via print_exc()
    #
    if sys.platform != 'linux2':
        single_instance_checker = wx.SingleInstanceChecker(appname + "-" +
                                                           wx.GetUserId())
    else:
        single_instance_checker = LinuxSingleInstanceChecker(appname)

    #print "[StartUpDebug]---------------- 1", time()-start_time
    if not ALLOW_MULTIPLE and single_instance_checker.IsAnotherRunning():
        if params[0] != "":
            torrentfilename = params[0]
            i2ic = Instance2InstanceClient(I2I_LISTENPORT, 'START',
                                           torrentfilename)
            time.sleep(1)
            return

    arg0 = sys.argv[0].lower()
    if arg0.endswith('.exe'):
        installdir = os.path.abspath(os.path.dirname(sys.argv[0]))
    else:
        installdir = os.getcwd()

    # Launch first single instance
    app = BackgroundApp(0, appname, params, single_instance_checker,
                        installdir, I2I_LISTENPORT, BG_LISTENPORT)

    status = Status.get_status_holder("LivingLab")
    s = app.s  #Session.get_instance()
    id = encodestring(s.get_permid()).replace("\n", "")
    reporter = LivingLabReporter.LivingLabPeriodicReporter(
        "Living lab CS reporter", 300, id)  # Report every 5 minutes
    status.add_reporter(reporter)

    app.MainLoop()

    print >> sys.stderr, "Sleeping seconds to let other threads finish"
    time.sleep(2)

    if not ALLOW_MULTIPLE:
        del single_instance_checker
Example #30
0
    def OnInit(self):
        parser = OptionParser(version='0.1.0')
        try:
            options, args = parser.parse_args()
        except optparse.OptParseError:
            return False
        frame_title = self.GetTitle()
        frame_userdata = 0xBEA1D0
        self.SetVendorName(VENDOR_NAME)
        self.SetAppName(APP_NAME)
        self.sic = wx.SingleInstanceChecker(self.GetAppName())
        if self.sic.IsAnotherRunning():
            if win32gui:
                other_hwnds = []

                def enum_windows_callback(hwnd, extra):
                    if win32gui.GetWindowText(hwnd) != frame_title:
                        return
                    hwnd_userdata = win32gui.GetWindowLong(hwnd, win32con.GWL_USERDATA)
                    if hwnd_userdata != frame_userdata:
                        return
                    extra.append(hwnd)
                win32gui.EnumWindows(enum_windows_callback, other_hwnds)
                other_hwnd = other_hwnds[0] if other_hwnds else None
                if other_hwnd:
                    win32gui.PostMessage(other_hwnd, win32con.WM_USER, 0, 1)
            self.ExitMainLoop()
            return True

        self.RebootAudioServer()
        self.RebootMidiListener()
        self.RebootMidiDispatcher()
        # wx.Log.SetActiveTarget(Log())
        # wx.Log.SetVerbose()
        # self.SetLogLevel()
        frame = Frame(None, wx.ID_ANY, frame_title)
        if win32gui:
            win32gui.SetWindowLong(frame.GetHandle(), win32con.GWL_USERDATA, frame_userdata)
        frame.Show()
        # wx.LogError('error')
        # wx.LogWarning('warning')
        # wx.LogMessage('--- %s %s ---' % (APP_NAME, VERSION))
        # wx.LogStatus('status')
        # wx.LogVerbose('verbose')
        # wx.LogDebug('debug')
        wx.UpdateUIEvent.SetUpdateInterval(50)
        self.Bind(EVT_AUDIO_SERVER_STARTED, self.OnAudioServerStarted)
        self.Bind(EVT_AUDIO_SERVER_STOPPED, self.OnAudioServerStopped)

        return True