efs-cli 1.2.1__tar.gz → 1.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {efs_cli-1.2.1/src/efs_cli.egg-info → efs_cli-1.2.2}/PKG-INFO +1 -1
- efs_cli-1.2.2/src/efs_cli/__init__.py +2 -0
- {efs_cli-1.2.1 → efs_cli-1.2.2}/src/efs_cli/cli.py +20 -14
- {efs_cli-1.2.1 → efs_cli-1.2.2/src/efs_cli.egg-info}/PKG-INFO +1 -1
- efs_cli-1.2.1/src/efs_cli/__init__.py +0 -2
- {efs_cli-1.2.1 → efs_cli-1.2.2}/LICENSE +0 -0
- {efs_cli-1.2.1 → efs_cli-1.2.2}/README.md +0 -0
- {efs_cli-1.2.1 → efs_cli-1.2.2}/pyproject.toml +0 -0
- {efs_cli-1.2.1 → efs_cli-1.2.2}/setup.cfg +0 -0
- {efs_cli-1.2.1 → efs_cli-1.2.2}/src/efs_cli.egg-info/SOURCES.txt +0 -0
- {efs_cli-1.2.1 → efs_cli-1.2.2}/src/efs_cli.egg-info/dependency_links.txt +0 -0
- {efs_cli-1.2.1 → efs_cli-1.2.2}/src/efs_cli.egg-info/entry_points.txt +0 -0
- {efs_cli-1.2.1 → efs_cli-1.2.2}/src/efs_cli.egg-info/requires.txt +0 -0
- {efs_cli-1.2.1 → efs_cli-1.2.2}/src/efs_cli.egg-info/top_level.txt +0 -0
|
@@ -12,6 +12,8 @@ CONFIG_PATH = os.path.expanduser("~/.efs-cli_config.json")
|
|
|
12
12
|
if os.path.exists(os.path.expanduser("~/.config/")):
|
|
13
13
|
CONFIG_PATH = os.path.expanduser("~/.config/efs-cli.json")
|
|
14
14
|
|
|
15
|
+
DEFAULT_EDITOR = "/usr/bin/nano"
|
|
16
|
+
|
|
15
17
|
def exception_handler(func):
|
|
16
18
|
def wrapper(*args, **kwargs):
|
|
17
19
|
try:
|
|
@@ -36,9 +38,13 @@ def get_conf():
|
|
|
36
38
|
conf = json.load(file)
|
|
37
39
|
|
|
38
40
|
if conf:
|
|
39
|
-
editor = conf.get("editor",
|
|
40
|
-
if
|
|
41
|
-
print("
|
|
41
|
+
editor = conf.get("editor", DEFAULT_EDITOR)
|
|
42
|
+
if not os.path.exists(editor.split(" ")[0]):
|
|
43
|
+
print("editor path does not exist")
|
|
44
|
+
print(f"using default editor, {DEFAULT_EDITOR}")
|
|
45
|
+
conf.update({"editor": DEFAULT_EDITOR})
|
|
46
|
+
if "sudo" in editor or "rm" in editor:
|
|
47
|
+
print("no 'sudo' or 'rm' allowed in editor path")
|
|
42
48
|
sys.exit(1)
|
|
43
49
|
|
|
44
50
|
return conf
|
|
@@ -64,23 +70,23 @@ def config(reset, **__):
|
|
|
64
70
|
conf = get_conf()
|
|
65
71
|
if conf is None or reset:
|
|
66
72
|
with open(CONFIG_PATH, "w") as file:
|
|
67
|
-
json.dump({"base_url": None, "password": None, "custom_api_path": "/api/v1", "editor":
|
|
73
|
+
json.dump({"base_url": None, "password": None, "custom_api_path": "/api/v1", "editor": DEFAULT_EDITOR}, file)
|
|
68
74
|
if reset:
|
|
69
75
|
print("Config reset")
|
|
70
76
|
sys.exit(0)
|
|
71
|
-
editor = conf.get("editor",
|
|
77
|
+
editor = conf.get("editor", DEFAULT_EDITOR)
|
|
72
78
|
|
|
73
79
|
status = os.system(f"{editor} {CONFIG_PATH}")
|
|
74
80
|
if status:
|
|
75
|
-
print("using default editor:
|
|
76
|
-
os.system(f"
|
|
81
|
+
print(f"using default editor: {DEFAULT_EDITOR}")
|
|
82
|
+
os.system(f"{DEFAULT_EDITOR} {CONFIG_PATH}")
|
|
77
83
|
print("Config saved successfully")
|
|
78
84
|
|
|
79
85
|
@exception_handler
|
|
80
86
|
def efs_config(verbose, **__):
|
|
81
87
|
conf = get_conf()
|
|
82
88
|
api = init_api()
|
|
83
|
-
editor = conf.get("editor",
|
|
89
|
+
editor = conf.get("editor", DEFAULT_EDITOR)
|
|
84
90
|
if not hasattr(api, "get_config"):
|
|
85
91
|
print("Login using 'efs-cli auth <base url> <root_password>' to get and change the config")
|
|
86
92
|
sys.exit(1)
|
|
@@ -90,8 +96,8 @@ def efs_config(verbose, **__):
|
|
|
90
96
|
tmp.seek(0)
|
|
91
97
|
status = os.system(f"{editor} {tmp.name}")
|
|
92
98
|
if status:
|
|
93
|
-
print("using default editor:
|
|
94
|
-
os.system(f"
|
|
99
|
+
print(f"using default editor: {DEFAULT_EDITOR}")
|
|
100
|
+
os.system(f"{DEFAULT_EDITOR} {tmp.name}")
|
|
95
101
|
api.update_config(json.load(tmp), _print_warnings = verbose)
|
|
96
102
|
print("Config saved successfully")
|
|
97
103
|
|
|
@@ -105,7 +111,7 @@ def auth(base_url, password, custom_api_path, **__):
|
|
|
105
111
|
if base_url.endswith("/"):
|
|
106
112
|
base_url = base_url[:-1]
|
|
107
113
|
|
|
108
|
-
data = {"base_url": base_url, "password": password, "custom_api_path": custom_api_path, "editor":
|
|
114
|
+
data = {"base_url": base_url, "password": password, "custom_api_path": custom_api_path, "editor": DEFAULT_EDITOR}
|
|
109
115
|
|
|
110
116
|
if conf is not None:
|
|
111
117
|
conf.update(data)
|
|
@@ -147,7 +153,7 @@ def read(file_path, no_less, **__):
|
|
|
147
153
|
def edit(file_path, **__):
|
|
148
154
|
api = init_api()
|
|
149
155
|
conf = get_conf()
|
|
150
|
-
editor = conf.get("editor",
|
|
156
|
+
editor = conf.get("editor", DEFAULT_EDITOR)
|
|
151
157
|
if not hasattr(api, "overwrite_file"):
|
|
152
158
|
print("Login using 'efs-cli auth <base url> <password>' to overwrite files")
|
|
153
159
|
sys.exit(1)
|
|
@@ -158,8 +164,8 @@ def edit(file_path, **__):
|
|
|
158
164
|
tmp.seek(0)
|
|
159
165
|
status = os.system(f"{editor} {tmp.name}")
|
|
160
166
|
if status:
|
|
161
|
-
print("using default editor:
|
|
162
|
-
os.system(f"
|
|
167
|
+
print(f"using default editor: {DEFAULT_EDITOR}")
|
|
168
|
+
os.system(f"{DEFAULT_EDITOR} {tmp.name}")
|
|
163
169
|
api.overwrite_file(file_path, tmp)
|
|
164
170
|
print(f"{file_path} overwritten")
|
|
165
171
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|