mirror of
https://github.com/45Drives/cockpit-navigator.git
synced 2025-07-29 16:45:13 +02:00
create parent directories if they don't exist
This commit is contained in:
parent
a837129f0c
commit
913461feee
@ -34,6 +34,12 @@ import json
|
|||||||
def write_chunk(chunk, file):
|
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)
|
||||||
|
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:
|
||||||
file = open(path, "wb")
|
file = open(path, "wb")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user