zulip_bots run.py: Rename options to args.
This commit is contained in:
parent
c6e7ddfb03
commit
0a588dad55
|
@ -76,9 +76,9 @@ def parse_args():
|
||||||
parser.add_argument('--provision',
|
parser.add_argument('--provision',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help='Install dependencies for the bot.')
|
help='Install dependencies for the bot.')
|
||||||
options = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
if not options.name and not options.path_to_bot:
|
if not args.name and not args.path_to_bot:
|
||||||
error_message = """
|
error_message = """
|
||||||
You must either specify the name of an existing bot or
|
You must either specify the name of an existing bot or
|
||||||
specify a path to the file (--path-to-bot) that contains
|
specify a path to the file (--path-to-bot) that contains
|
||||||
|
@ -89,40 +89,40 @@ the bot handler class.
|
||||||
# checks if both of these are in sync, otherwise we'll
|
# checks if both of these are in sync, otherwise we'll
|
||||||
# have to be bias towards one and the user may get incorrect
|
# have to be bias towards one and the user may get incorrect
|
||||||
# result.
|
# result.
|
||||||
elif not name_and_path_match(options.name, options.path_to_bot):
|
elif not name_and_path_match(args.name, args.path_to_bot):
|
||||||
error_message = """
|
error_message = """
|
||||||
Please make sure that the given name of the bot and the
|
Please make sure that the given name of the bot and the
|
||||||
given path to the bot are same and valid.
|
given path to the bot are same and valid.
|
||||||
"""
|
"""
|
||||||
parser.error(error_message)
|
parser.error(error_message)
|
||||||
|
|
||||||
return options
|
return args
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
# type: () -> None
|
# type: () -> None
|
||||||
options = parse_args()
|
args = parse_args()
|
||||||
bot_name = options.name
|
bot_name = args.name
|
||||||
if options.path_to_bot:
|
if args.path_to_bot:
|
||||||
if options.provision:
|
if args.provision:
|
||||||
bot_dir = os.path.dirname(os.path.abspath(options.path_to_bot))
|
bot_dir = os.path.dirname(os.path.abspath(args.path_to_bot))
|
||||||
provision_bot(bot_dir, options.force)
|
provision_bot(bot_dir, args.force)
|
||||||
lib_module = import_module_from_source(options.path_to_bot, name=bot_name)
|
lib_module = import_module_from_source(args.path_to_bot, name=bot_name)
|
||||||
elif options.name:
|
elif args.name:
|
||||||
if options.provision:
|
if args.provision:
|
||||||
current_dir = os.path.dirname(os.path.abspath(__file__))
|
current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
bots_parent_dir = os.path.join(current_dir, "bots")
|
bots_parent_dir = os.path.join(current_dir, "bots")
|
||||||
bot_dir = os.path.join(bots_parent_dir, options.name)
|
bot_dir = os.path.join(bots_parent_dir, args.name)
|
||||||
provision_bot(bot_dir, options.force)
|
provision_bot(bot_dir, args.force)
|
||||||
lib_module = import_module('zulip_bots.bots.{bot}.{bot}'.format(bot=bot_name))
|
lib_module = import_module('zulip_bots.bots.{bot}.{bot}'.format(bot=bot_name))
|
||||||
|
|
||||||
if not options.quiet:
|
if not args.quiet:
|
||||||
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
|
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
|
||||||
|
|
||||||
run_message_handler_for_bot(
|
run_message_handler_for_bot(
|
||||||
lib_module=lib_module,
|
lib_module=lib_module,
|
||||||
config_file=options.config_file,
|
config_file=args.config_file,
|
||||||
quiet=options.quiet,
|
quiet=args.quiet,
|
||||||
bot_name=bot_name
|
bot_name=bot_name
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue