def test_expandToAcquisitionBasePath(self): logger.info("== {} ==".format(self._testMethodName)) ev = Environment(debug=False, rt=self.rt, logger=logger) res = ev.expandToAcquisitionBasePath() tst = "{}/{}".format(self.rt.cfg["BASE_DIRECTORY"], ev.startTime) self.assertEqual( res, "{}/{}/".format(self.rt.cfg["BASE_DIRECTORY"], ev.startTime), "return value:{}, {}".format(res, tst) )
def setUp(self): self.rt = Configuration(logger=logger) self.fileName = './rts2saf-flux.cfg' self.success = self.rt.readConfiguration(fileName=self.fileName) self.ev = Environment(debug=False, rt=self.rt, logger=logger) self.args = Args() self.args.catalogAnalysis = True self.args.Ds9Display = False self.args.FitDisplay = False self.args.criteria = 'rts2saf.criteria_radius' self.args.basePath = '../samples' self.args.filterNames = None self.args.sxDebug = False self.args.flux = True self.args.fractObjs = 0.5
def setUp(self): self.rt = Configuration(logger=logger) self.fileName='./rts2saf-flux.cfg' self.success=self.rt.readConfiguration(fileName=self.fileName) self.ev=Environment(debug=False, rt=self.rt,logger=logger)
if not rt.checkConfiguration(args=args): logger.error( 'rts2saf_focus: exiting, check the configuration file: {0}'.format( args.config)) sys.exit(1) # overwrite config defaults rt.cfg['ANALYZE_FLUX'] = args.flux rt.cfg['ANALYZE_ASSOC'] = args.associate rt.cfg['ANALYZE_ASSOC_FRACTION'] = args.fractObjs if args.FitDisplay: rt.cfg['WITH_MATHPLOTLIB'] = True # get the environment ev = Environment(debug=args.debug, rt=rt, logger=logger) if not args.blind and args.focRange: logger.error( 'rts2saf_focus: --focrange has no effect without --blind'.format( args.focRange)) sys.exit(1) if args.focRange: if (args.focRange[0] >= args.focRange[1]) or args.focRange[2] <= 0: logger.error('rts2saf_focus: bad range values: {}, exiting'.format( args.focRange)) sys.exit(1) # establish a connection proxy = JSONProxy(url=rt.cfg['URL'],
def test_createAcquisitionBasePath(self): logger.info("== {} ==".format(self._testMethodName)) ev = Environment(debug=False, rt=self.rt, logger=logger) res = ev.createAcquisitionBasePath() self.assertTrue(res, "return value:{}".format(res))
def test_expandToPlotFileName(self): logger.info("== {} ==".format(self._testMethodName)) ev = Environment(debug=False, rt=self.rt, logger=logger) res = ev.expandToPlotFileName() self.assertEqual(res, "myPlot-{}.png".format(ev.startTime[0:19]), "return value:{}".format(res))
def test_expandToTmp(self): logger.info("== {} ==".format(self._testMethodName)) ev = Environment(debug=False, rt=self.rt, logger=logger) res = ev.expandToTmp(fn="fn") self.assertEqual(res, "{}/fn".format(self.rt.cfg["TEMP_DIRECTORY"]), "return value:{}".format(res))
def setUp(self): # by name self.uid = pwd.getpwuid(os.getuid())[0] self.gid = grp.getgrgid(os.getgid())[0] # lock prefix self.lockPrefix = '/tmp/rts2_{}'.format(self.uid) # sometimes they are present self.tearDown() # set up rts2saf # read configuration self.rt = Configuration(logger=logger) self.ev = Environment(debug=False, rt=self.rt, logger=logger) self.fileName = './rts2saf-bootes-2-autonomous.cfg' self.success = self.rt.readConfiguration(fileName=self.fileName) # set up RTS2 # rts2-centrald cmd = [ '/usr/local/bin/rts2-centrald', '--run-as', '{}.{}'.format(self.uid, self.gid), '--local-port', '1617', '--logfile', '/tmp/rts2saf_log/rts2-debug', '--lock-prefix', self.lockPrefix, '--config', './rts2-unittest.ini' ] self.p_centrald = subprocess.Popen(cmd) # rts2-executor cmd = [ '/usr/local/bin/rts2-executor', '--run-as', '{}.{}'.format(self.uid, self.gid), '--lock-prefix', self.lockPrefix, '--config', './rts2-unittest.ini', '--server', '127.0.0.1:1617', '--noauth' ] self.p_exec = subprocess.Popen(cmd) # rts2-xmlrpcd cmd = [ '/usr/local/bin/rts2-xmlrpcd', '--run-as', '{}.{}'.format(self.uid, self.gid), '--lock-prefix', self.lockPrefix, '--config', './rts2-unittest.ini', '--server', '127.0.0.1:1617', '-p', '9999', '--noauth' ] self.p_xmlrpcd = subprocess.Popen(cmd) # rts2-focusd-dummy focName = self.rt.cfg['FOCUSER_NAME'] cmd = [ '/usr/local/bin/rts2-focusd-dummy', '--run-as', '{}.{}'.format(self.uid, self.gid), '--lock-prefix', self.lockPrefix, '--server', '127.0.0.1:1617', '-d', focName, '--modefile', './f0.modefile' ] self.p_focusd_dummy = subprocess.Popen(cmd) # rts2-filterd-dummy ftwns = list() for ftwn in self.rt.cfg['inuse']: ftwns.append(ftwn) cmd = [ '/usr/local/bin/rts2-filterd-dummy', '--run-as', '{}.{}'.format(self.uid, self.gid), '--lock-prefix', self.lockPrefix, '--server', '127.0.0.1:1617', '-d', ftwn ] ftnames = str() for ftn in self.rt.cfg['FILTER WHEEL DEFINITIONS'][ftwn]: ftnames += '{}:'.format(ftn) if len(ftnames) > 0: cmd.append('-F') cmd.append(ftnames) self.p_filterd_dummy = subprocess.Popen(cmd) # rts2-camd-dummy name = self.rt.cfg['CCD_NAME'] # '--wheeldev', 'COLWSLT', '--filter-offsets', '1:2:3:4:5:6:7:8' cmd = [ '/usr/local/bin/rts2-camd-dummy', '--run-as', '{}.{}'.format(self.uid, self.gid), '--lock-prefix', self.lockPrefix, '--server', '127.0.0.1:1617', '-d', name, '--focdev', focName ] for nm in ftwns: cmd.append('--wheeldev') cmd.append(nm) if nm in self.rt.cfg['inuse'][0]: cmd.append('--filter-offsets') cmd.append('1:2:3:4:5:6:7:8') self.p_camd_dummy = subprocess.Popen(cmd) # time.sleep(20)
def test_createAcquisitionBasePath(self): logger.info('== {} =='.format(self._testMethodName)) ev=Environment(debug=False, rt=self.rt, logger=logger) res=ev.createAcquisitionBasePath() self.assertTrue(res,'return value:{}'.format(res))
def test_expandToAcquisitionBasePath(self): logger.info('== {} =='.format(self._testMethodName)) ev=Environment(debug=False, rt=self.rt, logger=logger) res=ev.expandToAcquisitionBasePath() tst='{}/{}'.format(self.rt.cfg['BASE_DIRECTORY'], ev.startTime) self.assertEqual( res, '{}/{}/'.format(self.rt.cfg['BASE_DIRECTORY'], ev.startTime),'return value:{}, {}'.format(res, tst))
def test_expandToPlotFileName(self): logger.info('== {} =='.format(self._testMethodName)) ev=Environment(debug=False, rt=self.rt, logger=logger) res=ev.expandToPlotFileName() self.assertEqual(res, 'myPlot-{}.png'.format(ev.startTime[0:19]),'return value:{}'.format(res))
def test_expandToTmp(self): logger.info('== {} =='.format(self._testMethodName)) ev=Environment(debug=False, rt=self.rt, logger=logger) res=ev.expandToTmp(fn='fn') self.assertEqual(res,'{}/fn'.format(self.rt.cfg['TEMP_DIRECTORY']),'return value:{}'.format(res))
rtc.cfg['WEIGHTED_MEANS'] = args.means if args.FitDisplay: rtc.cfg['WITH_MATHPLOTLIB'] = True if args.emptySlots is not None: rtc.cfg['EMPTY_SLOT_NAMES'] = [x.strip() for x in args.emptySlots] # ToDo ugly if args.filterNames is not None: fts = [x.strip() for x in args.filterNames] args.filterNames = fts rtc.checkConfiguration(args=args) # environment ev = Environment(debug=args.debug, rt=rtc, logger=logger) if not args.basePath: parser.print_help() logger.warn('rts2saf_analyze: no --basepath specified') sys.exit(1) if not args.toconsole: print 'you may wish to enable logging to console --toconsole' print 'log file is written to: {}'.format(args.logfile) aRs = AnalyzeRuns(debug=args.debug, basePath=args.basePath, args=args, rt=rtc, ev=ev,
if args.FitDisplay: rtc.cfg['WITH_MATHPLOTLIB'] = True if args.emptySlots is not None: rtc.cfg['EMPTY_SLOT_NAMES'] = [ x.strip() for x in args.emptySlots ] # ToDo ugly if args.filterNames is not None: fts = [ x.strip() for x in args.filterNames ] args.filterNames = fts rtc.checkConfiguration(args=args) # environment ev = Environment(debug = args.debug, rt = rtc, logger = logger) if not args.basePath: parser.print_help() logger.warn('rts2saf_analyze: no --basepath specified') sys.exit(1) if not args.toconsole: print 'you may wish to enable logging to console --toconsole' print 'log file is written to: {}'.format(args.logfile) aRs = AnalyzeRuns(debug = args.debug, basePath = args.basePath, args = args, rt = rtc, ev = ev, logger = logger, xdisplay = XDISPLAY) aRs.aggregateRuns() if len(aRs.fS) == 0: logger.warn('rts2saf_analyze: exiting, no files found in basepath: {}'.format(args.basePath))