Ejemplo n.º 1
0
def fetch_profiles(from_file=None):
    profiles = {}
    try:
        if from_file is None:
            settings = QtCore.QSettings()
        else:
            settings = QtCore.QSettings(from_file, QtCore.QSettings.IniFormat)

        size = settings.beginReadArray('database_profiles')

        if size == 0:
            return profiles

        for index in range(size):
            settings.setArrayIndex(index)
            info = {}
            profilename = unicode(settings.value('profilename', QtCore.QVariant('')).toString(), 'utf-8')
            if not profilename:
                continue  # well we should not really be doing anything
            info['dialect'] = _decode_setting(settings.value('dialect', QtCore.QVariant('')).toString())
            info['host'] = _decode_setting(settings.value('host', QtCore.QVariant('')).toString())
            info['port'] = _decode_setting(settings.value('port', QtCore.QVariant('')).toString())
            info['database'] = _decode_setting(settings.value('database', QtCore.QVariant('')).toString())
            info['user'] = _decode_setting(settings.value('user', QtCore.QVariant('')).toString())
            info['pass'] = _decode_setting(settings.value('pass', QtCore.QVariant('')).toString())
            info['media_location'] = _decode_setting(settings.value('media_location', QtCore.QVariant('')).toString())
            info['locale_language'] = _decode_setting(settings.value('locale_language', QtCore.QVariant('')).toString())
            info['proxy_host'] = _decode_setting(settings.value('proxy_host', QtCore.QVariant('')).toString())
            info['proxy_port'] = _decode_setting(settings.value('proxy_port', QtCore.QVariant('')).toString())
            info['proxy_username'] = _decode_setting(settings.value('proxy_username', QtCore.QVariant('')).toString())
            info['proxy_password'] = _decode_setting(settings.value('proxy_password', QtCore.QVariant('')).toString())
            profiles[profilename] = info
        settings.endArray()
    except Exception, e:
        logger.warn('Could not read existing profiles, proceed with what was available', exc_info=e)
Ejemplo n.º 2
0
def fetch_profiles(from_file=None):
    profiles = {}
    try:
        if from_file is None:
            settings = QtCore.QSettings()
        else:
            settings = QtCore.QSettings(from_file, QtCore.QSettings.IniFormat)

        size = settings.beginReadArray('database_profiles')

        if size == 0:
            return profiles

        for index in range(size):
            settings.setArrayIndex(index)
            info = {}
            profilename = unicode(settings.value('profilename', QtCore.QVariant('')).toString(), 'utf-8')
            if not profilename:
                continue  # well we should not really be doing anything
            info['dialect'] = _decode_setting(settings.value('dialect', QtCore.QVariant('')).toString())
            info['host'] = _decode_setting(settings.value('host', QtCore.QVariant('')).toString())
            info['port'] = _decode_setting(settings.value('port', QtCore.QVariant('')).toString())
            info['database'] = _decode_setting(settings.value('database', QtCore.QVariant('')).toString())
            info['user'] = _decode_setting(settings.value('user', QtCore.QVariant('')).toString())
            info['pass'] = _decode_setting(settings.value('pass', QtCore.QVariant('')).toString())
            info['media_location'] = _decode_setting(settings.value('media_location', QtCore.QVariant('')).toString())
            info['locale_language'] = _decode_setting(settings.value('locale_language', QtCore.QVariant('')).toString())
            info['proxy_host'] = _decode_setting(settings.value('proxy_host', QtCore.QVariant('')).toString())
            info['proxy_port'] = _decode_setting(settings.value('proxy_port', QtCore.QVariant('')).toString())
            info['proxy_username'] = _decode_setting(settings.value('proxy_username', QtCore.QVariant('')).toString())
            info['proxy_password'] = _decode_setting(settings.value('proxy_password', QtCore.QVariant('')).toString())
            profiles[profilename] = info
        settings.endArray()
    except Exception, e:
        logger.warn('Could not read existing profiles, proceed with what was available', exc_info=e)
Ejemplo n.º 3
0
def fetch_profiles(from_file=None):
    profiles = {}
    try:
        if from_file is None:
            settings = QtCore.QSettings()
        else:
            settings = QtCore.QSettings(from_file, QtCore.QSettings.IniFormat)

        size = settings.beginReadArray("database_profiles")

        if size == 0:
            return profiles

        for index in range(size):
            settings.setArrayIndex(index)
            info = {}
            profilename = unicode(settings.value("profilename", QtCore.QVariant("")).toString(), "utf-8")
            if not profilename:
                continue  # well we should not really be doing anything
            info["dialect"] = _decode_setting(settings.value("dialect", QtCore.QVariant("")).toString())
            info["host"] = _decode_setting(settings.value("host", QtCore.QVariant("")).toString())
            info["port"] = _decode_setting(settings.value("port", QtCore.QVariant("")).toString())
            info["database"] = _decode_setting(settings.value("database", QtCore.QVariant("")).toString())
            info["user"] = _decode_setting(settings.value("user", QtCore.QVariant("")).toString())
            info["pass"] = _decode_setting(settings.value("pass", QtCore.QVariant("")).toString())
            info["media_location"] = _decode_setting(settings.value("media_location", QtCore.QVariant("")).toString())
            info["locale_language"] = _decode_setting(settings.value("locale_language", QtCore.QVariant("")).toString())
            info["proxy_host"] = _decode_setting(settings.value("proxy_host", QtCore.QVariant("")).toString())
            info["proxy_port"] = _decode_setting(settings.value("proxy_port", QtCore.QVariant("")).toString())
            info["proxy_username"] = _decode_setting(settings.value("proxy_username", QtCore.QVariant("")).toString())
            info["proxy_password"] = _decode_setting(settings.value("proxy_password", QtCore.QVariant("")).toString())
            profiles[profilename] = info
        settings.endArray()
    except Exception, e:
        logger.warn("Could not read existing profiles, proceed with what was available", exc_info=e)
