From 4445575f36e6c37a7b8607c3f522d7f053238242 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20BEAU?= Date: Fri, 18 Nov 2022 16:48:36 +0100 Subject: [PATCH 1/5] bump version 8.0.0 --- docky/cmd/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docky/cmd/base.py b/docky/cmd/base.py index a06eb56..7f1d901 100644 --- a/docky/cmd/base.py +++ b/docky/cmd/base.py @@ -15,7 +15,7 @@ class Docky(cli.Application): PROGNAME = "docky" - VERSION = '7.1.0' + VERSION = '8.0.0' SUBCOMMAND_HELPMSG = None def _run(self, cmd, retcode=FG): From 8f743cd9909a34e94246a416ef6cf904575c369e Mon Sep 17 00:00:00 2001 From: Magno Costa Date: Fri, 7 Jun 2024 13:41:10 -0300 Subject: [PATCH 2/5] [UPD] Removed deprecated encondig and change '2018' for '2018-TODAY' --- docky/cmd/base.py | 3 +-- docky/cmd/forward.py | 3 +-- docky/cmd/kill.py | 3 +-- docky/cmd/run_open.py | 3 +-- docky/common/api.py | 3 +-- docky/common/project.py | 3 +-- 6 files changed, 6 insertions(+), 12 deletions(-) diff --git a/docky/cmd/base.py b/docky/cmd/base.py index 7f1d901..bc2af5d 100644 --- a/docky/cmd/base.py +++ b/docky/cmd/base.py @@ -1,5 +1,4 @@ -# -*- coding: utf-8 -*- -# Copyright 2018 Akretion (http://www.akretion.com). +# Copyright 2018-TODAY Akretion (http://www.akretion.com). # @author Sébastien BEAU # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). diff --git a/docky/cmd/forward.py b/docky/cmd/forward.py index 1632d83..b56bdc5 100644 --- a/docky/cmd/forward.py +++ b/docky/cmd/forward.py @@ -1,5 +1,4 @@ -# -*- coding: utf-8 -*- -# Copyright 2018 Akretion (http://www.akretion.com). +# Copyright 2018-TODAY Akretion (http://www.akretion.com). # @author Sébastien BEAU # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). diff --git a/docky/cmd/kill.py b/docky/cmd/kill.py index 12a6dac..269a752 100644 --- a/docky/cmd/kill.py +++ b/docky/cmd/kill.py @@ -1,5 +1,4 @@ -# -*- coding: utf-8 -*- -# Copyright 2018 Akretion (http://www.akretion.com). +# Copyright 2018-TODAY Akretion (http://www.akretion.com). # @author Sébastien BEAU # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). diff --git a/docky/cmd/run_open.py b/docky/cmd/run_open.py index 33a3de5..85bde83 100644 --- a/docky/cmd/run_open.py +++ b/docky/cmd/run_open.py @@ -1,5 +1,4 @@ -# -*- coding: utf-8 -*- -# Copyright 2018 Akretion (http://www.akretion.com). +# Copyright 2018-TODAY Akretion (http://www.akretion.com). # @author Sébastien BEAU # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). diff --git a/docky/common/api.py b/docky/common/api.py index 4907835..8824f98 100644 --- a/docky/common/api.py +++ b/docky/common/api.py @@ -1,5 +1,4 @@ -# -*- coding: utf-8 -*- -# Copyright 2018 Akretion (http://www.akretion.com). +# Copyright 2018-TODAY Akretion (http://www.akretion.com). # @author Sébastien BEAU # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). diff --git a/docky/common/project.py b/docky/common/project.py index c1428b5..ce44ace 100644 --- a/docky/common/project.py +++ b/docky/common/project.py @@ -1,5 +1,4 @@ -# -*- coding: utf-8 -*- -# Copyright 2018 Akretion (http://www.akretion.com). +# Copyright 2018-TODAY Akretion (http://www.akretion.com). # @author Sébastien BEAU # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). From ee41705b895b3b7ea5e3fe294974184494da6258 Mon Sep 17 00:00:00 2001 From: Magno Costa Date: Fri, 7 Jun 2024 13:45:14 -0300 Subject: [PATCH 3/5] [UPD] Included 'swp' and '~' in .gitignore --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index c60d141..5fba5c1 100644 --- a/.gitignore +++ b/.gitignore @@ -59,3 +59,7 @@ venv/ ENV/ env.bak/ venv.bak/ + +# Backup files +*~ +*.swp From d698aaaeee7619ad879fef2648333cf074a23e82 Mon Sep 17 00:00:00 2001 From: Magno Costa Date: Fri, 7 Jun 2024 13:52:13 -0300 Subject: [PATCH 4/5] [UPD] Method super() don't need parameters. --- docky/cmd/forward.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docky/cmd/forward.py b/docky/cmd/forward.py index b56bdc5..26947cf 100644 --- a/docky/cmd/forward.py +++ b/docky/cmd/forward.py @@ -29,7 +29,7 @@ class DockyUp(DockyForward): def _main(self, *args): self.project.display_service_tooltip() self.project.create_volume() - return super(DockyUp, self)._main(*args) + return super()._main(*args) @Docky.subcommand("down") From 6d99697e324ff72ea85859368af46de779626155 Mon Sep 17 00:00:00 2001 From: Magno Costa Date: Fri, 7 Jun 2024 14:09:30 -0300 Subject: [PATCH 5/5] [UPD] Changed single quotes ' for double quotes. --- docky/cmd/base.py | 11 +++++------ docky/cmd/forward.py | 2 +- docky/cmd/kill.py | 2 +- docky/cmd/run_open.py | 13 ++++++------- docky/common/api.py | 5 ++--- docky/common/project.py | 26 +++++++++++++------------- docky/dcpatched.py | 2 +- setup.py | 18 +++++++++--------- 8 files changed, 38 insertions(+), 41 deletions(-) diff --git a/docky/cmd/base.py b/docky/cmd/base.py index bc2af5d..c7279eb 100644 --- a/docky/cmd/base.py +++ b/docky/cmd/base.py @@ -2,7 +2,6 @@ # @author Sébastien BEAU # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - from plumbum import cli, local from plumbum.commands.modifiers import FG import logging @@ -14,24 +13,24 @@ class Docky(cli.Application): PROGNAME = "docky" - VERSION = '8.0.0' + VERSION = "8.0.0" SUBCOMMAND_HELPMSG = None def _run(self, cmd, retcode=FG): """Run a command in a new process and log it""" - logger.debug(str(cmd).replace('/usr/local/bin/', '')) + logger.debug(str(cmd).replace("/usr/local/bin/", "")) return cmd & retcode def _exec(self, cmd, args=[]): """Run a command in the same process and log it this will replace the current process by the cmd""" - logger.debug(cmd + ' '.join(args)) + logger.debug(cmd + " ".join(args)) os.execvpe(cmd, [cmd] + args, local.env) @cli.switch("--verbose", help="Verbose mode", group="Meta-switches") def set_log_level(self): logger.setLevel(logging.DEBUG) - logger.debug('Verbose mode activated') + logger.debug("Verbose mode activated") class DockySub(cli.Application): @@ -45,7 +44,7 @@ def _run(self, *args, **kwargs): def _init_project(self): self.project = Project() - self.compose = local['docker-compose'] + self.compose = local["docker-compose"] def main(self, *args, **kwargs): if self._project_specific: diff --git a/docky/cmd/forward.py b/docky/cmd/forward.py index 26947cf..fab7e2c 100644 --- a/docky/cmd/forward.py +++ b/docky/cmd/forward.py @@ -9,7 +9,7 @@ class DockyForward(DockySub): _cmd = None def _main(self, *args): - cmd = self._cmd.split(' ') + cmd = self._cmd.split(" ") if args: cmd.append(*args) return self._run(self.compose[cmd]) diff --git a/docky/cmd/kill.py b/docky/cmd/kill.py index 269a752..4786222 100644 --- a/docky/cmd/kill.py +++ b/docky/cmd/kill.py @@ -14,4 +14,4 @@ def _main(self, *args): # docker compose do not kill the container odoo as is was run # manually, so we implement our own kill containers = self.project.get_containers() - parallel_kill(containers, {'signal': 'SIGKILL'}) + parallel_kill(containers, {"signal": "SIGKILL"}) diff --git a/docky/cmd/run_open.py b/docky/cmd/run_open.py index 85bde83..ffcc80f 100644 --- a/docky/cmd/run_open.py +++ b/docky/cmd/run_open.py @@ -2,7 +2,6 @@ # @author Sébastien BEAU # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - from plumbum import cli from .base import Docky, DockySub from ..common.api import raise_error @@ -23,9 +22,9 @@ def _get_cmd_line(self, optionnal_command_line): user = self._use_specific_user(self.service) cmd = [] if user: - cmd = ['gosu', user] + cmd = ["gosu", user] if not optionnal_command_line: - cmd.append('bash') + cmd.append("bash") else: cmd += list(optionnal_command_line) return cmd @@ -55,11 +54,11 @@ def _main(self, *optionnal_command_line): super()._main(*optionnal_command_line) self._check_running() # Remove useless dead container before running a new one - self._run(self.compose['rm', '-f']) + self._run(self.compose["rm", "-f"]) self.project.display_service_tooltip() self.project.create_volume() - self._exec('docker-compose', [ - 'run', '--rm', '--service-ports', '--use-aliases', '-e', 'NOGOSU=True', + self._exec("docker-compose", [ + "run", "--rm", "--service-ports", "--use-aliases", "-e", "NOGOSU=True", self.service] + self.cmd) @@ -71,4 +70,4 @@ class DockyOpen(DockyExec): def _main(self, *optionnal_command_line): super()._main(*optionnal_command_line) - self._exec('dcpatched', ['exec', '-e', 'NOGOSU=True', self.service] + self.cmd) + self._exec("dcpatched", ["exec", "-e", "NOGOSU=True", self.service] + self.cmd) diff --git a/docky/common/api.py b/docky/common/api.py index 8824f98..1e181b1 100644 --- a/docky/common/api.py +++ b/docky/common/api.py @@ -2,19 +2,18 @@ # @author Sébastien BEAU # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - import logging import sys # Optionnal code for colorized log from rainbow_logging_handler import RainbowLoggingHandler -logger = logging.getLogger('docky') +logger = logging.getLogger("docky") formatter = logging.Formatter("%(message)s") logger.setLevel(logging.INFO) handler = RainbowLoggingHandler( sys.stderr, - color_message_info=('green', None, True), + color_message_info=("green", None, True), ) handler.setFormatter(formatter) logger.addHandler(handler) diff --git a/docky/common/project.py b/docky/common/project.py index ce44ace..7c0c78d 100644 --- a/docky/common/project.py +++ b/docky/common/project.py @@ -15,10 +15,10 @@ class Project(object): def __init__(self): try: - self.project = command.project_from_options('.', {}) + self.project = command.project_from_options(".", {}) except ComposeFileNotFound: print("No docker-compose found, create one with :") - print('$ docky init') + print("$ docky init") exit(-1) self.name = self.project.name @@ -29,23 +29,23 @@ def _get_main_service(self, project): """main_service has docky.main.service defined in his label.""" for service in project.services: - labels = service.options.get('labels', {}) + labels = service.options.get("labels", {}) # service.labels() do not contain docky.main.service # see also compose.service.merge_labels - if labels.get('docky.main.service', False): + if labels.get("docky.main.service", False): return service.name def get_containers(self, service=None): - kwargs = {'one_off': OneOffFilter.include} + kwargs = {"one_off": OneOffFilter.include} if service: - kwargs['service_names'] = [service] + kwargs["service_names"] = [service] return self.project.containers(**kwargs) def display_service_tooltip(self): infos = self._get_services_info() for service in self.project.services: - labels = service.options.get('labels', {}) - if labels.get('docky.access.help'): + labels = service.options.get("labels", {}) + if labels.get("docky.access.help"): # TODO remove after some versions logger.warning( "'docky.access.help' is replaced by 'docky.help'. " @@ -54,8 +54,8 @@ def display_service_tooltip(self): # some applications provide extra parameters to access resource infos[service.name] += labels.get("docky.url_suffix", "") logger.info(infos[service.name]) - if labels.get('docky.help'): - logger.info(labels.get('docky.help')) + if labels.get("docky.help"): + logger.info(labels.get("docky.help")) def _get_services_info(self): """ Search IP and Port for each services @@ -93,7 +93,7 @@ def create_volume(self): docker-compose up do not attemps to create it so we have to do it ourselves""" for service in self.project.services: - for volume in service.options.get('volumes', []): + for volume in service.options.get("volumes", []): if volume.external: path = local.path(local.env.expand(volume.external)) if not path.exists(): @@ -104,6 +104,6 @@ def create_volume(self): def get_user(self, service_name): service = self.project.get_service(name=service_name) - labels = service.options.get('labels') + labels = service.options.get("labels") if labels: - return labels.get('docky.user', None) + return labels.get("docky.user", None) diff --git a/docky/dcpatched.py b/docky/dcpatched.py index 3659258..2e3119e 100644 --- a/docky/dcpatched.py +++ b/docky/dcpatched.py @@ -16,7 +16,7 @@ def get_run_container(self, number=1): # search for container running in background for container in self.containers( - labels=['{0}={1}'.format(LABEL_CONTAINER_NUMBER, number)]): + labels=["{0}={1}".format(LABEL_CONTAINER_NUMBER, number)]): return container # search for container running with "run" cmd diff --git a/setup.py b/setup.py index 6cdcd1f..0e12db1 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ def read(*parts): path = os.path.join(os.path.dirname(__file__), *parts) - with codecs.open(path, encoding='utf-8') as fobj: + with codecs.open(path, encoding="utf-8") as fobj: return fobj.read() @@ -20,26 +20,26 @@ def find_version(*file_paths): setup( - name='docky', + name="docky", version=find_version("docky", "cmd", "base.py"), - author='Akretion', - author_email='contact@akretion.com', - url='https://github.com/akretion/docky/', - description='Make developpement with docker simply', + author="Akretion", + author_email="contact@akretion.com", + url="https://github.com/akretion/docky/", + description="Make developpement with docker simply", license="AGPLv3+", - long_description=open('README.rst').read(), + long_description=open("README.rst").read(), classifiers=[ "Programming Language :: Python :: 3", "Operating System :: POSIX :: Linux", ], install_requires=[ - r.strip() for r in open('requirements.txt').read().splitlines()], + r.strip() for r in open("requirements.txt").read().splitlines()], entry_points=""" [console_scripts] docky=docky.main:main dcpatched=docky.dcpatched:main """, include_package_data=True, - packages=find_packages() + ['docky'], + packages=find_packages() + ["docky"], zip_safe=False, )