Example #1
0
 def pid(self):
     """
     Return the pid of the timblserver associated with this
     instance of the class TimblServer. If no file is found, return None.
     """
     try:
         with open(pid_file(self)) as pidfile:
             return int(pidfile.read().strip())
     except IOError:
         return None
Example #2
0
 def pid(self):
     """
     Return the pid of the timblserver associated with this
     instance of the class TimblServer. If no file is found, return None.
     """
     try:
         with open(pid_file(self)) as pidfile:
             return int(pidfile.read().strip())
     except IOError:
         return None
Example #3
0
 def _setup(self):
     """
     Return the commandlist send to the TimblServer.
     """
     command_list = [self.process]
     command_list.extend(
         ['-S', '%s' % self.port, '--pidfile=', pid_file(self)])
     for option, value in self.features.items():
         if not option.startswith(('-','+')):
             option = '-%s' % option
         command_list.extend([option, value])
     return command_list
Example #4
0
 def _setup(self):
     """
     Return the commandlist send to the TimblServer.
     """
     command_list = [self.process]
     command_list.extend(
         ['-S', '%s' % self.port, '--pidfile=',
          pid_file(self)])
     for option, value in self.features.items():
         if not option.startswith(('-', '+')):
             option = '-%s' % option
         command_list.extend([option, value])
     return command_list
Example #5
0
 def run(self):
     """
     Tries to start the TimblServer at the given host and port. If the
     server is already running, does nothing
     """
     if (self.started() and os.path.exists(pid_file(self))
             and self.owns_server()):
         sys.stderr.write('Server already running at %s:%s\n' %
                          (self.host, self.port))
         return True
     if not free_port(self):
         raise ServerConnectionError(
             'Other process running at %s:%s. Specify another port' %
             (self.host, self.port))
     out = open(os.devnull, 'w')
     self._process = subprocess.Popen(self._setup(), stderr=out, stdout=out)
     sys.stderr.write('Starting server at %s:%s' % (self.host, self.port))
     while not self.started():
         time.sleep(1.0)
         sys.stderr.write('.')
     sys.stderr.write('\nServer up and running at %s:%s\n' %
                      (self.host, self.port))
     return True
Example #6
0
 def run(self):
     """
     Tries to start the TimblServer at the given host and port. If the
     server is already running, does nothing
     """
     if (self.started() and os.path.exists(pid_file(self)) and
         self.owns_server()):
         sys.stderr.write('Server already running at %s:%s\n' % (
             self.host, self.port))
         return True
     if not free_port(self):
         raise ServerConnectionError(
             'Other process running at %s:%s. Specify another port' % (
                 self.host, self.port))
     out = open(os.devnull, 'w')
     self._process = subprocess.Popen(
         self._setup(), stderr=out, stdout=out)
     sys.stderr.write('Starting server at %s:%s' % (self.host, self.port))
     while not self.started():
         time.sleep(1.0)
         sys.stderr.write('.')
     sys.stderr.write(
         '\nServer up and running at %s:%s\n' % (self.host, self.port))
     return True