efs-cli 1.2.1__tar.gz → 1.2.3__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.3}/PKG-INFO +1 -1
- efs_cli-1.2.3/src/efs_cli/__init__.py +2 -0
- {efs_cli-1.2.1 → efs_cli-1.2.3}/src/efs_cli/cli.py +22 -15
- {efs_cli-1.2.1 → efs_cli-1.2.3/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.3}/LICENSE +0 -0
- {efs_cli-1.2.1 → efs_cli-1.2.3}/README.md +0 -0
- {efs_cli-1.2.1 → efs_cli-1.2.3}/pyproject.toml +0 -0
- {efs_cli-1.2.1 → efs_cli-1.2.3}/setup.cfg +0 -0
- {efs_cli-1.2.1 → efs_cli-1.2.3}/src/efs_cli.egg-info/SOURCES.txt +0 -0
- {efs_cli-1.2.1 → efs_cli-1.2.3}/src/efs_cli.egg-info/dependency_links.txt +0 -0
- {efs_cli-1.2.1 → efs_cli-1.2.3}/src/efs_cli.egg-info/entry_points.txt +0 -0
- {efs_cli-1.2.1 → efs_cli-1.2.3}/src/efs_cli.egg-info/requires.txt +0 -0
- {efs_cli-1.2.1 → efs_cli-1.2.3}/src/efs_cli.egg-info/top_level.txt +0 -0
|
@@ -2,6 +2,7 @@ from . import __version__ as version
|
|
|
2
2
|
from efs_wrapper import __version__ as wrapper_version
|
|
3
3
|
from efs_wrapper.v1 import EepyFileServer, EepyFileServerPublic, DiskUsageObject
|
|
4
4
|
from argparse import ArgumentParser, Namespace
|
|
5
|
+
from shutil import which
|
|
5
6
|
import os
|
|
6
7
|
import pathlib
|
|
7
8
|
from tempfile import NamedTemporaryFile
|
|
@@ -12,6 +13,8 @@ CONFIG_PATH = os.path.expanduser("~/.efs-cli_config.json")
|
|
|
12
13
|
if os.path.exists(os.path.expanduser("~/.config/")):
|
|
13
14
|
CONFIG_PATH = os.path.expanduser("~/.config/efs-cli.json")
|
|
14
15
|
|
|
16
|
+
DEFAULT_EDITOR = "nano"
|
|
17
|
+
|
|
15
18
|
def exception_handler(func):
|
|
16
19
|
def wrapper(*args, **kwargs):
|
|
17
20
|
try:
|
|
@@ -36,10 +39,14 @@ def get_conf():
|
|
|
36
39
|
conf = json.load(file)
|
|
37
40
|
|
|
38
41
|
if conf:
|
|
39
|
-
editor = conf.get("editor",
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
editor = conf.get("editor", DEFAULT_EDITOR)
|
|
43
|
+
editor = editor.split(" ")[0]
|
|
44
|
+
if which(editor):
|
|
45
|
+
conf.update({"editor": editor})
|
|
46
|
+
else:
|
|
47
|
+
print("editor path does not exist")
|
|
48
|
+
print(f"using default editor, {DEFAULT_EDITOR}")
|
|
49
|
+
conf.update({"editor": DEFAULT_EDITOR})
|
|
43
50
|
|
|
44
51
|
return conf
|
|
45
52
|
|
|
@@ -64,23 +71,23 @@ def config(reset, **__):
|
|
|
64
71
|
conf = get_conf()
|
|
65
72
|
if conf is None or reset:
|
|
66
73
|
with open(CONFIG_PATH, "w") as file:
|
|
67
|
-
json.dump({"base_url": None, "password": None, "custom_api_path": "/api/v1", "editor":
|
|
74
|
+
json.dump({"base_url": None, "password": None, "custom_api_path": "/api/v1", "editor": DEFAULT_EDITOR}, file)
|
|
68
75
|
if reset:
|
|
69
76
|
print("Config reset")
|
|
70
77
|
sys.exit(0)
|
|
71
|
-
editor = conf.get("editor",
|
|
78
|
+
editor = conf.get("editor", DEFAULT_EDITOR)
|
|
72
79
|
|
|
73
80
|
status = os.system(f"{editor} {CONFIG_PATH}")
|
|
74
81
|
if status:
|
|
75
|
-
print("using default editor:
|
|
76
|
-
os.system(f"
|
|
82
|
+
print(f"using default editor: {DEFAULT_EDITOR}")
|
|
83
|
+
os.system(f"{DEFAULT_EDITOR} {CONFIG_PATH}")
|
|
77
84
|
print("Config saved successfully")
|
|
78
85
|
|
|
79
86
|
@exception_handler
|
|
80
87
|
def efs_config(verbose, **__):
|
|
81
88
|
conf = get_conf()
|
|
82
89
|
api = init_api()
|
|
83
|
-
editor = conf.get("editor",
|
|
90
|
+
editor = conf.get("editor", DEFAULT_EDITOR)
|
|
84
91
|
if not hasattr(api, "get_config"):
|
|
85
92
|
print("Login using 'efs-cli auth <base url> <root_password>' to get and change the config")
|
|
86
93
|
sys.exit(1)
|
|
@@ -90,8 +97,8 @@ def efs_config(verbose, **__):
|
|
|
90
97
|
tmp.seek(0)
|
|
91
98
|
status = os.system(f"{editor} {tmp.name}")
|
|
92
99
|
if status:
|
|
93
|
-
print("using default editor:
|
|
94
|
-
os.system(f"
|
|
100
|
+
print(f"using default editor: {DEFAULT_EDITOR}")
|
|
101
|
+
os.system(f"{DEFAULT_EDITOR} {tmp.name}")
|
|
95
102
|
api.update_config(json.load(tmp), _print_warnings = verbose)
|
|
96
103
|
print("Config saved successfully")
|
|
97
104
|
|
|
@@ -105,7 +112,7 @@ def auth(base_url, password, custom_api_path, **__):
|
|
|
105
112
|
if base_url.endswith("/"):
|
|
106
113
|
base_url = base_url[:-1]
|
|
107
114
|
|
|
108
|
-
data = {"base_url": base_url, "password": password, "custom_api_path": custom_api_path, "editor":
|
|
115
|
+
data = {"base_url": base_url, "password": password, "custom_api_path": custom_api_path, "editor": DEFAULT_EDITOR}
|
|
109
116
|
|
|
110
117
|
if conf is not None:
|
|
111
118
|
conf.update(data)
|
|
@@ -147,7 +154,7 @@ def read(file_path, no_less, **__):
|
|
|
147
154
|
def edit(file_path, **__):
|
|
148
155
|
api = init_api()
|
|
149
156
|
conf = get_conf()
|
|
150
|
-
editor = conf.get("editor",
|
|
157
|
+
editor = conf.get("editor", DEFAULT_EDITOR)
|
|
151
158
|
if not hasattr(api, "overwrite_file"):
|
|
152
159
|
print("Login using 'efs-cli auth <base url> <password>' to overwrite files")
|
|
153
160
|
sys.exit(1)
|
|
@@ -158,8 +165,8 @@ def edit(file_path, **__):
|
|
|
158
165
|
tmp.seek(0)
|
|
159
166
|
status = os.system(f"{editor} {tmp.name}")
|
|
160
167
|
if status:
|
|
161
|
-
print("using default editor:
|
|
162
|
-
os.system(f"
|
|
168
|
+
print(f"using default editor: {DEFAULT_EDITOR}")
|
|
169
|
+
os.system(f"{DEFAULT_EDITOR} {tmp.name}")
|
|
163
170
|
api.overwrite_file(file_path, tmp)
|
|
164
171
|
print(f"{file_path} overwritten")
|
|
165
172
|
|
|
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
|