dprojectstools 0.0.3__tar.gz → 0.0.5__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.
- {dprojectstools-0.0.3 → dprojectstools-0.0.5}/PKG-INFO +4 -4
- dprojectstools-0.0.5/README.md +2 -0
- {dprojectstools-0.0.3 → dprojectstools-0.0.5}/pyproject.toml +2 -2
- dprojectstools-0.0.5/src/dprojectstools/backups/__init__.py +3 -0
- dprojectstools-0.0.5/src/dprojectstools/backups/restic.py +62 -0
- {dprojectstools-0.0.3 → dprojectstools-0.0.5}/src/dprojectstools/commands/commands.py +10 -8
- {dprojectstools-0.0.3 → dprojectstools-0.0.5}/src/dprojectstools/secrets/secrets.py +8 -4
- {dprojectstools-0.0.3 → dprojectstools-0.0.5}/src/dprojectstools.egg-info/PKG-INFO +4 -4
- {dprojectstools-0.0.3 → dprojectstools-0.0.5}/src/dprojectstools.egg-info/SOURCES.txt +2 -0
- dprojectstools-0.0.3/README.md +0 -2
- {dprojectstools-0.0.3 → dprojectstools-0.0.5}/LICENSE +0 -0
- {dprojectstools-0.0.3 → dprojectstools-0.0.5}/setup.cfg +0 -0
- {dprojectstools-0.0.3 → dprojectstools-0.0.5}/src/dprojectstools/__init__.py +0 -0
- {dprojectstools-0.0.3 → dprojectstools-0.0.5}/src/dprojectstools/commands/__init__.py +0 -0
- {dprojectstools-0.0.3 → dprojectstools-0.0.5}/src/dprojectstools/crypto/__init__.py +0 -0
- {dprojectstools-0.0.3 → dprojectstools-0.0.5}/src/dprojectstools/crypto/aes.py +0 -0
- {dprojectstools-0.0.3 → dprojectstools-0.0.5}/src/dprojectstools/secrets/__init__.py +0 -0
- {dprojectstools-0.0.3 → dprojectstools-0.0.5}/src/dprojectstools.egg-info/dependency_links.txt +0 -0
- {dprojectstools-0.0.3 → dprojectstools-0.0.5}/src/dprojectstools.egg-info/top_level.txt +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: dprojectstools
|
|
3
|
-
Version: 0.0.
|
|
4
|
-
Summary: A
|
|
3
|
+
Version: 0.0.5
|
|
4
|
+
Summary: A set of development tools
|
|
5
5
|
Author-email: Marc Delos <marcdp@dprojects.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/marcdp/dprojectstools
|
|
7
7
|
Project-URL: Issues, https://github.com/marcdp/dprojectstools/issues
|
|
@@ -12,5 +12,5 @@ Requires-Python: >=3.8
|
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
License-File: LICENSE
|
|
14
14
|
|
|
15
|
-
#
|
|
16
|
-
A
|
|
15
|
+
# dprojectstools
|
|
16
|
+
A set of development tools
|
|
@@ -10,11 +10,11 @@ where = ["src"]
|
|
|
10
10
|
|
|
11
11
|
[project]
|
|
12
12
|
name = "dprojectstools"
|
|
13
|
-
version = "0.0.
|
|
13
|
+
version = "0.0.5"
|
|
14
14
|
authors = [
|
|
15
15
|
{ name="Marc Delos", email="marcdp@dprojects.com" },
|
|
16
16
|
]
|
|
17
|
-
description = "A
|
|
17
|
+
description = "A set of development tools"
|
|
18
18
|
readme = "README.md"
|
|
19
19
|
requires-python = ">=3.8"
|
|
20
20
|
classifiers = [
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import subprocess
|
|
3
|
+
from typing import Annotated
|
|
4
|
+
from ..commands import command, CommandsManager
|
|
5
|
+
|
|
6
|
+
class Restic:
|
|
7
|
+
|
|
8
|
+
# vars
|
|
9
|
+
_repository: str
|
|
10
|
+
_repository_password: str
|
|
11
|
+
_aws_access_key_id: str
|
|
12
|
+
_aws_secret_access_key: str
|
|
13
|
+
|
|
14
|
+
# ctor
|
|
15
|
+
def __init__(self, repository, repository_password, aws_access_key_id, aws_secret_access_key):
|
|
16
|
+
self._repository = repository
|
|
17
|
+
self._repository_password = repository_password
|
|
18
|
+
self._aws_access_key_id = aws_access_key_id
|
|
19
|
+
self._aws_secret_access_key = aws_secret_access_key
|
|
20
|
+
|
|
21
|
+
# commands
|
|
22
|
+
@command("Init repository", index = 1)
|
|
23
|
+
def init(self):
|
|
24
|
+
return subprocess.run("restic init", env = self._getEnv())
|
|
25
|
+
|
|
26
|
+
@command("Backup ", index = 10)
|
|
27
|
+
def backup(self):
|
|
28
|
+
return subprocess.run("restic backup ./data ./data2 --verbose", env = self._getEnv())
|
|
29
|
+
|
|
30
|
+
@command("List snapshots ", index = 20)
|
|
31
|
+
def snapshots_list(self):
|
|
32
|
+
return subprocess.run("restic snapshots", env = self._getEnv())
|
|
33
|
+
|
|
34
|
+
@command("List snapshot contents ")
|
|
35
|
+
def snapshots_contents(self,
|
|
36
|
+
id: Annotated[str, "ID"]
|
|
37
|
+
):
|
|
38
|
+
return subprocess.run("restic ls --long {0}".format(id), env = self._getEnv())
|
|
39
|
+
|
|
40
|
+
@command("Restore ")
|
|
41
|
+
def snapshots_restore(self,
|
|
42
|
+
id: Annotated[str, "ID"]
|
|
43
|
+
):
|
|
44
|
+
return subprocess.run("restic restore {0} --target ./restore --verbose".format(id), env = self._getEnv())
|
|
45
|
+
|
|
46
|
+
# methods
|
|
47
|
+
def exec(self, argv):
|
|
48
|
+
commandsManager = CommandsManager()
|
|
49
|
+
commandsManager.register(self)
|
|
50
|
+
return commandsManager.execute(argv)
|
|
51
|
+
|
|
52
|
+
# utils
|
|
53
|
+
def _getEnv(self):
|
|
54
|
+
myenv = os.environ.copy()
|
|
55
|
+
myenv['RESTIC_REPOSITORY'] = self._repository
|
|
56
|
+
myenv['RESTIC_PASSWORD'] = self._repository_password
|
|
57
|
+
myenv["AWS_ACCESS_KEY_ID"] = self._aws_access_key_id
|
|
58
|
+
myenv['AWS_SECRET_ACCESS_KEY'] = self._aws_secret_access_key
|
|
59
|
+
return myenv
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
@@ -86,8 +86,7 @@ class CommandsManager:
|
|
|
86
86
|
command_title = getattr(func, "title")
|
|
87
87
|
command_order = getattr(func, "order")
|
|
88
88
|
command_index = getattr(func, "index")
|
|
89
|
-
command_arguments = []
|
|
90
|
-
|
|
89
|
+
command_arguments = []
|
|
91
90
|
for param_name, param in inspect.signature(func).parameters.items():
|
|
92
91
|
if param_name == "self":
|
|
93
92
|
continue
|
|
@@ -134,9 +133,6 @@ class CommandsManager:
|
|
|
134
133
|
|
|
135
134
|
self._commands.sort(key=lambda x: x.index)
|
|
136
135
|
|
|
137
|
-
#for command in self._commands:
|
|
138
|
-
# print(command.name, command.index)
|
|
139
|
-
|
|
140
136
|
def showMenu(self):
|
|
141
137
|
# sort
|
|
142
138
|
self.sort()
|
|
@@ -148,10 +144,12 @@ class CommandsManager:
|
|
|
148
144
|
indent = self._indent * " "
|
|
149
145
|
while True:
|
|
150
146
|
# show menu
|
|
151
|
-
print(indent + "
|
|
152
|
-
print(indent + "
|
|
147
|
+
print(indent + "Select an option:")
|
|
148
|
+
print(indent + "=================")
|
|
153
149
|
command_ant = None
|
|
154
150
|
for command in self._commands:
|
|
151
|
+
if command_ant == None and command.index > 1:
|
|
152
|
+
print(indent + f" : ")
|
|
155
153
|
if command_ant != None and command_ant.name[0] != command.name[0]:
|
|
156
154
|
print(indent + f" : ")
|
|
157
155
|
print(indent + f"{command.index:2} : {command.title}")
|
|
@@ -300,7 +298,11 @@ class CommandsManager:
|
|
|
300
298
|
if command_args_errors:
|
|
301
299
|
return -1
|
|
302
300
|
# invoke
|
|
303
|
-
|
|
301
|
+
if not command_to_execute.instance is None:
|
|
302
|
+
func_bounded = types.MethodType(command_to_execute.func, command_to_execute.instance)
|
|
303
|
+
return func_bounded(**command_args_dict)
|
|
304
|
+
else:
|
|
305
|
+
return command_to_execute.func(**command_args_dict)
|
|
304
306
|
|
|
305
307
|
|
|
306
308
|
|
|
@@ -3,7 +3,7 @@ import os
|
|
|
3
3
|
import json
|
|
4
4
|
import keyring
|
|
5
5
|
from typing import Annotated
|
|
6
|
-
from ..commands import command
|
|
6
|
+
from ..commands import command, CommandsManager
|
|
7
7
|
from ..crypto import aes_decrypt, aes_encrypt, password_generate
|
|
8
8
|
|
|
9
9
|
# consts
|
|
@@ -30,8 +30,6 @@ class SecretsManager():
|
|
|
30
30
|
if username == "":
|
|
31
31
|
username = os.getlogin()
|
|
32
32
|
password = keyring.get_password(KEYRING_APP, username)
|
|
33
|
-
print(username)
|
|
34
|
-
print(password)
|
|
35
33
|
if password is None:
|
|
36
34
|
password = password_generate()
|
|
37
35
|
keyring.set_password(KEYRING_APP, username, password)
|
|
@@ -80,7 +78,7 @@ class SecretsManager():
|
|
|
80
78
|
file.write(text)
|
|
81
79
|
|
|
82
80
|
|
|
83
|
-
#
|
|
81
|
+
# commands
|
|
84
82
|
@command("List secrets", index = 90)
|
|
85
83
|
def secrets_list(self):
|
|
86
84
|
for key in self.keys():
|
|
@@ -103,3 +101,9 @@ class SecretsManager():
|
|
|
103
101
|
):
|
|
104
102
|
self.delete(name)
|
|
105
103
|
|
|
104
|
+
# methods
|
|
105
|
+
def exec(self, argv):
|
|
106
|
+
commandsManager = CommandsManager()
|
|
107
|
+
commandsManager.register(self)
|
|
108
|
+
return commandsManager.execute(argv)
|
|
109
|
+
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: dprojectstools
|
|
3
|
-
Version: 0.0.
|
|
4
|
-
Summary: A
|
|
3
|
+
Version: 0.0.5
|
|
4
|
+
Summary: A set of development tools
|
|
5
5
|
Author-email: Marc Delos <marcdp@dprojects.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/marcdp/dprojectstools
|
|
7
7
|
Project-URL: Issues, https://github.com/marcdp/dprojectstools/issues
|
|
@@ -12,5 +12,5 @@ Requires-Python: >=3.8
|
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
License-File: LICENSE
|
|
14
14
|
|
|
15
|
-
#
|
|
16
|
-
A
|
|
15
|
+
# dprojectstools
|
|
16
|
+
A set of development tools
|
|
@@ -6,6 +6,8 @@ src/dprojectstools.egg-info/PKG-INFO
|
|
|
6
6
|
src/dprojectstools.egg-info/SOURCES.txt
|
|
7
7
|
src/dprojectstools.egg-info/dependency_links.txt
|
|
8
8
|
src/dprojectstools.egg-info/top_level.txt
|
|
9
|
+
src/dprojectstools/backups/__init__.py
|
|
10
|
+
src/dprojectstools/backups/restic.py
|
|
9
11
|
src/dprojectstools/commands/__init__.py
|
|
10
12
|
src/dprojectstools/commands/commands.py
|
|
11
13
|
src/dprojectstools/crypto/__init__.py
|
dprojectstools-0.0.3/README.md
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dprojectstools-0.0.3 → dprojectstools-0.0.5}/src/dprojectstools.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|