コード例 #1
0
ファイル: test_utils.py プロジェクト: wendy-king/x7_venv
 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
ファイル: test_utils.py プロジェクト: wendy-king/x7_venv
 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
ファイル: manager.py プロジェクト: wendy-king/x7_venv
    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