def __init__(self, logger, cfg):
        self.logger = logger
        self.cfg = cfg

        self.fv = ro.remoteObjectProxy('fitsview')
        self.fv1 = ro.remoteObjectProxy('fitsview1')
        self.stars = ro.remoteObjectProxy('STARS')

        self.insconfig = INSconfig()
    def __init__(self, logger, cfg):
        self.logger = logger
        self.cfg = cfg

        self.tsc = ro.remoteObjectProxy('TSC')
        self.status = ro.remoteObjectProxy('status')

        # For doing pa/ma settings changes
        self.pama = pama.PAMASettings(self.logger)
        if pamafile and os.path.exists(pamafile):
            self.pama.loadYAML(pamafile)
def client(logger, options, args):

    import pyfits

    if options.host:
        auth = (options.svcname, options.svcname)
        svc = ro.remoteObjectClient(options.host,
                                    options.port,
                                    name=options.svcname,
                                    auth=auth)
    else:
        svc = ro.remoteObjectProxy(options.svcname)

    if options.framelist:
        # If --framelist=FILE was specified, then read FILE and make a
        # list of fits files from it.
        try:
            in_f = open(options.framelist, 'r')
            buf = in_f.read()
            args = buf.split()

            args = map(lambda fid: options.fitsdir + '/' + fid + '.fits', args)
        except IOError, e:
            raise DAQerror("Failed to open '%s': %s" %
                           (options.framelist, str(e)))
def main(options, args):

    logname = 'sendlog'
    logger = ssdlog.make_logger(logname, options)

    ro.init()
    tm = ro.remoteObjectProxy('taskmgr0')
    tm.loadModule('LOGTask')
    tm.addAllocs(['STARS'])

    today = datetime.date.today()
    one_day = datetime.timedelta(days=1)
    yesterday = today - one_day

    if not options.fromdate:
        obs_time_from = '%s 17:00:00' % (yesterday)
        day_time_from = '%s 08:00:00' % (yesterday)

    else:
        obs_time_from = options.fromdate
        day_time_from = options.fromdate

    if not options.todate:
        obs_time_to = '%s 08:00:00' % (today)
        day_time_to = '%s 17:00:00' % (yesterday)

    else:
        obs_time_to = options.todate
        day_time_to = options.fromdate

    try:
        logdir = os.environ['LOGHOME']
    except KeyError, e:
        logdir = '/gen2/logs'
 def __init__(self, interval=None, statusKeys=("TSCS.AZ", "TSCL.WINDD", "TSCL.WINDS_O"), size=DIRN_DEFAULTSIZE, mode=None, logger=None, parent=None):
     
     super(Directions, self).__init__(parent)
     self.setupUi(self, size=size)
     
     self.wind_direction=0
     self.subaru_az=0
     self.wind_speed=0
     self.logger=logger
     self.statusKeys = statusKeys   
     
     if mode=='test':
         interval=1000*interval # milli sec
         self.logger.debug('setting interval %d' %interval )
         timer_d = QTimer(self)
         self.connect(timer_d, SIGNAL("timeout()"), self.fetch_fake_data)
         self.logger.debug('timer connected to fetchData' )
         timer_d.start(interval)
       
     elif mode == 'solo':
         ro.init()
         #st.g2StatusObj('status')
         self.status = ro.remoteObjectProxy('status') 
         interval=1000*interval # milli sec
         self.logger.debug('setting interval %d' %interval )
         timer_d = QTimer(self)
         self.connect(timer_d, SIGNAL("timeout()"), self.fetch_solo_data)
         self.logger.debug('timer connected to fetchData' )
         timer_d.start(interval)  
    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"
