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

KeyError: 'sublime2' when creating a backup #202

Closed
AlexanderProd opened this issue Dec 14, 2018 · 8 comments
Closed

KeyError: 'sublime2' when creating a backup #202

AlexanderProd opened this issue Dec 14, 2018 · 8 comments
Labels
bug Something isn't working

Comments

@AlexanderProd
Copy link
Contributor

AlexanderProd commented Dec 14, 2018

Seems like I'm on a bug hunting streak today, while attempting to create the first backup of my machine I've encountered this error.

Traceback (most recent call last):
  File "/usr/local/bin/shallow-backup", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/shallow_backup/__main__.py", line 129, in cli
    backup_all(dotfiles_path, packages_path, fonts_path, configs_path)
  File "/usr/local/lib/python3.7/site-packages/shallow_backup/backup.py", line 199, in backup_all
    backup_packages(packages_path, skip)
  File "/usr/local/lib/python3.7/site-packages/shallow_backup/backup.py", line 144, in backup_packages
    sublime_2_path = os.path.join(config_paths["sublime2"], "Packages")
KeyError: 'sublime2'

This happened after it backuped Atom.

I don't have sublime2 or another sublime installed on my machine.
I'm using the shallow-backup version that fixes #200 .

Python version: 3.7.1
pip3: 18.1
macOS: 10.14.2

@alichtman
Copy link
Owner

alichtman commented Dec 14, 2018

Hmm. This error should not be possible...

Can you provide your configuration file? (Located at ~/.shallow-backup)

Some important methods to look at when debugging this may be: compatibility.get_paths() and config.get_default_config()

Note: I just wiped my backup and regenerated it using what's currently on master. I didn't get the same error you did, but I want to chase this down. It could definitely be an error in the code, but I'm not sure why it wouldn't occur on my system.

@AlexanderProd
Copy link
Contributor Author

Sure, this is the content of my configuration file.

{
    "backup_path": "~/shallow-backup",
    "dotfiles": [
        ".bashrc",
        ".bash_profile",
        ".gitconfig",
        ".profile",
        ".pypirc",
        ".shallow-backup",
        ".vimrc",
        ".zlogin",
        ".zprofile",
        ".zshrc"
    ],
    "dotfolders": [
        ".ssh",
        ".vim"
    ],
    "default-gitignore": [
        "dotfiles/.ssh",
        "dotfiles/.pypirc"
    ],
    "config_mapping": {
        "/Users/alexanderhoerl/Library/Application Support/Sublime Text 2": "sublime2",
        "/Users/alexanderhoerl/Library/Application Support/Sublime Text 3": "sublime3",
        "/Users/alexanderhoerl/.atom": "atom",
        "/Users/alexanderhoerl/Library/Preferences/com.apple.Terminal.plist": "terminal_plist"
    }
}

I've checked my Application Support directory and I don't have any Sublime text folder there.

@alichtman
Copy link
Owner

alichtman commented Dec 14, 2018

I've checked my Application Support directory and I don't have any Sublime text folder there.

This is alright. I don't have Sublime 2 installed, but I do have Sublime 3. shallow-backup backs up files if they exist, and doesn't back them up if they don't exist. This shouldn't error because you're missing Sublime 2.

@AlexanderProd
Copy link
Contributor Author

Gotcha, seems really strange then why he's trowing an error.

@alichtman
Copy link
Owner

Alright, I'm getting the same error now. I don't know why this didn't happen during any of my testing or the demo...

I can look through the git history to see when this error was introduced, but to solve it, I'm just going to remove the ability to back up a list of installed Sublime [2/3] packages. It's redundant, since I'm backing up the entirety of the Sublime folder in the configs backup.

Changes being pushed to a testing branch for you in a moment.

@alichtman
Copy link
Owner

alichtman commented Dec 14, 2018

https://github.com/alichtman/shallow-backup/tree/key-error-fixes

Note: This is completely untested (and therefore not on master.)

If it fixes this issue for you, lmk and I'll merge it in.

@AlexanderProd

Sidenote: Thanks for the bug reports. It's important that backup software works perfectly. I do a major testing spree every time before I make a new release, and I'm not sure how I missed this. One of my long term goals is to have code coverage on all the critical functions. I'm sitting at about 50% coverage at the moment, and that could definitely be improved.

image

@alichtman alichtman added the bug Something isn't working label Dec 14, 2018
@AlexanderProd
Copy link
Contributor Author

I've just tried it and it works now!

@alichtman
Copy link
Owner

Perfect. I'll merge this in and push a new version to PyPi.

alichtman added a commit that referenced this issue Dec 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants