I'm trying to find a solution to launch a plugin from outside the QGIS console
I've succeeded to call the plugin from the python console in the QGIS software but I'm now trying to do it outside of QGIS when it's already opened
for QGIS plugin in python console the following works to launch the plugin:
import sys
sys.path.append(r"path/to/plugin")
from plugin_name_folder import plugin_name
execute = plugin_name.plugin_class(iface)
execute.initGui()
execute.run()
in order to launch the plugin, here's the beginning of the code pre-made by the plugin builder :
from PyQt5.QtCore import QSettings, QTranslator, qVersion, QCoreApplication
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QAction
from .resources import *
from .zoom_snap_dialog import zoom_snapDialog
import os.path
class zoom_snap:
def __init__(self, iface):
self.iface = iface
self.plugin_dir = os.path.dirname(__file__)
locale = QSettings().value('locale/userLocale')[0:2]
locale_path = os.path.join(
self.plugin_dir,
'i18n',
'zoom_snap_{}.qm'.format(locale))
if os.path.exists(locale_path):
self.translator = QTranslator()
self.translator.load(locale_path)
if qVersion() > '4.3.3':
QCoreApplication.installTranslator(self.translator)
self.actions = []
self.menu = self.tr(u'&(name)')
# Check if plugin was started the first time in current QGIS session
# Must be set in initGui() to survive plugin reloads
self.first_start = None
When I try to launch my plugin with plugin_name.plugin_class(iface)
I'm hitting the following error :
"locale_path=os.path.join("
TypeError: 'NoneType' object is not subscriptable
I've seen that another line before generates the same TypeError when launched separately in window command line :
QSettings().value('locale/userLocale')[0:2]
TypeError: 'NoneType' object is not subscriptable
My questions will be :
1- Where is QSettings().value([path])[0:2] extracting values from ? I can't see where locale/userLocale
folder is and how is it taking its values
2- I've seen a lot of posts about the 'NoneType' TypeError posts but here I don't know if anybody had any clue about solving this type of error