Print versions and exit.
(args)
| 255 | |
| 256 | |
| 257 | def print_versions(args): |
| 258 | """Print versions and exit.""" |
| 259 | versions = _("EH Forwarder Bot\n" |
| 260 | "Version: {version}\n" |
| 261 | "Python version:\n" |
| 262 | "{py_version}\n" |
| 263 | "Running on profile \"{profile}\"." |
| 264 | ).format(version=__version__, py_version=sys.version, profile=args.profile) |
| 265 | try: |
| 266 | if args.profile: |
| 267 | coordinator.profile = str(args.profile) |
| 268 | |
| 269 | conf = config.load_config() |
| 270 | # Master channel |
| 271 | master_channel: MasterChannel = utils.locate_module(conf['master_channel'], 'master') |
| 272 | instance_id = conf['master_channel'].split('#', 1)[1:] |
| 273 | instance_id = (instance_id and instance_id[0]) or _("Default instance") |
| 274 | versions += "\n\n" + _("Master channel:") + "\n " + _("{name} ({id}) {version} # {instance_id}") \ |
| 275 | .format(name=master_channel.channel_name, |
| 276 | id=master_channel.channel_id, |
| 277 | version=master_channel.__version__, |
| 278 | instance_id=instance_id) |
| 279 | versions += "\n\n" + ngettext("Slave channel:", "Slave channels:", len(conf['slave_channels'])) |
| 280 | for i in conf['slave_channels']: |
| 281 | instance_id = i.split('#', 1)[1:] |
| 282 | instance_id = (instance_id and instance_id[0]) or _("Default instance") |
| 283 | slave_channel: SlaveChannel = utils.locate_module(i, 'slave') |
| 284 | versions += "\n " + _("{name} ({id}) {version} # {instance_id}") \ |
| 285 | .format(name=slave_channel.channel_name, |
| 286 | id=slave_channel.channel_id, |
| 287 | version=slave_channel.__version__, |
| 288 | instance_id=instance_id) |
| 289 | versions += "\n\n" + ngettext("Middleware:", "Middlewares:", len(conf['middlewares'])) |
| 290 | if conf['middlewares']: |
| 291 | for i in conf['middlewares']: |
| 292 | instance_id = i.split('#', 1)[1:] |
| 293 | instance_id = (instance_id and instance_id[0]) or _("Default instance") |
| 294 | middleware: Middleware = utils.locate_module(i, 'middleware') |
| 295 | versions += "\n " + _("{name} ({id}) {version} # {instance_id}") \ |
| 296 | .format(name=middleware.middleware_name, |
| 297 | id=middleware.middleware_id, |
| 298 | version=middleware.__version__, |
| 299 | instance_id=instance_id) |
| 300 | else: |
| 301 | versions += "\n " + _("No middleware is enabled.") |
| 302 | finally: |
| 303 | print(versions) |
| 304 | |
| 305 | |
| 306 | def main(): |