Skip to content

Commit

Permalink
Merge pull request #136 from perfsonar/bug/type-error
Browse files Browse the repository at this point in the history
fixes involving variable types and handling exceptions in agentctl
  • Loading branch information
arlake228 authored Sep 6, 2024
2 parents 5a04fd8 + 3d435df commit 7308c85
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
10 changes: 7 additions & 3 deletions psconfig/perfsonar-psconfig/bin/commands/agentctl
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,13 @@ elif len(args.values) > 0:
cli.print_msg("Successfully set {} in {}".format(args.prop, config_file))
elif args.unset:
#unset an option
del agent_conf.data[args.prop]
_save_and_validate(agent_conf, config_client, cli)
cli.print_msg("Successfully unset {} in {}".format(args.prop, config_file))
try:
del agent_conf.data[args.prop]
_save_and_validate(agent_conf, config_client, cli)
cli.print_msg("Successfully unset {} in {}".format(args.prop, config_file))
except KeyError:
cli.print_msg("{} was not set in {}. No action performed".format(args.prop, config_file))

else:
# print current value of property
_print_prop(args.prop, agent_conf.data.get(args.prop, None), cli)
2 changes: 1 addition & 1 deletion psconfig/perfsonar-psconfig/psconfig/base_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def run(self):
check_interval = None

try:
check_interval = duration_to_seconds(agent_conf.check_interval())
check_interval = int(duration_to_seconds(agent_conf.check_interval()))
except Exception as e:
self.logger.error(self.logf.format("Error parsing check-interval. Defaulting to " + str(self.check_interval_seconds) + " seconds: {}".format(e)))
pass
Expand Down
2 changes: 1 addition & 1 deletion psconfig/perfsonar-psconfig/psconfig/pscheduler/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def _run_start(self, agent_conf):
task_min_ttl_seconds = None

try:
task_min_ttl_seconds = duration_to_seconds(agent_conf.task_min_ttl())
task_min_ttl_seconds = int(duration_to_seconds(agent_conf.task_min_ttl()))
except Exception as e:
self.logger.error(self.logf.format("Error parsing task-min-ttl. Defaulting to " + str(self.task_min_ttl_seconds) + " seconds: {}".format(e)))

Expand Down
3 changes: 2 additions & 1 deletion psconfig/perfsonar-psconfig/psconfig/utilities/iso8601.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import isodate

def duration_to_seconds(iso):
"""Convert an ISO 8601 string to a timdelta and return total seconds"""
"""Convert an ISO 8601 string to a timdelta and return total seconds
Returns float"""
try:
duration = isodate.parse_duration(iso)
except isodate.isoerror.ISO8601Error:
Expand Down

0 comments on commit 7308c85

Please sign in to comment.