addftool 0.1.5__py3-none-any.whl → 0.1.6__py3-none-any.whl
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.
- addftool/addf_portal.py +8 -0
- addftool/process/__init__.py +1 -0
- addftool/util.py +68 -5
- {addftool-0.1.5.dist-info → addftool-0.1.6.dist-info}/METADATA +1 -1
- {addftool-0.1.5.dist-info → addftool-0.1.6.dist-info}/RECORD +8 -8
- {addftool-0.1.5.dist-info → addftool-0.1.6.dist-info}/WHEEL +0 -0
- {addftool-0.1.5.dist-info → addftool-0.1.6.dist-info}/entry_points.txt +0 -0
- {addftool-0.1.5.dist-info → addftool-0.1.6.dist-info}/top_level.txt +0 -0
addftool/addf_portal.py
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import argparse
|
|
2
2
|
from addftool.process import add_killer_args, killer_main
|
|
3
|
+
from addftool.sync import add_sync_args, sync_main
|
|
4
|
+
from addftool.deploy import add_deploy_args, deploy_main
|
|
3
5
|
|
|
4
6
|
|
|
5
7
|
def get_args():
|
|
@@ -7,6 +9,8 @@ def get_args():
|
|
|
7
9
|
|
|
8
10
|
subparsers = parser.add_subparsers(dest='command', help='Sub-command help')
|
|
9
11
|
add_killer_args(subparsers)
|
|
12
|
+
add_sync_args(subparsers)
|
|
13
|
+
add_deploy_args(subparsers)
|
|
10
14
|
|
|
11
15
|
return parser.parse_args()
|
|
12
16
|
|
|
@@ -15,6 +19,10 @@ def main():
|
|
|
15
19
|
args = get_args()
|
|
16
20
|
if args.command == "kill":
|
|
17
21
|
killer_main(args)
|
|
22
|
+
elif args.command == "sync":
|
|
23
|
+
sync_main(args)
|
|
24
|
+
elif args.command == "deploy":
|
|
25
|
+
deploy_main(args)
|
|
18
26
|
else:
|
|
19
27
|
print("Unknown command: ", args.command)
|
|
20
28
|
|
addftool/process/__init__.py
CHANGED
addftool/util.py
CHANGED
|
@@ -1,12 +1,75 @@
|
|
|
1
|
+
import os
|
|
1
2
|
import subprocess
|
|
2
3
|
|
|
3
4
|
|
|
4
|
-
def execute_command(command, to_file=None):
|
|
5
|
+
def execute_command(command, to_file=None, only_stdout=True, hide=False):
|
|
5
6
|
if to_file is not None:
|
|
6
7
|
to_file.write(command + "\n")
|
|
7
8
|
return None
|
|
8
9
|
else:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
if not hide:
|
|
11
|
+
print("Execute command: ", command)
|
|
12
|
+
result = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
|
|
13
|
+
result.wait()
|
|
14
|
+
print(f"Return code: {result.returncode}")
|
|
15
|
+
if result.stdout is not None:
|
|
16
|
+
stdout = result.stdout.read().decode()
|
|
17
|
+
print(f"Stdout: {stdout}")
|
|
18
|
+
else:
|
|
19
|
+
stdout = None
|
|
20
|
+
if only_stdout:
|
|
21
|
+
if not hide and stdout is not None:
|
|
22
|
+
print(stdout)
|
|
23
|
+
return stdout
|
|
24
|
+
if result.stderr is not None:
|
|
25
|
+
stderr = result.stderr.read().decode()
|
|
26
|
+
print(f"Stderr: {stderr}")
|
|
27
|
+
else:
|
|
28
|
+
stderr = None
|
|
29
|
+
|
|
30
|
+
return {'stdout': stdout, 'stderr': stderr, 'returncode': result.returncode}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def need_sudo():
|
|
34
|
+
return os.name == 'posix' and os.getuid() != 0
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def is_running_in_docker():
|
|
38
|
+
return os.path.exists('/.dockerenv') or \
|
|
39
|
+
any('docker' in line for line in open('/proc/self/cgroup', 'r')) if os.path.exists('/proc/self/cgroup') else False or \
|
|
40
|
+
os.environ.get('container') == 'docker' or \
|
|
41
|
+
os.environ.get('DOCKER') == 'true' or \
|
|
42
|
+
os.environ.get('DOCKER_CONTAINER') == 'yes'
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def get_ubuntu_version():
|
|
46
|
+
with open("/etc/os-release") as f:
|
|
47
|
+
for line in f:
|
|
48
|
+
if line.startswith("VERSION_ID="):
|
|
49
|
+
version = line.split("=")[1].strip().strip('"')
|
|
50
|
+
return version
|
|
51
|
+
return "22.04"
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def check_package_installed(package):
|
|
55
|
+
command = f"dpkg -l | grep {package}"
|
|
56
|
+
result = execute_command(command)
|
|
57
|
+
if result is not None and package in result:
|
|
58
|
+
return True
|
|
59
|
+
return False
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def install_packages(package_list):
|
|
63
|
+
to_install = []
|
|
64
|
+
for package in package_list:
|
|
65
|
+
if check_package_installed(package):
|
|
66
|
+
print(f"{package} is already installed")
|
|
67
|
+
continue
|
|
68
|
+
to_install.append(package)
|
|
69
|
+
|
|
70
|
+
if len(to_install) > 0:
|
|
71
|
+
packages = " ".join(to_install)
|
|
72
|
+
command = f"apt-get install -y {packages}"
|
|
73
|
+
if need_sudo():
|
|
74
|
+
command = "sudo " + command
|
|
75
|
+
execute_command(command)
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
addftool/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
addftool/addf_portal.py,sha256=
|
|
2
|
+
addftool/addf_portal.py,sha256=w2LgsoutfnrKhtrQAXouUMwLqnsp5ALlsBYUWg8n9NM,781
|
|
3
3
|
addftool/blob.py,sha256=NZOItDyFUIdV1tfhJZJJBEzGy296CE5NCictTzP4OPc,8282
|
|
4
4
|
addftool/tool.py,sha256=EuKQ2t2InN7yB-_oYLcdsA7vRqzRGTunwIxplUSqEG0,2054
|
|
5
|
-
addftool/util.py,sha256=
|
|
5
|
+
addftool/util.py,sha256=zlNLu8Be8cGIpNRqBw8_0q7nFxWlsJ9cToN62ohjdXE,2335
|
|
6
6
|
addftool/deploy/__init__.py,sha256=tpyoTh3SqAQojPizsJDvQohu1Pcb3-w-DP5sO4-5lBM,1220
|
|
7
7
|
addftool/deploy/azure.py,sha256=UQR1hOEYUtsm2fbWBczsnEB_mh7yUuN2NDv3sgMMsac,1246
|
|
8
8
|
addftool/deploy/ssh_server.py,sha256=f2T8fgwACVljPfdcimMywUjsFnLCWRde7iWPAILpRz8,5463
|
|
9
|
-
addftool/process/__init__.py,sha256=
|
|
9
|
+
addftool/process/__init__.py,sha256=gPdGsjMEET6crzOz4Iw5cmf6RR1toXGovydRXv8Uagk,3543
|
|
10
10
|
addftool/process/utils.py,sha256=me4HqMz5OgRcQMUJmVhKdTJh4SW5BB-pd_lq7g8-UwE,2252
|
|
11
11
|
addftool/ssh/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
12
|
addftool/sync/__init__.py,sha256=wOqFCOA51rFUttBjOO44W3Fc66mhX5ir2R89lsO6gR0,1702
|
|
13
|
-
addftool-0.1.
|
|
14
|
-
addftool-0.1.
|
|
15
|
-
addftool-0.1.
|
|
16
|
-
addftool-0.1.
|
|
17
|
-
addftool-0.1.
|
|
13
|
+
addftool-0.1.6.dist-info/METADATA,sha256=SQSnBFDxmD836XQAgZDtqvpzT_Z1LewNKTRCfdMC5ag,148
|
|
14
|
+
addftool-0.1.6.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
15
|
+
addftool-0.1.6.dist-info/entry_points.txt,sha256=9lkmuWMInwUAtev8w8poNkNd7iML9Bjd5CBCFVxg2b8,111
|
|
16
|
+
addftool-0.1.6.dist-info/top_level.txt,sha256=jqj56-plrBbyzY0tIxB6wPzjAA8kte4hUlajyyQygN4,9
|
|
17
|
+
addftool-0.1.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|