Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

menu-driven command line interface for configuring #139

Open
txoof opened this issue Sep 18, 2023 · 3 comments
Open

menu-driven command line interface for configuring #139

txoof opened this issue Sep 18, 2023 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@txoof
Copy link
Owner

txoof commented Sep 18, 2023

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

@txoof txoof added the enhancement New feature or request label Sep 18, 2023
@txoof txoof added this to the Web Configurator milestone Sep 23, 2023
@txoof
Copy link
Owner Author

txoof commented Sep 23, 2023

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
  • 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

@txoof txoof self-assigned this Sep 23, 2023
@txoof
Copy link
Owner Author

txoof commented Sep 24, 2023

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)

@txoof
Copy link
Owner Author

txoof commented Nov 26, 2023

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:

  1. paperpi.py -i
  2. option (1) Configure Plugins
  3. configure a plugin? y
  4. (8) moon phase
  5. Run helper function? y
  6. (2) list_country_locales
  7. NL
  8. run one of the helper functions? n
  9. CRASH

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: In Progress
Development

No branches or pull requests

1 participant