Example #8
0
    def __init__(self,
                 logger,
                 monitor,
                 debug,
                 dummyval,
                 usethread,
                 ev_quit=None):

        self.logger = logger
        self.debug = debug  # do dubug or not
        self.monitor = monitor  # do monitoring
        self.dummyval = dummyval  # use dummy fits values
        self.usethread = usethread  # use thread

        self.timeout = 0.2  # Q timeout

        self.cmd_end = "END"

        self.aliasVal = guiderfitsheader.getAlias()  # status alias values
        self.keyVal = guiderfitsheader.getKeyVal()

        # fits header template
        self.guiderFitsHeader = guiderfitsheader.guider_fits_header

        # set thread event
        if not ev_quit: self.ev_quit = threading.Event()
        else: self.ev_quit = ev_quit

        # monitor instance
        if self.monitor:
            self.db = Monitor.Minimon('GuiderInt.mon', self.logger)
            self.db.subscribe(self.monitor, ['GuiderInt'], None)

        if not self.dummyval:
            self.svc = ro.remoteObjectProxy('status')
    def setAllocs(self, allocNames):
        """Set the list of allocations for the task manager.  Given a list
        of remote object service names, allocate proxies (handles) to all of
        the remote objects and put them in the allocs list.
        """
        allocs = {}
        try:
            for svcname in allocNames:
                # Aliasing service under a different name?
                if '=' in svcname:
                    (alias, svcname) = svcname.split('=')
                else:
                    alias = svcname

                if self.internal_allocs.has_key(svcname):
                    proxy = self.internal_allocs[svcname]
                else:
                    proxy = ro.remoteObjectProxy(svcname)

                allocs[alias] = proxy

        except ro.remoteObjectError, e:
            errmsg = "Error allocating subsystem: %s" % svcname
            self.logger.error(errmsg)
            raise TaskManagerError(errmsg)
    def _getProxy(self, subscriber, options):
        """Internal method to create & cache remoteObject proxies to remote
        pubsubs (subscribers).
        """
        try:
            # If we already have a proxy for the _svcname_, return it.
            return self._proxyCache[subscriber]

        except KeyError:
            # Create a new proxy to the external pubsub and cache it

            # Fill in possible authentication and security params
            kwdargs = { 'timeout': self.remote_timeout }
            #kwdargs = {}
            if options.has_key('auth'):
                kwdargs['auth'] = options['auth']
            if options.has_key('secure'):
                kwdargs['secure'] = options['secure']

            # subscriber can be a service name or a host:port
            if not (':' in subscriber):
                proxy_obj = ro.remoteObjectProxy(subscriber, **kwdargs)
            else:
                (host, port) = subscriber.split(':')
                port = int(port)
                proxy_obj = ro.remoteObjectClient(host, port, **kwdargs)
                
            self._proxyCache[subscriber] = proxy_obj
            self.logger.debug("Created proxy for '%s'" % (subscriber))

            return proxy_obj
    def initialize(self, ocsint):
        '''Initialize instrument.  
        '''
        super(TSCCAM, self).initialize(ocsint)
        
        # Grab my handle to the OCS interface.
        self.ocs = ocsint

        # Thread pool for autonomous tasks
        self.threadPool = self.ocs.threadPool
        # For task inheritance:
        self.tag = 'TSCCAM'
        self.shares = ['logger', 'ev_quit', 'threadPool']
        
        # Used to format status buffer (item lengths must match definitions
        # of status aliases on SOSS side in $OSS_SYSTEM/StatusAlias.pro)
        statfmt = "%(status)-8.8s,%(mode)-8.8s,%(count)8d;"

        # Register my status.
        self.mystatus = self.ocs.addStatusTable('TSCC0001',
                                                ['status', 'mode', 'count'],
                                                formatStr=statfmt)
        
        # Establish initial status values
        self.mystatus.status = 'ALIVE'
        self.mystatus.mode = 'LOCAL'
        self.mystatus.count = 0

        # Will be set to periodic status task
        self.status_task = None

        # Thread-safe bunch for storing parameters read/written
        # by threads executing in this object
        self.param = Bunch.threadSafeBunch()
        
        # Interval between status packets (secs)
        self.param.status_interval = 60

        ro.init()
        self.g2status = ro.remoteObjectProxy('status')
        self.bootmgr = ro.remoteObjectProxy('bootmgr')

        # Simulation variables
        self.el = 89.5
        self.az = -90.0
def main(options, args):
    logger = ssdlog.make_logger('test', options)

    if options.mode == 'test':
        print 'test mode'
        feed_test_data()
        mymon = None

    else:

        ro.init()
        # make a name for our monitor

        #myMonName = ('testmon-%d' % os.getpid())
        myMonName = ('testmon')
        # monitor channels we are interested in
        channels = options.channels.split(',')

        # Create a local monitor
        mymon = Monitor.Monitor(myMonName, logger, numthreads=4)

        # 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)

        # Make our callback functions
        m = Make_cb(logger=logger, monitor=mymon)

        # Subscribe our callback functions to the local monitor
        mymon.subscribe_cb(m.anon_arr, channels)

        try:
            # subscribe our monitor to the central monitor hub
            monitor = ro.remoteObjectProxy(options.monitor)
            monitor.subscribe(myMonName, channels, ())
        except:
            logger.error("subscribe to the central monitor faild")

    try:

        app = QtGui.QApplication(sys.argv)
        tv = TreeView()
        tv.start_updating()
        tv.show()
        sys.exit(app.exec_())
        stop_service(tv, mymon=mymon)
        print 'GUI END'

    except KeyboardInterrupt:
        print 'Keyboard'
        #gtk.main_quit()
        stop_service(tv, mymon=mymon)
Example #13
0
        def stop_host(up, dn):

            try:
                svcname = ('g2disp-%s' % up.host.replace('.', '_'))
                handle = ro.remoteObjectProxy(svcname)

                handle.viewerOff(up.xdisp, up.geom)
                handle.viewerOff(dn.xdisp, dn.geom)
            except ro.remoteObjectError, e:
                self.logger.error(
                    "Error stopping viewer on remote host '%s': %s" %
                    (up.host, str(e)))
    def start(self):

        # prefixes will be mon.session and mon.alloc
        self.tagpfx = ('mon')
        self.channels = monchannels

        # For updating status system with session info
        # TODO: parameterize object
        self.status = ro.remoteObjectProxy('status')

        # For starting interfaces
        # TODO: parameterize object
        self.bootmgr = ro.remoteObjectProxy('bootmgr')

        # Try to restore previous session.  If it fails, then create
        # a new session.
        try:
            self.mon.restore()

        except IOError, e:
            self.initialize()
def main(options, args):

    # Initialize remote objects service, necessary before any
    ro.init()

    svcname = options.svcname
    auth = None
    if options.auth:
        auth = options.auth.split(':')

    if options.server:
        authDict = {}
        if auth:
            authDict[auth[0]] = auth[1]

        print "Starting '%s' service..." % svcname
        svc = MyRemoteService(svcname,
                              usethread=False,
                              authDict=authDict,
                              secure=options.secure,
                              cert_file=options.cert,
                              default_auth=False)

        try:
            # Start remote objects server.  Since usethread=False
            # in the constructor, we will block here until server
            # exits.
            svc.ro_start()

        except KeyboardInterrupt:
            print "Shutting down '%s' ..." % svcname

    else:
        # Create proxy object for service
        svc = ro.remoteObjectProxy(svcname, auth=auth, secure=options.secure)

        try:
            i = options.count
            while i > 0:
                # Call remote method on service
                try:
                    res = svc.search(1.0, 2.0, 3.0, 4.0)
                    print "(%5d)  res=%s" % (i, str(res))

                except ro.remoteObjectError, e:
                    print "Call error: %s" % (str(e))

                i -= 1
                if i > 0:
                    time.sleep(options.interval)

        except KeyboardInterrupt:
            print "Keyboard interrupt received!"
Example #16
0
def main(options, args):

    #logger = ssdlog.make_logger('checkstat', options)

    ro.init()

    st = ro.remoteObjectProxy(options.statussvc)

    insdata = INSdata()
    statusDict = {}
    lookupDict = {}

    # Get all the names of the 'ALIVE' status tables for the instruments
    for insname in insdata.getNames():
        if insname == 'VGW':
            continue
        inscode = insdata.getCodeByName(insname)
        tblname = '%3.3sS0001' % inscode

        alias = 'GEN2.STATUS.TBLTIME.%s' % tblname
        statusDict[alias] = 0
        lookupDict[alias] = insname

    # Additional tables to check
    for tblname in ('TSCS', 'TSCL', 'TSCV', 'VGWD', 'VGWQ'):
        alias = 'GEN2.STATUS.TBLTIME.%s' % tblname
        statusDict[alias] = 0
        lookupDict[alias] = tblname

    fetchDict = st.fetch(statusDict)

    if options.sorttime:
        times = fetchDict.items()
        times.sort(_timecmp)
        keys = [(alias, lookupDict[alias]) for alias in \
                map(lambda x: x[0], times)]
    else:
        keys = lookupDict.items()
        keys.sort(lambda x, y: cmp(x[1], y[1]))
    #print keys

    for alias, name in keys:
        timeval = fetchDict[alias]
        if timeval == '##NODATA##':
            time_s = 'No record'
        elif isinstance(timeval, float):
            time_s = time.strftime('%Y-%m-%d %H:%M:%S',
                                   time.localtime(timeval))
        else:
            time_s = 'ERROR: %s' % str(timeval)

        print "%-8.8s  %s" % (name, time_s)
