def setUp(self): self.env = environment.MockEnvironment() self.myhost = ro.get_myhost() self.rohosts = [] self.ns = remoteObjectNameSvc.remoteObjectNameService( self.rohosts, name='remoteObjectNameServer', host=self.myhost, port=ro.nameServicePort) self.ns.ro_start() waitForService(self.ns, 'names') #print "Hosts for",'names',self.ns.getHosts('names') ro.init() self.initval = 'init' self.server = FakeServer(self.initval) self.servicename = 'TestServiceName2' self.ROserver = ro.remoteObjectServer(obj=self.server, name=self.servicename, svcname=self.servicename, usethread=True) self.ROserver.ro_start() waitForService(self.ns, self.servicename) #print "Hosts for",self.servicename,self.ns.getHosts(self.servicename) self.ROclient = ro.remoteObjectProxy(self.servicename)
def setUp(self): self.env = environment.MockEnvironment() self.env.removeTestDirs() # just in case self.env.makeDirs() self.myhost = ro.get_myhost() self.rohosts = [] self.ns = remoteObjectNameSvc.remoteObjectNameService( self.rohosts, name='remoteObjectNameServer', host=self.myhost, port=ro.nameServicePort) self.ns.ro_start() waitForService(self.ns, 'names') #print "Status",self.ns.init0_up1_down2 #print "Hosts for",'names',self.ns.getHosts('names') ro.init() #time.sleep(1) self.servicename = 'TestServiceName' self.ROserver = FakeROServer(self.servicename, usethread=True) self.ROserver.ro_start() waitForService(self.ns, self.servicename) #print "Hosts for",self.servicename,self.ns.getHosts(self.servicename) self.ROclient = ro.remoteObjectProxy(self.servicename) self.val1 = '1' self.val2 = self.val1 + "22" self.rofilename = self.env.INST_PATH + "/ROfilename"
def setUp(self): self.myhost = ro.get_myhost() self.ns = remoteObjectNameSvc.remoteObjectNameService( [], name='remoteObjectNameServer', host=self.myhost, port=ro.nameServicePort) self.ns.ro_start()
def get_ms_handle(host=None): if not host: host = ro.get_myhost() # Create a handle to the manager service ms = ro.remoteObjectClient(host, ro.managerServicePort) return ms
def main(options, args): # Create top level logger. logger = ssdlog.make_logger('names', options) try: myhost = ro.get_myhost() except Exception, e: raise nameServiceError("Can't get my own hostname: %s" % str(e))
def main(options, args): ro_hosts = options.gen2host.split(',') ro.init(ro_hosts) svcname = options.svcname monname = svcname + '.mon' # create a real logger if you want logging logger = ssdlog.make_logger(svcname, options) ev_quit = threading.Event() # Create a local subscribe object myhost = ro.get_myhost(short=True) mymon = Monitor.Monitor(monname, logger) channels = options.channels.split(',') relay = StatusRelay(logger, options.statsvc, options.monitor, mymon, channels) # Startup monitor mymon.start(wait=True) monport = options.monport if not monport: monport = options.port + 1 mymon.start_server(wait=True, port=monport) threadPool = mymon.get_threadPool() svc = ro.remoteObjectServer(svcname=options.svcname, obj=relay, logger=logger, port=options.port, default_auth=None, ev_quit=ev_quit, usethread=False, threadPool=threadPool) try: relay.update_statusProxy() relay.update_monitorFeed() try: print "Press ^C to terminate the server." svc.ro_start(wait=True) svr_started = True except KeyboardInterrupt: logger.error("Caught keyboard interrupt!") ev_quit.set() finally: logger.info("Shutting down...") mymon.unsubscribe_remote('monitor', channels, {}) mymon.stop_server() mymon.stop()
def main(options, args): # Create top level logger. logger = ssdlog.make_logger('mgrsvc', options) # Get the names of the nodes in this cluster and remove our name. The # result is the list of hosts running name servers that we need to # synchronize with. try: myhost = ro.get_myhost(short=True) except Exception, e: raise managerSvcError("Can't get my own hostname: %s" % str(e))
############################################################################# # LAPTOP OR DESKTOP CONFIGURATION # Everything runs on one machine. Starts simulators for Telescope, # Instrument and STARS. ############################################################################# g2sim = Bunch() # All managers that will be controlled by this configuration. # # For each instance, possible attributes are # host -- host this instance will run on # port -- port at which to bind for remoteObject (XML-RPC) calls # user -- user to run under # basedir -- base directory in which to run # g2sim.managers = populate(h1=Bunch(host=ro.get_myhost(short=True)), ) g2sim.frontends = ['h1'] # Displays g2sim.disp = Bunch() # g2sim.disp.s6 = '%s:6' % (host(g2sim, 'h1')) # g2sim.disp.s5 = '%s:5' % (host(g2sim, 'h1')) # g2sim.disp.s4 = '%s:4' % (host(g2sim, 'h1')) # g2sim.disp.s3 = '%s:3' % (host(g2sim, 'h1')) # g2sim.disp.s2 = '%s:2' % (host(g2sim, 'h1')) # g2sim.disp.s1 = '%s:1' % (host(g2sim, 'h1')) g2sim.disp.s6 = ':6' g2sim.disp.s5 = ':5' g2sim.disp.s4 = ':4'
def main(options, args): global lock, status # create logger logger = ssdlog.make_logger('gen2sts', options) # Initialize remote objects system if not options.rohosts: rohosts = default_rohosts else: rohosts = options.rohosts.split(',') logger.debug("Initializing remote objects") ro.init(rohosts) if options.configfile: logger.info("Reading config file %s" % (options.configfile)) read_config(options.configfile) logger.debug("Opening output file %s" % (options.outfile)) out_f = open(options.outfile, 'a') # fetch initial status items that we need stobj = ro.remoteObjectProxy(options.statussvc) logger.info("Fetching initial status values") fetchDict = {}.fromkeys(aliases) statusDict = stobj.fetch(fetchDict) # Initial write out of information to STS with lock: statusDict['STS.TIME2'] = time.time() status.update(statusDict) write_sts(statusDict, logger, out_f) # Create a local subscribe object myhost = ro.get_myhost(short=True) mymon = Monitor.Monitor(myhost + '.mon', logger) if not options.channels: channels = default_channels else: channels = options.channels.split(',') # Subscribe our local callback function fn = lambda payload, name, channels: status_cb(payload, logger, out_f) mymon.subscribe_cb(fn, channels) # Startup monitor logger.debug("Starting pub/sub components") mymon.start(wait=True) mymon.start_server(wait=True, port=options.monport) # subscribe our monitor to the publication feed logger.debug("Subscribing to status feed") mymon.subscribe_remote(options.monitor, channels, {}) logger.info("starting up main program...") try: try: # YOUR MAIN PROGRAM CALL GOES HERE # (don't forget to use the mutex to arbitrate access to the # status dictionary) while True: time.sleep(1.0) #logger.debug("Zzzzz ...") except KeyboardInterrupt: logger.info("Received keyboard interrupt--shutting down...") finally: logger.info("shutting down...") mymon.unsubscribe_remote(options.monitor, channels, {}) mymon.stop_server() mymon.stop() out_f.close()
svcname = options.svcname logger = ssdlog.make_logger(svcname, options) # Initialize remote objects subsystem. try: ro.init() except ro.remoteObjectError, e: logger.error("Error initializing remote objects subsystem: %s" % \ str(e)) sys.exit(1) ev_quit = threading.Event() # make a name for our monitor myMonName = '%s-%s-%d.mon' % (svcname, ro.get_myhost(short=True), options.monport) # monitor channels we are interested in channels = options.monchannels.split(',') # Create a local pub sub instance mymon = Monitor.Monitor(myMonName, logger, numthreads=options.numthreads) threadPool = mymon.get_threadPool() sndsink = SoundSink.SoundSource(monitor=mymon, logger=logger, channels=['sound']) # Get settings folder
def main(options, args): # Create top level logger. logger = ssdlog.make_logger('sktask_gui', options) # evil hack required to use threads with GTK gtk.gdk.threads_init() # Parse resource string gtk.rc_parse_string(rc) ro.init() ev_quit = threading.Event() # make a name for our monitor if options.monname: myMonName = options.monname else: myMonName = 'sktask_gtk-%s-%d.mon' % (ro.get_myhost(short=True), options.monport) #print myMonName # monitor channels we are interested in channels = options.channels.split(',') # Create a local monitor mymon = Monitor.Monitor(myMonName, logger, numthreads=20) skdisp = skDisp(logger, ev_quit, monitor=mymon, monpath=options.monpath) if options.geometry: skdisp.setPos(options.geometry) skdisp.logupdate() # Subscribe our callback functions to the local monitor mymon.subscribe_cb(skdisp.anon_arr, channels) # for skfile in args: # skdisp.parsefile(skfile) server_started = False try: # Startup monitor threadpool mymon.start(wait=True) # start_server is necessary if we are subscribing, but not if only # publishing mymon.start_server(wait=True, port=options.monport) server_started = True # subscribe our monitor to the central monitor hub mymon.subscribe_remote(options.monitor, channels, ()) try: gtk.main() except KeyboardInterrupt: logger.error("Received keyboard interrupt!") finally: if server_started: mymon.stop_server(wait=True) mymon.stop(wait=True) logger.info("Exiting Gen2 skTask viewer...") ev_quit.set() sys.exit(0)
def main(options, args): global controller, gui # Create top level logger. logger = ssdlog.make_logger('integgui2', options) ro.init() ev_quit = threading.Event() # make a name for our monitor if options.monname: myMonName = options.monname else: myMonName = 'integgui2-%s-%d.mon' % (ro.get_myhost(short=True), options.monport) # monitor channels we are interested in sub_channels = [] pub_channels = ['g2task'] # Create a local monitor mymon = Monitor.Monitor(myMonName, logger, numthreads=options.numthreads) #mymon = Monitor.Minimon(myMonName, logger, numthreads=options.numthreads) threadPool = mymon.get_threadPool() # command queues queues = Bunch.Bunch(default=CommandQueue.CommandQueue('default', logger), ) if options.logmon: logtype = 'monlog' else: logtype = 'normal' # Create view gui = igview.IntegView(logger, ev_quit, queues, logtype=logtype) # Create network callable object for notifications notify_obj = fits.IntegGUINotify(gui, options.fitsdir) notify_obj.update_framelist() # For playing sounds soundsink = SoundSink.SoundSource(monitor=mymon, logger=logger, channels=['sound']) pub_channels.append('sound') # Create controller controller = igctrl.IntegController(logger, ev_quit, mymon, gui, queues, notify_obj, soundsink, options, logtype=logtype) view.common.set_view(gui) view.common.set_controller(controller) # Configure for currently allocated instrument if options.instrument: insname = options.instrument controller.set_instrument(insname) else: try: insname = controller.get_alloc_instrument() controller.set_instrument(insname) except Exception, e: # TODO: error popup? pass
statusValHistory.loadHistory(options.persistDataFile, svConfig) # Connect to the status service via a proxy object and fetch # initial status items that we need statusProxy = ro.remoteObjectProxy('status') logger.info("Fetching initial status values") statusFromGen2 = statusProxy.fetch(statusFromGen2) logger.info('initial status %s' % statusFromGen2) alhProxy = ro.remoteObjectProxy('alarm_handler') # make a name for our monitor if options.monname: myMonName = options.monname else: myMonName = 'alarm_monitor-%s.mon' % (ro.get_myhost(short=True)) # Create a local monitor mymon = Monitor.Monitor(myMonName, logger, numthreads=options.numthreads) mainWindow = None # Subscribe our local callback function fn = lambda payload, name, channels: status_cb(payload, logger, mainWindow, svConfig) mymon.subscribe_cb(fn, sub_channels) # Startup monitor mymon.start(wait=True) mymon.start_server(wait=True, port=options.monport)
def main(options, args): logger = ssdlog.make_logger('relay', options) ro.init() myhost = ro.get_myhost(short=False) myport = options.port myself = "%s:%d" % (myhost, myport) ev_quit = threading.Event() queue = Queue.Queue() # make a name for our monitor myMonName = options.name # monitor channels we are interested in channels = options.channels.split(',') sum_ns = ro.remoteObjectClient(options.gen2host, 7075) sum_ns.ro_echo(99) loc_status = ro.remoteObjectProxy('status') # Get a status dict of all aliases statusInfo = Convert.statusInfo() aliases = statusInfo.getAliasNames() # remove troublesome aliases for alias in ( 'CXWS.TSCV.OBE_INR', 'STATL.OBJKIND', 'TSCV.OBJKIND', 'TSCV.ZERNIKE_RMS', 'TSCV.ZERNIKE_RMS_WOA20', ): aliases.remove(alias) sum_status = get_handle(sum_ns, 'status') statusDict = dict.fromkeys(aliases, None) fetchDict = sum_status.fetch(statusDict) #print fetchDict loc_status.store(fetchDict) # Create a local monitor mymon = Monitor.Monitor(myMonName, logger, numthreads=20) # Make our callback functions m = Make_cb(logger=logger, monitor=mymon, queue=queue, monpath='mon.status') # Subscribe our callback functions to the local monitor mymon.subscribe_cb(m.anon_arr, channels) server_started = False try: # Startup monitor threadpool mymon.start(wait=True) # start_server is necessary if we are subscribing, but not if only # publishing mymon.start_server(wait=True, port=options.port, authDict={myMonName: myMonName}) server_started = True # subscribe our monitor to the summit monitor hub summit = get_handle(sum_ns, 'monitor') summit.subscribe(myself, channels, {'auth': "%s:%s" % (myMonName, myMonName)}) while not ev_quit.isSet(): try: (path, tree, time) = queue.get(block=True, timeout=1.0) #print tree try: loc_status.store(tree) except Exception, e: logger.error("Error relaying status: %s" % (str(e))) #printTree(path, tree, time) except Queue.Empty: continue except KeyboardInterrupt: logger.error("Received keyboard interrupt!") ev_quit.set() finally: if server_started: mymon.stop_server(wait=True) mymon.stop(wait=True)