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


Python Connector.stores方法代码示例

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


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

示例1: performSync

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import stores [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

示例2: test_sticky

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import stores [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

示例3: __init__

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import stores [as 别名]
    def __init__(self, link, parent=None):
        super(PropertiesDialog, self).__init__(parent)

        mainLayout = QtGui.QVBoxLayout()
        # mainLayout.setSizeConstraint(QtGui.QLayout.SetFixedSize)

        self.__doc = link.doc()
        self.__rev = link.rev()
        if self.__doc:
            isDoc = True
            banner = "document"
            l = Connector().lookupDoc(self.__doc)
            stores = [s for s in l.stores() if Connector().lookupRev(l.rev(s), [s]) == [s]]
        else:
            isDoc = False
            banner = "revision"
            stores = Connector().lookupRev(self.__rev)

        if len(stores) == 0:
            QtGui.QMessageBox.warning(self, "Missing document", "The requested document was not found on any store.")
            sys.exit(1)

        self.__docTab = DocumentTab(link.store(), stores, banner)
        self.__docTab.switchStore.connect(self.__switchStore)
        self.__revTab = RevisionTab()
        self.__annoTab = AnnotationTab(isDoc)
        self.__annoTab.changed.connect(self.__changed)
        self.__hisTab = HistoryTab()

        tabWidget = QtGui.QTabWidget()
        tabWidget.addTab(self.__annoTab, "Annotation")
        tabWidget.addTab(self.__hisTab, "History")

        if isDoc:
            self.__buttonBox = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Save | QtGui.QDialogButtonBox.Close)
            self.__buttonBox.button(QtGui.QDialogButtonBox.Save).setEnabled(False)
            self.__buttonBox.accepted.connect(self.__save)
            self.__buttonBox.rejected.connect(self.reject)
        else:
            self.__buttonBox = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok)
            self.__buttonBox.accepted.connect(self.accept)

        mainLayout.addWidget(self.__docTab)
        mainLayout.addWidget(self.__revTab)
        mainLayout.addWidget(tabWidget)
        mainLayout.addWidget(self.__buttonBox)
        self.setLayout(mainLayout)

        self.__switchStore(self.__docTab.activeStore())

        self.setWindowTitle("Properties of %s" % (self.__annoTab.getTitle()))
开发者ID:peerdrive,项目名称:peerdrive,代码行数:53,代码来源:properties.py

示例4: update

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import stores [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

示例5: createCommon

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import stores [as 别名]
	def createCommon(self, stores, type="public.data", creator="org.peerdrive.test-py", data={}):
		leadStore = stores.pop()
		w = self.create(leadStore, type, creator)
		for (part, blob) in data.items():
			w.writeAll(part, blob)
		w.commit()
		doc = w.getDoc()
		rev = w.getRev()
		for store in stores:
			w = self.create(store)
			w.writeAll('PDSD', struct.dumps([struct.DocLink(store, doc)]))
			w.commit()
			Connector().replicateDoc(leadStore, doc, store)

		# verify the common document on all stores
		l = Connector().lookupDoc(doc)
		self.assertEqual(l.revs(), [rev])
		for store in stores:
			self.assertTrue(store in l.stores())

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


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