Example #17
0
    def rosh_conn(self, svcname, auth=None):
        """Connect to remote object service (svcname)"""

        self.svc[svcname] = ro.remoteObjectProxy(svcname,
                                                 auth=auth)
        try:
            self.svc[svcname].ro_echo(1)
            self.cursor = svcname
            return svcname

        except ro.remoteObjectError, e:
            print str(e)
            return None
Example #18
0
        def start_host(up, up_rmdsp, dn, dn_rmdsp, passwd, viewonly):

            print "starting on host %s" % (up.host)
            try:
                svcname = ('g2disp-%s' % up.host.replace('.', '_'))
                handle = ro.remoteObjectProxy(svcname)

                handle.viewerOn(up.xdisp, up.geom, up_rmdsp, passwd, viewonly)
                handle.viewerOn(dn.xdisp, dn.geom, dn_rmdsp, passwd, viewonly)
            except ro.remoteObjectError, e:
                self.logger.error(
                    "Error starting viewer on remote host '%s': %s" %
                    (up.host, str(e)))
Example #19
0
def main(options, args):

    ro.init()

    insconfig = INSdata()

    archiver = ro.remoteObjectProxy('archiver')

    if options.infile:
        with open(options.infile, 'r') as in_f:
            buf = in_f.read()
    else:
        buf = sys.stdin.read()

    for line in buf.split('\n'):
        line = line.strip()
        # skip blank lines and comments
        if (len(line) == 0) or line.startswith('#'):
            continue

        (frameid, path) = line.split()
        if ':' in path:
            host, path = path.split(':')
        else:
            host = None

        finfo = frame.getFrameInfoFromPath(frameid)

        # TODO: we could do in groups, would be faster if there are
        # a lot of files to transfer
        framelist = [(finfo.frameid, path)]

        # Look up the instrument transfer info
        obcpinfo = insconfig.getOBCPInfoByCode(finfo.inscode)
        if not host:
            host = obcpinfo['obcphost']
        transfermethod = obcpinfo['transfermethod']

        # Make a call to the archiver to transfer this file
        print "Attempting to archive %s: %s" % (frameid, path)
        if not options.dry_run:
            res = archiver.archive_framelist(host, transfermethod, framelist)
            if res != ro.OK:
                print "Archiver returned error code %d" % (res)
            else:
                print "Archived file."

            time.sleep(options.interval)
        else:
            print "Host: %s Method: %s Framelist: %s" % (host, transfermethod,
                                                         str(framelist))
Example #20
0
    def __init__(self, options, logger):
        """Constructor for the INSintTester object.
        """

        # Invoke our base class constructor.
        INSintGUI.__init__(self)

        self.logger = logger
        self.insconfig = INSconfig()

        # Set up default connection parameters from command line
        self.obcpnum = options.obcpnum
        self.monunitnum = options.monunitnum
        if not options.obcphost:
            self.obcphost = SOSSrpc.get_myhost(short=True)
        else:
            self.obcphost = options.obcphost
        self.raidpath = options.fitsdir
        self.transfermethod = options.transfermethod
        self.username = options.username
        self.password = options.password

        self.ev_quit = threading.Event()
        self.ev_mainquit = threading.Event()
        self.soss = None

        # Did user specify a Gen2 status source?
        if options.statussvc:
            ro_status = ro.remoteObjectProxy(options.statussvc)
            statusObj = INSint.FetchStatusWrapper_Gen2(ro_status)

        # Did user specify a SOSS status source?
        elif options.statushost:
            from SOSS.status import cachedStatusObj

            statusDict = cachedStatusObj(options.statushost)
            statusObj = INSint.FetchStatusWrapper_SOSS(statusDict)

        # Did user specify a SOSS status file?
        elif options.statusfile:
            try:
                in_f = open(options.statusfile, 'r')
                statusDict = eval(in_f.read())
                in_f.close()

            except Exception, e:
                self.showStatus("Error reading status file '%s': %s" % \
                                (options.statusfile, str(e)))
                statusDict = {}

            statusObj = INSint.FetchStatusWrapper_SOSS(statusDict)
Example #21
0
    def __init__(self, svcname, debug, port, usethread=False):

        # Superclass constructor
        #self.guider=GuiderSaveFrame(debug=False, monitor=monitor, svcname=svcname)
        ro.remoteObjectServer.__init__(self,
                                       svcname=svcname,
                                       port=port,
                                       usethread=usethread)

        self.debug = debug
        #self.monitor=monitor
        self.image = None

        self.status = ro.remoteObjectProxy('status')
