Skip to content

kconf_update: print error messages, and more debug in testMode

Méven Car requested to merge work/meven/improve-testMode into master

So that I can have errors printed when the script fails and standard output in testMode and allow to load script from local path in testMode.

$ ~/kde6/build/kconfig/bin/kconf_update --testmode --debug ./directorycount-enum.upd
Automatically enabled the debug logging category kf.config.kconf_update
kf.config.kconf_update: Checking update-file "./directorycount-enum.upd" for new updates
kf.config.kconf_update: "directorycount-enum.upd" : Found new update "\"directorycount-enum\""
kf.config.kconf_update: "directorycount-enum.upd" : 3 :' "Script=directorycount-enum.py,python3" ':  Loading local script "directorycount-enum.py"  should be installed to "/home/meven/kde6/usr/lib/x86_64-linux-gnu/kconf_update_bin/directorycount-enum.py"
kf.config.kconf_update: "directorycount-enum.upd" : Running script "directorycount-enum.py"
kf.config.kconf_update: "About to run /usr/bin/python3 directorycount-enum.py"
kf.config.kconf_update: Script contents is:
 #!/usr/bin/env python
import os
import shutil
from tempfile import mkstemp

home = os.environ['HOME']

dolphin_config_file = home + "/.config/dolphinrc"

fd, name = mkstemp()
fout = open(name, 'w')

with open(dolphin_config_file, 'r', encoding='utf-8') as dolphinrc:
    
    for line in dolphinrc.readlines():
        if line.startswith("DirectorySizeCount=true"):
            fout.write("DirectorySizeCount=DirectorySizeOneOneLevel\n")
        elif line.startswith("DirectorySizeCount=false"):
            fout.write("DirectorySizeCount=DirectorySizeRecursive\n")
        else:
            fout.write(line)

shutil.move(name, dolphin_config_file) 

kf.config.kconf_update: Successfully ran "/usr/bin/python3"

Merge request reports