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


Python Connector.revs方法代码示例

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


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

示例1: test_transitive_keep

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import revs [as 别名]
	def test_transitive_keep(self):
		with Connector().create(self.store1, "public.data", "test.ignore") as w1:
			with Connector().create(self.store1, "public.data", "test.ignore") as w2:
				w2.write('FILE', 'test')
				w2.commit()
				doc2 = w2.getDoc()
				rev2 = w2.getRev()

				# create a reference from w1 to w2
				w1.write('PDSD', struct.dumps([struct.DocLink(self.store2, doc2)]))
				w1.commit()
				doc1 = w1.getDoc()
				rev1 = w1.getRev()

			# w2 is closed now, w1 still open, should prevent gc
			self.gc(self.store1)

			l = Connector().lookupDoc(doc1)
			self.assertEqual(l.revs(), [rev1])
			self.assertEqual(l.preRevs(), [])
			self.assertEqual(Connector().lookupRev(rev1), [self.store1])
			l = Connector().lookupDoc(doc2)
			self.assertEqual(l.revs(), [rev2])
			self.assertEqual(l.preRevs(), [])
			self.assertEqual(Connector().lookupRev(rev2), [self.store1])
开发者ID:wizzk42,项目名称:peerdrive,代码行数:27,代码来源:tests.py

示例2: test_suspend_multi

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import revs [as 别名]
	def test_suspend_multi(self):
		(doc, rev1, rev_s1) = self.createSuspendDoc()

		with Connector().update(self.store1, doc, rev1) as w:
			w.writeAll('FILE', 'forward')
			w.commit()
			rev2 = w.getRev()

		with Connector().update(self.store1, doc, rev2) as w:
			w.writeAll('FILE', 'Hail to the king, baby!')
			w.suspend()
			rev_s2 = w.getRev()

		l = Connector().lookupDoc(doc)
		self.assertEqual(l.revs(), [rev2])
		self.assertEqual(len(l.preRevs()), 2)
		self.assertTrue(rev_s1 in l.preRevs())
		self.assertTrue(rev_s2 in l.preRevs())

		s = Connector().stat(rev_s1)
		self.assertEqual(s.parents(), [rev1])
		s = Connector().stat(rev_s2)
		self.assertEqual(s.parents(), [rev2])

		self.assertRevContent(self.store1, rev1, {'FILE' : 'ok'})
		self.assertRevContent(self.store1, rev_s1, {'FILE' : 'update'})
		self.assertRevContent(self.store1, rev2, {'FILE' : 'forward'})
		self.assertRevContent(self.store1, rev_s2, {'FILE' : 'Hail to the king, baby!'})
开发者ID:wizzk42,项目名称:peerdrive,代码行数:30,代码来源:tests.py

示例3: performSync

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import revs [as 别名]
    def performSync(self, doc, strategy):
        watch = self.watchDoc(doc, connector.Watch.EVENT_MODIFIED)

        self.startSync(strategy, self.store1, self.store2)

        # first wait until the doc gets changed
        while True:
            watch.reset()
            self.assertTrue(watch.waitForWatch())
            l = Connector().lookupDoc(doc)
            if len(l.revs()) == 1:
                break

        self.assertEqual(len(l.stores()), 2)
        self.assertTrue(self.store1 in l.stores())
        self.assertTrue(self.store2 in l.stores())

        # wait until sync_worker moved on
        result = self.erlCall(
            """peerdrive_sync_locks:lock(<<16#"""
            + doc.encode("hex")
            + """:128>>),
			peerdrive_sync_locks:unlock(<<16#"""
            + doc.encode("hex")
            + """:128>>)."""
        )
        self.assertEqual(result, "{ok, ok}")

        return l
开发者ID:peerdrive,项目名称:peerdrive,代码行数:31,代码来源:tests.py

示例4: test_suspend

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import revs [as 别名]
	def test_suspend(self):
		(doc, rev1, rev2) = self.createSuspendDoc()

		l = Connector().lookupDoc(doc)
		self.assertEqual(l.revs(), [rev1])
		self.assertEqual(l.preRevs(), [rev2])
		self.assertRevContent(self.store1, rev1, {'FILE' : 'ok'})
		self.assertRevContent(self.store1, rev2, {'FILE' : 'update'})
开发者ID:wizzk42,项目名称:peerdrive,代码行数:10,代码来源:tests.py

示例5: test_resume_abort

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import revs [as 别名]
	def test_resume_abort(self):
		(doc, rev1, rev2) = self.createSuspendDoc()

		with Connector().resume(self.store1, doc, rev2) as w:
			w.writeAll('FILE', 'Hail to the king, baby!')

			l = Connector().lookupDoc(doc)
			self.assertEqual(l.revs(), [rev1])
			self.assertEqual(l.preRevs(), [rev2])

			w.close()

		l = Connector().lookupDoc(doc)
		self.assertEqual(l.revs(), [rev1])
		self.assertEqual(l.preRevs(), [rev2])
		self.assertRevContent(self.store1, rev1, {'FILE' : 'ok'})
		self.assertRevContent(self.store1, rev2, {'FILE' : 'update'})
