当前位置: 首页>>代码示例>>Python>>正文


Python QgsApplication.qgisUserDbFilePath方法代码示例

本文整理汇总了Python中qgis.core.QgsApplication.qgisUserDbFilePath方法的典型用法代码示例。如果您正苦于以下问题:Python QgsApplication.qgisUserDbFilePath方法的具体用法?Python QgsApplication.qgisUserDbFilePath怎么用?Python QgsApplication.qgisUserDbFilePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在qgis.core.QgsApplication的用法示例。


在下文中一共展示了QgsApplication.qgisUserDbFilePath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import qgisUserDbFilePath [as 别名]
    def __init__(self, iface):
        try:
            debug()
        except:
            print 'Debugger not enabled'
        # save reference to the QGIS interface
        # Save reference to the QGIS interface
        self.iface = iface
        # initialize plugin directory
        self.plugin_dir = \
            QFileInfo(QgsApplication.qgisUserDbFilePath()).path() + \
            "/python/plugins/qchainage"
        # initialize locale
        locale_path = ""
        locale = QSettings().value("locale/userLocale")[0:2]

        if QFileInfo(self.plugin_dir).exists():
            locale_path = self.plugin_dir + "/i18n/qchainage_" + locale + ".qm"

        if QFileInfo(locale_path).exists():
            self.translator = QTranslator()
            self.translator.load(locale_path)

            if qVersion() > '4.3.3':
                QCoreApplication.installTranslator(self.translator)
开发者ID:pbabik,项目名称:qchainage,代码行数:27,代码来源:qchainage.py

示例2: __init__

# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import qgisUserDbFilePath [as 别名]
    def __init__(self, iface):
        self.dock = None
        self.results = []
        # Save reference to the QGIS interface
        self.iface = iface
        self.iface.newProjectCreated.connect(self._hideMarker)
        self.iface.projectRead.connect(self._hideMarker)
        self.canvas = self.iface.mapCanvas()
        self.marker = QgsVertexMarker(self.iface.mapCanvas())
        self.marker.setIconSize(20)
        self.marker.setPenWidth(3)
        self.marker.setIconType(QgsVertexMarker.ICON_CROSS)
        self.marker.hide()
        
        # Create the dialog and keep reference
        self.widget = gazetteerSearchDialog()
        self.widget.runSearch.connect(self.runSearch)
        self.widget.ui.clearButton.pressed.connect(self.clearResults)
        self.widget.zoomRequested.connect(self.zoomTo)
        # initialize plugin directory
        self.plugin_dir = QFileInfo(QgsApplication.qgisUserDbFilePath()).path() + "/python/plugins/gazetteersearch"
        # initialize locale
        localePath = ""
        locale = QSettings().value("locale/userLocale").toString()[0:2]
       
        if QFileInfo(self.plugin_dir).exists():
            localePath = self.plugin_dir + "/i18n/gazetteersearch_" + locale + ".qm"

        if QFileInfo(localePath).exists():
            self.translator = QTranslator()
            self.translator.load(localePath)

            if qVersion() > '4.3.3':
                QCoreApplication.installTranslator(self.translator)
开发者ID:ibennett,项目名称:QGIS-Gazetteer-Plugin,代码行数:36,代码来源:gazetteersearch.py

示例3: userFolder

# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import qgisUserDbFilePath [as 别名]
def userFolder():
    userDir = QFileInfo(QgsApplication.qgisUserDbFilePath()).path() \
        + '/processing'
    if not QDir(userDir).exists():
        QDir().mkpath(userDir)

    return unicode(QDir.toNativeSeparators(userDir))
开发者ID:Ariki,项目名称:QGIS,代码行数:9,代码来源:system.py

示例4: requestFinished

# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import qgisUserDbFilePath [as 别名]
 def requestFinished(self, requestId, state):
   if requestId != self.httpGetId:
     return
   self.buttonBox.setEnabled(False)
   if state:
     self.mResult = self.http.errorString()
     self.reject()
     return
   self.file.close()
   pluginDir = QFileInfo(QgsApplication.qgisUserDbFilePath()).path() + "/python/plugins"
   tmpPath = self.file.fileName()
   # make sure that the parent directory exists
   if not QDir(pluginDir).exists():
     QDir().mkpath(pluginDir)
   # if the target directory already exists as a link, remove the link without resolving:
   QFile(pluginDir+QString(QDir.separator())+self.plugin["localdir"]).remove()
   try:
     un = unzip()
     un.extract(unicode(tmpPath), unicode(pluginDir)) # test extract. If fails, then exception will be raised and no removing occurs
     # removing old plugin files if exist
     removeDir(QDir.cleanPath(pluginDir+"/"+self.plugin["localdir"])) # remove old plugin if exists
     un.extract(unicode(tmpPath), unicode(pluginDir)) # final extract.
   except:
     self.mResult = self.tr("Failed to unzip the plugin package. Probably it's broken or missing from the repository. You may also want to make sure that you have write permission to the plugin directory:") + "\n" + pluginDir
     self.reject()
     return
   try:
     # cleaning: removing the temporary zip file
     QFile(tmpPath).remove()
   except:
     pass
   self.close()
开发者ID:CzendaZdenda,项目名称:qgis,代码行数:34,代码来源:installer_gui.py

示例5: defaultOutputFolder

# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import qgisUserDbFilePath [as 别名]
def defaultOutputFolder():
    folder = os.path.join(os.path.dirname(QgsApplication.qgisUserDbFilePath()),
                          "processing", "outputs")
    if not QDir(folder).exists():
        QDir().mkpath(folder)

    return unicode(QDir.toNativeSeparators(folder))
开发者ID:Geoneer,项目名称:QGIS,代码行数:9,代码来源:system.py

示例6: removeDir

# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import qgisUserDbFilePath [as 别名]
def removeDir(path):
    result = QString()
    if not QFile(path).exists():
      result = QCoreApplication.translate("QgsPluginInstaller","Nothing to remove! Plugin directory doesn't exist:")+"\n"+path
    elif QFile(path).remove(): # if it is only link, just remove it without resolving.
      pass
    else:
      fltr = QDir.Dirs | QDir.Files | QDir.Hidden
      iterator = QDirIterator(path, fltr, QDirIterator.Subdirectories)
      while iterator.hasNext():
        item = iterator.next()
        if QFile(item).remove():
          pass
      fltr = QDir.Dirs | QDir.Hidden
      iterator = QDirIterator(path, fltr, QDirIterator.Subdirectories)
      while iterator.hasNext():
        item = iterator.next()
        if QDir().rmpath(item):
          pass
    if QFile(path).exists():
      result = QCoreApplication.translate("QgsPluginInstaller","Failed to remove the directory:")+"\n"+path+"\n"+QCoreApplication.translate("QgsPluginInstaller","Check permissions or remove it manually")
    # restore plugin directory if removed by QDir().rmpath()
    pluginDir = QFileInfo(QgsApplication.qgisUserDbFilePath()).path() + "/python/plugins"
    if not QDir(pluginDir).exists():
      QDir().mkpath(pluginDir)
    return result
开发者ID:CzendaZdenda,项目名称:qgis,代码行数:28,代码来源:installer_gui.py

示例7: __init__

# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import qgisUserDbFilePath [as 别名]
    def __init__(self, iface):
        Plugin.__init__(self, iface, "PointsInPolygons")

        userPluginPath = QtCore.QFileInfo(QgsApplication.qgisUserDbFilePath()).path() + '/python/plugins/points_in_polygons'
        systemPluginPath = QgsApplication.prefixPath() + '/python/plugins/points_in_polygons'

        overrideLocale = QtCore.QSettings().value('locale/overrideFlag', False, type=bool)
        if not overrideLocale:
            localeFullName = QtCore.QLocale.system().name()[:2]
        else:
            localeFullName = QtCore.QSettings().value("locale/userLocale", "")

        if QtCore.QFileInfo(userPluginPath).exists():
            translationPath = userPluginPath + '/i18n/pointsinpolygons_' + localeFullName + '.qm'
            self.pluginPath = userPluginPath
        else:
            translationPath = systemPluginPath + '/i18n/pointsinpolygons_' + localeFullName + '.qm'
            self.pluginPath = systemPluginPath

        self.localePath = translationPath
        if QtCore.QFileInfo(self.localePath).exists():
            self.translator = QtCore.QTranslator()
            self.translator.load(self.localePath)
            QgsApplication.installTranslator(self.translator)

        self.pointLayerName = ""
        self.polygonLayerName = ""
        self.fieldName = ""
