From efc1367292eb3e62f3bdf62db6025bae94eb2ae4 Mon Sep 17 00:00:00 2001 From: Daniel STAN Date: Wed, 11 Feb 2015 22:21:05 +0100 Subject: [PATCH] dump_creds: ajoute mode debug --- client.py | 13 +++++++++++-- dump_creds.py | 2 ++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/client.py b/client.py index a88c7c8..97ef777 100644 --- a/client.py +++ b/client.py @@ -11,12 +11,21 @@ import string from lc_ldap import crans_utils 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', port=5671, credentials=CREDS, ssl=True) rabbit_c = pika.BlockingConnection(PARAMS) 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(): """Génère un mot de passe aléatoire""" @@ -62,7 +71,7 @@ class Ticket(object): if not self.data: print("Nothing to print !") return - ch.basic_publish(exchange='', routing_key='CransTicket', + ch.basic_publish(exchange='', routing_key=QUEUE_NAME, body=json.dumps(self.data)) print("Un nouveau ticket est en cours d'impression ...") diff --git a/dump_creds.py b/dump_creds.py index 474c078..5446e99 100755 --- a/dump_creds.py +++ b/dump_creds.py @@ -23,6 +23,8 @@ for arg in sys.argv[1:]: conf_wifi_only = False elif arg == '--pass': conf_reset_password = True + elif arg == '--debug': + pass elif arg.startswith('--'): print("Unknown arg") exit(12)