开发者ID:wizzk42,项目名称:peerdrive,代码行数:19,代码来源:tests.py

示例6: test_resume_wrong

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import revs [as 别名]
	def test_resume_wrong(self):
		(doc, rev1, rev2) = self.createSuspendDoc()
		self.assertRaises(IOError, Connector().resume, self.store1, doc, rev1)

		l = Connector().lookupDoc(doc)
		self.assertEqual(l.revs(), [rev1])
		self.assertEqual(l.preRevs(), [rev2])
		self.assertRevContent(self.store1, rev1, {'FILE' : 'ok'})
		self.assertRevContent(self.store1, rev2, {'FILE' : 'update'})
开发者ID:wizzk42,项目名称:peerdrive,代码行数:11,代码来源:tests.py

示例7: test_create_keep_handle

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import revs [as 别名]
	def test_create_keep_handle(self):
		with Connector().create(self.store1, "public.data", "test.ignore") as w:
			w.commit()
			doc = w.getDoc()
			rev = w.getRev()

			# perform a GC cycle
			self.gc(self.store1)

			l = Connector().lookupDoc(doc)
			self.assertEqual(l.revs(), [rev])
			self.assertEqual(l.preRevs(), [])

			Connector().stat(rev)
开发者ID:wizzk42,项目名称:peerdrive,代码行数:16,代码来源:tests.py

示例8: test_collect

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import revs [as 别名]
	def test_collect(self):
		# deliberately close handle after creating!
		with Connector().create(self.store1, "public.data", "test.ignore") as w:
			w.commit()
			doc = w.getDoc()
			rev = w.getRev()

		# perform a GC cycle
		self.gc(self.store1)

		l = Connector().lookupDoc(doc)
		self.assertEqual(l.revs(), [])
		self.assertEqual(l.preRevs(), [])
		self.assertRaises(IOError, Connector().stat, rev)
开发者ID:wizzk42,项目名称:peerdrive,代码行数:16,代码来源:tests.py

示例9: test_sync_ff_err

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import revs [as 别名]
    def test_sync_ff_err(self):
        (doc, rev1, rev2) = self.createMerge("public.data", {}, {"FILE": "left1"}, {"FILE": "right1"})

        watch = self.watchDoc(doc, connector.Watch.EVENT_MODIFIED)

        self.startSync("ff", self.store1, self.store2)
        self.startSync("ff", self.store2, self.store1)

        self.assertFalse(watch.waitForWatch(1))

        # check that doc is not synced
        l = Connector().lookupDoc(doc)
        self.assertEqual(len(l.revs()), 2)
        self.assertEqual(l.rev(self.store1), rev1)
        self.assertEqual(l.rev(self.store2), rev2)
开发者ID:peerdrive,项目名称:peerdrive,代码行数:17,代码来源:tests.py

示例10: update

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import revs [as 别名]
	def update(self, updateItem = True):
		# reset everything
		self.__valid = False
		self.__icon = None
		for i in xrange(len(self.__columnDefs)):
			column = self.__columnDefs[i]
			if column.derived():
				self.__columnValues[i] = column.default()

		# determine revision
		needMerge = False
		isReplicated = False
		if self.__doc:
			l = Connector().lookupDoc(self.__doc)
			isReplicated = len(l.stores()) > 1
			revisions = l.revs()
			if len(revisions) == 0:
				return
			elif len(revisions) > 1:
				needMerge = True
			if updateItem:
				self.__item[''].update()

		self.__rev = self.__item[''].rev()

		# stat
		try:
			s = Connector().stat(self.__rev)
		except IOError:
			return
		self.__uti = s.type()
		if needMerge or isReplicated:
			image = QtGui.QImage(Registry().getIcon(s.type()))
			painter = QtGui.QPainter()
			painter.begin(image)
			if needMerge:
				painter.drawImage(0, 16, QtGui.QImage("icons/emblems/split.png"))
			elif isReplicated:
				painter.drawImage(0, 16, QtGui.QImage("icons/emblems/distributed.png"))
			painter.end()
			self.__icon = QtGui.QIcon(QtGui.QPixmap.fromImage(image))
		else:
			self.__icon = QtGui.QIcon(Registry().getIcon(s.type()))

		self.__isFolder = Registry().conformes(self.__uti, "org.peerdrive.folder")
		self.__replacable = not needMerge and not self.__isFolder
		self.__valid = True
		self.__updateColumns(s)
开发者ID:DavidAlphaFox,项目名称:chef-server,代码行数:50,代码来源:folder.py

