Suppression de certains paramètres de lancement et création d'un fichier de configuration à la place
This commit is contained in:
@ -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)
|
||||
|
||||
Reference in New Issue
Block a user