예제 #1
0
 def test_remove_file(self):
     with temptree([]) as t:
         file_name = os.path.join(t, 'blah.pid')
         # assert no raise
         self.assertEquals(os.path.exists(file_name), False)
         self.assertEquals(utils.remove_file(file_name), None)
         with open(file_name, 'w') as f:
             f.write('1')
         self.assert_(os.path.exists(file_name))
         self.assertEquals(utils.remove_file(file_name), None)
         self.assertFalse(os.path.exists(file_name))
예제 #2
0
 def test_remove_file(self):
     with temptree([]) as t:
         file_name = os.path.join(t, 'blah.pid')
         # assert no raise
         self.assertEquals(os.path.exists(file_name), False)
         self.assertEquals(utils.remove_file(file_name), None)
         with open(file_name, 'w') as f:
             f.write('1')
         self.assert_(os.path.exists(file_name))
         self.assertEquals(utils.remove_file(file_name), None)
         self.assertFalse(os.path.exists(file_name))
예제 #3
0
    def signal_pids(self, sig, **kwargs):
        """Send a signal to pids for this server

        :param sig: signal to send

        :returns: a dict mapping pids (ints) to pid_files (paths)

        """
        pids = {}
        for pid_file, pid in self.iter_pid_files(**kwargs):
            try:
                if sig != signal.SIG_DFL:
                    print _("Signal %s  pid: %s  signal: %s") % (self.server, pid, sig)
                os.kill(pid, sig)
            except OSError, e:
                if e.errno == errno.ESRCH:
                    # pid does not exist
                    if kwargs.get("verbose"):
                        print _("Removing stale pid file %s") % pid_file
                    remove_file(pid_file)
            else:
                # process exists
                pids[pid] = pid_file
예제 #4
0
    def signal_pids(self, sig, **kwargs):
        """Send a signal to pids for this server

        :param sig: signal to send

        :returns: a dict mapping pids (ints) to pid_files (paths)

        """
        pids = {}
        for pid_file, pid in self.iter_pid_files(**kwargs):
            try:
                if sig != signal.SIG_DFL:
                    print _('Signal %s  pid: %s  signal: %s') % (self.server,
                                                                 pid, sig)
                os.kill(pid, sig)
            except OSError, e:
                if e.errno == errno.ESRCH:
                    # pid does not exist
                    if kwargs.get('verbose'):
                        print _("Removing stale pid file %s") % pid_file
                    remove_file(pid_file)
            else:
                # process exists
                pids[pid] = pid_file