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

Fix json.decoder.JSONDecodeError if index file was broken #60

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions mech/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ def instances():
except Timeout:
puts_err(colored.red(textwrap.fill("Couldn't access index, it seems locked.")))
sys.exit(1)
except json.decoder.JSONDecodeError:
puts_err(colored.red(textwrap.fill("Index file seems broken. Try to remove {}.".format(index_path))))
sys.exit(1)


def settle_instance(instance_name, obj=None, force=False):
Expand Down Expand Up @@ -222,6 +225,9 @@ def settle_instance(instance_name, obj=None, force=False):
except Timeout:
puts_err(colored.red(textwrap.fill("Couldn't access index, it seems locked.")))
sys.exit(1)
except json.decoder.JSONDecodeError:
puts_err(colored.red(textwrap.fill("Index file seems broken. Try to remove {}.".format(index_path))))
sys.exit(1)


def load_mechfile(pwd):
Expand Down