mirror of
https://github.com/markqvist/NomadNet.git
synced 2026-12-03 21:30:04 -05:00
Directory/Node: replace some bare open/close's with with's
Some checks failed
Create and publish a Docker image / build-and-push-image (push) Has been cancelled
Some checks failed
Create and publish a Docker image / build-and-push-image (push) Has been cancelled
This commit is contained in:
parent
7bc691169a
commit
ad10301569
2 changed files with 8 additions and 12 deletions
|
|
@ -97,9 +97,8 @@ class Directory:
|
|||
"announce_stream": self.announce_stream
|
||||
}
|
||||
|
||||
file = open(self.app.directorypath, "wb")
|
||||
file.write(msgpack.packb(directory))
|
||||
file.close()
|
||||
with open(self.app.directorypath, "wb") as file:
|
||||
file.write(msgpack.packb(directory))
|
||||
|
||||
except Exception as e:
|
||||
RNS.log("Could not write directory to disk. Then contained exception was: "+str(e), RNS.LOG_ERROR)
|
||||
|
|
@ -107,10 +106,9 @@ class Directory:
|
|||
def load_from_disk(self):
|
||||
if os.path.isfile(self.app.directorypath):
|
||||
try:
|
||||
file = open(self.app.directorypath, "rb")
|
||||
unpacked_directory = msgpack.unpackb(file.read())
|
||||
with open(self.app.directorypath, "rb") as file:
|
||||
unpacked_directory = msgpack.unpackb(file.read())
|
||||
unpacked_list = unpacked_directory["entry_list"]
|
||||
file.close()
|
||||
|
||||
entries = {}
|
||||
for e in unpacked_list:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue