mirror of
https://github.com/aljazceru/hummingbot-dashboard.git
synced 2025-12-29 03:04:19 +01:00
42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
import subprocess
|
|
from typing import Dict
|
|
|
|
import constants
|
|
from utils import os_utils
|
|
|
|
|
|
class DockerManager:
|
|
def __init__(self):
|
|
pass
|
|
|
|
@staticmethod
|
|
def get_active_containers():
|
|
cmd = "docker ps --format '{{.Names}}'"
|
|
output = subprocess.check_output(cmd, shell=True)
|
|
backtestings = [container for container in output.decode().split()]
|
|
return backtestings
|
|
|
|
@staticmethod
|
|
def get_exited_containers():
|
|
cmd = "docker ps --filter status=exited --format '{{.Names}}'"
|
|
output = subprocess.check_output(cmd, shell=True)
|
|
containers = output.decode().split()
|
|
return containers
|
|
|
|
@staticmethod
|
|
def clean_exited_containers():
|
|
cmd = "docker container prune --force"
|
|
subprocess.Popen(cmd, shell=True)
|
|
|
|
def stop_active_containers(self):
|
|
containers = self.get_active_containers()
|
|
for container in containers:
|
|
cmd = f"docker stop {container}"
|
|
subprocess.Popen(cmd, shell=True)
|
|
|
|
def create_download_candles_container(self, candles_config: Dict):
|
|
os_utils.dump_dict_to_yaml(candles_config, constants.DOWNLOAD_CANDLES_CONFIG_YML)
|
|
command = ["docker", "compose", "-p", "data_downloader", "-f",
|
|
"hummingbot_files/compose_files/data-downloader-compose.yml", "up", "-d"]
|
|
subprocess.Popen(command)
|