diff --git a/dockerctl/executer.py b/dockerctl/executer.py index 4d342b7..80846ac 100644 --- a/dockerctl/executer.py +++ b/dockerctl/executer.py @@ -4,92 +4,77 @@ def start(compose_name): - compose_dir = path + compose_name - os.chdir(compose_dir) + os.chdir('/etc/docker/' + compose_name) os.system('docker-compose start') def stop(compose_name): - compose_dir = path + compose_name - os.chdir(compose_dir) + os.chdir('/etc/docker/' + compose_name) os.system('docker-compose stop') def restart(compose_name): - compose_dir = path + compose_name - os.chdir(compose_dir) + os.chdir('/etc/docker/' + compose_name) os.system('docker-compose restart') def processes(compose_name): - compose_dir = path + compose_name - os.chdir(compose_dir) + os.chdir('/etc/docker/' + compose_name) os.system('docker-compose ps') def up(compose_name): - compose_dir = path + compose_name - os.chdir(compose_dir) - os.system('docker-compose up') + os.chdir('/etc/docker/' + compose_name) + os.system('docker-compose up -d') def kill(compose_name): - compose_dir = path + compose_name - os.chdir(compose_dir) + os.chdir('/etc/docker/' + compose_name) os.system('docker-compose kill') def pull(compose_name): - compose_dir = path + compose_name - os.chdir(compose_dir) + os.chdir('/etc/docker/' + compose_name) os.system('docker-compose pull') def push(compose_name): - compose_dir = path + compose_name - os.chdir(compose_dir) + os.chdir('/etc/docker/' + compose_name) os.system('docker-compose push') def rm(compose_name): - compose_dir = path + compose_name - os.chdir(compose_dir) + os.chdir('/etc/docker/' + compose_name) os.system('docker-compose rm') def top(compose_name): - compose_dir = path + compose_name - os.chdir(compose_dir) + os.chdir('/etc/docker/' + compose_name) os.system('docker-compose top') def pause(compose_name): - compose_dir = path + compose_name - os.chdir(compose_dir) + os.chdir('/etc/docker/' + compose_name) os.system('docker-compose pause') def unpause(compose_name): - compose_dir = path + compose_name - os.chdir(compose_dir) + os.chdir('/etc/docker/' + compose_name) os.system('docker-compose unpause') def images(compose_name): - compose_dir = path + compose_name - os.chdir(compose_dir) + os.chdir('/etc/docker/' + compose_name) os.system('docker-compose images') def port(compose_name): - compose_dir = path + compose_name - os.chdir(compose_dir) + os.chdir('/etc/docker/' + compose_name) os.system('docker-compose port') -def logss(compose_name): - compose_dir = path + compose_name - os.chdir(compose_dir) +def logs(compose_name): + os.chdir('/etc/docker/' + compose_name) os.system('docker-compose logs') diff --git a/dockerctl/parser.py b/dockerctl/parser.py index bef5727..b2eb030 100644 --- a/dockerctl/parser.py +++ b/dockerctl/parser.py @@ -4,36 +4,35 @@ import argparse from dockerctl import executer -version_nr = "0.1" +version_nr = "0.2" def compose_start(option, compose_name): args = { - "start" : executer.start(compose_name), - "stop" : executer.stop(compose_name), - "restart" : executer.restart(compose_name), - "ps": executer.processes(compose_name), - "up" : executer.up(compose_name), - "kill" : executer.kill(compose_name), - "pull" : executer.pull(compose_name), - "push" : executer.push(compose_name), - "rm" : executer.remove(compose_name), - "top" : executer.top(compose_name), - "pause" : executer.pause(compose_name), - "unpause" : executer.unpause(compose_name), - "images" : executer.images(compose_name), - "port" : executer.port(compose_name), - "logs" : executer.logs(compose_name), + "start" : executer.start, + "stop" : executer.stop, + "restart": executer.restart, + "ps" : executer.processes, + "up" : executer.up, + "kill" : executer.kill, + "pull" : executer.pull, + "push" : executer.push, + "rm" : executer.rm, + "top" : executer.top, + "pause" : executer.pause, + "unpause": executer.unpause, + "images" : executer.images, + "port" : executer.port, + "logs" : executer.logs, + "add" : executer.add, + "remove" : executer.remove, } - for i in option[1:]: - args[option](compose_name) + args[option](compose_name) def main(argv): parser = argparse.ArgumentParser(prog='dockerctl', add_help=True) - exgroup = parser.add_mutually_exclusive_group() - - exgroup.add_argument('-v', '--version', action="version", version='dockerctl ' + version_nr, + parser.add_argument('-v', '--version', action="version", version='dockerctl ' + version_nr, help="Print version number") # common commands parser.add_argument('command', choices=['start', 'stop', 'restart', 'ps', 'up', ' kill', 'rm', 'top', 'logs', diff --git a/setup.py b/setup.py index cc9afa1..af3b183 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( name = "dockerctl", - version = "0.1", + version = "0.2", description = "Python Script to steer (multiple) docker-compose-yaml's from everywhere.", long_description= long_description, url = "https://github.com/bionade24/dockerctl", @@ -27,7 +27,7 @@ 'Programming Language :: Python :: 3', "Operating System :: POSIX :: Linux", ], - py_modules = ["sys", "argparse", "os"], + py_modules = ["sys", "argparse", "os", "docker-compose"], packages = ["dockerctl"], - srcipts = ["bin/dockerctl"] + scripts = ["bin/dockerctl"] ) \ No newline at end of file