Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7790350

Browse files
committedApr 30, 2021
added command line options to epp-gate script
1 parent 74f1b5d commit 7790350

File tree

1 file changed

+45
-6
lines changed

1 file changed

+45
-6
lines changed
 

‎src/epp/rpc_server.py

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -290,20 +290,59 @@ def do_process_epp_command(self, request_json):
290290
#------------------------------------------------------------------------------
291291

292292
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:\nepp.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:\nhostname 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+
293332
logging.basicConfig(
294-
level=logging.DEBUG,
333+
level=logging.DEBUG if options.verbose else logging.WARNING,
295334
stream=sys.stdout,
296335
format='%(asctime)s %(message)s',
297336
datefmt='%Y-%m-%d %H:%M:%S',
298337
)
299338
logging.getLogger('pika').setLevel(logging.WARNING)
300339

301340
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,
307346
)
308347
if not srv.connect_epp():
309348
return False

0 commit comments

Comments
 (0)
Please sign in to comment.