ZAdamMac / Tapestry

Specialist Batch File Backup Tool
GNU General Public License v3.0
3 stars 1 forks source link

Inappropriate handling of absent config file #25

Closed ZAdamMac closed 3 years ago

ZAdamMac commented 3 years ago

Describe the bug Tapestry does not currently correctly handle instances where it is invoked without a config file available.

To Reproduce Steps to reproduce the behavior:

  1. Navigate to a directory with no local copy of tapestry.cfg
  2. Run tapestry without specifying a config file, ie python3 -m tapestry
  3. See output below

Expected behavior This should simply exit after the issue is raised rather than attempting to proceed, which is what is causing the error listed below.

Log/Console Output Where possible, add the output of the Logs or Console when the problem occurs.

patches@sevastopol:~/Downloads$ python3 -m tapestry
The indicated config file: tapestry.cfg cannot be found.
Generating a template config file in that location.
Please edit this config file appropriately and rerun the program.
Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/patches/.local/lib/python3.8/site-packages/tapestry/__main__.py", line 13, in <module>
    tapestry.runtime()
  File "/home/patches/.local/lib/python3.8/site-packages/tapestry/functions.py", line 1192, in runtime
    state = parse_config(state)
  File "/home/patches/.local/lib/python3.8/site-packages/tapestry/functions.py", line 858, in parse_config
    place_config_template(ns.config_path)
  File "/home/patches/.local/lib/python3.8/site-packages/tapestry/functions.py", line 985, in place_config_template
    config.set(section, option, value)
  File "/usr/lib/python3.8/configparser.py", line 1200, in set
    self._validate_value_types(option=option, value=value)
  File "/usr/lib/python3.8/configparser.py", line 1185, in _validate_value_types
    raise TypeError("option values must be strings")
TypeError: option values must be strings

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

ZAdamMac commented 3 years ago

Upon further review it also appears that the .cfg file is also not being placed as would otherwise be expected. This is a critical bug that will prevent adoption in new users and can be limiting to (e.g.) recovering users hwho cannot access their old .cfg file.

ZAdamMac commented 3 years ago

This is down to the structure of the "default configuration" dictionary which is used to generate this configuration file. Commit 7284540 includes the relevant code change. Bug will stay open until the 2.1.1 release.

ZAdamMac commented 3 years ago

2.1.1 release is complete. Issue is resolved.