Example #22
0
def main(options, args):

    # Initialize remote objects service, necessary before any
    ro.init()

    svcname = options.svcname
    auth = None
    if options.auth:
        auth = options.auth.split(':')

    if options.server:
        authDict = {}
        if auth:
            authDict[auth[0]] = auth[1]

        print "Starting '%s' service..." % svcname
        svc = MyRemoteService(svcname, usethread=False, authDict=authDict,
                              secure=options.secure, cert_file=options.cert,
                              default_auth=False)

        try:
            # Start remote objects server.  Since usethread=False
            # in the constructor, we will block here until server
            # exits.
            svc.ro_start()

        except KeyboardInterrupt:
            print "Shutting down '%s' ..." % svcname

    else:
        # Create proxy object for service
        svc = ro.remoteObjectProxy(svcname, auth=auth, secure=options.secure)

        try:
            i = options.count
            while i > 0:
                # Call remote method on service
                try:
                    res = svc.search(1.0, 2.0, 3.0, 4.0)
                    print "(%5d)  res=%s" % (i, str(res))

                except ro.remoteObjectError, e:
                    print "Call error: %s" % (str(e))

                i -= 1
                if i > 0:
                    time.sleep(options.interval)

        except KeyboardInterrupt:
            print "Keyboard interrupt received!"
    def __init__(self, logger):

        starsdb = STARSdb(logger)
        self.isSTARS = starsdb.is_log_stars

        ro.init()
        self.tm = ro.remoteObjectProxy('taskmgr0')
        self.tm.loadModule('LOGTask')
        self.tm.addAllocs(['STARS'])

        self.sendcmd_tpl = 'EXEC LOG Send_Log logpath="%s" indexdir="%s" name=%s logstarttime="%s" logendtime="%s" '

        self.removecmd_tpl = 'EXEC LOG Remove_Log logpath="%s"'

        self.logger = logger
Example #24
0
    def __init__(self, svcname, logger, monitor=None, monchannels=[]):
        
        self.logger = logger
        self.monitor = monitor
        self.monchannels = monchannels
        # TODO: parameterize tag template (from svcname?)
        self.tag_template = 'mon.frame.%s.frameSvc'

        self.insconfig = INSconfig()
        
        # For updating status system with session info
        # TODO: parameterize object
        self.status = ro.remoteObjectProxy('status')

        # For mutual exclusion
        self.lock = threading.RLock()
def main(options, args):

    logname = 'deletelog'
    logger = ssdlog.make_logger(logname, options)

    starsdb = STARSdb(logger)
    isSTARS = starsdb.is_log_stars

    ro.init()
    tm = ro.remoteObjectProxy('taskmgr0')
    tm.loadModule('LOGTask')
    tm.addAllocs(['STARS'])

    try:
        logdir = os.environ['LOGHOME']
    except KeyError, e:
        logdir = '/gen2/logs'
    def on_setup_clicked(self, widget):
        sw = self.widgets['dialog_setup']

        # Set other fields to defaults
        self.on_location_changed(widget)

        sw.window.show()
        resp = sw.run()
        sw.window.hide()

        if resp == gtk.RESPONSE_OK:
            starshost = self.widgets['starshost'].get_text()
            if starshost == 'N/A':
                starshost = None
            self.starshost = starshost
            starsdir = self.widgets['starsdir'].get_text()
            if starsdir == 'N/A':
                starsdir = None
            self.starsdir = starsdir
            channels = self.widgets['channels'].get_text()
            channels = map(int, channels.split(','))
            for ch_i in channels:
                if not ch_i in [1, 2, 3, 4, 5, 6, 7, 8]:
                    self.showStatus("Channels must be in the range 1-8!!")

                    return gtk.TRUE
            self.channels = channels

            db = StatusBundle.nestedStatusBundle()
            if self.monitor:
                monitor = ro.remoteObjectProxy(self.monitor)
                svcname = 'STARSint'
                db.register_sync(svcname, monitor)

            # Any way to force collection of the socket here?
            self.stars = None
            try:
                self.stars = STARSinterface(starshost=self.starshost,
                                            starsdir=self.starsdir,
                                            channels=self.channels,
                                            db=db,
                                            ev_quit=self.ev_quit)
            except Exception, e:
                self.showStatus("FAILED TO INITIALIZE INTERFACE")
                self.stars = None
