efs-cli 1.0.6__tar.gz → 1.0.8__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.0.6 → efs_cli-1.0.8}/PKG-INFO +2 -2
- {efs_cli-1.0.6 → efs_cli-1.0.8}/pyproject.toml +2 -2
- efs_cli-1.0.8/src/efs_cli/__init__.py +2 -0
- {efs_cli-1.0.6 → efs_cli-1.0.8}/src/efs_cli/cli.py +67 -6
- {efs_cli-1.0.6 → efs_cli-1.0.8}/src/efs_cli.egg-info/PKG-INFO +2 -2
- efs_cli-1.0.8/src/efs_cli.egg-info/requires.txt +2 -0
- efs_cli-1.0.6/src/efs_cli/__init__.py +0 -2
- efs_cli-1.0.6/src/efs_cli.egg-info/requires.txt +0 -2
- {efs_cli-1.0.6 → efs_cli-1.0.8}/LICENSE +0 -0
- {efs_cli-1.0.6 → efs_cli-1.0.8}/README.md +0 -0
- {efs_cli-1.0.6 → efs_cli-1.0.8}/setup.cfg +0 -0
- {efs_cli-1.0.6 → efs_cli-1.0.8}/src/efs_cli.egg-info/SOURCES.txt +0 -0
- {efs_cli-1.0.6 → efs_cli-1.0.8}/src/efs_cli.egg-info/dependency_links.txt +0 -0
- {efs_cli-1.0.6 → efs_cli-1.0.8}/src/efs_cli.egg-info/entry_points.txt +0 -0
- {efs_cli-1.0.6 → efs_cli-1.0.8}/src/efs_cli.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: efs-cli
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.8
|
|
4
4
|
Summary: EepyFileServer API CLI written in Python
|
|
5
5
|
Author: maxie
|
|
6
6
|
License-Expression: MIT
|
|
@@ -17,7 +17,7 @@ Requires-Python: >=3.10
|
|
|
17
17
|
Description-Content-Type: text/markdown
|
|
18
18
|
License-File: LICENSE
|
|
19
19
|
Requires-Dist: requests>=2.30
|
|
20
|
-
Requires-Dist: efs-wrapper>=1.0.
|
|
20
|
+
Requires-Dist: efs-wrapper>=1.0.5
|
|
21
21
|
Dynamic: license-file
|
|
22
22
|
|
|
23
23
|
# efs-cli (formerly eepyfileserver-cli)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
[build-system]
|
|
2
|
-
requires = ["setuptools >= 77.0.3", "requests >= 2.30", "efs-wrapper >= 1.0.
|
|
2
|
+
requires = ["setuptools >= 77.0.3", "requests >= 2.30", "efs-wrapper >= 1.0.5"]
|
|
3
3
|
build-backend = "setuptools.build_meta"
|
|
4
4
|
|
|
5
5
|
[project]
|
|
@@ -12,7 +12,7 @@ readme = "README.md"
|
|
|
12
12
|
requires-python = ">=3.10"
|
|
13
13
|
dependencies = [
|
|
14
14
|
"requests >= 2.30",
|
|
15
|
-
"efs-wrapper >= 1.0.
|
|
15
|
+
"efs-wrapper >= 1.0.5"
|
|
16
16
|
]
|
|
17
17
|
classifiers = [
|
|
18
18
|
"Programming Language :: Python :: 3",
|
|
@@ -10,6 +10,17 @@ CONFIG_PATH = os.path.expanduser("~/.efs-cli_config.json")
|
|
|
10
10
|
if os.path.exists(os.path.expanduser("~/.config/")):
|
|
11
11
|
CONFIG_PATH = os.path.expanduser("~/.config/efs-cli.json")
|
|
12
12
|
|
|
13
|
+
def exception_handler(func):
|
|
14
|
+
def wrapper(*args, **kwargs):
|
|
15
|
+
try:
|
|
16
|
+
func(*args, **kwargs)
|
|
17
|
+
except Exception as exc:
|
|
18
|
+
if isinstance(exc.args[1], int):
|
|
19
|
+
print(f"Error: {exc.args[0]}")
|
|
20
|
+
sys.exit(1)
|
|
21
|
+
print(f"Error: {exc.__class__.__name__}: {exc}")
|
|
22
|
+
return wrapper
|
|
23
|
+
|
|
13
24
|
def get_conf():
|
|
14
25
|
conf = None
|
|
15
26
|
|
|
@@ -31,23 +42,33 @@ def init_api():
|
|
|
31
42
|
efs = EepyFileServerPublic(base_url, ignore_initialization = True) if password is None else EepyFileServer(base_url, password, ignore_initialization = True)
|
|
32
43
|
return efs
|
|
33
44
|
|
|
45
|
+
@exception_handler
|
|
34
46
|
def auth(base_url, password, **__):
|
|
35
47
|
data = {"base_url": base_url, "password": password}
|
|
36
48
|
with open(CONFIG_PATH, "w") as file:
|
|
37
49
|
json.dump(data, file)
|
|
38
50
|
print("Saved eepyfileserver password and base url in config.json")
|
|
39
51
|
|
|
40
|
-
|
|
52
|
+
@exception_handler
|
|
53
|
+
def download(from_path, to_path, public, **__):
|
|
41
54
|
api = init_api()
|
|
55
|
+
if to_path is None:
|
|
56
|
+
to_path = from_path.split("/")[-1]
|
|
57
|
+
if public and not isinstance(api, EepyFileServerPublic):
|
|
58
|
+
api = api.public
|
|
59
|
+
if from_path.startswith("/public"):
|
|
60
|
+
from_path = from_path.removeprefix("/public")
|
|
42
61
|
file = api.get_file(from_path)
|
|
43
62
|
file.fetch_file().save(to_path)
|
|
44
63
|
print(f"Downloaded {from_path} to {to_path}")
|
|
45
64
|
|
|
65
|
+
@exception_handler
|
|
46
66
|
def read(file_path, **__):
|
|
47
67
|
api = init_api()
|
|
48
68
|
file = api.get_file(file_path)
|
|
49
69
|
print(file.fetch_file().load().decode("utf-8"))
|
|
50
70
|
|
|
71
|
+
@exception_handler
|
|
51
72
|
def upload(from_path, to_path, **__):
|
|
52
73
|
api = init_api()
|
|
53
74
|
if hasattr(api, "upload_file"):
|
|
@@ -58,10 +79,12 @@ def upload(from_path, to_path, **__):
|
|
|
58
79
|
print("Login using 'efs-cli auth <base url> <password>' to upload files")
|
|
59
80
|
sys.exit(1)
|
|
60
81
|
|
|
82
|
+
@exception_handler
|
|
61
83
|
def list_files(**__):
|
|
62
84
|
api = init_api()
|
|
63
85
|
print(api.get_filelist())
|
|
64
86
|
|
|
87
|
+
@exception_handler
|
|
65
88
|
def remove(file_path, **__):
|
|
66
89
|
api = init_api()
|
|
67
90
|
if hasattr(api, "delete_file"):
|
|
@@ -71,6 +94,7 @@ def remove(file_path, **__):
|
|
|
71
94
|
print("Login using 'efs-cli auth <base url> <password>' to delete files")
|
|
72
95
|
sys.exit(1)
|
|
73
96
|
|
|
97
|
+
@exception_handler
|
|
74
98
|
def ver(**__):
|
|
75
99
|
conf = get_conf()
|
|
76
100
|
print(f"efs-cli: {version}")
|
|
@@ -79,6 +103,7 @@ def ver(**__):
|
|
|
79
103
|
api = init_api()
|
|
80
104
|
print(f"EepyFileServer ({conf['base_url']}): {api.get_instance_info()['instance']['version']}")
|
|
81
105
|
|
|
106
|
+
@exception_handler
|
|
82
107
|
def instance(**__):
|
|
83
108
|
api = init_api()
|
|
84
109
|
instance_info = api.get_instance_info()["instance"]
|
|
@@ -90,9 +115,10 @@ def instance(**__):
|
|
|
90
115
|
print(f" Used : {disk_usage.human.used} Megabytes")
|
|
91
116
|
print(f" Free : {disk_usage.human.free} Megabytes")
|
|
92
117
|
|
|
118
|
+
@exception_handler
|
|
93
119
|
def url_for(file_path, public, check_if_exists, **__):
|
|
94
120
|
api = init_api()
|
|
95
|
-
if public:
|
|
121
|
+
if public and not isinstance(api, EepyFileServerPublic):
|
|
96
122
|
api = api.public
|
|
97
123
|
if file_path.startswith("/public"):
|
|
98
124
|
file_path = file_path.removeprefix("/public")
|
|
@@ -102,8 +128,32 @@ def url_for(file_path, public, check_if_exists, **__):
|
|
|
102
128
|
print(e.args[0])
|
|
103
129
|
sys.exit(1)
|
|
104
130
|
|
|
105
|
-
|
|
106
|
-
|
|
131
|
+
@exception_handler
|
|
132
|
+
def overwrite(from_path, to_path, **__):
|
|
133
|
+
api = init_api()
|
|
134
|
+
if hasattr(api, "overwrite_file"):
|
|
135
|
+
with open(from_path, "rb") as file:
|
|
136
|
+
api.overwrite_file(to_path, file)
|
|
137
|
+
print(f"{to_path} overwritten")
|
|
138
|
+
else:
|
|
139
|
+
print("Login using 'efs-cli auth <base url> <password>' to delete files")
|
|
140
|
+
sys.exit(1)
|
|
141
|
+
|
|
142
|
+
@exception_handler
|
|
143
|
+
def metadata(path, public, **__):
|
|
144
|
+
api = init_api()
|
|
145
|
+
if public and not isinstance(api, EepyFileServerPublic):
|
|
146
|
+
api = api.public
|
|
147
|
+
if path.startswith("/public"):
|
|
148
|
+
path = path.removeprefix("/public")
|
|
149
|
+
if api.is_file(path):
|
|
150
|
+
print(api.get_file(path).metadata.to_dict())
|
|
151
|
+
return
|
|
152
|
+
if api.is_directory(path):
|
|
153
|
+
print(api.get_tree(path))
|
|
154
|
+
return
|
|
155
|
+
print(f"{path} does not exist or is not a file or a directory")
|
|
156
|
+
sys.exit(1)
|
|
107
157
|
|
|
108
158
|
def main():
|
|
109
159
|
parser = ArgumentParser("efs-cli", description="eepyfileserver cli tool for downloading and uploading files")
|
|
@@ -116,7 +166,8 @@ def main():
|
|
|
116
166
|
|
|
117
167
|
download_parser = subparser.add_parser("download", help="download a file", aliases=["get", "d"])
|
|
118
168
|
download_parser.add_argument("from_path", help="the efs path of the file to download")
|
|
119
|
-
download_parser.add_argument("to_path", help="the local path to download the file to")
|
|
169
|
+
download_parser.add_argument("to_path", nargs="?", help="the local path to download the file to")
|
|
170
|
+
download_parser.add_argument("-p", "--public", action="store_true", help="use a public url if set")
|
|
120
171
|
download_parser.set_defaults(func=download)
|
|
121
172
|
|
|
122
173
|
read_parser = subparser.add_parser("read", help="read a file", aliases=["cat"])
|
|
@@ -128,6 +179,16 @@ def main():
|
|
|
128
179
|
upload_parser.add_argument("to_path", help="the efs path to upload the file to")
|
|
129
180
|
upload_parser.set_defaults(func=upload)
|
|
130
181
|
|
|
182
|
+
overwrite_parser = subparser.add_parser("overwrite", help="overwrite a file", aliases=["over"])
|
|
183
|
+
overwrite_parser.add_argument("from_path", help="the local path of the file to use")
|
|
184
|
+
overwrite_parser.add_argument("to_path", help="the efs file path to overwrite")
|
|
185
|
+
overwrite_parser.set_defaults(func=overwrite)
|
|
186
|
+
|
|
187
|
+
metadata_parser = subparser.add_parser("metadata", help="get metadata for a file or a directory", aliases=["meta"])
|
|
188
|
+
metadata_parser.add_argument("path", help="the efs path of the file to get metadata for")
|
|
189
|
+
metadata_parser.add_argument("-p", "--public", action="store_true", help="use a public url if set")
|
|
190
|
+
metadata_parser.set_defaults(func=metadata)
|
|
191
|
+
|
|
131
192
|
list_files_parser = subparser.add_parser("list", help="list current files on efs", aliases=["ls", "files"])
|
|
132
193
|
list_files_parser.set_defaults(func=list_files)
|
|
133
194
|
|
|
@@ -143,7 +204,7 @@ def main():
|
|
|
143
204
|
|
|
144
205
|
urlfor_parser = subparser.add_parser("url-for", help="get the url for a file", aliases=["url"])
|
|
145
206
|
urlfor_parser.add_argument("file_path", help="the efs file path to return url for")
|
|
146
|
-
urlfor_parser.add_argument("-p", "--public", action="store_true", help="return public url if set
|
|
207
|
+
urlfor_parser.add_argument("-p", "--public", action="store_true", help="return public url if set")
|
|
147
208
|
urlfor_parser.add_argument("-c", "--check-if-exists", action="store_true", help="check if the file exists before returning the url")
|
|
148
209
|
urlfor_parser.set_defaults(func=url_for)
|
|
149
210
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: efs-cli
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.8
|
|
4
4
|
Summary: EepyFileServer API CLI written in Python
|
|
5
5
|
Author: maxie
|
|
6
6
|
License-Expression: MIT
|
|
@@ -17,7 +17,7 @@ Requires-Python: >=3.10
|
|
|
17
17
|
Description-Content-Type: text/markdown
|
|
18
18
|
License-File: LICENSE
|
|
19
19
|
Requires-Dist: requests>=2.30
|
|
20
|
-
Requires-Dist: efs-wrapper>=1.0.
|
|
20
|
+
Requires-Dist: efs-wrapper>=1.0.5
|
|
21
21
|
Dynamic: license-file
|
|
22
22
|
|
|
23
23
|
# efs-cli (formerly eepyfileserver-cli)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|