8000 db_migrator script does not support non-default config locations · Issue #2566 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

db_migrator script does not support non-default config locations #2566

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

Closed
chennin opened this issue Jul 19, 2016 · 2 comments · Fixed by #2570
Closed

db_migrator script does not support non-default config locations #2566

chennin opened this issue Jul 19, 2016 · 2 comments · Fixed by #2570

Comments

@chennin
Copy link
Contributor
chennin commented Jul 19, 2016

Home Assistant release (hass --version): First seen in 0.24.0 and mentioned in gitter; still here as I work in 0.25.0.dev0

Python release (python3 --version): Python 3.4.3

Component/platform: db_migrator

Description of problem:

(venv) hassdev@t:~/home-assistant$ hass --script db_migrator --config /home/hassdev/haconfig
Fatal Error: Old format database '/home/hassdev/.homeassistant/home-assistant.db' does not exist

Although I tell the script to look in /home/hassdev/haconfig/, it looks for the database in /home/hassdev/.homeassistant/ (the default). For testing, the default config dir does not exist and the db does exist in the given location:

(venv) hassdev@t:~/home-assistant$ ls -ld ~/.homeassistant
ls: cannot access /home/hassdev/.homeassistant: No such file or directory
(venv) hassdev@t:~/home-assistant$ ls -l ~/haconfig/home-assistant.db 
-rw-r--r-- 1 hassdev hassdev 712704 Jun 28 16:36 /home/hassdev/haconfig/home-assistant.db

Expected:
db_migrator finds the db in the given directory.

Additional info:

Here is db_migrator.py line 80-87:

# Test if configuration directory exists
if not os.path.isdir(config_dir):
    if config_dir != config_util.get_default_config_dir():
        print(('Fatal Error: Specified configuration directory does '
               'not exist {} ').format(config_dir))
        return 1
else:
    config_dir = config_util.get_default_config_dir()

Which if I understand right, will set the place to look for the db (config_dir) back to the default, if the config_dir passed to it DOES exist. I don't understand the reason for the else block. I can submit a PR removing the else block, or otherwise fixing this, if the author could please clarify the intent of this block.

@balloob
Copy link
Member
balloob commented Jul 20, 2016

hmm that is weird, looks like you're right. Care to submit a PR ?

n8henrie added a commit to n8henrie/home-assistant that referenced this issue Jul 20, 2016
Closes home-assistant#2566

The `else` seems to have been an error and was overwriting a non-default config directory with the default location.
@n8henrie
Copy link
Contributor
n8henrie commented Jul 20, 2016

Thanks to @AlucardZero for pointing out the issue. Simply removing the else seems to have things back in order with a non-default config directory.

balloob pushed a commit that referenced this issue Jul 20, 2016
Closes #2566

The `else` seems to have been an error and was overwriting a non-default config directory with the default location.
balloob pushed a commit that referenced this issue Jul 21, 2016
Closes #2566

The `else` seems to have been an error and was overwriting a non-default config directory with the default location.
@home-assistant home-assistant locked and limited conversation to collaborators Mar 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
0