Quantcast
Channel: configuration - Forum - FlexGet
Viewing all articles
Browse latest Browse all 716

How to pass variables into the config from a script or a user

$
0
0

@user1215 wrote:

Is there a more efficient way to do what I am doing? Currently I'm taking user-input from python and editing the variables.yml file, as explained below.

In my config.yml, I have templates for each item (item1, item2,..., item70), as well as two other settings templates called manual_import_settings and auto_import_settings. Input is taken from the user for both the method variable (which can be "move" or "copy") and the type variable (which can be auto_import_files or manual_import_files).

Upon user intervention, the python script loads variables.yml and replaces the value for method or type with the user input, then saves the new variables.yml file. Then the command flexget --execute --tasks import_* is run from the python script. I'd prefer not to have the script opening and editing the variables file, if it can be avoided. Is there a better way to achieve these four possible tasks (without opening and editing the variables file and also without creating 3 additional tasks for each item I have)?

variables.yml........................................
  import:
    method: move
    type: auto_import_files
.....................................................

.
.
.

config.yml...........................................
  tasks:
    import_item1:
      template: [item1, '{? import.type ?}']
      '{? import.method ?}':
        to: '{? dirs.main_path ?}{? vars.item1.dir ?}/'
        rename: '{{ jinja_stuff_here }}{{ filename | pathext}}'
    import_item2:
      template: [item2, '{? import.type ?}']
        '{? import.method ?}':
          to: '{? dirs.main_path ?}{? vars.item2.dir ?}/'
          rename: '{{ jinja_stuff_here }}{{ filename | pathext}}

.....................................................

ADDITIONAL INFO:
The scheduler is set to run all import_* tasks regularly. When it does, it uses the default values for type and method that are stored in the variables.yml file. The default variable for type is auto_import_files and the default variable for method is determined by the user only once.

When the command to execute the flexget --execute --tasks import_* is called manually by the user through the python script, type is changed to manual_import_files and method might stay the same or might change. After the command is finished. The python script, again, opens the variables.yml file and restores the original defaults.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 716

Trending Articles