Exemple #1
0
    def finish(self):
        if self.testname is not None:
            self.finish_test()
        self.logger = None
        # in recording mode, pause before exiting
        if self.recording and "-nopause" not in sys.argv:
            self.mqs.disconnect()
            octopussy.stop()
            if self._assay_stat:
                print(
                    """\n*** ERROR ***: Assay data recording failed, please review the log.\n"""
                )
            a = input("""\n\n
Since you're running the assayer in recording mode, we have disconnected 
from the meqserver without stopping it. You may wish to run the browser to
ensure that tree state is correct. Run the browser now (Y/n)? """).rstrip()
            if not a or a[0].lower() == 'y':
                os.system("meqbrowser.py")
            print(
                """\n\nReminder: you may need to kill the meqserver manually."""
            )
        else:
            meqserver.stop_default_mqs()
        self.mqs = None
        return self._assay_stat
Exemple #2
0
def stop_default_mqs():
    global mqs
    if mqs:
        if mqs.current_server:
            mqs.dprint(1, "stopping default meqserver")
            mqs.halt()
            mqs.disconnect()
        # kill process if it is still running after 10 seconds
        if mqs.serv_pid:
            for i in range(20):
                pid, stat = os.waitpid(mqs.serv_pid, os.WNOHANG)
                if pid:
                    break
                mqs.dprint(
                    0, "meqserver not exited yet, waiting another 10 seconds")
                time.sleep(10)
            else:
                mqs.dprint(
                    0,
                    "meqserver not exiting cleanly after 200 seconds, killing it"
                )
                os.kill(mqs.serv_pid, 9)
                pid, stat = os.waitpid(mqs.serv_pid, os.WNOHANG)
        mqs = None
    if octopussy.is_running():
        octopussy.stop()
Exemple #3
0
def meqbrowse(debug={}, **kwargs):
    args = dict(app_defaults.args)
    args['spawn'] = False
    for d, l in debug.iteritems():
        debuglevels[d] = max(debuglevels.get(d, 0), l)

    # insert '' into sys.path, so that CWD is always in the search path
    sys.path.insert(1, '')
    if debuglevels:
        octopussy.set_debug(debuglevels)

    # start octopussy if needed
    port = options.port
    sock = options.socket
    if sock == "None" or sock == "none":
        sock = ""
        print "Not binding to a local socket."
    else:
        # Use abstract socket on Linux and corresponding file-based socket elsewhere
        sock = "=" + sock
        if not sys.platform.startswith('linux'):
            sock = "/tmp/" + sock
        print "Binding to local socket %s" % sock
        # check local socket
        sk = socket.socket(socket.AF_UNIX)
        try:
            sk.bind(("\0" + sock[1:]) if sock[0] == '=' else sock)
        except:
            print "Error binding to local socket %s" % sock
            print "This probably means that another meqbrowser is already running."
            print "For advanced use, see the -s option (use -h to get help)."
            sys.exit(1)
        sk.close()
        if sock[0] != '=' and os.path.exists(sock):
            os.remove(sock)
    print "Binding to TCP port %d, remote meqservers may connect with gwpeer=<host>:%d" % (
        port, port)
    if not octopussy.is_initialized():
        octopussy.init(gwclient=False, gwtcp=port, gwlocal=sock)
    if not octopussy.is_running():
        octopussy.start(wait=True)
    # start meqserver
    # print "starting meqserver"
    args['gui'] = True
    mqs = meqserver.meqserver(**args)

    #   try:
    #     import psyco
    #     psyco.log('psyco.log');
    #     psyco.profile();
    #     print "****** psyco enabled.";
    #   except:
    #     print "****** You do not have the psyco package installed.";
    #     print "****** Proceeding anyway, things will run some what slower.";
    #     pass;

    mqs.run_gui()
    mqs.disconnect()
    octopussy.stop()
def meqbrowse (debug={},**kwargs):
  args = dict(app_defaults.args);
  args['spawn'] = False;
  for d,l in debug.iteritems():
    debuglevels[d] = max(debuglevels.get(d,0),l);

  # insert '' into sys.path, so that CWD is always in the search path
  sys.path.insert(1,'');
  if debuglevels:
    octopussy.set_debug(debuglevels);

  # start octopussy if needed
  port = options.port;
  sock = options.socket;
  if sock == "None" or sock == "none":
    sock = "";
    print "Not binding to a local socket.";
  else:
    # Use abstract socket on Linux and corresponding file-based socket elsewhere
    sock = "="+sock;
    if not sys.platform.startswith('linux'):
      sock = "/tmp/"+sock;
    print "Binding to local socket %s"%sock;
    # check local socket
    sk = socket.socket(socket.AF_UNIX);
    try:
      sk.bind( ("\0"+sock[1:]) if sock[0] == '=' else sock);
    except:
      print "Error binding to local socket %s"%sock;
      print "This probably means that another meqbrowser is already running."
      print "For advanced use, see the -s option (use -h to get help).";
      sys.exit(1);
    sk.close();
    if sock[0] != '=' and os.path.exists(sock):
      os.remove(sock)
  print "Binding to TCP port %d, remote meqservers may connect with gwpeer=<host>:%d"%(port,port);
  if not octopussy.is_initialized():
    octopussy.init(gwclient=False,gwtcp=port,gwlocal=sock);
  if not octopussy.is_running():
    octopussy.start(wait=True);
  # start meqserver
  # print "starting meqserver"
  args['gui'] = True;
  mqs = meqserver.meqserver(**args);

