mirror of
https://github.com/containers/podman-compose.git
synced 2025-02-16 18:31:34 +01:00
Fix pylint issues
Signed-off-by: Bas Zoetekouw <bas.zoetekouw@surf.nl>
This commit is contained in:
parent
c3a152e68f
commit
688ee9a104
2
.github/workflows/static-checks.yml
vendored
2
.github/workflows/static-checks.yml
vendored
@ -22,4 +22,4 @@ jobs:
|
|||||||
ruff check
|
ruff check
|
||||||
- name: Analysing the code with pylint
|
- name: Analysing the code with pylint
|
||||||
run: |
|
run: |
|
||||||
pylint podman-compose.py
|
pylint podman_compose.py
|
||||||
|
@ -1169,14 +1169,14 @@ class Podman:
|
|||||||
xargs = self.compose.get_podman_args(cmd) if cmd else []
|
xargs = self.compose.get_podman_args(cmd) if cmd else []
|
||||||
cmd_ls = [self.podman_path, *podman_args, cmd] + xargs + cmd_args
|
cmd_ls = [self.podman_path, *podman_args, cmd] + xargs + cmd_args
|
||||||
log.info(str(cmd_ls))
|
log.info(str(cmd_ls))
|
||||||
p = await asyncio.subprocess.create_subprocess_exec(
|
p = await asyncio.create_subprocess_exec(
|
||||||
*cmd_ls, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE
|
*cmd_ls, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE
|
||||||
)
|
)
|
||||||
|
|
||||||
stdout_data, stderr_data = await p.communicate()
|
stdout_data, stderr_data = await p.communicate()
|
||||||
if p.returncode == 0:
|
if p.returncode == 0:
|
||||||
return stdout_data
|
return stdout_data
|
||||||
else:
|
|
||||||
raise subprocess.CalledProcessError(p.returncode, " ".join(cmd_ls), stderr_data)
|
raise subprocess.CalledProcessError(p.returncode, " ".join(cmd_ls), stderr_data)
|
||||||
|
|
||||||
def exec(
|
def exec(
|
||||||
@ -1191,7 +1191,7 @@ class Podman:
|
|||||||
log.info(" ".join([str(i) for i in cmd_ls]))
|
log.info(" ".join([str(i) for i in cmd_ls]))
|
||||||
os.execlp(self.podman_path, *cmd_ls)
|
os.execlp(self.podman_path, *cmd_ls)
|
||||||
|
|
||||||
async def run(
|
async def run( # pylint: disable=dangerous-default-value
|
||||||
self,
|
self,
|
||||||
podman_args,
|
podman_args,
|
||||||
cmd="",
|
cmd="",
|
||||||
@ -1219,7 +1219,7 @@ class Podman:
|
|||||||
if stdout.at_eof():
|
if stdout.at_eof():
|
||||||
break
|
break
|
||||||
|
|
||||||
p = await asyncio.subprocess.create_subprocess_exec(
|
p = await asyncio.create_subprocess_exec(
|
||||||
*cmd_ls, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE
|
*cmd_ls, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE
|
||||||
) # pylint: disable=consider-using-with
|
) # pylint: disable=consider-using-with
|
||||||
|
|
||||||
@ -1234,7 +1234,7 @@ class Podman:
|
|||||||
err_t.add_done_callback(task_reference.discard)
|
err_t.add_done_callback(task_reference.discard)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
p = await asyncio.subprocess.create_subprocess_exec(*cmd_ls) # pylint: disable=consider-using-with
|
p = await asyncio.create_subprocess_exec(*cmd_ls) # pylint: disable=consider-using-with
|
||||||
|
|
||||||
try:
|
try:
|
||||||
exit_code = await p.wait()
|
exit_code = await p.wait()
|
||||||
@ -1912,9 +1912,12 @@ class PodmanCompose:
|
|||||||
|
|
||||||
podman_compose = PodmanCompose()
|
podman_compose = PodmanCompose()
|
||||||
|
|
||||||
|
|
||||||
###################
|
###################
|
||||||
# decorators to add commands and parse options
|
# decorators to add commands and parse options
|
||||||
###################
|
###################
|
||||||
|
class PodmanComposeError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class cmd_run: # pylint: disable=invalid-name,too-few-public-methods
|
class cmd_run: # pylint: disable=invalid-name,too-few-public-methods
|
||||||
@ -1928,7 +1931,7 @@ class cmd_run: # pylint: disable=invalid-name,too-few-public-methods
|
|||||||
return func(*args, **kw)
|
return func(*args, **kw)
|
||||||
|
|
||||||
if not asyncio.iscoroutinefunction(func):
|
if not asyncio.iscoroutinefunction(func):
|
||||||
raise Exception("Command must be async")
|
raise PodmanComposeError("Command must be async")
|
||||||
wrapped._compose = self.compose
|
wrapped._compose = self.compose
|
||||||
# Trim extra indentation at start of multiline docstrings.
|
# Trim extra indentation at start of multiline docstrings.
|
||||||
wrapped.desc = self.cmd_desc or re.sub(r"^\s+", "", func.__doc__)
|
wrapped.desc = self.cmd_desc or re.sub(r"^\s+", "", func.__doc__)
|
||||||
@ -2010,8 +2013,8 @@ async def compose_systemd(compose, args):
|
|||||||
f.write(f"{k}={v}\n")
|
f.write(f"{k}={v}\n")
|
||||||
log.debug("writing [%s]: done.", fn)
|
log.debug("writing [%s]: done.", fn)
|
||||||
log.info("\n\ncreating the pod without starting it: ...\n\n")
|
log.info("\n\ncreating the pod without starting it: ...\n\n")
|
||||||
process = await asyncio.subprocess.create_subprocess_exec(script, ["up", "--no-start"])
|
process = await asyncio.create_subprocess_exec(script, ["up", "--no-start"])
|
||||||
log.info("\nfinal exit code is ", process)
|
log.info("\nfinal exit code is %d", process)
|
||||||
username = getpass.getuser()
|
username = getpass.getuser()
|
||||||
print(
|
print(
|
||||||
f"""
|
f"""
|
||||||
@ -2305,7 +2308,7 @@ async def compose_up(compose: PodmanCompose, args):
|
|||||||
# cause the status to overwrite. Sleeping for 1 seems to fix this and make it match
|
# cause the status to overwrite. Sleeping for 1 seems to fix this and make it match
|
||||||
# docker-compose
|
# docker-compose
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
[_.cancel() for _ in tasks if not _.cancelling() and not _.cancelled()]
|
_ = [_.cancel() for _ in tasks if not _.cancelling() and not _.cancelled()]
|
||||||
t: Task
|
t: Task
|
||||||
exiting = True
|
exiting = True
|
||||||
for t in done:
|
for t in done:
|
||||||
|
Loading…
Reference in New Issue
Block a user