Example #1
0
    def __init__(self):
        # repo_id -> version map
        self.version_table = {}
        # repo_dir -> request usk map
        self.request_usks = {}
        # repo_id -> insert uri map
        self.insert_usks = {}
        # fms_id -> (usk_hash, ...) map
        self.fmsread_trust_map = DEFAULT_TRUST.copy()
        self.fmsread_groups = DEFAULT_GROUPS

        self.file_name = None

        # Use a dict instead of members to avoid pylint R0902.
        self.defaults = {}  # REDFLAG: Why is this called defaults? BAD NAME
        self.defaults['HOST'] = '127.0.0.1'
        self.defaults['PORT'] = 9481
        self.defaults['TMP_DIR'] = None
        self.defaults['DEFAULT_PRIVATE_KEY'] = None

        self.defaults['FMS_HOST'] = '127.0.0.1'
        self.defaults['FMS_PORT'] = 1119
        self.defaults['FMS_ID'] = None  # User must set this in config.
        self.defaults['FMSNOTIFY_GROUP'] = DEFAULT_NOTIFICATION_GROUP

        self.defaults['FORMAT_VERSION'] = 'Unknown'  # Read from file.
Example #2
0
    def __init__(self):
        # repo_id -> version map
        self.version_table = {}
        # repo_dir -> request usk map
        self.request_usks = {}
        # repo_id -> insert uri map
        self.insert_usks = {}
        # fms_id -> (usk_hash, ...) map
        self.fmsread_trust_map = DEFAULT_TRUST.copy()
        self.fmsread_groups = DEFAULT_GROUPS

        self.file_name = None

        # Use a dict instead of members to avoid pylint R0902.
        self.defaults = {} # REDFLAG: Why is this called defaults? BAD NAME
        self.defaults['HOST'] = '127.0.0.1'
        self.defaults['PORT'] = 9481
        self.defaults['TMP_DIR'] = None
        self.defaults['DEFAULT_PRIVATE_KEY'] = None

        self.defaults['FMS_HOST'] = '127.0.0.1'
        self.defaults['FMS_PORT'] = 1119
        self.defaults['FMS_ID'] = None # User must set this in config.
        self.defaults['FMSNOTIFY_GROUP'] = DEFAULT_NOTIFICATION_GROUP

        self.defaults['FORMAT_VERSION'] = 'Unknown' # Read from file.
Example #3
0
def get_config_info(ui_, opts):
    """ INTERNAL: Read configuration info out of the config file and
        or command line options. """

    cfg = Config.from_ui(ui_)
    if cfg.defaults['FORMAT_VERSION'] != FORMAT_VERSION:
        ui_.warn(('Updating config file: %s\n' +
                  'From format version: %s\nTo format version: %s\n') %
                 (str(cfg.file_name), cfg.defaults['FORMAT_VERSION'],
                  FORMAT_VERSION))

        # Hacks to clean up variables that were set wrong.
        if not cfg.fmsread_trust_map:
            ui_.warn('Set default trust map.\n')
            cfg.fmsread_trust_map = DEFAULT_TRUST.copy()
        if not cfg.fmsread_groups or cfg.fmsread_groups == [
                '',
        ]:
            ui_.warn('Set default fmsread groups.\n')
            cfg.fmsread_groups = DEFAULT_GROUPS
        Config.to_file(cfg)
        ui_.warn('Converted OK.\n')

    if opts.get('fcphost') != '':
        cfg.defaults['HOST'] = opts['fcphost']
    if opts.get('fcpport') != 0:
        cfg.defaults['PORT'] = opts['fcpport']

    params = DEFAULT_PARAMS.copy()
    params['FCP_HOST'] = cfg.defaults['HOST']
    params['FCP_PORT'] = cfg.defaults['PORT']
    params['TMP_DIR'] = cfg.defaults['TMP_DIR']
    params['VERBOSITY'] = get_verbosity(ui_)
    params['NO_SEARCH'] = (bool(opts.get('nosearch'))
                           and (opts.get('uri', None)
                                or opts.get('requesturi', None)))

    request_uri = opts.get('uri') or opts.get('requesturi')
    if bool(opts.get('nosearch')) and not request_uri:
        if opts.get('uri'):
            arg_name = 'uri'
        else:
            assert opts.get('requesturi')
            arg_name = 'requesturi'

        ui_.status('--nosearch ignored because --%s was not set.\n' % arg_name)
    params['AGGRESSIVE_SEARCH'] = (bool(opts.get('aggressive'))
                                   and not params['NO_SEARCH'])
    if bool(opts.get('aggressive')) and params['NO_SEARCH']:
        ui_.status('--aggressive ignored because --nosearch was set.\n')

    return (params, cfg)
