Skip to content

Commit 7308c85

Browse files
authored
Merge pull request #136 from perfsonar/bug/type-error
fixes involving variable types and handling exceptions in agentctl
2 parents 5a04fd8 + 3d435df commit 7308c85

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

psconfig/perfsonar-psconfig/bin/commands/agentctl

+7-3
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,13 @@ elif len(args.values) > 0:
259259
cli.print_msg("Successfully set {} in {}".format(args.prop, config_file))
260260
elif args.unset:
261261
#unset an option
262-
del agent_conf.data[args.prop]
263-
_save_and_validate(agent_conf, config_client, cli)
264-
cli.print_msg("Successfully unset {} in {}".format(args.prop, config_file))
262+
try:
263+
del agent_conf.data[args.prop]
264+
_save_and_validate(agent_conf, config_client, cli)
265+
cli.print_msg("Successfully unset {} in {}".format(args.prop, config_file))
266+
except KeyError:
267+
cli.print_msg("{} was not set in {}. No action performed".format(args.prop, config_file))
268+
265269
else:
266270
# print current value of property
267271
_print_prop(args.prop, agent_conf.data.get(args.prop, None), cli)

psconfig/perfsonar-psconfig/psconfig/base_agent.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def run(self):
146146
check_interval = None
147147

148148
try:
149-
check_interval = duration_to_seconds(agent_conf.check_interval())
149+
check_interval = int(duration_to_seconds(agent_conf.check_interval()))
150150
except Exception as e:
151151
self.logger.error(self.logf.format("Error parsing check-interval. Defaulting to " + str(self.check_interval_seconds) + " seconds: {}".format(e)))
152152
pass

psconfig/perfsonar-psconfig/psconfig/pscheduler/agent.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def _run_start(self, agent_conf):
5757
task_min_ttl_seconds = None
5858

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

psconfig/perfsonar-psconfig/psconfig/utilities/iso8601.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
import isodate
33

44
def duration_to_seconds(iso):
5-
"""Convert an ISO 8601 string to a timdelta and return total seconds"""
5+
"""Convert an ISO 8601 string to a timdelta and return total seconds
6+
Returns float"""
67
try:
78
duration = isodate.parse_duration(iso)
89
except isodate.isoerror.ISO8601Error:

0 commit comments

Comments
 (0)