Ejemplo n.º 1
0
def _createMultilayerTestRepo(modifiesRepo=True):
    conf.update([(k, os.getenv(k)) for k in conf if k in os.environ])

    if modifiesRepo:
        repo = createRepoAtUrl(conf['REPOS_SERVER_URL'], "test",
                               "severallayers_%s" % str(time.time()))
    else:
        global multilayerTestRepo
        if multilayerTestRepo is not None:
            return multilayerTestRepo
        try:
            multilayerTestRepo = createRepoAtUrl(conf['REPOS_SERVER_URL'],
                                                 "test",
                                                 "original_severallayers")
        except GeoGigException:
            multilayerTestRepo = Repository(
                conf['REPOS_SERVER_URL'] + "repos/original_severallayers/",
                "test", "original_severallayers")
            return multilayerTestRepo
        repo = multilayerTestRepo
    _importLayerToRepo(repo, "first")
    _importLayerToRepo(repo, "second")
    _importLayerToRepo(repo, "third")
    _importLayerToRepo(repo, "lines")
    repo.createbranch(repo.HEAD, "mybranch")
    global _lastRepo
    _lastRepo = repo
    return _lastRepo
Ejemplo n.º 2
0
 def testCreateRepo(self):
     repos = repositoriesFromUrl(conf['REPOS_SERVER_URL'], "test")
     n = len(repos)
     name = str(uuid.uuid4()).replace("-", "")
     createRepoAtUrl(conf['REPOS_SERVER_URL'], "test", name)
     repos = repositoriesFromUrl(conf['REPOS_SERVER_URL'], "test")
     self.assertEqual(n + 1, len(repos))
     self.assertTrue(name in [r.title for r in repos])
Ejemplo n.º 3
0
def _createSimpleTestRepo(modifiesRepo=True, group=None, name=None):
    conf.update([(k, os.getenv(k)) for k in conf if k in os.environ])

    if modifiesRepo:
        repo = createRepoAtUrl(conf['REPOS_SERVER_URL'], group or "test", name
                               or "simple_%s" % str(time.time()))
    else:
        global simpleTestRepo
        if simpleTestRepo is not None:
            return simpleTestRepo
        try:
            simpleTestRepo = createRepoAtUrl(conf['REPOS_SERVER_URL'], group
                                             or "test", name
                                             or "original_simple")
        except GeoGigException:
            simpleTestRepo = Repository(
                conf['REPOS_SERVER_URL'] + "repos/original_simple/", group
                or "test", name or "original_simple")
            return simpleTestRepo
        repo = simpleTestRepo
    _importLayerToRepo(repo, "first")

    log = repo.log()
    filename = tempFilename("gpkg")
    repo.checkoutlayer(filename, "points", ref=log[0].commitid)
    layer = loadLayerNoCrsDialog(filename, "points", "ogr")
    with edit(layer):
        feat = QgsFeature()
        feat.setGeometry(QgsGeometry.fromPoint(QgsPoint(10, 10)))
        feat.setAttributes([3, 2])
        layer.addFeatures([feat])
    repo.importgeopkg(layer, "master", "second", "tester", "*****@*****.**",
                      True)
    log = repo.log()
    filename = tempFilename("gpkg")
    repo.checkoutlayer(filename, "points", ref=log[0].commitid)
    layer = loadLayerNoCrsDialog(filename, "points", "ogr")
    features = list(layer.getFeatures())
    for feature in features:
        pt = feature.geometry().asPoint()
        if pt.x() == 10 and pt.y() == 10:
            featureid = feature.id()
            break
    with edit(layer):
        layer.changeGeometry(featureid, QgsGeometry.fromPoint(QgsPoint(5, 5)))
    repo.importgeopkg(layer, "master", "third", "tester", "*****@*****.**",
                      True)
    repo.createbranch(repo.HEAD, "mybranch")
    repo.createtag(repo.HEAD, "mytag")
    global _lastRepo
    _lastRepo = repo
    return _lastRepo
