Stop en cas d'erreur de config
This commit is contained in:
parent
4014c85e48
commit
7b40ce6c6a
9
main.py
9
main.py
@ -16,7 +16,7 @@ Il est conseillé de mettre un chemin absolu.
|
||||
# Press Maj+F10 to execute it or replace it with your code.
|
||||
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
|
||||
|
||||
import os, json, subprocess, zipfile
|
||||
import os, json, subprocess, zipfile, sys
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
import piexif
|
||||
from pdf2image import convert_from_path
|
||||
@ -160,7 +160,10 @@ def create_original_files_directory():
|
||||
config["source_directory"] = temp_directory
|
||||
with open("config.json", "w") as f:
|
||||
json.dump(config, f, indent=4)
|
||||
print(f"Sauvegarde de la configuration")
|
||||
print(f"Sauvegarde de la configuration OK")
|
||||
print(f"Il ne reste plus qu'à mettre les fichiers originaux dans le répertoire ", temp_directory,"' et relancer le script.")
|
||||
sys.exit(1) # Arrête le script avec un code d'erreur non nul
|
||||
|
||||
|
||||
def is_key_defined_in_json(json_file, key):
|
||||
with open(json_file, 'r') as f:
|
||||
@ -175,7 +178,7 @@ def zip_directory(directory, zip_file):
|
||||
zipf.write(file_path, os.path.relpath(file_path, directory))
|
||||
|
||||
if __name__ == '__main__':
|
||||
# Creation du répertoire soruces pour mettre les documents
|
||||
# Creation du répertoire sources pour mettre les documents
|
||||
create_original_files_directory()
|
||||
|
||||
# Lecture de la configuration
|
||||
|
Loading…
Reference in New Issue
Block a user