开发者ID:nextgis,项目名称:qgis.points_in_polygons,代码行数:30,代码来源:plugin.py

示例8: get_QuickOSM_folder

# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import qgisUserDbFilePath [as 别名]
def get_QuickOSM_folder():
    """
    Get the user folder, ~/.qgis2/QuickOSM on linux for instance

    @rtype: str
    @return: path
    """
    folder = QFileInfo(QgsApplication.qgisUserDbFilePath()).path() + "QuickOSM"
    return unicode(QDir.toNativeSeparators(folder))
开发者ID:harry-wood,项目名称:QuickOSM,代码行数:11,代码来源:tools.py

示例9: _populate_bookmarks_list

# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import qgisUserDbFilePath [as 别名]
    def _populate_bookmarks_list(self):
        """Read the sqlite database and populate the bookmarks list.

        If no bookmarks are found, the bookmarks radio button will be disabled
        and the label will be shown indicating that the user should add
        bookmarks in QGIS first.

        Every bookmark are reprojected to mapcanvas crs.
        """
        # Connect to the QGIS sqlite database and check if the table exists.
        # noinspection PyArgumentList
        db_file_path = QgsApplication.qgisUserDbFilePath()
        db = sqlite3.connect(db_file_path)
        cursor = db.cursor()
        cursor.execute(
            'SELECT COUNT(*) '
            'FROM sqlite_master '
            'WHERE type=\'table\' '
            'AND name=\'tbl_bookmarks\';')

        number_of_rows = cursor.fetchone()[0]
        if number_of_rows > 0:
            cursor.execute(
                'SELECT * '
                'FROM tbl_bookmarks;')
            bookmarks = cursor.fetchall()

            canvas_srid = self.canvas.mapSettings().destinationCrs().srsid()

            for bookmark in bookmarks:
                name = bookmark[1]
                srid = bookmark[7]
                rectangle = QgsRectangle(
                    bookmark[3], bookmark[4], bookmark[5], bookmark[6])

                if srid != canvas_srid:
                    transform = QgsCoordinateTransform(
                        srid, canvas_srid)
                    try:
                        rectangle = transform.transform(rectangle)
                    except QgsCsException:
                        rectangle = None

                if rectangle is None or rectangle.isEmpty():
                    pass

                self.bookmarks_list.addItem(name, rectangle)
        if self.bookmarks_list.currentIndex() >= 0:
            self.create_bookmarks_label.hide()
        else:
            self.create_bookmarks_label.show()
            self.hazard_exposure_bookmark.setDisabled(True)
            self.bookmarks_list.hide()
开发者ID:timlinux,项目名称:inasafe,代码行数:55,代码来源:extent_selector_dialog.py

示例10: uninstallPlugin

# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import qgisUserDbFilePath [as 别名]
 def uninstallPlugin(self,key):
   """ uninstall currently selected plugin """
   plugin = plugins.all()[key]
   if not plugin:
     return
   warning = self.tr("Are you sure you want to uninstall the following plugin?") + "\n(" + plugin["name"] + ")"
   if plugin["status"] == "orphan" and not plugin["error"]:
     warning += "\n\n"+self.tr("Warning: this plugin isn't available in any accessible repository!")
   if QMessageBox.warning(self, self.tr("QGIS Python Plugin Installer"), warning , QMessageBox.Yes, QMessageBox.No) == QMessageBox.No:
     return
   # unload the plugin if it's not plugin_installer itself (otherwise, do it after removing its directory):
   if key != "plugin_installer":
     try:
       unloadPlugin(key)
     except:
       pass
   pluginDir = QFileInfo(QgsApplication.qgisUserDbFilePath()).path() + "/python/plugins/" + plugin["localdir"]
   result = removeDir(pluginDir)
   if result:
     QMessageBox.warning(self, self.tr("Plugin uninstall failed"), result)
   else:
     # if the uninstalled plugin is the installer itself, reload it and quit
     if key == "plugin_installer":
       if QGIS_15:
         try:
           QMessageBox.information(self, self.tr("QGIS Python Plugin Installer"), self.tr("Plugin Installer update uninstalled. Plugin Installer will now close and revert to its primary version. You can find it in the Plugins menu and continue operation."))
           reloadPlugin(key)
           return
         except:
           pass
       else:
         QMessageBox.information(self, self.tr("QGIS Python Plugin Installer"), self.tr("Plugin Installer update uninstalled. Please restart QGIS in order to load its primary version."))
     # safe remove
     try:
       unloadPlugin(plugin["localdir"])
     except:
       pass
     try:
       exec ("plugins[%s].unload()" % plugin["localdir"])
       exec ("del plugins[%s]" % plugin["localdir"])
     except:
       pass
     try:
       exec ("del sys.modules[%s]" % plugin["localdir"])
     except:
       pass
     plugins.getAllInstalled()
     plugins.rebuild()
     self.populatePluginTree()
     if QGIS_14: QMessageBox.information(self, self.tr("Plugin uninstalled successfully"), self.tr("Plugin uninstalled successfully"))
     else: QMessageBox.information(self, self.tr("Plugin uninstalled successfully"), self.tr("Python plugin uninstalled. Note that you may need to restart Quantum GIS in order to remove it completely."))
     history.markChange(key,'D')
开发者ID:CzendaZdenda,项目名称:qgis,代码行数:54,代码来源:installer_gui.py

示例11: _populate_bookmarks_list

# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import qgisUserDbFilePath [as 别名]
    def _populate_bookmarks_list(self):
        """Read the sqlite database and populate the bookmarks list.

        Every bookmark are reprojected to mapcanvas crs.
        """

        # Connect to the QGIS sqlite database and check if the table exists.
        db_file_path = QgsApplication.qgisUserDbFilePath()
        if not isfile(db_file_path):
            # If the database does not exist.
            return

        try:
            db = sqlite3.connect(db_file_path)
            cursor = db.cursor()
            cursor.execute(
                'SELECT COUNT(*) '
                'FROM sqlite_master '
                'WHERE type=\'table\' '
                'AND name=\'tbl_bookmarks\';')

            number_of_rows = cursor.fetchone()[0]
            if number_of_rows > 0:
                cursor.execute(
                    'SELECT * '
                    'FROM tbl_bookmarks;')
                bookmarks = cursor.fetchall()

                map_renderer = self.canvas.mapRenderer()
                canvas_srid = map_renderer.destinationCrs().srsid()

                for bookmark in bookmarks:
                    name = bookmark[1]
                    srid = bookmark[7]
                    rectangle = QgsRectangle(
                        bookmark[3], bookmark[4], bookmark[5], bookmark[6])

                    if srid != canvas_srid:
                        transform = QgsCoordinateTransform(
                            srid, canvas_srid)
                        rectangle = transform.transform(rectangle)

                    if rectangle.isEmpty():
                        pass

                    self.comboBox_bookmarks_list.addItem(name, rectangle)
        except sqlite3.Error:
            # If we have any SQL error with SQLite.
            return
开发者ID:NyakudyaA,项目名称:inasafe,代码行数:51,代码来源:extent_selector_dialog.py

示例12: __init__

# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import qgisUserDbFilePath [as 别名]
    def __init__(self, iface):
        self.iface = iface
        self.settings = MySettings()
        self.mainDialog = MainDialog()

         # Initialise the translation environment.
        userPluginPath = QFileInfo(QgsApplication.qgisUserDbFilePath()).path()+"/python/plugins/qwat"
        systemPluginPath = QgsApplication.prefixPath()+"/share/qgis/python/plugins/qwat"
        locale = QSettings().value("locale/userLocale")
        myLocale = locale[0:2]
        if QFileInfo(userPluginPath).exists():
            pluginPath = userPluginPath+"/i18n/qwat_"+myLocale+".qm"
        elif QFileInfo(systemPluginPath).exists():
            pluginPath = systemPluginPath+"/i18n/qwat_"+myLocale+".qm"
        self.localePath = pluginPath
        if QFileInfo(self.localePath).exists():
            self.translator = QTranslator()
            self.translator.load(self.localePath)
            QCoreApplication.installTranslator(self.translator)
开发者ID:andrei4002,项目名称:qWat,代码行数:21,代码来源:qwat.py

示例13: __init__

# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import qgisUserDbFilePath [as 别名]
    def __init__(self, iface):
        self.iface = iface
        self.mapCanvas = iface.mapCanvas()

        # Initialise the translation environment.
        userPluginPath = QFileInfo(QgsApplication.qgisUserDbFilePath()).path()+"/python/plugins/intersectit"
        systemPluginPath = QgsApplication.prefixPath()+"/share/qgis/python/plugins/intersectit"
        locale = QSettings().value("locale/userLocale")
        myLocale = locale[0:2]
        pluginPath = "" # default case
        if QFileInfo(userPluginPath).exists():
            pluginPath = '{}/i18n/intersectit_{}.qm'.format(userPluginPath, myLocale)
        elif QFileInfo(systemPluginPath).exists():
            pluginPath = '{}/i18n/intersectit_{}.qm'.format(systemPluginPath, myLocale)
        self.localePath = pluginPath
        if QFileInfo(self.localePath).exists():
            self.translator = QTranslator()
            self.translator.load(self.localePath)
            QCoreApplication.installTranslator(self.translator)
开发者ID:3nids,项目名称:intersectit,代码行数:21,代码来源:intersectit_plugin.py

示例14: __init__

# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import qgisUserDbFilePath [as 别名]
    def __init__(self, iface):
        """Constructor

        :param iface: An interface instance that will be passed to this class
            which provides the hook by which you can manipulate the QGIS
            application at run time.
        :type iface: QgsInterface

        """
        # Save reference to the QGIS interface
        self.iface = iface
        # noinspection PyArgumentList
        self.user_plugin_dir = QFileInfo(
            QgsApplication.qgisUserDbFilePath()).path() + 'python/plugins'
        self.plugin_builder_path = os.path.dirname(__file__)

        # class members
        self.action = None
        self.dialog = None
        self.plugin_path = None
开发者ID:timlinux,项目名称:Qgis-Plugin-Builder,代码行数:22,代码来源:plugin_builder.py

示例15: __init__

# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import qgisUserDbFilePath [as 别名]
    def __init__(self, iface):
        # Save reference to the QGIS interface
        self.context = zmq.Context()
        self.iface = iface
        # initialize plugin directory
        self.plugin_dir = \
            QFileInfo(QgsApplication.qgisUserDbFilePath()).path() + \
            "/python/plugins/world_engine"
        # initialize locale
        locale_path = ""
        locale = QSettings().value("locale/userLocale")[0:2]

        if QFileInfo(self.plugin_dir).exists():
            locale_path = self.plugin_dir + "/i18n/world_engine_" + locale + ".qm"

        if QFileInfo(locale_path).exists():
            self.translator = QTranslator()
            self.translator.load(locale_path)

            if qVersion() > '4.3.3':
                QCoreApplication.installTranslator(self.translator)
开发者ID:friend0,项目名称:world-engine-plugin,代码行数:23,代码来源:world_engine.py


注:本文中的qgis.core.QgsApplication.qgisUserDbFilePath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。