Ejemplo n.º 4
0
def _createWithMergeTestRepo(modifiesRepo=True):
    conf.update([(k, os.getenv(k)) for k in conf if k in os.environ])

    if modifiesRepo:
        repo = createRepoAtUrl(conf['REPOS_SERVER_URL'], "test",
                               "withmerge_%s" % str(time.time()))
    else:
        global withMergeTestRepo
        if withMergeTestRepo is not None:
            return withMergeTestRepo
        try:
            withMergeTestRepo = createRepoAtUrl(conf['REPOS_SERVER_URL'],
                                                "test", "original_withmerge")
        except GeoGigException:
            withMergeTestRepo = Repository(
                conf['REPOS_SERVER_URL'] + "repos/original_withmerge/", "test",
                "original_withmerge")
            return withMergeTestRepo
        repo = withMergeTestRepo
    _importLayerToRepo(repo, "first")

    repo.createbranch(repo.HEAD, "mybranch")
    filename = tempFilename("gpkg")
    repo.checkoutlayer(filename, "points", ref=repo.HEAD)
    layer = loadLayerNoCrsDialog(filename, "points", "ogr")
    with edit(layer):
        feat = QgsFeature()
        feat.setGeometry(QgsGeometry.fromPoint(QgsPoint(10, 10)))
        feat.setAttributes([3, 2])
        layer.addFeatures([feat])
    repo.importgeopkg(layer, "mybranch", "second", "tester", "*****@*****.**",
                      True)

    filename = tempFilename("gpkg")
    repo.checkoutlayer(filename, "points", ref=repo.HEAD)
    layer = loadLayerNoCrsDialog(filename, "points", "ogr")
    with edit(layer):
        feat = QgsFeature()
        feat.setGeometry(QgsGeometry.fromPoint(QgsPoint(9, 9)))
        feat.setAttributes([9, 9])
        layer.addFeatures([feat])
    repo.importgeopkg(layer, "master", "second", "tester", "*****@*****.**",
                      True)

    repo.merge("mybranch", "master")
    global _lastRepo
    _lastRepo = repo
    return _lastRepo
def createSimpleTestRepo(group=None, name=None):

    repo = createRepoAtUrl(REPOS_SERVER_URL, group or "Lesson repos", name or "simple_%s" %  str(time.time()))

    _importLayerToRepo(repo, "first")

    log = repo.log()
    filename = tempFilename("gpkg")
    repo.checkoutlayer(filename, "points", ref = log[0].commitid)
    layer = QgsVectorLayer(filename, "points", "ogr")
    with edit(layer):
        feat = QgsFeature()
        feat.setGeometry(QgsGeometry.fromPoint(QgsPoint(10, 10)))
        feat.setAttributes([3, 2])
        layer.addFeatures([feat])
    repo.importgeopkg(layer, "master", "second", "tester", "*****@*****.**", True)
    log = repo.log()
    filename = tempFilename("gpkg")
    repo.checkoutlayer(filename, "points", ref = log[0].commitid)
    layer = QgsVectorLayer(filename, "points", "ogr")
    features = list(layer.getFeatures())
    for feature in features:
        pt = feature.geometry().asPoint()
        if pt.x() == 10 and pt.y()== 10:
            featureid = feature.id()
            break
    with edit(layer):
        layer.changeGeometry(featureid, QgsGeometry.fromPoint(QgsPoint(5, 5)))
    repo.importgeopkg(layer, "master", "third", "tester", "*****@*****.**", True)
    repo.createbranch(repo.HEAD, "mybranch")
    repo.createtag(repo.HEAD, "mytag")
    global _lastRepo
    _lastRepo = repo
    return _lastRepo
