4

I would like to remove the official repository from several QGIS installations.

Removing the Repository from the Settings works so far with:

from qgis.PyQt.QtCore import QSettings
settings=QSettings()

test=settings.allKeys()
for i in test:
    if u'Qgis/plugin-repos/' in i:
        if u'/url' in i:
            if settings.value(i)==u'https://plugins.qgis.org/plugins/plugins.xml':
                repo_key = i.rsplit('/', 1)[0]
                settings.setValue(i,'')
                settings.remove(repo_key);

but as soon as QGIS is started the next time the repository is added to the settings again.

How can I remove it permanently?

2 Answers 2

3

I was able to remove the official repository by removing it during startup and replacing the official repository with my repository by editing the installer_data.py of the QGIS installation.

I just replaced the line where the official repository is defined:

https://github.com/qgis/QGIS/blob/ec2ddb4295badd6953237e5e9182b7903f429e5a/python/pyplugin_installer/installer_data.py#L97

old:
officialRepo = (QCoreApplication.translate("QgsPluginInstaller", "QGIS Official Plugin Repository"), "https://plugins.qgis.org/plugins/plugins.xml")

new:
officialRepo = ("my Repository name", "my repository url")
0
1

Your code is correct, but the official repository can't be deleted. Every time you open QGIS it's reset (file installer_data.py, on my pc "C: \ OSGeo4W64 \ apps \ qgis-ltr \ python \ pyplugin_installer \ installer_data.py ").

To avoid this you can create a startup.py file, but I do not know if it can work.

Another solution is to make a minimal plugin, that simply execute that code, that way you could avoid it and you will only have to copy that plugin in those machines

1
  • 1
    I had already added the code in the startup.py but even if the setting is deleted during startup the repository exists in the plugin manager. If a plugin removes the settings after startup the result is the same
    – Thomas B
    Commented Oct 11, 2018 at 8:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.