catch control-c action.
This commit is contained in:
parent
9d62d3fb6a
commit
9ed9c4d0f2
@ -50,6 +50,8 @@ def main() -> None:
|
||||
except MDRSException as e:
|
||||
print(f"Error: {e}")
|
||||
sys.exit(2)
|
||||
except KeyboardInterrupt:
|
||||
sys.exit(130)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -6,6 +6,7 @@ import validators
|
||||
|
||||
from mdrsclient.exceptions import IllegalArgumentException
|
||||
from mdrsclient.settings import CONFIG_DIRNAME
|
||||
from mdrsclient.utils import FileLock
|
||||
|
||||
|
||||
class ConfigFile:
|
||||
@ -70,7 +71,9 @@ class ConfigFile:
|
||||
def __save(self) -> None:
|
||||
self.__ensure_cache_dir()
|
||||
with open(self.__config_path, "w") as f:
|
||||
FileLock.lock(f)
|
||||
self.__config.write(f)
|
||||
FileLock.unlock(f)
|
||||
os.chmod(self.__config_path, 0o600)
|
||||
|
||||
def __ensure_cache_dir(self) -> None:
|
||||
|
@ -3,7 +3,6 @@ from typing import IO, Any
|
||||
|
||||
if os.name == "nt":
|
||||
import msvcrt
|
||||
|
||||
elif os.name == "posix":
|
||||
import fcntl
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user