示例11: test_resume_commit

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import revs [as 别名]
	def test_resume_commit(self):
		(doc, rev1, rev2) = self.createSuspendDoc()

		with Connector().resume(self.store1, doc, rev2) as w:
			w.writeAll('FILE', 'What are you waiting for, christmas?')
			w.commit()
			rev3 = w.getRev()

		l = Connector().lookupDoc(doc)
		self.assertEqual(l.revs(), [rev3])
		self.assertEqual(len(l.preRevs()), 0)

		s = Connector().stat(rev3)
		self.assertEqual(s.parents(), [rev1])
		self.assertRevContent(self.store1, rev1, {'FILE' : 'ok'})
		self.assertRevContent(self.store1, rev3, {'FILE' : 'What are you waiting for, christmas?'})
开发者ID:wizzk42,项目名称:peerdrive,代码行数:18,代码来源:tests.py

示例12: test_resume_suspend_orig

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import revs [as 别名]
	def test_resume_suspend_orig(self):
		(doc, rev1, rev2) = self.createSuspendDoc()

		with Connector().resume(self.store1, doc, rev2) as w:
			w.suspend()
			rev3 = w.getRev()

		l = Connector().lookupDoc(doc)
		self.assertEqual(l.revs(), [rev1])
		self.assertEqual(l.preRevs(), [rev3])

		s = Connector().stat(rev3)
		self.assertEqual(s.parents(), [rev1])

		self.assertRevContent(self.store1, rev1, {'FILE' : 'ok'})
		self.assertRevContent(self.store1, rev3, {'FILE' : 'update'})
开发者ID:wizzk42,项目名称:peerdrive,代码行数:18,代码来源:tests.py

示例13: test_resume_suspend_mod

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import revs [as 别名]
    def test_resume_suspend_mod(self):
        (doc, rev1, rev2) = self.createSuspendDoc()

        with Connector().resume(self.store1, doc, rev2) as w:
            w.writeAll("FILE", "What are you waiting for, christmas?")
            w.suspend()
            rev3 = w.getRev()

        l = Connector().lookupDoc(doc)
        self.assertEqual(l.revs(), [rev1])
        self.assertEqual(l.preRevs(), [rev3])

        s = Connector().stat(rev3)
        self.assertEqual(s.parents(), [rev1])

        self.assertRevContent(self.store1, rev1, {"FILE": "ok"})
        self.assertRevContent(self.store1, rev3, {"FILE": "What are you waiting for, christmas?"})
开发者ID:peerdrive,项目名称:peerdrive,代码行数:19,代码来源:tests.py

示例14: test_sticky

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import revs [as 别名]
    def test_sticky(self):
        # create the document which should get replicated
        w = self.create(self.store1)
        w.writeAll("FILE", "foobar")
        w.commit()
        doc = w.getDoc()
        rev = w.getRev()

        # create sticky contianer on first store
        s = struct.Folder()
        with s.create(self.store1, "foo") as dummy:
            s.append(struct.DocLink(self.store1, doc))
            s.save()
            contDoc = s.getDoc()

            # need a dummy folder on both stores
            self.createCommon(
                [self.store1, self.store2],
                "org.peerdrive.folder",
                data={"PDSD": struct.dumps([{"": struct.DocLink(self.store1, contDoc)}])},
            )

        watch1 = self.watchDoc(doc, connector.Watch.EVENT_REPLICATED)
        watch2 = self.watchRev(rev, connector.Watch.EVENT_REPLICATED)

        # now replicate the folder to 2nd store
        Connector().replicateDoc(self.store1, contDoc, self.store2)

        # wait for sticky replicatin to happen
        self.assertTrue(watch1.waitForWatch())
        self.assertTrue(watch2.waitForWatch())

        # check doc (with rev) to exist on all stores
        l = Connector().lookupDoc(doc)
        self.assertEqual(l.revs(), [rev])
        self.assertEqual(len(l.stores(rev)), 2)
        self.assertTrue(self.store1 in l.stores(rev))
        self.assertTrue(self.store2 in l.stores(rev))

        l = Connector().lookupRev(rev)
        self.assertEqual(len(l), 2)
        self.assertTrue(self.store1 in l)
        self.assertTrue(self.store2 in l)
开发者ID:peerdrive,项目名称:peerdrive,代码行数:45,代码来源:tests.py

示例15: test_forget

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import revs [as 别名]
	def test_forget(self):
		(doc, rev1, rev_s1) = self.createSuspendDoc()

		with Connector().update(self.store1, doc, rev1) as w:
			w.writeAll('FILE', 'forward')
			w.commit()
			rev2 = w.getRev()

		with Connector().update(self.store1, doc, rev2) as w:
			w.writeAll('FILE', 'Hail to the king, baby!')
			w.suspend()
			rev_s2 = w.getRev()

		self.assertRaises(IOError, Connector().forget, self.store1, doc, rev1)
		Connector().forget(self.store1, doc, rev_s1)

		l = Connector().lookupDoc(doc)
		self.assertEqual(l.revs(), [rev2])
		self.assertEqual(l.preRevs(), [rev_s2])
开发者ID:wizzk42,项目名称:peerdrive,代码行数:21,代码来源:tests.py


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