/
podman_loader.py
62 lines (44 loc) · 1.76 KB
/
podman_loader.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env python
# python2.7 -m compileall . # compilation to .pyc extension
import subprocess
from os import listdir
from os.path import isfile, join
import os
# TODO podman/docker
directory = "." # . working directory in which you have to be to run the script
extension = ".tar" # extension for image files
def main():
# command = "podman load --input " # default command to run
command = "echo "
# creates a list of all files (also hidden) in specified directory
allfiles = [f for f in listdir(directory) if isfile(join(directory, f))]
# creates an empty list to which all found *.tar archives will append
archives = []
# Display all files (also hidden)
# for filename in onlyfiles:
# print(filename)
print('-'*30)
print("PODMAN LOADER:")
print("[>] workdir:\t" + directory)
print("[>] extension:\t" + extension)
print('-'*30)
print("[>] all files: " + str(len(allfiles)))
# display files with *.tar extension
for filename in allfiles:
if(filename.find(extension, -4) != -1): # checks if the last 4 characters are the extension ( .XXX )
print(filename)
archives.append(filename)
# TODO, multitasking
# subprocess.run(["echo", filename])
# process = subprocess.Popen(command + "ea", stdout=subprocess.PIPE)
# output, error = process.communicate()
print("[>] " + extension + " files: " + str(len(archives)))
print("[>] running")
for archive in archives:
os.system("podman load --input " + archive)
print("\t loaded " + archive)
print("[>] done")
pass
if __name__ == "__main__":
main()
pass