def client(options, data, is_binary):

    datafile = None
    if options.datafile:
        datafile = open(options.datafile, 'a')

    auth = None
    if options.auth:
        auth = options.auth.split(':')

    # Get handle to server
    testro = ro.remoteObjectProxy(options.svcname,
                                  auth=auth,
                                  secure=options.secure)

    print "Starting '%s' client..." % (options.svcname)
    size = len(data)

    time1 = time.time()

    if is_binary:
        data = ro.binary_encode(data)

    time2 = time.time()

    amount = 0.0
    for i in xrange(options.count):
        res = testro.recv(data, is_binary)
        amount += size

    tottime = time.time() - time1
    # Average time if more than one call made
    if options.count > 1:
        tottime = tottime / options.count

    print "Time taken: %f secs (%f bytes/sec) (enc: %f secs) " % \
          (tottime, amount/tottime, time2-time1)

    if datafile:
        # total bytes, count, total time, encode time, avg rate
        datafile.write("%d %d %f %f %f\n" %
                       (size * options.count, options.count, tottime,
                        time2 - time1, amount / tottime))
        datafile.close()
    def build_gui(self, container):
        self.firstTime = True
        self.root = container
        self.aliases = []
        self.previousStatusDict = None

        # Set up a connection to the alarm_handler so that the GUI can
        # send messages to it
        self.alhProxy = ro.remoteObjectProxy('alarm_handler')

        layout = QtGui.QVBoxLayout()
        layout.setContentsMargins(4, 4, 4, 4)
        layout.setSpacing(4)
        container.setLayout(layout)

        # Create the GUI from the MainWindow class in alarm_gui.py
        self.mw = AlarmGui.MainWindow('', self.alhProxy, self.logger,
                                      container)
        layout.addWidget(self.mw, stretch=1)
def resend(options, logger, files):
    # Second pass.  Resend files NOT in STARS.
    logger.info("Cleanup PASS 2: resend files.")

    # initialize remoteObjects and get a handle to the STARS interface
    ro.init()
    stars = ro.remoteObjectProxy('STARS')
    
    for fitsfile in files:

        fitspath = os.path.join(options.fitsdir, fitsfile)
        
        logger.info("File '%s' NOT in STARS--resending..." % fitsfile)
        try:
            if not options.dry_run:
                stars.resend_fits(fitspath)

                time.sleep(options.interval)

        except Exception, e:
            logger.error("Error resending %s: %s" % (fitsfile, str(e)))
Example #30
0
def decode_abscmd(cmdstr, envstr, sk_bank, logger):

    import remoteObjects as ro
    ro.init()

    fakeStatus = {
        'STATL.TSC_F_SELECT': 'CS_IR',
    }

    # Create top level logger.
    logger = ssdlog.make_logger('sk_decode', options)

    sk_bank = skBank(options.skdir, logger=logger)

    variable_resolver = VariableResolver({})
    register_resolver = RegisterResolver()
    #status_resolver = MockStatusResolver(fakeStatus)
    status_resolver = StatusResolver(ro.remoteObjectProxy('status'))
    frame_source = MockFrameSource()

    eval = Evaluator(variable_resolver, register_resolver, status_resolver,
                     frame_source, logger)

    # Parse environment string into an AST, raising parse error if
    # necessary
    envstr = envstr.strip()
    if len(envstr) > 0:
        res = sk_bank.parser.parse_params(envstr)
        if res[0]:
            raise DecodeError("Error parsing default parameters '%s': %s" %
                              (envstr, res[2]))

        try:
            ast_global_params = res[1]
            assert ast_global_params.tag == 'param_list', ASTerr(
                ast_global_params)

        except AssertionError, e:
            raise DecodeError("Malformed default parameter list '%s': AST=%s" %
                              (envstr, str(ast_global_params)))
def client2(options):

    datafile = None
    if options.datafile:
        datafile = open(options.datafile, 'a')

    auth = None
    if options.auth:
        auth = options.auth.split(':')

    # Get handle to server
    testro = ro.remoteObjectProxy(options.svcname,
                                  auth=auth,
                                  secure=options.secure,
                                  timeout=2.0)

    time1 = time.time()

    for i in xrange(options.count):
        res = testro.search(1.0, 2.0, 3.0, 4.0)

        if options.interval:
            time.sleep(options.interval)

    tottime = time.time() - time1
    time_per_call = tottime / options.count
    calls_per_sec = int(1.0 / time_per_call)

    print "Time taken: %f secs total  %f sec per call  %d calls/sec" % \
          (tottime, time_per_call, calls_per_sec)

    if datafile:
        # total bytes, count, total time, encode time, avg rate
        datafile.write("%d %d %f %f %f\n" %
                       (size * options.count, options.count, tottime,
                        time2 - time1, amount / tottime))
        datafile.close()