def _createSimpleTestRepo(modifiesRepo = True, group=None, name=None):
    conf.update([(k, os.getenv(k)) for k in conf if k in os.environ])

    if modifiesRepo:
        repo = createRepoAtUrl(conf['REPOS_SERVER_URL'], group or "test", name or "simple_%s" %  str(time.time()))
    else:
        global simpleTestRepo
        if simpleTestRepo is not None:
            return simpleTestRepo
        try:
            simpleTestRepo = createRepoAtUrl(conf['REPOS_SERVER_URL'], group or "test", name or "original_simple")
        except GeoGigException:
            simpleTestRepo = Repository(conf['REPOS_SERVER_URL'] + "repos/original_simple/", group or "test", name or "original_simple")
            return simpleTestRepo
        repo = simpleTestRepo
    _importLayerToRepo(repo, "first")

    log = repo.log()
    filename = tempFilename("gpkg")
    repo.checkoutlayer(filename, "points", ref = log[0].commitid)
    layer = loadLayerNoCrsDialog(filename, "points", "ogr")
    with edit(layer):
        feat = QgsFeature()
        feat.setGeometry(QgsGeometry.fromPoint(QgsPoint(10, 10)))
        feat.setAttributes([3, 2])
        layer.addFeatures([feat])
    repo.importgeopkg(layer, "master", "second", "tester", "*****@*****.**", True)
    log = repo.log()
    filename = tempFilename("gpkg")
    repo.checkoutlayer(filename, "points", ref = log[0].commitid)
    layer = loadLayerNoCrsDialog(filename, "points", "ogr")
    features = list(layer.getFeatures())
    for feature in features:
        pt = feature.geometry().asPoint()
        if pt.x() == 10 and pt.y()== 10:
            featureid = feature.id()
            break
    with edit(layer):
        layer.changeGeometry(featureid, QgsGeometry.fromPoint(QgsPoint(5, 5)))
    repo.importgeopkg(layer, "master", "third", "tester", "*****@*****.**", True)
    repo.createbranch(repo.HEAD, "mybranch")
    repo.createtag(repo.HEAD, "mytag")
    global _lastRepo
    _lastRepo = repo
    return _lastRepo
def _createEmptyTestRepo(modifiesRepo = True, group=None, name=None):
    conf.update([(k, os.getenv(k)) for k in conf if k in os.environ])

    if modifiesRepo:
        repo = createRepoAtUrl(conf['REPOS_SERVER_URL'], group or "test", name or "empty_%s" %  str(time.time()))
    else:
        global emptyTestRepo
        if emptyTestRepo is not None:
            return emptyTestRepo
        try:
            emptyTestRepo = createRepoAtUrl(conf['REPOS_SERVER_URL'], group or "test", name or "original_empty")
        except GeoGigException:
            emptyTestRepo = Repository(conf['REPOS_SERVER_URL'] + "repos/original_empty/", group or "test", name or "original_empty")
            return emptyTestRepo
        repo = emptyTestRepo
    global _lastRepo
    _lastRepo = repo
    return _lastRepo
Ejemplo n.º 8
0
def _createEmptyTestRepo(modifiesRepo = False):
    conf.update([(k, os.getenv(k)) for k in conf if k in os.environ])

    if modifiesRepo:
        repo = createRepoAtUrl(conf['REPOS_SERVER_URL'], "test", "empty_%s" %  str(time.time()))
    else:
        global emptyTestRepo
        if emptyTestRepo is not None:
            return emptyTestRepo
        try:
            emptyTestRepo = createRepoAtUrl(conf['REPOS_SERVER_URL'], "test", "original_empty")
        except GeoGigException:
            emptyTestRepo = Repository(conf['REPOS_SERVER_URL'] + "repos/original_empty/", "test", "original_empty")
            return emptyTestRepo
        repo = emptyTestRepo
    global _lastRepo
    _lastRepo = repo
    return _lastRepo
