Skip to content

Commit

Permalink
reorganize files
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcusStrobl committed Apr 5, 2024
1 parent cd71eda commit 8c60994
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
18 changes: 11 additions & 7 deletions processes/podman_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ def connect(uri='unix:///run/podman/podman.sock'):
client = PodmanClient(base_url=uri)

if not client.ping():
raise Exception("Podman service is not running")
logging.error("Podman service is NOT running")
raise Exception("Podman service is NOT running")
else:
print("Podman service is running")
logging.info("Podman service is running")
Expand All @@ -22,8 +23,9 @@ def connect(uri='unix:///run/podman/podman.sock'):

return client

def pull_run_image(client, image_name, container_name, environment=None, mounts=None, network_mode=None, volumes=None, command=None):

def pull_run_image(client, image_name, container_name, environment=None, mounts=None, network_mode=None,
volumes=None, command=None):
secrets = PodmanProcessor.get_secrets()
# Pull the Docker image
print("image: ", client.images.list(filters={"reference": image_name}))
logging.info("image: ", client.images.list(filters={"reference": image_name}))
Expand All @@ -36,6 +38,7 @@ def pull_run_image(client, image_name, container_name, environment=None, mounts=
if existing_container:
print(f"Container '{container_name}' already exists. Removing...")
logging.info(f"Container '{container_name}' already exists. Removing...")
existing_container[0].stop()
existing_container[0].remove(force=True)

print(f"Running Podman container: {container_name}")
Expand Down Expand Up @@ -83,10 +86,11 @@ def pull_run_image(client, image_name, container_name, environment=None, mounts=
print(line.strip().decode('utf-8'))
logging.info(line.strip().decode('utf-8'))

return {
"container" : container,
"container_status": container.status
}
return container
# return {
# "container": container,
# "container_status": container.status
# }

def get_secrets(file_name="processes/secret.txt"):

Expand Down
6 changes: 2 additions & 4 deletions processes/tool_vforwater_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,8 @@ def execute(self, data):
os.makedirs(host_path_out)
logging.debug(f'Created output directory at: {host_path_out}')

with open(f'{host_path_in}/inputs.json', 'w') as f:
json.dump(input_dict, f)
# with open(f'{host_path_in}/inputs.json', 'w', encoding='utf-8') as f:
# json.dump(input_dict, f, ensure_ascii=False, indent=4)
with open(f'{host_path_in}/inputs.json', 'w', encoding='utf-8') as f:
json.dump(input_dict, f, ensure_ascii=False, indent=4)

logging.debug(f'wrote json to {host_path_in}/inputs.json')

Expand Down

0 comments on commit 8c60994

Please sign in to comment.