Beispiel #1
0
def get_config(defaults, section):
    dir_root = get_config_dir()

    if dir_root is None:
        return {}

    configdir = os.path.join(dir_root, '.bittorrent')
        
    if not os.path.isdir(configdir):
        try:
            os.mkdir(configdir, 0700)
        except:
            pass

    p = _read_config(os.path.join(configdir, 'config'))
    values = {}
    if p.has_section(section):
        for name, value in p.items(section):
            if name in defaults:
                values[name] = value
    if p.has_section('common'):
        for name, value in p.items('common'):
            if name in defaults and name not in values:
                values[name] = value
    if defaults.get('data_dir') == '' and \
           'data_dir' not in values and os.path.isdir(configdir):
        datadir = os.path.join(configdir, 'data')
        values['data_dir'] = datadir
    parseargs.parse_options(defaults, values)
    return values
Beispiel #2
0
def get_config(defaults, section):
    dir_root = get_config_dir()

    if dir_root is None:
        return {}

    configdir = os.path.join(dir_root, '.bittorrent')

    if not os.path.isdir(configdir):
        try:
            os.mkdir(configdir, 0700)
        except:
            pass

    p = _read_config(os.path.join(configdir, 'config'))
    values = {}
    if p.has_section(section):
        for name, value in p.items(section):
            if name in defaults:
                values[name] = value
    if p.has_section('common'):
        for name, value in p.items('common'):
            if name in defaults and name not in values:
                values[name] = value
    if defaults.get('data_dir') == '' and \
           'data_dir' not in values and os.path.isdir(configdir):
        datadir = os.path.join(configdir, 'data')
        values['data_dir'] = datadir
    parseargs.parse_options(defaults, values)
    return values
Beispiel #3
0
 def _get_sic_path(self):
     directory = get_config_dir()
     configdir = os.path.join(directory, '.bittorrent')
     filename = os.path.join(configdir, ".btcontrol")
     return filename
Beispiel #4
0
 def get_sic_path(self):
     directory = get_config_dir()
     configdir = os.path.join(directory, '.bittorrent')
     filename = os.path.join(configdir, ".btcontrol")
     return filename