Ejemplo n.º 4
0
def store_profiles(profiles, to_file=None):
    if to_file is None:
        settings = QtCore.QSettings()
    else:
        settings = QtCore.QSettings(to_file, QtCore.QSettings.IniFormat)

    settings.beginWriteArray('database_profiles')

    for index, (profilename, info) in enumerate(profiles.items()):
        settings.setArrayIndex(index)
        settings.setValue('profilename', QtCore.QVariant(unicode(profilename).encode('utf-8')))
        settings.setValue('dialect', QtCore.QVariant(_encode_setting(info['dialect'])))
        settings.setValue('host', QtCore.QVariant(_encode_setting(info['host'])))
        settings.setValue('port', QtCore.QVariant(_encode_setting(info['port'])))
        settings.setValue('database', QtCore.QVariant(_encode_setting(info['database'])))
        settings.setValue('user', QtCore.QVariant(_encode_setting(info['user'])))
        settings.setValue('pass', QtCore.QVariant(_encode_setting(info['pass'])))
        settings.setValue('media_location', QtCore.QVariant(_encode_setting(info['media_location'])))
        settings.setValue('locale_language', QtCore.QVariant(_encode_setting(info['locale_language'])))
        settings.setValue('proxy_host', QtCore.QVariant(_encode_setting(info['proxy_host'])))
        settings.setValue('proxy_port', QtCore.QVariant(_encode_setting(info['proxy_port'])))
        settings.setValue('proxy_username', QtCore.QVariant(_encode_setting(info['proxy_username'])))
        settings.setValue('proxy_password', QtCore.QVariant(_encode_setting(info['proxy_password'])))
    settings.endArray()
Ejemplo n.º 5
0
def store_profiles(profiles, to_file=None):
    if to_file is None:
        settings = QtCore.QSettings()
    else:
        settings = QtCore.QSettings(to_file, QtCore.QSettings.IniFormat)

    settings.beginWriteArray('database_profiles')

    for index, (profilename, info) in enumerate(profiles.items()):
        settings.setArrayIndex(index)
        settings.setValue('profilename', QtCore.QVariant(unicode(profilename).encode('utf-8')))
        settings.setValue('dialect', QtCore.QVariant(_encode_setting(info['dialect'])))
        settings.setValue('host', QtCore.QVariant(_encode_setting(info['host'])))
        settings.setValue('port', QtCore.QVariant(_encode_setting(info['port'])))
        settings.setValue('database', QtCore.QVariant(_encode_setting(info['database'])))
        settings.setValue('user', QtCore.QVariant(_encode_setting(info['user'])))
        settings.setValue('pass', QtCore.QVariant(_encode_setting(info['pass'])))
        settings.setValue('media_location', QtCore.QVariant(_encode_setting(info['media_location'])))
        settings.setValue('locale_language', QtCore.QVariant(_encode_setting(info['locale_language'])))
        settings.setValue('proxy_host', QtCore.QVariant(_encode_setting(info['proxy_host'])))
        settings.setValue('proxy_port', QtCore.QVariant(_encode_setting(info['proxy_port'])))
        settings.setValue('proxy_username', QtCore.QVariant(_encode_setting(info['proxy_username'])))
        settings.setValue('proxy_password', QtCore.QVariant(_encode_setting(info['proxy_password'])))
    settings.endArray()
Ejemplo n.º 6
0
def store_profiles(profiles, to_file=None):
    if to_file is None:
        settings = QtCore.QSettings()
    else:
        settings = QtCore.QSettings(to_file, QtCore.QSettings.IniFormat)

    settings.beginWriteArray("database_profiles")

    for index, (profilename, info) in enumerate(profiles.items()):
        settings.setArrayIndex(index)
        settings.setValue("profilename", QtCore.QVariant(unicode(profilename).encode("utf-8")))
        settings.setValue("dialect", QtCore.QVariant(_encode_setting(info["dialect"])))
        settings.setValue("host", QtCore.QVariant(_encode_setting(info["host"])))
        settings.setValue("port", QtCore.QVariant(_encode_setting(info["port"])))
        settings.setValue("database", QtCore.QVariant(_encode_setting(info["database"])))
        settings.setValue("user", QtCore.QVariant(_encode_setting(info["user"])))
        settings.setValue("pass", QtCore.QVariant(_encode_setting(info["pass"])))
        settings.setValue("media_location", QtCore.QVariant(_encode_setting(info["media_location"])))
        settings.setValue("locale_language", QtCore.QVariant(_encode_setting(info["locale_language"])))
        settings.setValue("proxy_host", QtCore.QVariant(_encode_setting(info["proxy_host"])))
        settings.setValue("proxy_port", QtCore.QVariant(_encode_setting(info["proxy_port"])))
        settings.setValue("proxy_username", QtCore.QVariant(_encode_setting(info["proxy_username"])))
        settings.setValue("proxy_password", QtCore.QVariant(_encode_setting(info["proxy_password"])))
    settings.endArray()