Suppression de certains paramètres de lancement et création d'un fichier de configuration à la place

This commit is contained in:
Jason SECULA
2025-06-04 13:25:13 +02:00
parent 339fd61fa0
commit f7ef0e2a8c
2 changed files with 71 additions and 29 deletions

View File

@ -3,32 +3,61 @@ import os
import base64
import requests
import json
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("-debug", action=argparse.BooleanOptionalAction)
parser.add_argument("-force", action=argparse.BooleanOptionalAction)
args = parser.parse_args()
settingsDefault = {
"airwatchServer":"https://apimagenta.phm.education.gouv.fr",
"airwatchAPIKey":"",
"airwatchAPIUser":"",
"airwatchAPIPassword":"",
"glpiServer":"http://127.0.0.1/glpi/",
"glpiAppToken":"",
"glpiUserToken":"",
"stagingUser":"staging-pr"
}
settings = None
if(not os.path.isfile("./settings.json")):
f = open("./settings.json", "w")
f.write(json.dumps(settingsDefault, indent=4))
f.close()
exit(1)
else:
with open("./settings.json", "r") as f:
settings = json.load(f)
#======== Paramètres du script ========#
# Emplacement du verrou
lockFile = './magentaGLPIStaging.lock'
lockFile = './airwatchStagingUserAssignation.lock'
debug=False
debug=args.debug
# Informations du serveur Airwatch
#airwatchServer = 'https://pp-apimagenta.phm.education.gouv.fr'
airwatchServer = 'https://apimagenta.phm.education.gouv.fr'
airwatchAPIKey = ''
airwatchAPIUser = ''
airwatchAPIPassword = ''
stagingUser = 'staging-pr'
airwatchServer = settings["airwatchServer"]
airwatchAPIKey = settings["airwatchAPIKey"]
airwatchAPIUser = settings["airwatchAPIUser"]
airwatchAPIPassword = settings["airwatchAPIPassword"]
stagingUser = settings["stagingUser"]
# Informations du serveur GLPI
GLPIServer = 'http://127.0.0.1/glpi/'
GLPIAppToken = ''
GLPIUserToken = ''
GLPIServer = settings["glpiServer"]
GLPIAppToken = settings["glpiAppToken"]
GLPIUserToken = settings["glpiUserToken"]
# ====================================== #
# Vérification de la présence du verrou avant de continuer
if(os.path.isfile(lockFile)):
if(os.path.isfile(lockFile) and not args.force):
if(debug):
print('Lock file is present, exiting...')
exit(0)