Skip to content
This repository was archived by the owner on Oct 1, 2025. It is now read-only.
Open
Show file tree
Hide file tree
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
8 changes: 6 additions & 2 deletions command_callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1743,10 +1743,14 @@ def savestate_filename(input_dict, environment_dict):
input_dict = input_dict[command_key]['children']
command_key = input_dict.keys()[0]


if not environment_dict['currentkeyname']:
raise seash_exceptions.UserError("Specify the key name by first typing 'as [username]'.")

# expand ~
fileandpath = os.path.expanduser(command_key)


if not os.access(fileandpath, os.W_OK):
raise seash_exceptions.UserError("Permission denied: " + fileandpath)
try:
seash_helper.savestate(fileandpath, environment_dict['handleinfo'],
environment_dict['host'], environment_dict['port'],
Expand Down
20 changes: 20 additions & 0 deletions tests/ut_seash_savestate_nicermessageone.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""
This unit test is to test error messages when using savestate before
having loaded at least a pubkey, and work as that identity.
"""

import seash
import sys
import os
import seash_exceptions

#pragma out Specify the key name by first typing 'as [username]'.

command_list = [
'savestate NO_KEYS_LOADED',
]

try:
seash.command_loop(command_list)
except seash_exceptions.UserError, e:
print str(e)
27 changes: 27 additions & 0 deletions tests/ut_seash_savestate_nicermessagetwo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""
This unit test is to test error messages when using savestate to
a write-protected file.
"""

import seash
import sys
import os
import seash_exceptions

#pragma out Permission denied: write_protected_file

open('write_protected_file', 'w+').close()
os.chmod('write_protected_file', 0444)

command_list = [
'loadkeys guest0',
'as guest0',
'savestate write_protected_file',
]

try:
seash.command_loop(command_list)
except seash_exceptions.UserError, e:
print str(e)

os.remove('write_protected_file')