Skip to content

fix cli templates error#3377

Closed
Spider84 wants to merge 1 commit intoFlexget:developfrom
Spider84:fix_cli_templates_error
Closed

fix cli templates error#3377
Spider84 wants to merge 1 commit intoFlexget:developfrom
Spider84:fix_cli_templates_error

Conversation

@Spider84
Copy link
Copy Markdown
Contributor

@Spider84 Spider84 commented Mar 6, 2022

Traceback (most recent call last):
File "/usr/local/bin/flexget", line 8, in
sys.exit(main())
File "/usr/local/lib/python3.9/dist-packages/flexget/init.py", line 44, in main
manager.start()
File "/usr/local/lib/python3.9/dist-packages/flexget/manager.py", line 383, in start
self.handle_cli()
File "/usr/local/lib/python3.9/dist-packages/flexget/manager.py", line 412, in handle_cli
options.cli_command_callback(self, command_options)
File "/usr/local/lib/python3.9/dist-packages/flexget/plugins/cli/templates.py", line 31, in list_file_templates
table.add_row(name, plugin, template.filename, '')
File "/usr/local/lib/python3.9/dist-packages/rich/table.py", line 423, in add_row
raise errors.NotRenderableError(
rich.errors.NotRenderableError: unable to render list; a string or other renderable object is required

Traceback (most recent call last):
  File "/usr/local/bin/flexget", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/dist-packages/flexget/__init__.py", line 44, in main
    manager.start()
  File "/usr/local/lib/python3.9/dist-packages/flexget/manager.py", line 383, in start
    self.handle_cli()
  File "/usr/local/lib/python3.9/dist-packages/flexget/manager.py", line 412, in handle_cli
    options.cli_command_callback(self, command_options)
  File "/usr/local/lib/python3.9/dist-packages/flexget/plugins/cli/templates.py", line 31, in list_file_templates
    table.add_row(name, plugin, template.filename, '')
  File "/usr/local/lib/python3.9/dist-packages/rich/table.py", line 423, in add_row
    raise errors.NotRenderableError(
rich.errors.NotRenderableError: unable to render list; a string or other renderable object is required
@@ -19,8 +19,11 @@ def list_file_templates(manager, options):
else:
plugin = '-'
name = template_name.replace('.template', '').split('/')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can just go with this change, and skip all the rest. The result of a str.split is always a list, so no need to check that, and there will always be at least one part, because all the templates will have a name.

Suggested change
name = template_name.replace('.template', '').split('/')
name = template_name.replace('.template', '').split('/')[-1]

name = template_name.replace('.template', '').split('/')
if len(name) == 2:
name = name[1]
if type(name) == list:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using instanceof to check type is preferable

@gazpachoking
Copy link
Copy Markdown
Member

Thanks for the report and PR! Went with a slightly simpler fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants