()
| 579 | |
| 580 | |
| 581 | def main(): |
| 582 | parser = build_parser() |
| 583 | args = parser.parse_args() |
| 584 | subcommand = args.subcommand |
| 585 | |
| 586 | # Adjust logging level if terse output is set. |
| 587 | if args.terse: |
| 588 | log_help.set_level(logging.WARNING) |
| 589 | |
| 590 | # Handle version printing specially, because it doesn't need |
| 591 | # credentials. |
| 592 | if subcommand == 'version': |
| 593 | import pkgutil |
| 594 | |
| 595 | print(pkgutil.get_data('wal_e', 'VERSION').decode('ascii').strip()) |
| 596 | sys.exit(0) |
| 597 | |
| 598 | # Print a start-up message right away. |
| 599 | # |
| 600 | # Otherwise, it is hard to tell when and how WAL-E started in logs |
| 601 | # because often emits status output too late. |
| 602 | rendered = render_subcommand(args) |
| 603 | if rendered is not None: |
| 604 | logger.info(msg='starting WAL-E', |
| 605 | detail='The subcommand is "{0}".'.format(rendered)) |
| 606 | |
| 607 | try: |
| 608 | backup_cxt = configure_backup_cxt(args) |
| 609 | |
| 610 | if subcommand == 'backup-fetch': |
| 611 | monkeypatch_tarfile_copyfileobj() |
| 612 | |
| 613 | external_program_check([LZOP_BIN]) |
| 614 | backup_cxt.database_fetch( |
| 615 | args.PG_CLUSTER_DIRECTORY, |
| 616 | args.BACKUP_NAME, |
| 617 | blind_restore=args.blind_restore, |
| 618 | restore_spec=args.restore_spec, |
| 619 | pool_size=args.pool_size) |
| 620 | elif subcommand == 'backup-list': |
| 621 | backup_cxt.backup_list(query=args.QUERY, detail=args.detail) |
| 622 | elif subcommand == 'backup-push': |
| 623 | monkeypatch_tarfile_copyfileobj() |
| 624 | |
| 625 | if args.while_offline: |
| 626 | # we need to query pg_config first for the |
| 627 | # pg_controldata's bin location |
| 628 | external_program_check([CONFIG_BIN]) |
| 629 | parser = PgControlDataParser(args.PG_CLUSTER_DIRECTORY) |
| 630 | controldata_bin = parser.controldata_bin() |
| 631 | external_programs = [ |
| 632 | LZOP_BIN, |
| 633 | PV_BIN, |
| 634 | controldata_bin] |
| 635 | else: |
| 636 | external_programs = [LZOP_BIN, PSQL_BIN, PV_BIN] |
| 637 | |
| 638 | external_program_check(external_programs) |
no test coverage detected