PaperPi
PaperPi copied to clipboard
menu-driven command line interface for configuring
Is your feature request related to a problem? Please describe. Add a command line interface for adding, removing and configuring plugins. Use the same interface to configure the main section of the config as well.
Describe the solution you'd like Add a function that can help users configure plugins by displaying fields, descriptions and checking for reasonable values. The interface should also reveal the user-facing helper functions that some plugins have (e.g. LMS search, lat/lon lookup). This should be a menu driven interface with yes/no questions, prompts for input.
Describe alternatives you've considered The JSON config file that will be rolled out in 0.6 is terrible to edit by hand
Update documentation for plugin configuration
- [ ] Plugin documentation needs to be updated to indicate how to add/enable/disable plugins
Build menu driven interface for configuring JSON configuration
- [ ] add method for configuring display
- [ ] add method for (re)configuring plugins
- [x] add function for returning user facing functions easily that provides: method_name, description, params :[param1 name, type, description...] - see
library.get_help
- [ ] need a method for deleting plugin configurations that are no longer needed; it is only possible to disable them at this time
Connect menu driven interface to PaperPi from command line
- [ ] add command line switch to launch configuration
- [ ] add option to edit user or system version
- [ ] remind user of backups
see also #123 #130
rewrite user facing functions to have defined key-word args and also accept args and kwargs.
def get_coord(place=None, *args, **kwargs):
'''USER FACING HELPER FUNCTION:
lookup and print the latitude, longitude of a place given as a string:
usage: --run_plugin_func met_no.get_coord "Horsetooth Reservoir, Fort Collins CO, USA"
Args:
place(`str`): "City, Provence, Country
Returns:
`tuple`: lat, lon
Example:
get_coord("Denver, Colorado, USA")
get_coord("Bamako, Mali")
%U'''
# if args:
# place = args[0]
# elif 'place' in kwargs:
# place = kwargs['place']
# else:
# place = None
....
return (lat, lon)
weird crash when running from command line:
Traceback (most recent call last):
File "/home/pi/src/PaperPi/paperpi/./paperpi.py", line 482, in <module>
exit_code = main()
^^^^^^
File "/home/pi/src/PaperPi/paperpi/./paperpi.py", line 365, in main
interactive_config.interactive_config(config, backup_notify=True)
File "/home/pi/src/PaperPi/paperpi/interactive_config.py", line 800, in interactive_config
function(**kwargs)
File "/home/pi/src/PaperPi/paperpi/interactive_config.py", line 658, in plugin_configuration
configured_plugin, plugin_index = _configure_plugin(config_json, plugin_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pi/src/PaperPi/paperpi/interactive_config.py", line 533, in _configure_plugin
module_json, config_index = _find_plugin_config(config_json, plugin_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pi/src/PaperPi/paperpi/interactive_config.py", line 345, in _find_plugin_config
if plugin_name in plugin.get('plugin', {}).get('value', ''):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'get'
This does not appear to happen when running in Jupyter.
Steps to reproduce:
-
paperpi.py -i
- option (1) Configure Plugins
- configure a plugin? y
- (8) moon phase
- Run helper function? y
- (2) list_country_locales
- NL
- run one of the helper functions? n
- CRASH