#   try:
#     import psyco
#     psyco.log('psyco.log');
#     psyco.profile();
#     print "****** psyco enabled.";
#   except:
#     print "****** You do not have the psyco package installed.";
#     print "****** Proceeding anyway, things will run some what slower.";
#     pass;

  mqs.run_gui();
  mqs.disconnect();
  octopussy.stop();
Exemple #5
0
  def finish (self):
    if self.testname is not None:
      self.finish_test();
    self.logger = None;
    # in recording mode, pause before exiting
    if self.recording and "-nopause" not in sys.argv:
      self.mqs.disconnect();
      octopussy.stop();
      if self._assay_stat:
        print """\n*** ERROR ***: Assay data recording failed, please review the log.\n""";
      a = raw_input("""\n\n
Since you're running the assayer in recording mode, we have disconnected 
from the meqserver without stopping it. You may wish to run the browser to
ensure that tree state is correct. Run the browser now (Y/n)? """).rstrip();
      if not a or a[0].lower() == 'y':
        os.system("meqbrowser.py");
      print """\n\nReminder: you may need to kill the meqserver manually.""";
    else:
      meqserver.stop_default_mqs();
    self.mqs = None;
    return self._assay_stat;
def stop_default_mqs ():
  global mqs;
  if mqs: 
    if mqs.current_server:
      mqs.dprint(1,"stopping default meqserver");
      mqs.halt();
      mqs.disconnect();
    # kill process if it is still running after 10 seconds
    if mqs.serv_pid:
      for i in range(20):
        pid,stat = os.waitpid(mqs.serv_pid,os.WNOHANG);
        if pid:
          break;
        mqs.dprint(0,"meqserver not exited yet, waiting another 10 seconds");
        time.sleep(10);
      else:
        mqs.dprint(0,"meqserver not exiting cleanly after 200 seconds, killing it");
        os.kill(mqs.serv_pid,9);
        pid,stat = os.waitpid(mqs.serv_pid,os.WNOHANG);
    mqs = None;
  if octopussy.is_running():
    octopussy.stop();
Exemple #7
0
 def kill(self):
     "sends Halt command to app and exits OCTOPUSSY"
     self.send_command("Halt")
     octopussy.stop()
Exemple #8
0
        mqs = None
    if octopussy.is_running():
        octopussy.stop()


#
# self-test block
#
if __name__ == '__main__':
    app_defaults.parse_argv(sys.argv[1:])
    gui = app_defaults.args['gui']

    default_mqs(verbose=2, wp_verbose=2)
    for i in range(1, 10):
        print(
            'createnode:',
            mqs.createnode(meq.node('MeqConstant', 'x' + str(i), value=0),
                           wait=False))

    if gui:
        mqs.run_gui()
    else:
        time.sleep(2)

    print('================= stopping mqs')
    mqs.halt()
    mqs.disconnect()

    print("===== calling octopussy.stop() =====")
    octopussy.stop()
        os.kill(mqs.serv_pid,9);
        pid,stat = os.waitpid(mqs.serv_pid,os.WNOHANG);
    mqs = None;
  if octopussy.is_running():
    octopussy.stop();
  
  
#
# self-test block
#
if __name__ == '__main__':
  app_defaults.parse_argv(sys.argv[1:]);
  gui = app_defaults.args['gui'];

  default_mqs(verbose=2,wp_verbose=2);
  for i in range(1,10):
    print 'createnode:',mqs.createnode(meq.node('MeqConstant','x'+str(i),value=0),wait=False);

  if gui:
    mqs.run_gui(); 
  else:
    time.sleep(2);

  print '================= stopping mqs';
  mqs.halt();
  mqs.disconnect();

  print "===== calling octopussy.stop() =====";
  octopussy.stop();

 def kill (self):
   "sends Halt command to app and exits OCTOPUSSY"
   self.send_command("Halt");
   octopussy.stop();