Skip to content

Commit

Permalink
fix #195 add maxClientRetries config directive
Browse files Browse the repository at this point in the history
Honestly, why didn't I think to do this 2 hours ago when I added the
cmdline option. Sigh.
  • Loading branch information
ryran committed May 31, 2018
1 parent 54fef24 commit aa0a364
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
6 changes: 6 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@

#unableToLoginMsg: Ohmg contact bob at the helpdesk!

######
## If present, *maxClientRetries* is passed to RavelloClient(). See --retries in
## help page for full explanation.

#maxClientRetries: 3

######
## If present, *sshKeyFile* is integrated into the ssh command reported to the
## user by ravshello's query_app_status command.
Expand Down
5 changes: 3 additions & 2 deletions modules/cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@
prog = 'ravshello'

# Version info
__version__ = '1.36.0'
__date__ = '2018/05/30'
__version__ = '1.36.1'
__date__ = '2018/05/31'
version = "{} v{} last mod {}".format(prog, __version__, __date__)

# Defaults
defaultUserCfgDir = '~/.ravshello'
defaultUserCfgFile = 'config.yaml'
defaultAppExpireTime = 120
defaultAppExtendTime = 60
defaultMaxClientRetries = 3

# Some learner mode rules
maxLearnerPublishedApps = 3
Expand Down
19 changes: 16 additions & 3 deletions ravshello.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,12 @@ def main():
"and set exit code '5' (note that using this will override an "
"explicit 'neverPromptCreds=false' setting from a config file)"))
grpU.add_argument(
'-r', '--retries', dest='maxClientRetries', metavar='NUM', type=int, default=3,
help=("Raise/lower the http retries setting (default: 3) of ravello_sdk's "
'-r', '--retries', dest='maxClientRetries', metavar='NUM', type=int,
help=("Raise/lower the http retries setting (default: {}) of ravello_sdk's "
"RavelloClient() object, which has retry logic for when a request "
"returns http status 401/429, times out, or raises ValueError"))
"returns http status 401/429, times out, or raises ValueError "
"(note that using this will override an explicit 'maxClientRetries' "
"setting from a config file)".format(cfg.defaultMaxClientRetries)))
grpU.add_argument(
'-n', '--nocolor', dest='enableColor', action='store_false',
help="Disable all color terminal enhancements")
Expand Down Expand Up @@ -294,6 +296,17 @@ def main():
print(c.yellow(
"Error: Ignoring configFile `neverPromptCreds` directive because it's not a boolean\n"
" See /usr/share/{}/config.yaml for example".format(cfg.prog)), file=stderr)
# Validate maxClientRetries
maxClientRetries = cfg.cfgFile.get('maxClientRetries', cfg.defaultMaxClientRetries)
if rOpt.maxClientRetries is None:
if isinstance(maxClientRetries, int) and maxClientRetries >= 0:
rOpt.maxClientRetries = maxClientRetries
else:
rOpt.maxClientRetries = cfg.defaultMaxClientRetries
print(c.yellow(
"Error: Ignoring configFile `maxClientRetries` directive because it's not an int\n"
" (Using default value: {})\n"
" See /usr/share/{}/config.yaml for example".format(cfg.defaultMaxClientRetries, cfg.prog)), file=stderr)

# Set sshKeyFile var to none if missing
cfg.cfgFile['sshKeyFile'] = cfg.cfgFile.get('sshKeyFile', None)
Expand Down

0 comments on commit aa0a364

Please sign in to comment.