daemon: updated utils.cmd to use returncode instead of wait(), removed redundant default encoding value for calls to decode/encode
This commit is contained in:
parent
94f070e0ff
commit
81230edac3
5 changed files with 8 additions and 8 deletions
|
@ -1179,7 +1179,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
||||||
logger.debug("open xml: %s", request)
|
logger.debug("open xml: %s", request)
|
||||||
session = self.coreemu.create_session()
|
session = self.coreemu.create_session()
|
||||||
temp = tempfile.NamedTemporaryFile(delete=False)
|
temp = tempfile.NamedTemporaryFile(delete=False)
|
||||||
temp.write(request.data.encode("utf-8"))
|
temp.write(request.data.encode())
|
||||||
temp.close()
|
temp.close()
|
||||||
temp_path = Path(temp.name)
|
temp_path = Path(temp.name)
|
||||||
file_path = Path(request.file)
|
file_path = Path(request.file)
|
||||||
|
|
|
@ -105,7 +105,7 @@ class DistributedServer:
|
||||||
"""
|
"""
|
||||||
with self.lock:
|
with self.lock:
|
||||||
temp = NamedTemporaryFile(delete=False)
|
temp = NamedTemporaryFile(delete=False)
|
||||||
temp.write(data.encode("utf-8"))
|
temp.write(data.encode())
|
||||||
temp.close()
|
temp.close()
|
||||||
self.conn.put(temp.name, str(dst_path))
|
self.conn.put(temp.name, str(dst_path))
|
||||||
os.unlink(temp.name)
|
os.unlink(temp.name)
|
||||||
|
|
|
@ -227,7 +227,7 @@ class DockerNode(CoreNode):
|
||||||
"""
|
"""
|
||||||
logger.debug("node(%s) create file(%s) mode(%o)", self.name, file_path, mode)
|
logger.debug("node(%s) create file(%s) mode(%o)", self.name, file_path, mode)
|
||||||
temp = NamedTemporaryFile(delete=False)
|
temp = NamedTemporaryFile(delete=False)
|
||||||
temp.write(contents.encode("utf-8"))
|
temp.write(contents.encode())
|
||||||
temp.close()
|
temp.close()
|
||||||
temp_path = Path(temp.name)
|
temp_path = Path(temp.name)
|
||||||
directory = file_path.parent
|
directory = file_path.parent
|
||||||
|
|
|
@ -170,7 +170,7 @@ class LxcNode(CoreNode):
|
||||||
"""
|
"""
|
||||||
logger.debug("node(%s) create file(%s) mode(%o)", self.name, file_path, mode)
|
logger.debug("node(%s) create file(%s) mode(%o)", self.name, file_path, mode)
|
||||||
temp = NamedTemporaryFile(delete=False)
|
temp = NamedTemporaryFile(delete=False)
|
||||||
temp.write(contents.encode("utf-8"))
|
temp.write(contents.encode())
|
||||||
temp.close()
|
temp.close()
|
||||||
temp_path = Path(temp.name)
|
temp_path = Path(temp.name)
|
||||||
directory = file_path.parent
|
directory = file_path.parent
|
||||||
|
|
|
@ -87,7 +87,7 @@ def hashkey(value: Union[str, int]) -> int:
|
||||||
"""
|
"""
|
||||||
if isinstance(value, int):
|
if isinstance(value, int):
|
||||||
value = str(value)
|
value = str(value)
|
||||||
value = value.encode("utf-8")
|
value = value.encode()
|
||||||
return int(hashlib.sha256(value).hexdigest(), 16)
|
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)
|
p = Popen(args, stdout=output, stderr=output, env=env, cwd=cwd, shell=shell)
|
||||||
if wait:
|
if wait:
|
||||||
stdout, stderr = p.communicate()
|
stdout, stderr = p.communicate()
|
||||||
stdout = stdout.decode("utf-8").strip()
|
stdout = stdout.decode().strip()
|
||||||
stderr = stderr.decode("utf-8").strip()
|
stderr = stderr.decode().strip()
|
||||||
status = p.wait()
|
status = p.returncode
|
||||||
if status != 0:
|
if status != 0:
|
||||||
raise CoreCommandError(status, input_args, stdout, stderr)
|
raise CoreCommandError(status, input_args, stdout, stderr)
|
||||||
return stdout
|
return stdout
|
||||||
|
|
Loading…
Add table
Reference in a new issue