diff --git a/daemon/core/api/grpc/server.py b/daemon/core/api/grpc/server.py index 69822252..8796d604 100644 --- a/daemon/core/api/grpc/server.py +++ b/daemon/core/api/grpc/server.py @@ -1179,7 +1179,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): logger.debug("open xml: %s", request) session = self.coreemu.create_session() temp = tempfile.NamedTemporaryFile(delete=False) - temp.write(request.data.encode("utf-8")) + temp.write(request.data.encode()) temp.close() temp_path = Path(temp.name) file_path = Path(request.file) diff --git a/daemon/core/emulator/distributed.py b/daemon/core/emulator/distributed.py index 57e9d1ef..1c0d3c92 100644 --- a/daemon/core/emulator/distributed.py +++ b/daemon/core/emulator/distributed.py @@ -105,7 +105,7 @@ class DistributedServer: """ with self.lock: temp = NamedTemporaryFile(delete=False) - temp.write(data.encode("utf-8")) + temp.write(data.encode()) temp.close() self.conn.put(temp.name, str(dst_path)) os.unlink(temp.name) diff --git a/daemon/core/nodes/docker.py b/daemon/core/nodes/docker.py index ba470167..053d1c5e 100644 --- a/daemon/core/nodes/docker.py +++ b/daemon/core/nodes/docker.py @@ -227,7 +227,7 @@ class DockerNode(CoreNode): """ logger.debug("node(%s) create file(%s) mode(%o)", self.name, file_path, mode) temp = NamedTemporaryFile(delete=False) - temp.write(contents.encode("utf-8")) + temp.write(contents.encode()) temp.close() temp_path = Path(temp.name) directory = file_path.parent diff --git a/daemon/core/nodes/lxd.py b/daemon/core/nodes/lxd.py index 497c228e..e4cba002 100644 --- a/daemon/core/nodes/lxd.py +++ b/daemon/core/nodes/lxd.py @@ -170,7 +170,7 @@ class LxcNode(CoreNode): """ logger.debug("node(%s) create file(%s) mode(%o)", self.name, file_path, mode) temp = NamedTemporaryFile(delete=False) - temp.write(contents.encode("utf-8")) + temp.write(contents.encode()) temp.close() temp_path = Path(temp.name) directory = file_path.parent diff --git a/daemon/core/utils.py b/daemon/core/utils.py index 5947c006..2cfd3605 100644 --- a/daemon/core/utils.py +++ b/daemon/core/utils.py @@ -87,7 +87,7 @@ def hashkey(value: Union[str, int]) -> int: """ if isinstance(value, int): value = str(value) - value = value.encode("utf-8") + value = value.encode() return int(hashlib.sha256(value).hexdigest(), 16) @@ -224,9 +224,9 @@ def cmd( p = Popen(args, stdout=output, stderr=output, env=env, cwd=cwd, shell=shell) if wait: stdout, stderr = p.communicate() - stdout = stdout.decode("utf-8").strip() - stderr = stderr.decode("utf-8").strip() - status = p.wait() + stdout = stdout.decode().strip() + stderr = stderr.decode().strip() + status = p.returncode if status != 0: raise CoreCommandError(status, input_args, stdout, stderr) return stdout