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

check conditions for .signac_shell_history permission. #279

Merged
merged 14 commits into from
Feb 19, 2020
18 changes: 13 additions & 5 deletions signac/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1052,11 +1052,19 @@ def jobs():
try:
csadorf marked this conversation as resolved.
Show resolved Hide resolved
readline.read_history_file(fn_hist)
readline.set_history_length(1000)
except (IOError, OSError) as error:
if error.errno != errno.ENOENT:
raise
atexit.register(readline.write_history_file, fn_hist)

except FileNotFoundError:
pass
except PermissionError:
print("Warning: Shell history could not be read from "
"{}.".format(os.path.relpath(fn_hist)))

def write_history_file():
try:
readline.write_history_file(fn_hist)
except PermissionError:
print("Warning: Shell history could not be written to "
"{}.".format(os.path.relpath(fn_hist)))
atexit.register(write_history_file)
readline.set_completer(Completer(local_ns).complete)
readline.parse_and_bind('tab: complete')
code.interact(
Expand Down