when_not,
)
import charms.sshproxy
+import os
@when('sshproxy.configured')
@when('actions.touch')
def touch():
+ if not in_action_context():
+ clear_flag('actions.touch')
+ return
+
err = ''
try:
filename = action_get('filename')
cmd = ['touch {}'.format(filename)]
result, err = charms.sshproxy._run(cmd)
- except:
+ except Exception:
action_fail('command failed:' + err)
else:
action_set({'output': result})
finally:
clear_flag('actions.touch')
+
+
+def in_action_context():
+ """Determine whether we're running on an action context."""
+ return 'JUJU_ACTION_UUID' in os.environ