@@ -290,20 +290,59 @@ def do_process_epp_command(self, request_json):
290
290
#------------------------------------------------------------------------------
291
291
292
292
def main ():
293
+ p = optparse .OptionParser (
294
+ description = 'Starts the local RPC-server and connects to the EPP back-end system. Connection to this server is carried out through RabbitMQ RPC-client.' ,
295
+ prog = 'epp-gate' ,
296
+ usage = '%prog --epp=<EPP credentials file path> --rabbitmq=<RabbitMQ credentials file path> --queue=<queue name>'
297
+ )
298
+ p .add_option (
299
+ '--epp' ,
300
+ '-e' ,
301
+ help = "path to the local text file that stores EPP connection info, format:\n epp.host.com 700 login password" ,
302
+ default = "./epp_credentials" ,
303
+ )
304
+ p .add_option (
305
+ '--rabbitmq' ,
306
+ '-r' ,
307
+ help = "path to the local text file that stores RabbitMQ connection info, format:\n hostname 5672 login password" ,
308
+ default = "./rabbitmq_credentials" ,
309
+ )
310
+ p .add_option (
311
+ '--queue' ,
312
+ '-q' ,
313
+ help = "RabbitMQ queue name" ,
314
+ default = "epp_messages" ,
315
+ )
316
+ p .add_option (
317
+ '--reconnect' ,
318
+ action = "store_true" ,
319
+ dest = "reconnect" ,
320
+ help = "automatically reconnect to the EPP system when connection was closed on server side" ,
321
+ )
322
+ p .add_option (
323
+ '--verbose' ,
324
+ '-v' ,
325
+ action = "store_true" ,
326
+ dest = "verbose" ,
327
+ help = "enable verbose logging" ,
328
+ )
329
+
330
+ options , arguments = p .parse_args ()
331
+
293
332
logging .basicConfig (
294
- level = logging .DEBUG ,
333
+ level = logging .DEBUG if options . verbose else logging . WARNING ,
295
334
stream = sys .stdout ,
296
335
format = '%(asctime)s %(message)s' ,
297
336
datefmt = '%Y-%m-%d %H:%M:%S' ,
298
337
)
299
338
logging .getLogger ('pika' ).setLevel (logging .WARNING )
300
339
301
340
srv = EPP_RPC_Server (
302
- epp_params = open (sys . argv [ 1 ] , 'r' ).read ().split (' ' ),
303
- rabbitmq_params = open (sys . argv [ 2 ] , 'r' ).read ().split (' ' ),
304
- queue_name = 'epp_messages' ,
305
- epp_reconnect = True ,
306
- verbose = True ,
341
+ epp_params = open (options . epp , 'r' ).read ().split (' ' ),
342
+ rabbitmq_params = open (options . rabbitmq , 'r' ).read ().split (' ' ),
343
+ queue_name = options . queue ,
344
+ epp_reconnect = options . reconnect ,
345
+ verbose = options . verbose ,
307
346
)
308
347
if not srv .connect_epp ():
309
348
return False
0 commit comments