maj api.py
This commit is contained in:
parent
a775864131
commit
5bf01b77db
@ -22,7 +22,6 @@ from glob import glob
|
||||
from bs4 import BeautifulSoup
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
app = Flask(__name__)
|
||||
api = Api(app)
|
||||
|
||||
@ -117,19 +116,16 @@ cloud_ident=os.environ.get('nextcloud_NEXTCLOUD_ADMIN_USER')
|
||||
cloud_pass=os.environ.get('nextcloud_NEXTCLOUD_ADMIN_PASSWORD')
|
||||
cloud_url=os.environ.get('cloud_url')
|
||||
|
||||
sympa_ident=os.environ.get('sympa_SOAP_USER')
|
||||
sympa_pass=os.environ.get('sympa_SOAP_PASSWORD')
|
||||
sympa_url=os.environ.get('sympa_url')
|
||||
sympa_liste_info=os.environ.get('sympa_liste_info')
|
||||
|
||||
gandi_key=os.environ.get('gandi_GANDI_KEY')
|
||||
gandi_url_api=os.environ.get('gandi_GANDI_API')
|
||||
|
||||
site_url=os.environ.get('site_url')
|
||||
|
||||
#pour webmail_url et mdp_url, ça renvoie des tuples et non des str, bizarre, du coup, je mets en dur
|
||||
webmail_url=os.environ.get('webmail_url'),
|
||||
mdp_url=os.environ.get('mdp_url'),
|
||||
#webmail_url=os.environ.get('webmail_url'),
|
||||
#mdp_url=os.environ.get('mdp_url'),
|
||||
webmail_url='https://webmail.kaz.bzh',
|
||||
mdp_url='https://mdp.kazkouil.fr',
|
||||
|
||||
#pour le mail
|
||||
app.config['MAIL_SERVER']= os.environ.get('apikaz_MAIL_SERVER')
|
||||
@ -141,6 +137,12 @@ app.config['MAIL_USE_TLS'] = True
|
||||
app.config['MAIL_USE_SSL'] = False
|
||||
mail = Mail(app)
|
||||
|
||||
#sympa
|
||||
sympa_ident=os.environ.get('sympa_SOAP_USER')
|
||||
sympa_pass=os.environ.get('sympa_SOAP_PASSWORD')
|
||||
sympa_url=os.environ.get('sympa_url')
|
||||
sympa_liste_info=os.environ.get('sympa_liste_info')
|
||||
MAIL_USERNAME=app.config['MAIL_USERNAME']
|
||||
|
||||
#pour QUOTA (à virer ensuite)
|
||||
serveur_imap = os.environ.get('serveur_imap')
|
||||
@ -1260,7 +1262,7 @@ api.add_resource(Cloud_user_delete, '/cloud/user/delete/<string:email>')
|
||||
|
||||
class Sympa_user(Resource):
|
||||
def __init__(self):
|
||||
global sympa_ident, sympa_pass, sympa_url, app.config['MAIL_USERNAME']
|
||||
global sympa_ident, sympa_pass, sympa_url,MAIL_USERNAME
|
||||
self.sympa_ident = sympa_ident
|
||||
self.sympa_pass = sympa_pass
|
||||
self.sympa_url = sympa_url
|
||||
@ -1268,7 +1270,7 @@ class Sympa_user(Resource):
|
||||
def _execute_sympa_command(self, email, liste, service):
|
||||
try:
|
||||
if validate_email(email) and validate_email(liste):
|
||||
cmd = f'export PERL5LIB=/usr/src/app/:$PERL5LIB && /usr/src/app/Sympa/sympa_soap_client.pl --soap_url={self.sympa_url}/sympasoap --trusted_application={self.sympa_ident} --trusted_application_password={self.sympa_pass} --proxy_vars=USER_EMAIL={app.config['MAIL_USERNAME']} --service={service} --service_parameters="{liste},{email}" && echo $?'
|
||||
cmd = f'export PERL5LIB=/usr/src/app/:$PERL5LIB && /usr/src/app/Sympa/sympa_soap_client.pl --soap_url={self.sympa_url}/sympasoap --trusted_application={self.sympa_ident} --trusted_application_password={self.sympa_pass} --proxy_vars=USER_EMAIL={MAIL_USERNAME} --service={service} --service_parameters="{liste},{email}" && echo $?'
|
||||
output = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)
|
||||
return output.decode("utf-8"), 200 # Retourne la sortie et un code de succès
|
||||
except EmailNotValidError as e:
|
||||
@ -1793,7 +1795,7 @@ class Test(Resource):
|
||||
#**** test messagerie
|
||||
|
||||
NOM="toto"
|
||||
EMAIL_SOUHAITE=''
|
||||
EMAIL_SOUHAITE='f@kaz.bzh'
|
||||
PASSWORD="toto"
|
||||
QUOTA="1"
|
||||
ADMIN_ORGA="0"
|
||||
|
Loading…
Reference in New Issue
Block a user