Skip to content

Commit cb9d441

Browse files
author
javierfh03
committed
Change minimals details in the command manager
1 parent c46021a commit cb9d441

4 files changed

Lines changed: 56 additions & 11 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ All notable changes to this project will be documented in this file.
33

44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
55

6-
## [Unreleased]
6+
## [0.1.1] - 2024-02-04
7+
### Changed
8+
- @javierfh03 - Change minimals details in the command manager.
79
### Fixed
810
- @javierfh03 - Fix error message.
911

1012
## [0.1.0] - 2024-02-04
1113
### Added
12-
- @javierfh03 - Add command manager with units test
14+
- @javierfh03 - Add command manager with units test.
1315

14-
[Unreleased]: https://github.com/Lagatrix/shell_executor_lib
16+
[0.1.1]: https://github.com/Lagatrix/shell_executor_lib
1517
[0.1.0]: https://github.com/Lagatrix/shell_executor_lib/releases/tag/0.1.0

poetry.lock

Lines changed: 47 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ authors = [
1414
[tool.poetry]
1515
name = "shell_executor_lib"
1616
version = "0.1.1"
17-
description = "Seed for python projects"
17+
description = "This library execute async commands in shell"
1818
keywords = ["Python", "Library", "Commands"]
1919
license = "Apache License"
2020

src/shell_executor_lib/manager/command_manager.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ async def execute_command(self, command: str, sudo: bool, *stdin: str) -> list[s
3434
3535
"""
3636
process = await asyncio.create_subprocess_shell(
37-
f"su - {self.user} -c {'sudo -S ' if sudo else ''}{command}",
37+
f"su - {self.user} -c {'/bin/sudo -S ' if sudo else ''}{command}",
3838
stdin=asyncio.subprocess.PIPE,
3939
stdout=asyncio.subprocess.PIPE,
4040
stderr=asyncio.subprocess.PIPE
4141
)
4242

43-
await self._set_stdin(process, sudo, *stdin)
43+
await self.__set_stdin(process, sudo, *stdin)
4444

4545
if process.stdout and process.stderr is not None:
4646
output, error = await asyncio.gather(process.stdout.read(), process.stderr.read())
@@ -54,16 +54,13 @@ async def execute_command(self, command: str, sudo: bool, *stdin: str) -> list[s
5454
else:
5555
raise CommandError(-2, "Stdout and stderr read error")
5656

57-
async def _set_stdin(self, process: Process, sudo: bool, *stdin: str) -> None:
57+
async def __set_stdin(self, process: Process, sudo: bool, *stdin: str) -> None:
5858
"""Put the stdin data into the command.
5959
6060
Args:
6161
process: The process of the command to exec.
6262
sudo: If the command require sudo privileges.
6363
*stdin: Stdin params of the command.
64-
65-
Returns:
66-
None.
6764
"""
6865
if process.stdin is not None:
6966
process.stdin.write(self.password.encode() + b"\n")

0 commit comments

Comments
 (0)