diff options
author | Helmut Grohne <helmut@subdivi.de> | 2022-06-23 17:30:40 +0200 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2022-06-23 17:30:40 +0200 |
commit | c77c413b89a001f0379690a9073d64680fdb8289 (patch) | |
tree | f7284029eb332b28042e2dd9c9c86603440dc883 /mdbp/ssh.py | |
parent | a3d803cb7b9161cf4177c65fc9059e8a7f346c92 (diff) | |
download | mdbp-c77c413b89a001f0379690a9073d64680fdb8289.tar.gz |
ssh: use tarfile as a context manager
Diffstat (limited to 'mdbp/ssh.py')
-rw-r--r-- | mdbp/ssh.py | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/mdbp/ssh.py b/mdbp/ssh.py index e53b23f..8445dc7 100644 --- a/mdbp/ssh.py +++ b/mdbp/ssh.py @@ -32,17 +32,17 @@ def produce_request_tar(buildjsonobj: JsonObject, else: sendjsonobj["input"] = sendjsonobj["input"].copy() sendjsonobj["input"]["source_package_path"] = dscpath.name - tar = tarfile.open(mode="w|", fileobj=fileobj) - info = tarfile.TarInfo("build.json") - sendjsonfile = io.BytesIO() - for chunk in json.JSONEncoder().iterencode(sendjsonobj): - sendjsonfile.write(chunk.encode("utf8")) - info.size = sendjsonfile.tell() - sendjsonfile.seek(0) - tar.addfile(info, sendjsonfile) - if dscpath: - for path in [dscpath] + get_dsc_files(dscpath): - tar_add(tar, path) + with tarfile.open(mode="w|", fileobj=fileobj) as tar: + info = tarfile.TarInfo("build.json") + sendjsonfile = io.BytesIO() + for chunk in json.JSONEncoder().iterencode(sendjsonobj): + sendjsonfile.write(chunk.encode("utf8")) + info.size = sendjsonfile.tell() + sendjsonfile.seek(0) + tar.addfile(info, sendjsonfile) + if dscpath: + for path in [dscpath] + get_dsc_files(dscpath): + tar_add(tar, path) def main() -> None: """Entry point for mdbp-ssh backend""" |