Skip to content
This repository has been archived by the owner on Dec 18, 2022. It is now read-only.

Commit

Permalink
Merge pull request #63 from ermakov-oleg/cmd-run-fixes
Browse files Browse the repository at this point in the history
Fix bug `TypeError: Pyproject.__run_poetry_add() missing 1 required positional argument: 'self'`
  • Loading branch information
MousaZeidBaker authored Sep 15, 2022
2 parents 564b9fd + 6e77cf9 commit 1760427
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "poetryup"
version = "0.11.0"
version = "0.11.1"
description = "Update dependencies and bump their version in the pyproject.toml file"
authors = ["Mousa Zeid Baker"]
packages = [
Expand Down
11 changes: 6 additions & 5 deletions src/poetryup/core/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ def __init__(self, cmd: str, return_code: int) -> None:
self.return_code = return_code


def cmd_run(cmd: List) -> str:
def cmd_run(cmd: List, capture_output: bool = False) -> str:
"""Run command with subprocess
Args:
cmd: The command to run
capture_output: Capture process output
Returns:
The output from the command
Expand All @@ -25,13 +26,13 @@ def cmd_run(cmd: List) -> str:
logging.debug(f"Run command: '{' '.join(cmd)}'")
process = subprocess.run(
cmd,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
stdout=subprocess.PIPE if capture_output else None,
stderr=subprocess.STDOUT if capture_output else None,
)
if process.returncode != 0:
logging.debug(
f"Command '{' '.join(cmd)}' exited with non-zero"
f"exit code '{process.return_code}'"
f"exit code '{process.returncode}'"
)
raise CommandError(cmd="".join(cmd), return_code=process.returncode)
return process.stdout.decode()
return process.stdout.decode() if capture_output else None
5 changes: 2 additions & 3 deletions src/poetryup/core/pyproject.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def __get_poetry_version() -> str:
The poetry version installed
"""

output = cmd_run(["poetry", "--version"])
output = cmd_run(["poetry", "--version"], capture_output=True)
# output is: 'Poetry version x.y.z'
return output.rsplit(" ", 1).pop().strip()

Expand All @@ -339,15 +339,14 @@ def __run_poetry_show() -> str:
The output from the poetry show command
"""

return cmd_run(["poetry", "show", "--tree"])
return cmd_run(["poetry", "show", "--tree"], capture_output=True)

@staticmethod
def __run_poetry_update() -> None:
"""Run poetry update command"""

cmd_run(["poetry", "update"])

@staticmethod
def __run_poetry_add(
self,
packages: List[str],
Expand Down

0 comments on commit 1760427

Please sign in to comment.