Merge pull request #51 from jeromelebleu/dev

Split words with '-' in action name
This commit is contained in:
Alexis Gavoty 2013-12-14 09:44:49 -08:00
commit 9333de164c
4 changed files with 16 additions and 16 deletions

View file

@ -546,9 +546,9 @@ monitor:
action: store_true action: store_true
### monitor_updatestats() ### monitor_updatestats()
updatestats: update-stats:
action_help: Update monitored statistics action_help: Update monitoring statistics
api: POST /monitor/updatestats api: POST /monitor/update-stats
arguments: arguments:
period: period:
help: Time period to update help: Time period to update
@ -558,9 +558,9 @@ monitor:
- month - month
### monitor_showstats() ### monitor_showstats()
showstats: show-stats:
action_help: Show monitored statistics action_help: Show monitoring statistics
api: GET /monitor/showstats api: GET /monitor/show-stats
arguments: arguments:
period: period:
help: Time period to show help: Time period to show

View file

@ -490,7 +490,7 @@ def parse_dict(action_map):
# Set the action s related function # Set the action s related function
parsers[category + '_' + action].set_defaults( parsers[category + '_' + action].set_defaults(
func=str_to_func('yunohost_' + category + '.' func=str_to_func('yunohost_' + category + '.'
+ category + '_' + action)) + category + '_' + action.replace('-', '_')))
# Add arguments # Add arguments
if 'arguments' in action_params: if 'arguments' in action_params:
for arg_name, arg_params in action_params['arguments'].items(): for arg_name, arg_params in action_params['arguments'].items():

View file

@ -244,7 +244,7 @@ def main():
api.register(method, path, http_exec) api.register(method, path, http_exec)
api.register('OPTIONS', path, http_exec) api.register('OPTIONS', path, http_exec)
action_dict[action_params['api']] = { action_dict[action_params['api']] = {
'function': 'yunohost_'+ category +'.'+ category +'_'+ action, 'function': 'yunohost_'+ category +'.'+ category +'_'+ action.replace('-', '_'),
'help' : action_params['action_help'] 'help' : action_params['action_help']
} }
if 'arguments' in action_params: if 'arguments' in action_params:

View file

@ -234,9 +234,9 @@ def monitor_system(units=None, human_readable=False):
return result return result
def monitor_updatestats(period): def monitor_update_stats(period):
""" """
Update monitored statistics Update monitoring statistics
Keyword argument: Keyword argument:
period -- Time period to update (day, week, month) period -- Time period to update (day, week, month)
@ -250,7 +250,7 @@ def monitor_updatestats(period):
stats = { 'disk': {}, 'network': {}, 'system': {}, 'timestamp': [] } stats = { 'disk': {}, 'network': {}, 'system': {}, 'timestamp': [] }
monitor = None monitor = None
# Get monitored stats # Get monitoring stats
if period == 'day': if period == 'day':
monitor = _monitor_all('day') monitor = _monitor_all('day')
else: else:
@ -261,7 +261,7 @@ def monitor_updatestats(period):
else: else:
monitor = _monitor_all(p, 0) monitor = _monitor_all(p, 0)
if not monitor: if not monitor:
raise YunoHostError(1, _("No monitored statistics to update")) raise YunoHostError(1, _("No monitoring statistics to update"))
stats['timestamp'].append(time.time()) stats['timestamp'].append(time.time())
@ -317,9 +317,9 @@ def monitor_updatestats(period):
_save_stats(stats, period) _save_stats(stats, period)
def monitor_showstats(period, date=None): def monitor_show_stats(period, date=None):
""" """
Show monitored statistics Show monitoring statistics
Keyword argument: Keyword argument:
period -- Time period to show (day, week, month) period -- Time period to show (day, week, month)
@ -573,11 +573,11 @@ def _calculate_stats_mean(stats):
def _append_to_stats(stats, monitor, statics=[]): def _append_to_stats(stats, monitor, statics=[]):
""" """
Append monitored statistics to current statistics Append monitoring statistics to current statistics
Keyword argument: Keyword argument:
stats -- Current stats dict stats -- Current stats dict
monitor -- Monitored statistics monitor -- Monitoring statistics
statics -- List of stats static keys statics -- List of stats static keys
""" """