Beispiel #1
0
def gui_main():

    args = get_arguments()

    try:
        # todo: today we're redirecting api.abel.co so for this we need to go direct.  In the future have everything on AWS including DNS.
        sentry_dsn = requests.get('http://l3wp7vlxe8.execute-api.us-west-2.amazonaws.com/dev/apps/propmtime/sentrydsn').text
        if not (sentry_dsn.startswith('http') and '@sentry.io' in sentry_dsn):
            sentry_dsn = None
    except ConnectionError:
        sentry_dsn = None

    balsa = Balsa( __application_name__, __author__, gui=True, use_sentry=sentry_dsn is not None, sentry_dsn=sentry_dsn)
    balsa.init_logger_from_args(args)

    app_data_folder = appdirs.user_config_dir(appname=__application_name__, appauthor=__author__)
    init_preferences_db(app_data_folder)

    init_exit_control_event()

    app = QApplication(sys.argv)
    app.setQuitOnLastWindowClosed(False)  # so popup dialogs don't close the system tray icon
    system_tray = PropMTimeSystemTray(app, app_data_folder, balsa.log_path)
    system_tray.show()
    app.exec_()
Beispiel #2
0
def cli_main(args):

    ui_type = UITypes.cli

    balsa = Balsa(__application_name__, __author__)
    balsa.log_console_prefix = "\r"
    balsa.init_logger_from_args(args)
    log.info(f"__application_name__={__application_name__}")
    log.info(f"__author__={__author__}")
    log.info(f"__version__={__version__}")

    try:
        preferences = get_preferences(ui_type)
        preferences.backup_directory = args.path  # backup classes will read the preferences DB directly
        preferences.github_token = args.token
        preferences.aws_profile = args.profile

        # If setting the exclusions, just do it for one backup type at a time.  The values are stored for subsequent runs.
        if args.exclude is not None and len(args.exclude) > 0:
            if args.s3:
                ExclusionPreferences(BackupTypes.S3.name).set(args.exclude)
            elif args.dynamodb:
                ExclusionPreferences(BackupTypes.DynamoDB.name).set(
                    args.exclude)
            elif args.github:
                ExclusionPreferences(BackupTypes.github.name).set(args.exclude)

        did_something = False
        dynamodb_local_backup = None
        s3_local_backup = None
        github_local_backup = None
        if args.s3 or args.aws:
            s3_local_backup = S3Backup(ui_type, log.info, log.warning,
                                       log.error)
            s3_local_backup.start()
            did_something = True
        if args.dynamodb or args.aws:
            dynamodb_local_backup = DynamoDBBackup(ui_type, log.info,
                                                   log.warning, log.error)
            dynamodb_local_backup.start()
            did_something = True
        if args.github:
            github_local_backup = GithubBackup(ui_type, log.info, log.warning,
                                               log.error)
            github_local_backup.start()
            did_something = True
        if not did_something:
            print(
                "nothing to do - please specify a backup to do or -h/--help for help"
            )

        if dynamodb_local_backup is not None:
            dynamodb_local_backup.join()
        if s3_local_backup is not None:
            s3_local_backup.join()
        if github_local_backup is not None:
            github_local_backup.join()
    except Exception as e:
        log.exception(e)
Beispiel #3
0
def main():

    parser = argparse.ArgumentParser()
    parser.add_argument('-v', '--verbose', action='store_true', help='verbose')
    args = parser.parse_args()

    balsa = Balsa(application_name, author, error_callback=balsa_example_error_callback)
    balsa.init_logger_from_args(args)

    something_useful()
Beispiel #4
0
def cli_main():

    args = get_arguments()

    balsa = Balsa(__application_name__, __author__)
    balsa.init_logger_from_args(args)

    log_selections(args)

    init_exit_control_cli()

    pmt = PropMTime(args.path, not args.noupdate, args.hidden, args.system)
    pmt.start()
    pmt.join()  # pmt uses exit control
    if not args.silent:
        print()
        print(f'processed {pmt.files_folders_count} files/folders in {pmt.total_time} seconds')
Beispiel #5
0
def test_balsa_args():
    balsa = Balsa(application_name, __author__)
    balsa.init_logger_from_args(None)  # args is fake for now ...
    log.info(__file__)
Beispiel #6
0
def main():

    epilog = """
    cmpa - directory compare (by abel.co)

    Prints the result of the directory comparison.  Only the differences and the summary flag will be printed, unless 
    verbose is given (or if silent given then nothing will be printed). 

    - means extra files in first directory
    + means extra files in second directory
    ! means file contents mismatch
    = equality flag
    s summary

    process returns 1 if any mis-compares
    """

    parser = argparse.ArgumentParser(
        epilog=epilog, formatter_class=argparse.RawDescriptionHelpFormatter)
    parser.add_argument('directories',
                        nargs=2,
                        help='two directories to compare')
    parser.add_argument('-f',
                        '--filters',
                        nargs='*',
                        default=['*'],
                        help='file filters')
    parser.add_argument(
        '-e',
        '--exclude',
        nargs='*',
        default=[],
        help='exclude directories that start with these name(s)')
    parser.add_argument('-s',
                        '--silent',
                        action='store_true',
                        help='do not print')
    parser.add_argument(
        '-t',
        '--text',
        action='store_true',
        help='text based compare that ignores CR/LF differences')
    parser.add_argument('-i',
                        '--image',
                        action='store_true',
                        help='image based compare')
    parser.add_argument('--version',
                        action='store_true',
                        help='display version')
    parser.add_argument('-v', '--verbose', action='store_true', help='verbose')
    args = parser.parse_args()

    balsa = Balsa(__title__, __author__)
    balsa.init_logger_from_args(args)

    if args.version:
        print(__version__)

    cd = Compare(args.directories, args.filters, args.silent, args.text,
                 args.exclude, args.verbose)
    sys.exit(int(not cd.compare_ok_all))  # 0 is all compared OK, 1 otherwise