OrkoHunter / keep

A Meta CLI toolkit : Personal shell command keeper and snippets manager
MIT License
599 stars 54 forks source link

Errors after updating keep from v2.4.2 to v2.6.1 #50

Closed krzysztof-wolowski closed 4 years ago

krzysztof-wolowski commented 5 years ago
File "/home/kris/.local/lib/python2.7/site-packages/keep/utils.py", line 72, in list_commands
    table_data.append(['$ ' + cmd, fields['desc'], fields['alias']])
TypeError: string indices must be integers

I was getting the above error when trying to run any keep command. Rolled back to v.2.4.2.

OrkoHunter commented 5 years ago

Hi @kriswolo ! Thank you for raising the issue. The problem is raised because the new version of keep uses a different schema for ~/.keep/commands.json. Unfortunately, no migration script has been shipped out with the latest version, hence the errors are being raised. (This is a technical error from my side, which I can not solve due to unavailability of time.) :(

The fix is as below:

# Use Python3

import os
import json

home_dir = os.path.expanduser("~")

with open(home_dir + "/.keep/commands.json", "r") as f:
    old_commands = json.load(f)

new_commands = {}

for key, value in old_commands.items():
    new_commands[key] = {
        "desc": value,
        "alias": ""
    }

print(new_commands)

Please put the new_commands inside your ~/.keep/commands.json and the new version will be good to go. Also please use pip3 to install keep. :)

Thank you! Let me know if the problem persists.

jcdevil commented 5 years ago

Thx @OrkoHunter : worked fine for me !