def _createWithMergeTestRepo(modifiesRepo = True):
    conf.update([(k, os.getenv(k)) for k in conf if k in os.environ])

    if modifiesRepo:
        repo = createRepoAtUrl(conf['REPOS_SERVER_URL'], "test", "withmerge_%s" %  str(time.time()))
    else:
        global withMergeTestRepo
        if withMergeTestRepo is not None:
            return withMergeTestRepo
        try:
            withMergeTestRepo = createRepoAtUrl(conf['REPOS_SERVER_URL'], "test", "original_withmerge")
        except GeoGigException:
            withMergeTestRepo = Repository(conf['REPOS_SERVER_URL'] + "repos/original_withmerge/", "test", "original_withmerge")
            return withMergeTestRepo
        repo = withMergeTestRepo
    _importLayerToRepo(repo, "first")

    repo.createbranch(repo.HEAD, "mybranch")
    filename = tempFilename("gpkg")
    repo.checkoutlayer(filename, "points", ref = repo.HEAD)
    layer = loadLayerNoCrsDialog(filename, "points", "ogr")
    with edit(layer):
        feat = QgsFeature()
        feat.setGeometry(QgsGeometry.fromPoint(QgsPoint(10, 10)))
        feat.setAttributes([3, 2])
        layer.addFeatures([feat])
    repo.importgeopkg(layer, "mybranch", "second", "tester", "*****@*****.**", True)

    filename = tempFilename("gpkg")
    repo.checkoutlayer(filename, "points", ref = repo.HEAD)
    layer = loadLayerNoCrsDialog(filename, "points", "ogr")
    with edit(layer):
        feat = QgsFeature()
        feat.setGeometry(QgsGeometry.fromPoint(QgsPoint(9, 9)))
        feat.setAttributes([9, 9])
        layer.addFeatures([feat])
    repo.importgeopkg(layer, "master", "second", "tester", "*****@*****.**", True)

    repo.merge("mybranch", "master")
    global _lastRepo
    _lastRepo = repo
    return _lastRepo
def _createMultilayerTestRepo(modifiesRepo = True):
    conf.update([(k, os.getenv(k)) for k in conf if k in os.environ])

    if modifiesRepo:
        repo = createRepoAtUrl(conf['REPOS_SERVER_URL'], "test", "severallayers_%s" %  str(time.time()))
    else:
        global multilayerTestRepo
        if multilayerTestRepo is not None:
            return multilayerTestRepo
        try:
            multilayerTestRepo = createRepoAtUrl(conf['REPOS_SERVER_URL'], "test", "original_severallayers")
        except GeoGigException:
            multilayerTestRepo = Repository(conf['REPOS_SERVER_URL'] + "repos/original_severallayers/", "test", "original_severallayers")
            return multilayerTestRepo
        repo = multilayerTestRepo
    _importLayerToRepo(repo, "first")
    _importLayerToRepo(repo, "second")
    _importLayerToRepo(repo, "third")
    _importLayerToRepo(repo, "lines")
    repo.createbranch(repo.HEAD, "mybranch")
    global _lastRepo
    _lastRepo = repo
    return _lastRepo
Ejemplo n.º 11
0
 def createRepo(self):
     name, ok = QInputDialog.getText(self, 'Create repository',
                                           'Enter the repository name:')
     if ok:
         group = self.comboEndpoint.currentText()
         url = repository.repoEndpoints[group]
         try:
             repo = execute(lambda: createRepoAtUrl(url, group, name))
         except GeoGigException as e:
             config.iface.messageBar().pushMessage("Error", str(e),
                            level=QgsMessageBar.CRITICAL,
                            duration=5)
             return
         item = RepoItem(self, self.repoTree, repo)
         addRepo(repo)
         self.repoTree.addTopLevelItem(item)
         config.iface.messageBar().pushMessage("Create repository", "Repository correctly created",
                                        level=QgsMessageBar.INFO,
                                        duration=5)
Ejemplo n.º 12
0
def createExampleRepo(group=None, name=None):

    repo = createRepoAtUrl(REPOS_SERVER_URL, group or "Lesson repos", name
                           or "simple_%s" % str(time.time()))

    AUTHOR = "Samuel Tarly"
    EMAIL = "*****@*****.**"

    repo.importgeopkg(_layerPath("buildings_000_original"), "master",
                      "Adds 2016 Buildings layer", AUTHOR, EMAIL, False)

    repo.importgeopkg(_layerPath("buildings_001_edits"), "master",
                      "Updates Block 1026 buildings", AUTHOR, EMAIL, False)

    repo.importgeopkg(_layerPath("buildings_002_edits"), "master",
                      "Updates Block 1024 buildings", AUTHOR, EMAIL, False)

    global _lastRepo
    _lastRepo = repo
    return _lastRepo
