def default_mqs(debug={}, nokill=False, extra=None, **kwargs): global mqs if not isinstance(mqs, meqserver): # create a local tcp port gwlocal = "=meqbatch-%d" % os.getpid() # start octopussy if needed if not octopussy.is_initialized(): octopussy.init(gwclient=False, gwtcp=0, gwlocal=gwlocal + ":1") if not octopussy.is_running(): octopussy.start(wait=True) # start meqserver, overriding default args with any kwargs args = record(**app_defaults.args) args.update(kwargs) # add gwpeer= argument if isinstance(extra, str): extra = args.extra + extra.split(' ') extra = (extra or []) + ["-gw", gwlocal] spawn = args.get('spawn', None) mqs = meqserver(extra=extra, **args) mqs.dprint(1, 'default meqserver args:', args) meqds.set_meqserver(mqs) if not nokill: atexit.register(stop_default_mqs) if debug is None: pass else: octopussy.set_debug(app_defaults.debuglevels) if isinstance(debug, dict): octopussy.set_debug(debug) return mqs
def default_mqs (debug={},nokill=False,extra=None,**kwargs): global mqs; if not isinstance(mqs,meqserver): # create a local tcp port gwlocal = "=meqbatch-%d"%os.getpid(); # start octopussy if needed if not octopussy.is_initialized(): octopussy.init(gwclient=False,gwtcp=0,gwlocal=gwlocal+":1"); if not octopussy.is_running(): octopussy.start(wait=True); # start meqserver, overriding default args with any kwargs args = record(**app_defaults.args); args.update(kwargs); # add gwpeer= argument if isinstance(extra,str): extra = args.extra + extra.split(' '); extra = (extra or []) + ["-gw",gwlocal]; spawn = args.get('spawn',None); mqs = meqserver(extra=extra,**args); mqs.dprint(1,'default meqserver args:',args); meqds.set_meqserver(mqs); if not nokill: atexit.register(stop_default_mqs); if debug is None: pass; else: octopussy.set_debug(app_defaults.debuglevels); if isinstance(debug,dict): octopussy.set_debug(debug); return mqs;
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();