mirror of
https://github.com/45Drives/cockpit-navigator.git
synced 2025-07-29 16:45:13 +02:00
better error message on failure
This commit is contained in:
parent
9220812edb
commit
48c422e043
@ -35,20 +35,24 @@ def write_chunk(chunk, file):
|
|||||||
if not file:
|
if not file:
|
||||||
path = sys.argv[1]
|
path = sys.argv[1]
|
||||||
parent_path = os.path.dirname(path)
|
parent_path = os.path.dirname(path)
|
||||||
if not os.path.exists(parent_path):
|
|
||||||
os.makedirs(parent_path, exist_ok=True)
|
|
||||||
elif os.path.isfile(parent_path):
|
|
||||||
print(parent_path + ": exists and is not a directory.")
|
|
||||||
sys.exit(1)
|
|
||||||
try:
|
try:
|
||||||
|
if not os.path.exists(parent_path):
|
||||||
|
os.makedirs(parent_path, exist_ok=True)
|
||||||
|
elif os.path.isfile(parent_path):
|
||||||
|
print(parent_path + ": exists and is not a directory.")
|
||||||
|
sys.exit(1)
|
||||||
file = open(path, "wb")
|
file = open(path, "wb")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
seek = chunk["seek"]
|
seek = chunk["seek"]
|
||||||
data = base64.b64decode(chunk["chunk"])
|
data = base64.b64decode(chunk["chunk"])
|
||||||
file.seek(seek)
|
try:
|
||||||
file.write(data)
|
file.seek(seek)
|
||||||
|
file.write(data)
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
file = None
|
file = None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user