예제 #1
0
    def start (self):
        """
        Start an instance of process and wait for it to appear on the bus.
        """
        if self.process is not None:
            raise RuntimeError(
                "%s process already started" % self.PROCESS_NAME)

        self._bus_name_watch_id = Gio.bus_watch_name_on_connection(
            self.bus, self.BUS_NAME, Gio.BusNameWatcherFlags.NONE,
            self._bus_name_appeared, self._bus_name_vanished)
        self.loop.run()

        if options.is_manual_start():
            print ("Start %s manually" % self.PROCESS_NAME)
        else:
            if self.available:
                # It's running, but we didn't start it...
                raise Exception ("Unable to start test instance of %s: "
                                 "already running " % self.PROCESS_NAME)

            self.process = self._start_process ()
            log ('[%s] Started process %i' % (self.PROCESS_NAME, self.process.pid))
            self.process_watch_timeout = GLib.timeout_add (200, self._process_watch_cb)

        self.abort_if_process_exits_with_status_0 = True

        # Run the loop until the bus name appears, or the process dies.
        self.loop.run ()

        self.abort_if_process_exits_with_status_0 = False
예제 #2
0
파일: helpers.py 프로젝트: marco-c/tracker
    def start (self, env=None):
        """
        Start an instance of process and wait for it to appear on the bus.
        """
        if self.process is not None:
            raise RuntimeError(
                "%s process already started" % self.PROCESS_NAME)

        self._bus_name_watch_id = Gio.bus_watch_name_on_connection(
            self.bus, self.BUS_NAME, Gio.BusNameWatcherFlags.NONE,
            self._bus_name_appeared, self._bus_name_vanished)
        self.loop.run()

        if options.is_manual_start():
            print ("Start %s manually" % self.PROCESS_NAME)
        else:
            if self.available:
                # It's running, but we didn't start it...
                raise Exception ("Unable to start test instance of %s: "
                                 "already running " % self.PROCESS_NAME)

            self.process = self._start_process (env=env)
            log ('[%s] Started process %i' % (self.PROCESS_NAME, self.process.pid))
            self.process_watch_timeout = GLib.timeout_add (200, self._process_watch_cb)

        self.abort_if_process_exits_with_status_0 = True

        # Run the loop until the bus name appears, or the process dies.
        self.loop.run ()

        self.abort_if_process_exits_with_status_0 = False
예제 #3
0
 def _stop_process (self):
     if options.is_manual_start ():
         if self.available:
             print ("Kill %s manually" % self.PROCESS_NAME)
             self.loop.run ()
     else:
         self.process.terminate ()
         self.process.wait ()
     return False
예제 #4
0
 def _stop_process(self):
     if options.is_manual_start():
         if self.available:
             print("Kill %s manually" % self.PROCESS_NAME)
             self.loop.run()
     else:
         self.process.terminate()
         self.process.wait()
     return False
예제 #5
0
파일: helpers.py 프로젝트: marco-c/tracker
    def kill (self):
        if options.is_manual_start():
            log ("kill(): ignoring, because process was started manually.")
            return

        self.process.kill ()

        # Name owner changed callback should take us out from this loop
        self.loop.run ()
        Gio.bus_unwatch_name(self._bus_name_watch_id)

        self.process = None

        log ("[%s] killed." % self.PROCESS_NAME)
예제 #6
0
    def kill (self):
        if options.is_manual_start():
            log ("kill(): ignoring, because process was started manually.")
            return

        self.process.kill ()

        # Name owner changed callback should take us out from this loop
        self.loop.run ()
        Gio.bus_unwatch_name(self._bus_name_watch_id)

        self.process = None

        log ("[%s] killed." % self.PROCESS_NAME)
예제 #7
0
파일: helpers.py 프로젝트: plundstr/tracker
    def _start_process(self):
        path = getattr(self, "PROCESS_PATH", os.path.join(cfg.EXEC_PREFIX, self.PROCESS_NAME))
        flags = getattr(self, "FLAGS", [])

        if options.is_manual_start():
            print ("Start %s manually" % self.PROCESS_NAME)
        else:
            kws = {}

            if not options.is_verbose():
                FNULL = open("/dev/null", "w")
                kws = {"stdout": FNULL, "stderr": FNULL}

            return subprocess.Popen([path] + flags, **kws)
예제 #8
0
    def start (self):
        """
        Start an instance of process and wait for it to appear on the bus.
        """

        self._get_bus ()

        if self.bus_admin.NameHasOwner(self.BUS_NAME):
            if options.is_manual_start():
                self.available = True
                log ("Found existing %s process (D-Bus name %s)" %
                     (self.PROCESS_NAME, self.BUS_NAME))
                return
            else:
                raise Exception ("Unable to start test instance of %s: "
                                 "already running" % self.PROCESS_NAME)
        else:
            log ("Name %s does not have an owner." % self.BUS_NAME)

        self.name_owner_match = self.bus.add_signal_receiver (self._name_owner_changed_cb,
                                                              signal_name="NameOwnerChanged",
                                                              path="/org/freedesktop/DBus",
                                                              dbus_interface="org.freedesktop.DBus")

        if options.is_manual_start():
            print ("Start %s manually" % self.PROCESS_NAME)
        else:
            self.process = self._start_process ()
            log ('[%s] Started process %i' % (self.PROCESS_NAME, self.process.pid))
            self.process_watch_timeout = GLib.timeout_add (200, self._process_watch_cb)

        self.abort_if_process_exits_with_status_0 = True

        # Run the loop until the bus name appears, or the process dies.
        self.loop.run ()

        self.abort_if_process_exits_with_status_0 = False
예제 #9
0
    def _start_process(self):
        path = getattr(self, "PROCESS_PATH",
                       os.path.join(cfg.EXEC_PREFIX, self.PROCESS_NAME))
        flags = getattr(self, "FLAGS", [])

        if options.is_manual_start():
            print("Start %s manually" % self.PROCESS_NAME)
        else:
            kws = {}

            if not options.is_verbose():
                FNULL = open('/dev/null', 'w')
                kws = {'stdout': FNULL, 'stderr': FNULL}

            return subprocess.Popen([path] + flags, **kws)
예제 #10
0
    def _stop_process (self):
        if options.is_manual_start ():
            if self.available:
                log ("Kill %s manually" % self.PROCESS_NAME)
                self.loop.run ()
        else:
            control_binary = os.path.join (cfg.BINDIR, "tracker-control")

            kws = {}

            if not options.is_verbose ():
                FNULL = open ('/dev/null', 'w')
                kws = { 'stdout': FNULL }

            subprocess.call ([control_binary, "--kill=miners"], **kws)

        return False
예제 #11
0
    def _stop_process(self):
        if options.is_manual_start():
            if self.available:
                log("Kill %s manually" % self.PROCESS_NAME)
                self.loop.run()
        else:
            control_binary = os.path.join(cfg.BINDIR, "tracker-control")

            kws = {}

            if not options.is_verbose():
                FNULL = open('/dev/null', 'w')
                kws = {'stdout': FNULL}

            subprocess.call([control_binary, "--kill=miners"], **kws)

        return False
예제 #12
0
 def _stop_process(self):
     if options.is_manual_start():
         if self.available:
             print("Kill %s manually" % self.PROCESS_NAME)
             self.loop.run()
     else:
         # FIXME: this can hang if the we try to terminate the
         # process too early in its lifetime ... if you see:
         #
         #   GLib-CRITICAL **: g_main_loop_quit: assertion 'loop != NULL' failed
         #
         # This means that the signal_handler() function was called
         # before the main loop was started and the process failed to
         # terminate.
         self.process.terminate()
         self.process.wait()
     return False
예제 #13
0
파일: helpers.py 프로젝트: amtep/tracker
 def _stop_process (self):
     if options.is_manual_start ():
         if self.available:
             print ("Kill %s manually" % self.PROCESS_NAME)
             self.loop.run ()
     else:
         # FIXME: this can hang if the we try to terminate the
         # process too early in its lifetime ... if you see:
         #
         #   GLib-CRITICAL **: g_main_loop_quit: assertion 'loop != NULL' failed
         #
         # This means that the signal_handler() function was called
         # before the main loop was started and the process failed to
         # terminate.
         self.process.terminate ()
         self.process.wait ()
     return False
예제 #14
0
파일: helpers.py 프로젝트: mlehtima/tracker
    def _start_process (self):
        path = getattr (self,
                        "PROCESS_PATH",
                        os.path.join (cfg.EXEC_PREFIX, self.PROCESS_NAME))
        flags = getattr (self,
                         "FLAGS",
                         [])

        if options.is_manual_start ():
            print ("Start %s manually" % self.PROCESS_NAME)
        else:
            kws = {}

            if not options.is_verbose ():
                FNULL = open ('/dev/null', 'w')
                kws = { 'stdout': FNULL, 'stderr': FNULL }

            command = [path] + flags
            log ("Starting %s" % ' '.join(command))
            return subprocess.Popen ([path] + flags, **kws)