def createExampleRepo(group=None, name=None):

    repo = createRepoAtUrl(REPOS_SERVER_URL, group or "Lesson repos", name or "simple_%s" %  str(time.time()))

    AUTHOR = "Samuel Tarly"
    EMAIL = "*****@*****.**"

    repo.importgeopkg(_layerPath("buildings_000_original"), "master",
                      "Adds 2016 Buildings layer",
                      AUTHOR, EMAIL, False)

    repo.importgeopkg(_layerPath("buildings_001_edits"), "master",
                      "Updates Block 1026 buildings",
                      AUTHOR, EMAIL, False)

    repo.importgeopkg(_layerPath("buildings_002_edits"), "master",
                      "Updates Block 1024 buildings",
                      AUTHOR, EMAIL, False)

    global _lastRepo
    _lastRepo = repo
    return _lastRepo
Ejemplo n.º 14
0
def createSimpleTestRepo(group=None, name=None):

    repo = createRepoAtUrl(REPOS_SERVER_URL, group or "Lesson repos", name
                           or "simple_%s" % str(time.time()))

    _importLayerToRepo(repo, "first")

    log = repo.log()
    filename = tempFilename("gpkg")
    repo.checkoutlayer(filename, "points", ref=log[0].commitid)
    layer = QgsVectorLayer(filename, "points", "ogr")
    with edit(layer):
        feat = QgsFeature()
        feat.setGeometry(QgsGeometry.fromPoint(QgsPoint(10, 10)))
        feat.setAttributes([3, 2])
        layer.addFeatures([feat])
    repo.importgeopkg(layer, "master", "second", "tester", "*****@*****.**",
                      True)
    log = repo.log()
    filename = tempFilename("gpkg")
    repo.checkoutlayer(filename, "points", ref=log[0].commitid)
    layer = QgsVectorLayer(filename, "points", "ogr")
    features = list(layer.getFeatures())
    for feature in features:
        pt = feature.geometry().asPoint()
        if pt.x() == 10 and pt.y() == 10:
            featureid = feature.id()
            break
    with edit(layer):
        layer.changeGeometry(featureid, QgsGeometry.fromPoint(QgsPoint(5, 5)))
    repo.importgeopkg(layer, "master", "third", "tester", "*****@*****.**",
                      True)
    repo.createbranch(repo.HEAD, "mybranch")
    repo.createtag(repo.HEAD, "mytag")
    global _lastRepo
    _lastRepo = repo
    return _lastRepo
def createEmptyTestRepo(modifiesRepo = True, group=None, name=None):
    repo = createRepoAtUrl(REPOS_SERVER_URL, group or "Lesson repos", name or "empty_%s" %  str(time.time()))
    global _lastRepo
    _lastRepo = repo
    return repo
Ejemplo n.º 16
0
 def testCreateRepoWithNameThatAlreadyExists(self):
     repo_name =  "test-repo-same-name-%s" %  str(time.time())
     repo = _createSimpleTestRepo(group="test",name=repo_name)
     self.assertRaises(GeoGigException, lambda: createRepoAtUrl(conf['REPOS_SERVER_URL'], "test", repo_name))
Ejemplo n.º 17
0
def createEmptyTestRepo(modifiesRepo=True, group=None, name=None):
    repo = createRepoAtUrl(REPOS_SERVER_URL, group or "Lesson repos", name
                           or "empty_%s" % str(time.time()))
    global _lastRepo
    _lastRepo = repo
    return repo
Ejemplo n.º 18
0
 def testCreateRepoWithNameThatAlreadyExists(self):
     repo = _createSimpleTestRepo()
     self.assertRaises(
         GeoGigException, lambda: createRepoAtUrl(conf[
             'REPOS_SERVER_URL'], "test", "original_simple"))