refactor: set check flag to True

`subprocess.run` uses a default of `check=False`, which means that a nonzero exit code will be
ignored by default, instead of raising an exception.

You can ignore this issue if this behaviour is intended.
This commit is contained in:
deepsource-autofix[bot]
2024-05-01 21:09:31 +00:00
committed by Abhi
parent b8cf14326a
commit 2600b8098f
4 changed files with 11 additions and 11 deletions

View File

@@ -68,7 +68,7 @@ async def main():
logging.warning(
"Session file is locked. Trying to kill blocking process..."
)
subprocess.run(["fuser", "-k", "my_account.session"])
subprocess.run(["fuser", "-k", "my_account.session"], check=True)
restart()
raise
except (errors.NotAcceptable, errors.Unauthorized) as e:

View File

@@ -105,8 +105,8 @@ async def openfile(client: Client, message: Message):
)
content_new = f"{code_start}\n{content}{code_end}"
paste = subprocess.run(
["rentry", "new", content_new], capture_output=True, text=True
)
["rentry", "new", content_new], capture_output=True, text=True,
check=True)
await client.send_message("me", paste.stdout, disable_web_page_preview=True)
lines = paste.stdout.split("\n")
for line in lines:

View File

@@ -66,8 +66,8 @@ async def update(_, message: Message):
await message.edit("<b>Updating...</b>")
try:
subprocess.run([sys.executable, "-m", "pip", "install", "-U", "pip"])
subprocess.run(["git", "pull"])
subprocess.run([sys.executable, "-m", "pip", "install", "-U", "pip"], check=True)
subprocess.run(["git", "pull"], check=True)
subprocess.run(
[
@@ -78,11 +78,11 @@ async def update(_, message: Message):
"-U",
"-r",
"requirements.txt",
]
)
],
check=True)
subprocess.run(
[sys.executable, "-m", "pip", "install", "-U", *requirements_list]
)
[sys.executable, "-m", "pip", "install", "-U", *requirements_list],
check=True)
except Exception as e:
await message.edit(format_exc(e))
db.remove("core.updater", "restart_info")

View File

@@ -313,8 +313,8 @@ def import_library(library_name: str, package_name: str = None):
return importlib.import_module(library_name)
except ImportError as exc:
completed = subprocess.run(
[sys.executable, "-m", "pip", "install", package_name]
)
[sys.executable, "-m", "pip", "install", package_name],
check=True)
if completed.returncode != 0:
raise AssertionError(
f"Failed to install library {package_name} (pip exited with code {completed.returncode})"