diff --git a/utility/check_ant.py b/utility/check_ant.py index 2ff86def..4311c659 100755 --- a/utility/check_ant.py +++ b/utility/check_ant.py @@ -25,7 +25,7 @@ def check_digitisers(): if ant.sensor.dig_selected_band.get_value() not in ["u", "l", "s", "x"]: user_logger.warning("digitiser is in %s band. expected u, l, s or x band" % ant.sensor.dig_selected_band.get_value()) else: - print("digitiser is in %s band" % ant.sensor.dig_selected_band.get_value()) + user_logger.info("digitiser is in %s band" % ant.sensor.dig_selected_band.get_value()) # Checking L-band receiver for now. will add more checks for UHF and others on the next push def check_receivers(): @@ -33,16 +33,16 @@ def check_receivers(): raise RuntimeError("rsc_rxl_startup_state is %s, cold-operational expected"% ant.sensor.rsc_rxl_startup_state.get_value()) if ant.sensors.rsc_rxl_rfe1_temperature.get_value() < 29: - print("L-band rfe1 temperature is ok :)") + user_logger.info("L-band rfe1 temperature is ok :)") if not ant.sensor.rsc_rxl_lna_h_power_enabled.get_value(): user_logger.warning("L-band receiver hpol LNA power is not enabled. switch on the hpol LNA power") else: - print(":) receiver hpol LNA power is ON") + user_logger.info(":) receiver hpol LNA power is ON") if not ant.sensor.rsc_rxl_lna_v_power_enabled.get_value(): user_logger.warning("L-band receiver vpol LNA power is not enabled. switch on the vpol LNA power") else: - print(":) receiver vpol LNA power is ON") + user_logger.info(":) receiver vpol LNA power is ON") elif ant.sensors.rsc_rxl_rfe1_temperature.get_value() > 30 and ant.sensors.rsc_rxl_rfe1_temperature.get_value() < 100: user_logger.warning("L-band rfe1 temperature is warm @ %.2f. alert the site technician" % (ant.sensors.rsc_rxl_rfe1_temperature.get_value())) @@ -50,12 +50,12 @@ def check_receivers(): user_logger.warning("L-band rfe1 temperature is warm. alert the site technician") indexer_angle = ant.sensor.ap_indexer_position_raw.get_value() - print("receiver indexer value is %d." % indexer_angle) + user_logger.info("receiver indexer value is %d." % indexer_angle) ril=ant.sensor.ap_indexer_position.get_value().upper() if ril not in ["u", "l", "s", "x"]: user_logger.warning("AP indexer in unknown position") else: - print("receiver indexer is at the %s-band position" % ril) + user_logger.info("receiver indexer is at the %s-band position" % ril) # Parse command-line options that allow the defaults to be overridden parser = standard_script_options(usage="usage: %prog [options]", @@ -70,7 +70,7 @@ def check_receivers(): raise SystemExit("antenna name required %s" % parser.print_usage()) with verify_and_connect(opts) as kat: - print("Antenna quick check : start") + user_logger.info("Antenna quick check : start") ant_active = [ant for ant in kat.ants] for ant in ant_active: @@ -87,24 +87,24 @@ def check_receivers(): raise RuntimeError("AP e_stop: %s" % ant.sensor.ap_e_stop_reason.get_value()) # Verify that all the config data has been added from RTS - print("\nBeginning a quick check of antenna %s" % ant.name) - print("\nAP version: %s" % ant.sensor.ap_api_version.get_value()) + user_logger.info("Beginning a quick check of antenna %s" % ant.name) + user_logger.info("AP version: %s" % ant.sensor.ap_api_version.get_value()) if ant.sensor.rsc_rxu_serial_number.get_value(): - print("UHF band serial number: %s" % ant.sensor.rsc_rxu_serial_number.get_value()) + user_logger.info("UHF band serial number: %s" % ant.sensor.rsc_rxu_serial_number.get_value()) if ant.sensor.rsc_rxl_serial_number.get_value(): - print("L-band serial number: %s" % ant.sensor.rsc_rxl_serial_number.get_value()) + user_logger.info("L-band serial number: %s" % ant.sensor.rsc_rxl_serial_number.get_value()) if ant.sensor.rsc_rxs_serial_number.get_value(): - print("S-band serial number: %s" % ant.sensor.rsc_rxs_serial_number.get_value()) + user_logger.info("S-band serial number: %s" % ant.sensor.rsc_rxs_serial_number.get_value()) if ant.sensor.rsc_rxx_serial_number.get_value(): - print("X-band serial number: %s" % ant.sensor.rsc_rxx_serial_number.get_value()) + user_logger.info("X-band serial number: %s" % ant.sensor.rsc_rxx_serial_number.get_value()) - print("\nChecking Receiver") + user_logger.info("Checking Receiver") check_receivers() - print("\nChecking Digitisers") + user_logger.info("Checking Digitisers") check_digitisers() - print("\nchecking acu encoder") + user_logger.info("checking acu encoder") enc=[ "ap_azim_enc_failed", "ap_elev_enc_failed" @@ -112,9 +112,9 @@ def check_receivers(): if check_sensors(ant.sensor, enc): any_errors = True else: - print(":) ACU encoders OK") + user_logger.info(":) ACU encoders OK") - print("\nchecking antenna key lock switch") + user_logger.info("checking antenna key lock switch") safe_pos=[ "ap_key_switch_safe1_enabled", "ap_key_switch_safe2_enabled" @@ -122,9 +122,9 @@ def check_receivers(): if check_sensors(ant.sensor, safe_pos): any_errors = True else: - print(":) antenna is unlocked") + user_logger.info(":) antenna is unlocked") - print("\nChecking motion") + user_logger.info("Checking motion") amps=[ "ap_azim_amp1_failed", "ap_azim_amp2_failed", @@ -138,9 +138,9 @@ def check_receivers(): if check_sensors(ant.sensor, amps): any_errors = True else: - print(":) AP Servo OK") + user_logger.info(":) AP Servo OK") - print("\nChecking brakes") + user_logger.info("Checking brakes") breaks=[ "ap_azim_brake1_failed", "ap_azim_brake2_failed", @@ -150,7 +150,7 @@ def check_receivers(): if check_sensors(ant.sensor, breaks): any_errors = True else: - print(":) Brakes OK") + user_logger.info(":) Brakes OK") breaks=[ "ap_azim_brakes_released", @@ -159,9 +159,9 @@ def check_receivers(): if check_sensors(ant.sensor, breaks, test_false=True): any_errors = True else: - print(":) Brakes released") + user_logger.info(":) Brakes released") - print("\nChecking doors") + user_logger.info("Checking doors") doors=[ "ap_hatch_door_open", "ap_ped_door_open", @@ -170,9 +170,9 @@ def check_receivers(): if check_sensors(ant.sensor, doors): any_errors = True else: - print(":) All Doors Closed") + user_logger.info(":) All Doors Closed") - print("\nChecking AP drive limits") + user_logger.info("Checking AP drive limits") azim_limits=[ "ap_azim_emergency2_limit_ccw_reached", "ap_azim_emergency2_limit_cw_reached", @@ -190,7 +190,7 @@ def check_receivers(): if check_sensors(ant.sensor, azim_limits): any_errors = True else: - print(":) AP not in Azimuth Limit") + user_logger.info(":) AP not in Azimuth Limit") elev_limits=[ "ap_elev_emergency2_limit_down_reached", @@ -207,13 +207,12 @@ def check_receivers(): if check_sensors(ant.sensor, elev_limits): any_errors = True else: - print(":) AP not in Elevation Limit") + user_logger.info(":) AP not in Elevation Limit") if any_errors: - print('\n') user_logger.warning("Some errors detected, investigate before accepting %s" % ant.name) else: - print("\n{} has passed the handover test".format(opts.ant)) + user_logger.info("{} has passed the handover test".format(opts.ant)) # -fin- - print("check_ant_AR1.py: stop\n") + user_logger.info("check_ant_AR1.py: stop") diff --git a/utility/enable_vacuum_pump.py b/utility/enable_vacuum_pump.py index 51be6d37..4fcd625f 100755 --- a/utility/enable_vacuum_pump.py +++ b/utility/enable_vacuum_pump.py @@ -25,7 +25,7 @@ def timestamp(): def log_message(msg, level='info'): - print('{timestamp} {level} {msg}'.format( + user_logger.info('{timestamp} {level} {msg}'.format( timestamp=timestamp(), level=level.upper(), msg=str(msg))) @@ -57,11 +57,11 @@ def enable_vac_pump(ant): if __name__ == "__main__": if opts.receptors is None: - print("Error. Specify which receptors to enable the vacuum pumps.") + user_logger.error("Error. Specify which receptors to enable the vacuum pumps.") else: ants = opts.receptors.replace(' ', '') for x in ants.split(','): if not x.startswith('m'): - print("Error. Illegal antenna name: {}".format(x)) + user_logger.error("Error. Illegal antenna name: {}".format(x)) else: enable_vac_pump(x) diff --git a/utility/global_sync.py b/utility/global_sync.py index 36f462bf..32f1b4af 100755 --- a/utility/global_sync.py +++ b/utility/global_sync.py @@ -41,7 +41,7 @@ # assume basic options passed from instruction_set parser.set_defaults(description='AR1 Global sync') (opts, args) = parser.parse_args() -print("global_sync_AR1 script: start") +user_logger.info("global_sync_AR1 script: start") def log_info(response): @@ -52,11 +52,11 @@ def log_info(response): user_logger.info(response) with verify_and_connect(opts) as kat: - print("_______________________") - print(kat.controlled_objects) - print(kat.ants.clients) - print(opts) - print("_______________________") + user_logger.info("_______________________") + user_logger.info(str(kat.controlled_objects)) + user_logger.info(str(kat.ants.clients)) + user_logger.info(str(opts)) + user_logger.info("_______________________") subarrays = kat.katpool.sensor.subarrays.get_value() subarrays_free = kat.katpool.sensor.subarrays_free.get_value() @@ -67,7 +67,7 @@ def log_info(response): count = 1 if not kat.dry_run: - print('Building CAM object') + user_logger.info('Building CAM object') cam = cambuild(password="camcam", full_control="all") cam.until_synced() @@ -76,13 +76,13 @@ def log_info(response): try: delay_values=katconf.resource_string(opts.configdelayfile).split('\n') except: - print ('Failed to read delay values from config. Using local delays instead') + user_logger.warn('Failed to read delay values from config. Using local delays instead') delay_values = open(opts.localdelayfile) for line in delay_values: x = ((line.strip('\n')).split(',')) if (len(x[0]) == 4 and x[0][0] == 'm'): delay_list[x[0]] = int(x[1]) - print('Receptor: %s delay: %s' % (x[0], x[1])) + user_logger.info('Receptor: %s delay: %s' % (x[0], x[1])) except: raise RuntimeError('Failure to read pps delay file!') @@ -94,34 +94,34 @@ def log_info(response): else: ant_active = [ant for ant in cam.ants if ant.name not in cam.katpool.sensor.resources_in_maintenance.get_value()] - print('Set PPS delay compensation for digitisers') + user_logger.info('Set PPS delay compensation for digitisers') for ant in ant_active: - print ant.name + user_logger.info(ant.name) # look at current delay and program in delay specified in CSV if ant.name in delay_list: # set the delay compensations for a digitiser (assuming L band) try: response = ant.req.dig_digitiser_offset('l') except Exception as msg: - print('Caught exception antenna %s' % ant.name) - print(msg) + user_logger.error('Caught exception antenna %s' % ant.name) + user_logger.error(msg) raise curr_delay_l = int(str(response).split(' ')[2]) if curr_delay_l == delay_list[ant.name]: - print(ant.name + ': no change to PPS delay offset') + user_logger.info(ant.name + ': no change to PPS delay offset') else: - print(ant.name + " is on L band") - print(ant.name + ' L-band current delay : ' + str(curr_delay_l)) + user_logger.info(ant.name + " is on L band") + user_logger.info(ant.name + ' L-band current delay : ' + str(curr_delay_l)) response = ant.req.dig_digitiser_offset('l', delay_list[ant.name]) - print(ant.name + ' L-band PPS delay offset : ' + str(response)) + user_logger.info(ant.name + ' L-band PPS delay offset : ' + str(response)) init_epoch = cam.mcp.sensor.dmc_synchronisation_epoch.get_value() - print('Performing global sync on AR1 ...') + user_logger.info('Performing global sync on AR1 ...') serial_sync_timeout = 300 # seconds start_time = time.time() cam.mcp.req.dmc_global_synchronise(timeout=serial_sync_timeout) - print("Duration of global sync: {} try number {}" + user_logger.info("Duration of global sync: {} try number {}" .format(time.time() - start_time, 1)) wait_time = 0 @@ -133,22 +133,21 @@ def log_info(response): etime = cam.mcp.sensor.dmc_synchronisation_epoch.get_value() for ant in ant_active: - print("Verify epoch digitiser for antenna %s" % ant.name) + user_logger.info("Verify epoch digitiser for antenna %s" % ant.name) ant_epoch = ant.sensor.dig_l_band_time_synchronisation_epoch.get_value() if ant_epoch != etime: raise RuntimeError('System not synced, investigation is required...') else: print('%s sync epoch: %d' % (ant.name, ant_epoch)) - print("Resetting capture destination %s" % ant.name) + user_logger.info("Resetting capture destination %s" % ant.name) response = ant.req.deactivate() print(ant.req.dig_capture_list()) - print('\n') - print("Script complete") + user_logger.info("Script complete") finally: if cam: - print("Cleaning up cam object") + user_logger.info("Cleaning up cam object") cam.disconnect() - print("\nGlobal Sync Date %s" % time.ctime(etime)) + user_logger.info("Global Sync Date %s" % time.ctime(etime)) # -fin- diff --git a/utility/lubricate_vacuum_pump.py b/utility/lubricate_vacuum_pump.py index 75836c47..ff545324 100755 --- a/utility/lubricate_vacuum_pump.py +++ b/utility/lubricate_vacuum_pump.py @@ -246,9 +246,9 @@ def read_sensor_history(ants): '{} - Error reading and processing sensor data.'.format(ant), 'error') with verify_and_connect(opts) as kat1: - print "_______________________" - print opts - print "_______________________" + user_logger.info("_______________________") + user_logger.info(str(opt)) + user_logger.info("_______________________") log_message("Opts:\n{}\n".format(opts)) MAINT_PORT = 7148