[elbe-devel] [PATCH] elbepack: replace os.sys with plain sys
Thomas Weißschuh
thomas.weissschuh at linutronix.de
Mon Jul 29 12:17:30 CEST 2024
The builtin module "sys" is also available through "os.sys".
This however is confusing and highly irregular.
Use the normal "sys" import instead.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
elbepack/commands/check-build.py | 3 ++-
elbepack/log.py | 3 ++-
elbepack/rpcaptcache.py | 12 ++++++------
3 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/elbepack/commands/check-build.py b/elbepack/commands/check-build.py
index 373242c26b35..730666c4da4f 100644
--- a/elbepack/commands/check-build.py
+++ b/elbepack/commands/check-build.py
@@ -8,6 +8,7 @@ import os
import pathlib
import shutil
import subprocess
+import sys
import tempfile
import traceback
@@ -60,7 +61,7 @@ def run_command(argv):
logging.info('Passed %d tests ouf of %d',
total_cnt - fail_cnt, total_cnt)
- os.sys.exit(fail_cnt)
+ sys.exit(fail_cnt)
class CheckException(Exception):
diff --git a/elbepack/log.py b/elbepack/log.py
index 5fc1eeab1917..9db224de4b1d 100644
--- a/elbepack/log.py
+++ b/elbepack/log.py
@@ -7,6 +7,7 @@ import collections
import logging
import os
import re
+import sys
import threading
from contextlib import contextmanager
@@ -167,7 +168,7 @@ def add_file_handlers(files):
for f in files:
if f is None:
- out = logging.StreamHandler(os.sys.stdout)
+ out = logging.StreamHandler(sys.stdout)
else:
out = logging.FileHandler(f)
out.addFilter(ThreadFilter(['root',
diff --git a/elbepack/rpcaptcache.py b/elbepack/rpcaptcache.py
index ddc2c2db2ad1..3624f6c05d3e 100644
--- a/elbepack/rpcaptcache.py
+++ b/elbepack/rpcaptcache.py
@@ -39,14 +39,14 @@ class MyMan(BaseManager):
@staticmethod
def redirect_outputs(w):
"""Redirect all outputs to the writing end of a pipe 'w'"""
- os.dup2(w, os.sys.stdout.fileno())
- os.dup2(w, os.sys.stderr.fileno())
+ os.dup2(w, sys.stdout.fileno())
+ os.dup2(w, sys.stderr.fileno())
# Buffering of 1 because in Python3 buffering of 0 is illegal
# for non binary mode ..
- os.sys.stdout = os.fdopen(os.sys.stdout.fileno(), 'w', 1)
- os.sys.stderr = os.fdopen(os.sys.stderr.fileno(), 'w', 1)
- os.sys.__stdout__ = os.sys.stdout
- os.sys.__stderr__ = os.sys.stderr
+ sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 1)
+ sys.stderr = os.fdopen(sys.stderr.fileno(), 'w', 1)
+ sys.__stdout__ = sys.stdout
+ sys.__stderr__ = sys.stderr
def start(self):
"""Redirect outputs of the process to an async logging thread"""
---
base-commit: e4a0e331ee6f0bec03af434ff313902e5f3cd424
change-id: 20240729-ossys-8439b6c85001
Best regards,
--
Thomas Weißschuh <thomas.weissschuh at linutronix.de>
More information about the elbe-devel
mailing list