コード例 #1
0
def _setReposFolder(folder):
    global _oldReposPath
    global _tempReposPath
    _oldReposPath = config.getConfigValue(config.GENERAL, config.REPOS_FOLDER)
    reposPath = os.path.join(os.path.dirname(__file__), "data", "repos", folder)
    _tempReposPath = tempfile.mkdtemp()
    tempReposPath = os.path.join(_tempReposPath, "repos")
    shutil.copytree(reposPath, tempReposPath)
    config.setConfigValue(config.GENERAL, config.REPOS_FOLDER, tempReposPath)
コード例 #2
0
def _removeUserConfig():
    global _oldUserName
    global _configContent
    configFile = os.path.join(os.path.expanduser("~"), ".geogigconfig")
    if os.path.exists(configFile):
        with open(configFile) as f:
            _configContent = "".join(f.readlines())
        os.unlink(configFile)
    else:
        _configContent = ""
    _oldUserName = config.getConfigValue(config.GENERAL, config.USERNAME)
    config.setConfigValue(config.GENERAL, config.USERNAME, "")
コード例 #3
0
def commitLayer(layer):
    trackedLayer = getTrackingInfo(layer)
    try:
        repo = createRepository(trackedLayer.repoFolder, False)
    except Py4JConnectionException:
        QtGui.QApplication.restoreOverrideCursor()
        dlg = GatewayNotAvailableWhileEditingDialog(config.iface.mainWindow())
        dlg.exec_()
        return
    QtGui.QApplication.restoreOverrideCursor()

    if layer.dataProvider().fieldNameIndex("geogigid") == -1:
        config.iface.messageBar().pushMessage(
            "Cannot update GeoGig repository. Layer has no 'geogigid' field",
            level=QgsMessageBar.WARNING,
            duration=4)
        return

    exported, charset = exportVectorLayer(layer)
    repo.importshp(exported, False, trackedLayer.layername, "geogigid", True,
                   charset)

    unstaged = repo.difftreestats(geogig.HEAD, geogig.WORK_HEAD)
    total = 0
    for counts in unstaged.values():
        total += sum(counts)
    if total == 0:
        config.iface.messageBar().pushMessage(
            "No changes detected. Repository was already up to date",
            level=QgsMessageBar.INFO,
            duration=4)
        return

    dlg = CommitDialog(repo, config.iface.mainWindow())
    dlg.exec_()
    try:
        repo.addandcommit(dlg.getMessage())
    except UnconfiguredUserException, e:
        user = config.getConfigValue(config.GENERAL, config.USERNAME)
        email = config.getConfigValue(config.GENERAL, config.EMAIL)
        if not (user and email):
            configdlg = UserConfigDialog(config.iface.mainWindow())
            configdlg.exec_()
            if configdlg.user is not None:
                user = configdlg.user
                email = configdlg.email
                config.setConfigValue(config.GENERAL, config.USERNAME, user)
                config.setConfigValue(config.GENERAL, config.EMAIL, email)
            else:
                return
        repo.config(geogig.USER_NAME, user, True)
        repo.config(geogig.USER_EMAIL, email, True)
        repo.commit(dlg.getMessage())
コード例 #4
0
def commitLayer(layer):
    trackedLayer = getTrackingInfo(layer)
    try:
        repo = createRepository(trackedLayer.repoFolder, False)
    except Py4JConnectionException:
        QtGui.QApplication.restoreOverrideCursor()
        dlg = GatewayNotAvailableWhileEditingDialog(config.iface.mainWindow())
        dlg.exec_()
        return
    QtGui.QApplication.restoreOverrideCursor()

    if layer.dataProvider().fieldNameIndex("geogigid") == -1:
        config.iface.messageBar().pushMessage("Cannot update GeoGig repository. Layer has no 'geogigid' field",
                                                  level = QgsMessageBar.WARNING, duration = 4)
        return

    exported, charset = exportVectorLayer(layer)
    repo.importshp(exported, False, trackedLayer.layername, "geogigid", True, charset)

    unstaged = repo.difftreestats(geogig.HEAD, geogig.WORK_HEAD)
    total = 0
    for counts in unstaged.values():
        total += sum(counts)
    if total == 0:
        config.iface.messageBar().pushMessage("No changes detected. Repository was already up to date",
                                              level = QgsMessageBar.INFO, duration = 4)
        return

    dlg = CommitDialog(repo, config.iface.mainWindow())
    dlg.exec_()
    try:
        repo.addandcommit(dlg.getMessage())
    except UnconfiguredUserException, e:
        user = config.getConfigValue(config.GENERAL, config.USERNAME)
        email = config.getConfigValue(config.GENERAL, config.EMAIL)
        if not (user and email):
            configdlg = UserConfigDialog(config.iface.mainWindow())
            configdlg.exec_()
            if configdlg.user is not None:
                user = configdlg.user
                email = configdlg.email
                config.setConfigValue(config.GENERAL, config.USERNAME, user)
                config.setConfigValue(config.GENERAL, config.EMAIL, email)
            else:
                return
        repo.config(geogig.USER_NAME, user, True)
        repo.config(geogig.USER_EMAIL, email, True)
        repo.commit(dlg.getMessage())
コード例 #5
0
def configureUser():
    user = config.getConfigValue(config.GENERAL, config.USERNAME)
    email = config.getConfigValue(config.GENERAL, config.EMAIL)
    if not (user and email):
        configdlg = UserConfigDialog(config.iface.mainWindow())
        configdlg.exec_()
        if configdlg.user is not None:
            user = configdlg.user
            email = configdlg.email
            config.setConfigValue(config.GENERAL, config.USERNAME, user)
            config.setConfigValue(config.GENERAL, config.EMAIL, email)
        else:
            return
    con = PyQtConnectorDecorator()
    con.configglobal(geogig.USER_NAME, user)
    con.configglobal(geogig.USER_EMAIL, email)
コード例 #6
0
def configureUser():
    user = config.getConfigValue(config.GENERAL, config.USERNAME)
    email = config.getConfigValue(config.GENERAL, config.EMAIL)
    if not (user and email):
        configdlg = UserConfigDialog(config.iface.mainWindow())
        configdlg.exec_()
        if configdlg.user is not None:
            user = configdlg.user
            email = configdlg.email
            config.setConfigValue(config.GENERAL, config.USERNAME, user)
            config.setConfigValue(config.GENERAL, config.EMAIL, email)
        else:
            return
    con = PyQtConnectorDecorator()
    con.configglobal(geogig.USER_NAME, user)
    con.configglobal(geogig.USER_EMAIL, email)
コード例 #7
0
def _restoreReposFolder():
    config.setConfigValue(config.GENERAL, config.REPOS_FOLDER, _oldReposPath)
コード例 #8
0
def _restoreUserConfig():
    config.setConfigValue(config.GENERAL, config.USERNAME, _oldUserName)
    configFile = os.path.join(os.path.expanduser("~"), ".geogigconfig")
    with open(configFile, "w") as f:
        f.write(_configContent)
    _restoreReposFolder()