Example #4
0
def get_config_info(ui_, opts):
    """ INTERNAL: Read configuration info out of the config file and
        or command line options. """

    cfg = Config.from_ui(ui_)
    if cfg.defaults['FORMAT_VERSION'] != FORMAT_VERSION:
        ui_.warn(('Updating config file: %s\n'
                  + 'From format version: %s\nTo format version: %s\n') %
                 (str(cfg.file_name),
                  cfg.defaults['FORMAT_VERSION'],
                  FORMAT_VERSION))

        # Hacks to clean up variables that were set wrong.
        if not cfg.fmsread_trust_map:
            ui_.warn('Set default trust map.\n')
            cfg.fmsread_trust_map = DEFAULT_TRUST.copy()
        if not cfg.fmsread_groups or cfg.fmsread_groups == ['', ]:
            ui_.warn('Set default fmsread groups.\n')
            cfg.fmsread_groups = DEFAULT_GROUPS
        Config.to_file(cfg)
        ui_.warn('Converted OK.\n')

    if opts.get('fcphost') != '':
        cfg.defaults['HOST'] = opts['fcphost']
    if opts.get('fcpport') != 0:
        cfg.defaults['PORT'] = opts['fcpport']

    params = DEFAULT_PARAMS.copy()
    params['FCP_HOST'] = cfg.defaults['HOST']
    params['FCP_PORT'] = cfg.defaults['PORT']
    params['TMP_DIR'] = cfg.defaults['TMP_DIR']
    params['VERBOSITY'] = get_verbosity(ui_)
    params['NO_SEARCH'] = (bool(opts.get('nosearch')) and
                           (opts.get('uri', None) or
                            opts.get('requesturi', None)))

    request_uri = opts.get('uri') or opts.get('requesturi')
    if bool(opts.get('nosearch')) and not request_uri:
        if opts.get('uri'):
            arg_name = 'uri'
        else:
            assert opts.get('requesturi')
            arg_name = 'requesturi'

        ui_.status('--nosearch ignored because --%s was not set.\n' % arg_name)
    params['AGGRESSIVE_SEARCH'] = (bool(opts.get('aggressive')) and
                                   not params['NO_SEARCH'])
    if bool(opts.get('aggressive')) and params['NO_SEARCH']:
        ui_.status('--aggressive ignored because --nosearch was set.\n')

    return (params, cfg)
Example #5
0
    def __init__(self):
        # repo_id -> version map
        self.version_table = {}
        # repo_dir -> request usk map
        self.request_usks = {}
        # repo_id -> insert uri map
        self.insert_usks = {}
        # repo id -> publisher WoT identity ID
        self.wot_identities = {}
        # TODO: Should this be keyed by str(WoT_ID) ?
        # WoT identity ID -> Freemail password
        self.freemail_passwords = {}
        # WoT identity ID -> last known repo list edition.
        # TODO: Once WoT allows setting a property without triggering an
        # immediate insert, this can move to a WoT property. (Can then query
        # remote identities! Easier bootstrapping than from edition 0.)
        self.repo_list_editions = {}
        # fms_id -> (usk_hash, ...) map
        self.fmsread_trust_map = DEFAULT_TRUST.copy()
        self.fmsread_groups = DEFAULT_GROUPS

        self.file_name = None

        # Use a dict instead of members to avoid pylint R0902.

        # REDFLAG: Why is this called defaults? BAD NAME. Perhaps 'values'? 
        # That would conflict with the .values() method of
        # dictionaries. config.config sounds OK, I think (though it is
        # a bit awkward to have the same name twice. But that is also
        # done at other places, IIRC, so it should not be too
        # surprising).
        self.defaults = {}
        self.defaults['HOST'] = '127.0.0.1'
        self.defaults['PORT'] = 9481
        self.defaults['TMP_DIR'] = None
        self.defaults['DEFAULT_PRIVATE_KEY'] = None
        self.defaults['DEFAULT_TRUSTER'] = ''

        self.defaults['FMS_HOST'] = '127.0.0.1'
        self.defaults['FMS_PORT'] = 1119
        self.defaults['FMS_ID'] = None # User must set this in config.
        self.defaults['FMSNOTIFY_GROUP'] = DEFAULT_NOTIFICATION_GROUP

        self.defaults['FORMAT_VERSION'] = 'Unknown' # Read from file.