def _main(): from support.logs import setup_logging import datetime import os parsed = create_arg_parser().parse_args() level = logging.DEBUG if not parsed.verbose: level = logging.INFO logdir = "/usr/local/Logs/" + socket.gethostname() if not os.path.exists(logdir): logdir = os.path.dirname(os.path.abspath(__file__)) timestamp = datetime.datetime.utcnow().strftime("%Y-%j-%Hh%Mm%Ss") logfile = os.path.join( logdir, "{}_{}.log".format(server_cls.__name__, timestamp)) dss = parsed.dss site = DSN.complexID[DSN.DSN_complex_of(dss)] setup_logging(logLevel=level, logfile=logfile) server = server_cls(wsn=parsed.wsn, dss=dss, site=site, logLevel=level, simulated=parsed.s) # print(server.feed_change(0, 0, 0)) server.launch_server(ns=False, objectId="APC", objectPort=50001, local=parsed.local, threaded=False)
def _main(): from support.logs import setup_logging import datetime import os parsed = create_arg_parser().parse_args() level = logging.DEBUG if not parsed.verbose: level = logging.INFO # logdir = "/home/ops/roach_data/sao_test_data/logdir/" logdir = "/usr/local/Logs/"+socket.gethostname() if not os.path.exists(logdir): logdir = os.path.dirname(os.path.abspath(__file__)) timestamp = datetime.datetime.utcnow().strftime("%Y-%j-%Hh%Mm%Ss") logfile = os.path.join( logdir, "{}_{}.log".format( server_cls.__name__, timestamp ) ) setup_logging(logLevel=level, logfile=None) server = server_cls( name="test" ) # print(server.feed_change(0, 0, 0)) server.launch_server( ns=False, objectId="backend", objectPort=50004, local=parsed.local, threaded=False )
def main(): from support.arguments import simple_parse_args from support.logs import setup_logging setup_logging(logger=logging.getLogger(), logLevel=logging.DEBUG) parser = simple_parse_args( "Launch combined WBDC Front End server").parse_args() wbdc = WBDCFrontEndServer(simulated=parser.simulated) wbdc.perform_minical() wbdc.launch_server(ns=False, threaded=False, local=parser.local, objectPort=50004, objectId="WBDCFE")
antenna = SimulatedAntenna(43) if __name__ == "__main__": from support.logs import setup_logging parsed = create_arg_parser().parse_args() log_dir = parsed.log_dir if not os.path.exists(log_dir): log_dir = os.path.dirname(os.path.abspath(__file__)) level = logging.INFO if parsed.verbose: level = logging.DEBUG if parsed.dss: antenna = SimulatedAntenna(int(parsed.dss)) log_dir = "/usr/local/Logs/dss" + parsed.dss antenna.logger.setLevel(level) antenna.start_weather_thread() timestamp = datetime.datetime.utcnow().strftime("%Y-%j-%Hh%Mm%Ss") setup_logging(logLevel=level, logfile=os.path.join( log_dir, "NMC_simulator_{}.log".format(timestamp))) address = ("localhost", 6700 + int(parsed.dss)) server = NMCServer(address, NMCRequestHandler) server.serve_forever()
class TestControlFlowMixin(unittest.TestCase): @classmethod def setUpClass(cls): cls.logger = logging.getLogger("TestControlFlowMixin") cls.obj = MixedIn() def test_until_run(self): now = self.obj.now() later = now + datetime.timedelta(seconds=1) for e in self.obj.until(later).run(self.obj.generator()): self.logger.debug("test_until_run: {}".format(e)) def test_until_loop(self): now = self.obj.now() later = now + datetime.timedelta(seconds=0.8) for e in self.obj.until(later).loop(self.obj.generator_func()): self.logger.debug("test_until_loop: {}".format(e)) def test_at_run(self): now = self.obj.now() later = now + datetime.timedelta(seconds=1) for e in self.obj.at(later).run(self.obj.generator): self.logger.debug("test_at_run: {}".format(e)) if __name__ == "__main__": setup_logging(logging.getLogger(""), logLevel=logging.DEBUG) unittest.main()
def test_lookup_function_or_method(self): self.proxy.register(self.callback) res = self.proxy.lookup_function_or_method(self.callback) self.assertTrue(res["method"] == self.callback.__name__) # @unittest.skip("") def test_wait_fn(self): self.proxy.register(self.callback) obj, _ = self.proxy.lookup(self.callback)[0] with self.proxy.wait(self.callback): obj.callback("hello") # res = self.proxy.wait(self.callback) # self.assertTrue(res == "hello") # @unittest.skip("") def test_wait_obj(self): client = self.Client() self.proxy.register(client) obj, _ = self.proxy.lookup(client)[0] with self.proxy.wait(client.callback): obj.callback("hello") if __name__ == "__main__": setup_logging(logLevel=logging.INFO) unittest.main()
from MonitorControl.Configurations import station_configuration from support.logs import setup_logging from support.pyro.pyro5_server import Pyro5Server __version__ = "1.0.2" default_level = logging.DEBUG module_levels = { "support": logging.WARNING, "MonitorControl": logging.DEBUG, "MonitorControl.FrontEnds": logging.DEBUG, "MonitorControl.apps.postproc.util": logging.INFO } setup_logging(logger=logging.getLogger(""), logLevel=default_level) for module in module_levels: logging.getLogger(module).setLevel(module_levels[module]) class PyroServer(CentralServer, Pyro5Server): """ """ def __init__( self, context, # required project="TAMS", import_path=None, config_args=None, config_kwargs=None,
return parser if __name__ == "__main__": from support.logs import setup_logging parsed = create_arg_parser().parse_args() log_dir = parsed.log_dir level = logging.INFO if parsed.verbose: level = logging.DEBUG timestamp = datetime.datetime.utcnow().strftime("%Y-%j-%Hh%Mm%Ss") setup_logging(logger=logging.getLogger(""), logLevel=level, logfile=os.path.join(log_dir, "NMC_sim43_{}.log".format(timestamp))) antenna = SimulatedAntenna(43) # antenna.start_weather_updates() antenna_server = NMCServer(antenna) host = "localhost" port = 6743 loop = asyncio.get_event_loop() loop.create_task( asyncio.start_server(antenna_server.handle_client, host, port)) try: loop.run_forever() except KeyboardInterrupt: loop.close()
# @unittest.skip("") def test_event_from_server(self): p = EventEmitterProxy(self.uri) p.on("event", self.on_event.call) self.server.emit("event", "hello") while not self.on_event.called: pass self.assertTrue(self.on_event.called) # @unittest.skip("") def test_multiple_handlers(self): new_handler = self.OnEvent() p = EventEmitterProxy(self.uri) p.on("event", self.on_event.call) p.on("event", new_handler.call) p.emit("event", "hello") module_logger.debug(self.server._handlers) while not self.on_event.called: pass while not new_handler.called: pass self.assertTrue(self.on_event.called) self.assertTrue(new_handler.called) if __name__ == "__main__": setup_logging() unittest.main()
from support.logs import setup_logging from MonitorControl.FrontEnds.Kband import K_4ch auto_tester = AutoTestSuite(K_4ch,args=("K",)) suite, TestK_4ch_factory = auto_tester.create_test_suite(factory=True) class TestK_4ch(TestK_4ch_factory()): pass class TestK_4ch_with_hardware(unittest.TestCase): @classmethod def setUpClass(cls): cls.fe = K_4ch("K",hardware=True) def test_init(self): self.assertTrue(self.fe.channel.keys() == ["F1","F2"]) def test_read_temp(self): temp = self.fe.read_temps() print(temp) def test_read_pm(self): pm = self.fe.read_PMs() print(pm) if __name__ == "__main__": setup_logging(logLevel=logging.DEBUG) unittest.main()
parsed = create_arg_parser().parse_args() level = logging.DEBUG if not parsed.verbose: level = logging.INFO logdir = "/usr/local/Logs/"+socket.gethostname() if not os.path.exists(logdir): logdir = os.path.dirname(os.path.abspath(__file__)) timestamp = datetime.datetime.utcnow().strftime("%Y-%j-%Hh%Mm%Ss") logfile = os.path.join( logdir, "{}_{}.log".format( server_cls.__name__, timestamp ) ) setup_logging(logLevel=level, logfile=None) server = server_cls( name="test" ) # print(server.feed_change(0, 0, 0)) server.launch_server( ns=False, objectId="backend", objectPort=50000, local=parsed.local, threaded=False ) return _main if __name__ == "__main__":