guisettings.xml vs ViewModes6.db
#1
I know accessing databases directly is not something that should be done, but I'm trying to reset (set) globally the viewmodes with a Python addon.

Now to the question..
I see some viewmodes are stored in both guisettings.xml and viewmode6.db (DB), which one has priority over the other? or changes should be made to both at once?
or does guisettings.xml just set the "root" view which sticks unless DB says different?

in which case by editing guisettings.xml content and completely deleting DB.. it should be easy to set views.
Am I close?

help.

Also, If i missed a simpler way to globally set (reset) views all across the system, please forgive the question and let me know.

thanks.
Image Image
Did I Help? Add to my reputation
Reply
#2
I came up with this...
Code:
import os
import sys
import xbmc
import xbmcgui
import xbmcplugin
import xbmcaddon
import random
import urllib
import shutil
import glob, os
from xml.dom import minidom

__addon__     = xbmcaddon.Addon()
__addonid__   = __addon__.getAddonInfo('id')
__language__  = __addon__.getLocalizedString


dialog = xbmcgui.Dialog()
localtxt2 = __language__(32007)
localtxt3 = xbmc.getLocalizedString(750)
# prnum= sys.argv[ 1 ]

path = xbmc.translatePath(os.path.join('special://home/userdata',''))

def replaceText(node, newText):

    node.firstChild.replaceWholeText(newText)

def viewsdb():
    localtxt1 = __language__(32004)
    if dialog.yesno(localtxt1, localtxt3):
        database = os.path.join(path, 'Database/ViewModes*.db')
        print database
        filelist = glob.glob(database)
        print filelist
        if filelist != []:
            for f in filelist:
                print f
                os.remove(f)
            xbmc.executebuiltin("Notification("+localtxt2+",Restart Kodi)")
        else:
            print 'merdaa'
            xbmc.executebuiltin("Notification(Error,File doesn't exists)")

        viewsettings = os.path.join(path, 'guisettings.xml')
        data = minidom.parse(viewsettings)
        for node in data.getElementsByTagName('viewmode'):
            # print node.toxml()
            replaceText(node, "458802")
            print node.toxml()
        f = open(viewsettings, 'w')
        data.writexml( f )
        f.close()

#------------------

viewsdb()
changes <viewmodes> to 458802

and erases viewmodes.db

but

when kodi starts.. nothing has changed!!!! Rolleyes Sad
Image Image
Did I Help? Add to my reputation
Reply
#3
I don't think you can change them while Kodi is actually running.
Reply
#4
(2014-11-13, 18:19)Hitcher Wrote: I don't think you can change them while Kodi is actually running.

i forgot to add that after running the addon i restart kodi. much like deleting textures.db (which actually works)

I checked timestamps and it seems database is recreated on startup not shutdown, and guisettings keeps the changes through restart...
but everything goes back to starting point, which kinda makes sense.

I wonder if there's a place to change those settings to make them stick. (I also believe - no empirical proof - ) that database is empty on creation, so i don't think that anything is in there when it gets built back..

where are viewed ACTUALLY stored.. and why they have those weird numbers is a mystery to me.

anybody with more core knowledge willing to help?

oooops . double posted
Image Image
Did I Help? Add to my reputation
Reply
#5
fastcolors, did you ever get that sorted ?
Reply

Logout Mark Read Team Forum Stats Members Help
guisettings.xml vs ViewModes6.db1