hakan42 / calibre-beam-ebooks-downloader-plugin

A Plugin to automatically download new ebooks from beam-ebooks.de
0 stars 0 forks source link

Store options in library #4

Open hakan42 opened 11 years ago

hakan42 commented 11 years ago

For running plugin on multiple computers

hakan42 commented 11 years ago

Options except for authentication info, just in case the library.db ends up where it shouldn't be

hakan42 commented 11 years ago

From fanfictiondownloaderplugin/prefs.py:

def set_library_config(library_config,db):
    db.prefs.set_namespaced(PREFS_NAMESPACE,
                            PREFS_KEY_SETTINGS,
                            library_config)

def get_library_config(db):
    library_id = get_library_uuid(db)
    library_config = None
    # Check whether this is a configuration needing to be migrated
    # from json into database.  If so: get it, set it, rename it in json.
    if library_id in old_prefs:
        #print("get prefs from old_prefs")
        library_config = old_prefs[library_id]
        set_library_config(library_config,db)
        old_prefs["migrated to library db %s"%library_id] = old_prefs[library_id]
        del old_prefs[library_id]

    if library_config is None:
        #print("get prefs from db")
        library_config = db.prefs.get_namespaced(PREFS_NAMESPACE, PREFS_KEY_SETTINGS,
                                                 copy.deepcopy(default_prefs))
    return library_config
hakan42 commented 11 years ago

Dump configuration to log file on startup