Exemplo n.º 1
0
    def run(self):
        self._wrapper = ClientWrapper()
        self._collector = ModelCollector(self._wrapper, self._pid_store)
        while True:
            self._cv.acquire()
            if self._terminate:
                logging.info('quitting test thread')
                self._cv.release()
                return

            if self._request is not None:
                request = self._request
                self._request = None
                self._cv.release()
                request()
                continue
            # Nothing to do, go into the wait
            self._cv.wait()
            self._cv.release()
Exemplo n.º 2
0
def main():
    try:
        opts, args = getopt.getopt(sys.argv[1:], 'dhp:u:', [
            'debug', 'help', 'skip-queued-messages', 'pid-location=',
            'universe='
        ])
    except getopt.GetoptError as e:
        print(str(e))
        Usage()
        sys.exit(2)

    universe = None
    pid_location = None
    level = logging.INFO
    skip_queued_messages = False
    for o, a in opts:
        if o in ('-d', '--debug'):
            level = logging.DEBUG
        elif o in ('-h', '--help'):
            Usage()
            sys.exit()
        elif o in ('--skip-queued-messages'):
            skip_queued_messages = True
        elif o in (
                '-p',
                '--pid-location',
        ):
            pid_location = a
        elif o in ('-u', '--universe'):
            universe = int(a)

    if universe is None:
        Usage()
        sys.exit()

    logging.basicConfig(level=level, format='%(message)s')

    client_wrapper = ClientWrapper()
    pid_store = PidStore.GetStore(pid_location)
    controller = ModelCollector(client_wrapper, pid_store)
    data = controller.Run(universe, skip_queued_messages)
    pprint.pprint(data)
Exemplo n.º 3
0
  skip_queued_messages = False
  for o, a in opts:
    if o in ('-d', '--debug'):
      level = logging.DEBUG
    elif o in ('-h', '--help'):
      Usage()
      sys.exit()
    elif o in ('--skip_queued_messages'):
      skip_queued_messages = True
    elif o in ('--pid_file',):
      pid_file = a
    elif o in ('-u', '--universe'):
      universe = int(a)

  if universe is None:
    Usage()
    sys.exit()

  logging.basicConfig(
      level=level,
      format='%(message)s')

  client_wrapper = ClientWrapper()
  pid_store = PidStore.GetStore(pid_file)
  controller = ModelCollector(client_wrapper, pid_store)
  data = controller.Run(universe, skip_queued_messages)
  pprint.pprint(data)

if __name__ == '__main__':
  main()