mirror of
https://github.com/markqvist/LXMF.git
synced 2025-12-17 09:24:15 -05:00
Improved error handling
This commit is contained in:
parent
704930f91a
commit
38cc471eaf
1 changed files with 16 additions and 14 deletions
30
LXMF/LXMF.py
30
LXMF/LXMF.py
|
|
@ -405,26 +405,28 @@ class LXMessage:
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def packed_container(self):
|
||||||
|
if not self.packed:
|
||||||
|
self.pack()
|
||||||
|
|
||||||
|
container = {
|
||||||
|
"state": self.state,
|
||||||
|
"lxmf_bytes": self.packed,
|
||||||
|
"transport_encrypted": self.transport_encrypted,
|
||||||
|
"transport_encryption": self.transport_encryption,
|
||||||
|
"method": self.method
|
||||||
|
}
|
||||||
|
|
||||||
|
return msgpack.packb(container)
|
||||||
|
|
||||||
|
|
||||||
def write_to_directory(self, directory_path):
|
def write_to_directory(self, directory_path):
|
||||||
file_name = RNS.hexrep(self.hash, delimit=False)
|
file_name = RNS.hexrep(self.hash, delimit=False)
|
||||||
file_path = directory_path+"/"+file_name
|
file_path = directory_path+"/"+file_name
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if not self.packed:
|
|
||||||
self.pack()
|
|
||||||
|
|
||||||
container = {
|
|
||||||
"state": self.state,
|
|
||||||
"lxmf_bytes": self.packed,
|
|
||||||
"transport_encrypted": self.transport_encrypted,
|
|
||||||
"transport_encryption": self.transport_encryption,
|
|
||||||
"method": self.method
|
|
||||||
}
|
|
||||||
|
|
||||||
packed_container = msgpack.packb(container)
|
|
||||||
|
|
||||||
file = open(file_path, "wb")
|
file = open(file_path, "wb")
|
||||||
file.write(packed_container)
|
file.write(self.packed_container())
|
||||||
file.close()
|
file.close()
|
||||||
|
|
||||||
return file_path
|
return file_path
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue