-
Notifications
You must be signed in to change notification settings - Fork 2
Update to user logger #250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 4 commits
e262766
127ab4a
dc30f9f
d256191
18e28a2
d7e6c38
0ecdd8c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,37 +25,37 @@ 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(): | ||
| if ant.sensor.rsc_rxl_startup_state.get_value() != "cold-operational": | ||
| 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())) | ||
| else: | ||
| 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,44 +87,44 @@ 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("\nBeginning a quick check of antenna %s" % ant.name) | ||
|
||
| user_logger.info("\nAP 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("\nChecking Receiver") | ||
|
||
| check_receivers() | ||
|
|
||
| print("\nChecking Digitisers") | ||
| user_logger.info("\nChecking Digitisers") | ||
|
||
| check_digitisers() | ||
|
|
||
| print("\nchecking acu encoder") | ||
| user_logger.info("\nchecking acu encoder") | ||
| enc=[ | ||
| "ap_azim_enc_failed", | ||
| "ap_elev_enc_failed" | ||
| ] | ||
| 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("\nchecking antenna key lock switch") | ||
| safe_pos=[ | ||
| "ap_key_switch_safe1_enabled", | ||
| "ap_key_switch_safe2_enabled" | ||
| ] | ||
| 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("\nChecking 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("\nChecking 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("\nChecking 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("\nChecking 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,13 @@ 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.info('\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("\n{} has passed the handover test".format(opts.ant)) | ||
| # -fin- | ||
| print("check_ant_AR1.py: stop\n") | ||
| user_logger.info("check_ant_AR1.py: stop\n") | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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(kat.controlled_objects) | ||
| user_logger.info(kat.ants.clients) | ||
| user_logger.info(opts) | ||
| user_logger.info("_______________________") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The objects should be formatted into strings to prevent unexpected surprises |
||
|
|
||
| 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,22 @@ 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('\n') | ||
|
||
| 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("\nGlobal Sync Date %s" % time.ctime(etime)) | ||
|
|
||
| # -fin- | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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(opt) | ||
|
||
| user_logger.info("_______________________") | ||
| log_message("Opts:\n{}\n".format(opts)) | ||
|
|
||
| MAINT_PORT = 7148 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the advantages of logging is that string formatting is more compact. You can just write:
This is especially useful when multiple items are formatted, but a good habit nonetheless.