Пример #1
0
def run_init(storage_path, use_sso=False, skip_cert_verify=False):
    config = ConfigHelper(storage_path)

    if config.is_present():
        do_override_input = cutie.prompt_yes_or_no(
            'Do you want to override the existing config?')

        if not do_override_input:
            sys.exit(0)

    MailService(config).interactively_configure()

    do_sentry = cutie.prompt_yes_or_no(
        'Do you want to configure Error Reporting via Sentry?')
    if do_sentry:
        sentry_dsn = input('Please enter your Sentry DSN:   ')
        config.set_property('sentry_dsn', sentry_dsn)

    moodle = MoodleService(config, storage_path, skip_cert_verify)

    if (use_sso):
        moodle.interactively_acquire_sso_token()
    else:
        moodle.interactively_acquire_token()

    print('Configuration finished and saved!')

    if (storage_path == '.'):
        print(
            '  To set a cron-job for this program on your Unix-System:\n' +
            '    1. `crontab -e`\n' +
            '    2. Add `*/15 * * * * cd %s && python3 %smain.py`\n' % (
                os.getcwd(), os.path.join(os.path.dirname(
                    os.path.realpath(__file__)), '')) +
            '    3. Save and you\'re done!'
        )
    else:
        print(
            '  To set a cron-job for this program on your Unix-System:\n' +
            '    1. `crontab -e`\n' +
            '    2. Add `*/15 * * * *' +
            ' cd %s && python3 %smain.py --path %s`\n' % (
                os.getcwd(), os.path.join(os.path.dirname(
                    os.path.realpath(__file__)), ''), storage_path) +
            '    3. Save and you\'re done!'
        )

    print('')

    print('You can always do the additional configuration later' +
          ' with the --config option.')

    do_config = cutie.prompt_yes_or_no(
        'Do you want to make additional configurations now?')

    if do_config:
        run_configure(storage_path, skip_cert_verify)

    print('')
    print('All set and ready to go!')
Пример #2
0
def run_init(storage_path, use_sso=False, skip_cert_verify=False):
    config = ConfigHelper(storage_path)

    if config.is_present():
        do_override_input = input('Do you want to override the existing' +
                                  ' config [y/n]?   ').lower()
        while do_override_input not in ['y', 'n']:
            do_override_input = input('Unrecognized input.' +
                                      ' Try again:   ').lower()

        if do_override_input == 'n':
            sys.exit(0)

    MailService(config).interactively_configure()

    raw_do_sentry = ''
    while raw_do_sentry not in ['y', 'n']:
        raw_do_sentry = input('Do you want to configure Error Reporting via' +
                              ' Sentry? [y/n]   ').lower()
    if raw_do_sentry == 'y':
        sentry_dsn = input('Please enter your Sentry DSN:   ')
        config.set_property('sentry_dsn', sentry_dsn)

    moodle = MoodleService(config, storage_path, skip_cert_verify)

    if (use_sso):
        moodle.interactively_acquire_sso_token()
    else:
        moodle.interactively_acquire_token()

    print('Configuration finished and saved!')

    if (storage_path == '.'):
        print('  To set a cron-job for this program on your Unix-System:\n' +
              '    1. `crontab -e`\n' +
              '    2. Add `*/15 * * * * cd %s && python3 %smain.py`\n' %
              (os.getcwd(),
               os.path.join(os.path.dirname(os.path.realpath(__file__)), '')) +
              '    3. Save and you\'re done!')
    else:
        print('  To set a cron-job for this program on your Unix-System:\n' +
              '    1. `crontab -e`\n' + '    2. Add `*/15 * * * *' +
              ' cd %s && python3 %smain.py --path %s`\n' %
              (os.getcwd(),
               os.path.join(os.path.dirname(os.path.realpath(__file__)), ''),
               storage_path) + '    3. Save and you\'re done!')

    print('')
    raw_do_config = ''
    while raw_do_config not in ['y', 'n']:
        raw_do_config = input(
            'Do you want to make additional configurations now?' +
            ' You can always do the additional configuration later' +
            ' with the --config option. [y/n]   ').lower()
    if raw_do_config == 'y':
        run_configure(storage_path, skip_cert_verify)

    print('')
    print('All set and ready to go!')
Пример #3
0
def run_init(storage_path, use_sso=False, skip_cert_verify=False):
    config = ConfigHelper(storage_path)

    if config.is_present():
        do_override_input = cutie.prompt_yes_or_no(
            Log.error_str('Do you want to override the existing config?'))

        if not do_override_input:
            sys.exit(0)

    MailService(config).interactively_configure()
    TelegramService(config).interactively_configure()

    do_sentry = cutie.prompt_yes_or_no(
        'Do you want to configure Error Reporting via Sentry?')
    if do_sentry:
        sentry_dsn = input('Please enter your Sentry DSN:   ')
        config.set_property('sentry_dsn', sentry_dsn)

    moodle = MoodleService(config, storage_path, skip_cert_verify)

    if use_sso:
        moodle.interactively_acquire_sso_token()
    else:
        moodle.interactively_acquire_token()

    if os.name != 'nt':
        Log.info(
            'On Windows many characters are forbidden in filenames and paths, if you want, these characters can be'
            + ' automatically removed from filenames.')

        Log.warning(
            'If you want to view the downloaded files on Windows this is important!'
        )

        default_windows_map = cutie.prompt_yes_or_no(
            'Do you want to load the default filename character map for windows?'
        )
        if default_windows_map:
            config.set_default_filename_character_map(True)
        else:
            config.set_default_filename_character_map(False)
    else:
        config.set_default_filename_character_map(True)

    Log.success('Configuration finished and saved!')

    if os.name != 'nt':
        if storage_path == '.':
            Log.info(
                '  To set a cron-job for this program on your Unix-System:\n' +
                '    1. `crontab -e`\n' +
                '    2. Add `*/15 * * * * cd %s && python3 %smain.py`\n' %
                (os.getcwd(),
                 os.path.join(os.path.dirname(os.path.realpath(__file__)), ''))
                + '    3. Save and you\'re done!')
        else:
            Log.info(
                '  To set a cron-job for this program on your Unix-System:\n' +
                '    1. `crontab -e`\n' + '    2. Add `*/15 * * * *' +
                ' cd %s && python3 %smain.py --path %s`\n' %
                (os.getcwd(),
                 os.path.join(os.path.dirname(os.path.realpath(__file__)), ''),
                 storage_path) + '    3. Save and you\'re done!')

    print('')

    Log.info(
        'You can always do the additional configuration later with the --config option.'
    )

    do_config = cutie.prompt_yes_or_no(
        'Do you want to make additional configurations now?')

    if do_config:
        run_configure(storage_path, skip_cert_verify)

    print('')
    Log.success('All set and ready to go!')