dump_creds: ajoute mode debug

This commit is contained in:
Daniel STAN 2015-02-11 22:21:05 +01:00
parent 6b74765a55
commit efc1367292
2 changed files with 13 additions and 2 deletions

View file

@ -11,12 +11,21 @@ import string
from lc_ldap import crans_utils from lc_ldap import crans_utils
CREDS = pika.credentials.PlainCredentials('oie', secrets.get('rabbitmq_oie'), True) CREDS = pika.credentials.PlainCredentials('oie', secrets.get('rabbitmq_oie'), True)
import sys
if '--debug' in sys.argv[1:]:
CREDS = pika.credentials.PlainCredentials('rasputin', secrets.get('rabbitmq_rasputin'), True)
PARAMS = pika.ConnectionParameters(host='rabbitmq.crans.org', PARAMS = pika.ConnectionParameters(host='rabbitmq.crans.org',
port=5671, credentials=CREDS, ssl=True) port=5671, credentials=CREDS, ssl=True)
rabbit_c = pika.BlockingConnection(PARAMS) rabbit_c = pika.BlockingConnection(PARAMS)
ch = rabbit_c.channel() ch = rabbit_c.channel()
ch.queue_declare('CransTicket') if '--debug' in sys.argv[1:]:
QUEUE_NAME = 'CransTicketDebug'
print("Debug")
else:
QUEUE_NAME = 'CransTicket'
ch.queue_declare(QUEUE_NAME)
def gen_password(): def gen_password():
"""Génère un mot de passe aléatoire""" """Génère un mot de passe aléatoire"""
@ -62,7 +71,7 @@ class Ticket(object):
if not self.data: if not self.data:
print("Nothing to print !") print("Nothing to print !")
return return
ch.basic_publish(exchange='', routing_key='CransTicket', ch.basic_publish(exchange='', routing_key=QUEUE_NAME,
body=json.dumps(self.data)) body=json.dumps(self.data))
print("Un nouveau ticket est en cours d'impression ...") print("Un nouveau ticket est en cours d'impression ...")

View file

@ -23,6 +23,8 @@ for arg in sys.argv[1:]:
conf_wifi_only = False conf_wifi_only = False
elif arg == '--pass': elif arg == '--pass':
conf_reset_password = True conf_reset_password = True
elif arg == '--debug':
pass
elif arg.startswith('--'): elif arg.startswith('--'):
print("Unknown arg") print("Unknown arg")
exit(12) exit(12)