Exemplo n.º 1
0
	def __add(self):
		(store, peer) = self.__addItems[self.__addChooser.currentIndex()]
		self.__rules.setMode(store, peer, 'ff')
		self.__rules.setDescr(store, peer, "Sync '" +
			struct.readTitle(DocLink(store, store, False), '?') + "' and '" +
			struct.readTitle(DocLink(peer, peer, False), '?') + "'")
		line = SyncRuleWidget(store, peer, self.__rules, self)
		line.removed.connect(self.__removed)
		self.__lines.append(line)
		self.__ruleLayout.addWidget(line)
		self.__fillAddChooser()
Exemplo n.º 2
0
	def __add(self):
		(store, peer) = self.__addItems[self.__addChooser.currentIndex()]
		self.__rules.setMode(store, peer, 'ff')
		self.__rules.setDescr(store, peer, "Sync '" +
			struct.readTitle(struct.DocLink(store, store, False), '?') +	"' and '" +
			struct.readTitle(struct.DocLink(peer, peer, False), '?') + "'")
		line = SyncRuleWidget(store, peer, self.__rules, self)
		line.removed.connect(self.__removed)
		self.__lines.append(line)
		self.__ruleLayout.addWidget(line)
		self.__fillAddChooser()
Exemplo n.º 3
0
    def progress(self, tag, state, value, err_code=None, err_doc=None, err_rev=None):
        if self.tag != tag:
            return

        if value > 0:
            self.progressBar.setMaximum(255)
        self.progressBar.setValue(value)
        if self.__state == state:
            return

        self.__state = state
        self.progressBar.setVisible(state != Connector().PROGRESS_ERROR)
        self.__errorMsg.setVisible(state == Connector().PROGRESS_ERROR)
        self.__skipBtn.setVisible(state == Connector().PROGRESS_ERROR)
        if state == Connector().PROGRESS_RUNNING:
            self.__pauseBtn.setIcon(QtGui.QIcon("icons/progress-pause.png"))
            self.__pauseBtn.setToolTip("Pause")
            if self.__type == Connector().PROGRESS_SYNC:
                self.__progressInd.setPixmap(QtGui.QPixmap("icons/progress-sync.png"))
            else:
                self.__progressInd.setPixmap(QtGui.QPixmap("icons/progress-replicate.png"))
        elif state == Connector().PROGRESS_PAUSED:
            self.__pauseBtn.setIcon(QtGui.QIcon("icons/progress-start.png"))
            self.__pauseBtn.setToolTip("Resume")
            self.__progressInd.setPixmap(QtGui.QPixmap("icons/progress-pause.png"))
        elif state == Connector().PROGRESS_ERROR:
            self.__pauseBtn.setIcon(QtGui.QIcon("icons/progress-retry.png"))
            self.__pauseBtn.setToolTip("Retry")
            self.__progressInd.setPixmap(QtGui.QPixmap("icons/progress-error.png"))
            doc = struct.readTitle(RevLink(self.__fromStore, err_rev), "unknown document")
            self.__errorMsg.setText("Error '" + err_code[1] + "' while processing '" + doc + "'!")
            if self.__type == Connector().PROGRESS_SYNC:
                title = "Synchronization error"
                message = "synchronizing"
            else:
                title = "Replication error"
                message = "replicating"
            message = (
                "Error '"
                + err_code[1]
                + "' while "
                + message
                + " '"
                + doc
                + "' \nfrom '"
                + struct.readTitle(DocLink(self.__fromStore, self.__fromStore), "unknown store")
                + "' to '"
                + struct.readTitle(DocLink(self.__toStore, self.__toStore), "unknown store")
                + "'!"
            )
            self.__trayIcon.showMessage(title, message, QtGui.QSystemTrayIcon.Warning)
Exemplo n.º 4
0
    def __addReplicateActions(self, menu, link):
        c = Connector()
        try:
            allVolumes = set(c.lookupRev(self.rev()))
            if isinstance(link, connector.DocLink):
                lookup = c.lookupDoc(link.doc())
                curVolumes = set(lookup.stores())
                try:
                    for rev in lookup.revs():
                        curVolumes = curVolumes & set(
                            c.lookupRev(rev, curVolumes))
                except IOError:
                    curVolumes = set()
            else:
                curVolumes = set(c.lookupRev(link.rev()))
        except IOError:
            return

        if not curVolumes:
            return

        srcVol = list(curVolumes)[0]
        repVolumes = allVolumes - curVolumes
        for store in repVolumes:
            name = struct.readTitle(connector.DocLink(store, store),
                                    "Unknown store")
            action = menu.addAction("Replicate item to '%s'" % name)
            action.triggered.connect(
                lambda x, l=link, s=store: self.__doReplicate(srcVol, l, s))
Exemplo n.º 5
0
	def __fillAddChooser(self):
		self.__addChooser.clear()
		self.__addItems = []

		enum = Connector().enum()
		rules = self.__rules.rules()
		stores = [enum.doc(s) for s in enum.allStores()
			if not enum.isSystem(s) and enum.isMounted(s)]
		self.__addItems = [(s, p) for s in stores for p in stores
			if s < p and (s,p) not in rules and (p,s) not in rules ]

		self.__addBtn.setEnabled(bool(self.__addItems))
		for (store, peer) in self.__addItems:
			title = (struct.readTitle(struct.DocLink(store, store, False), '?') +
				' - ' + struct.readTitle(struct.DocLink(peer, peer, False), '?'))
			self.__addChooser.addItem(title)
Exemplo n.º 6
0
	def __addReplicateActions(self, menu, link):
		c = Connector()
		try:
			allVolumes = set(c.lookupRev(self.rev()))
			if isinstance(link, connector.DocLink):
				lookup = c.lookupDoc(link.doc())
				curVolumes = set(lookup.stores())
				try:
					for rev in lookup.revs():
						curVolumes = curVolumes & set(c.lookupRev(rev, curVolumes))
				except IOError:
					curVolumes = set()
			else:
				curVolumes = set(c.lookupRev(link.rev()))
		except IOError:
			return

		if not curVolumes:
			return

		srcVol = list(curVolumes)[0]
		repVolumes = allVolumes - curVolumes
		for store in repVolumes:
			name = struct.readTitle(connector.DocLink(store, store), "Unknown store")
			action = menu.addAction("Replicate item to '%s'" % name)
			action.triggered.connect(
				lambda x,l=link,s=store: self.__doReplicate(srcVol, l, s))
Exemplo n.º 7
0
	def __fillAddChooser(self):
		self.__addChooser.clear()
		self.__addItems = []

		enum = Connector().enum()
		rules = self.__rules.rules()
		stores = [s.sid for s in enum.regularStores()]
		self.__addItems = [(s, p) for s in stores for p in stores
			if s < p and (s,p) not in rules and (p,s) not in rules ]

		self.__addBtn.setEnabled(bool(self.__addItems))
		for (store, peer) in self.__addItems:
			fromStore = '[' + enum.fromSId(store).label + '] '
			fromStore += struct.readTitle(DocLink(store, store, False), '?')
			peerStore = '[' + enum.fromSId(peer).label + '] '
			peerStore += struct.readTitle(DocLink(peer, peer, False), '?')
			self.__addChooser.addItem(fromStore + ' - ' + peerStore)
Exemplo n.º 8
0
    def __fillAddChooser(self):
        self.__addChooser.clear()
        self.__addItems = []

        enum = Connector().enum()
        rules = self.__rules.rules()
        stores = [s.sid for s in enum.regularStores()]
        self.__addItems = [
            (s, p) for s in stores for p in stores if s < p and (s, p) not in rules and (p, s) not in rules
        ]

        self.__addBtn.setEnabled(bool(self.__addItems))
        for (store, peer) in self.__addItems:
            fromStore = "[" + enum.fromSId(store).label + "] "
            fromStore += struct.readTitle(DocLink(store, store, False), "?")
            peerStore = "[" + enum.fromSId(peer).label + "] "
            peerStore += struct.readTitle(DocLink(peer, peer, False), "?")
            self.__addChooser.addItem(fromStore + " - " + peerStore)
Exemplo n.º 9
0
	def progress(self, tag, state, value, err_code=None, err_doc=None, err_rev=None):
		if self.tag != tag:
			return

		if value > 0:
			self.progressBar.setMaximum(255)
		self.progressBar.setValue(value)
		if self.__state == state:
			return

		self.__state = state
		self.progressBar.setVisible(state != Connector().PROGRESS_ERROR)
		self.__errorMsg.setVisible(state == Connector().PROGRESS_ERROR)
		self.__skipBtn.setVisible(state == Connector().PROGRESS_ERROR)
		if state == Connector().PROGRESS_RUNNING:
			self.__pauseBtn.setIcon(QtGui.QIcon("icons/progress-pause.png"))
			self.__pauseBtn.setToolTip("Pause")
			if self.__type == Connector().PROGRESS_SYNC:
				self.__progressInd.setPixmap(QtGui.QPixmap("icons/progress-sync.png"))
			else:
				self.__progressInd.setPixmap(QtGui.QPixmap("icons/progress-replicate.png"))
		elif state == Connector().PROGRESS_PAUSED:
			self.__pauseBtn.setIcon(QtGui.QIcon("icons/progress-start.png"))
			self.__pauseBtn.setToolTip("Resume")
			self.__progressInd.setPixmap(QtGui.QPixmap("icons/progress-pause.png"))
		elif state == Connector().PROGRESS_ERROR:
			self.__pauseBtn.setIcon(QtGui.QIcon("icons/progress-retry.png"))
			self.__pauseBtn.setToolTip("Retry")
			self.__progressInd.setPixmap(QtGui.QPixmap("icons/progress-error.png"))
			doc = struct.readTitle(RevLink(self.__fromStore, err_rev),
				'unknown document')
			self.__errorMsg.setText("Error '" + err_code[1] + "' while processing '"
				+ doc + "'!")
			if self.__type == Connector().PROGRESS_SYNC:
				title = "Synchronization error"
				message = "synchronizing"
			else:
				title = "Replication error"
				message = "replicating"
			message = "Error '" + err_code[1] + "' while " + message + " '" + doc + \
				"' \nfrom '" + struct.readTitle(DocLink(self.__fromStore, self.__fromStore), "unknown store") + \
				"' to '" + struct.readTitle(DocLink(self.__toStore, self.__toStore), "unknown store") + \
				"'!"
			self.__trayIcon.showMessage(title, message, QtGui.QSystemTrayIcon.Warning)
Exemplo n.º 10
0
	def __addStoreMenu(self, store, removable):
		l = DocLink(store.sid, store.sid)
		type = Connector().stat(l.rev(), [store.sid]).type()
		executables = Registry().getExecutables(type)
		title = struct.readTitle(l)
		if len(title) > 20:
			title = title[:20] + '...'
		title += ' ['+store.label+']'

		menu = self.__trayIconMenu.addMenu(QtGui.QIcon("icons/uti/store.png"), title)
		if removable:
			menu.aboutToShow.connect(lambda m=menu, l=l, s=store: self.__fillMenu(m, l, s))
		else:
			menu.aboutToShow.connect(lambda m=menu, l=l: self.__fillMenu(m, l))
Exemplo n.º 11
0
    def __addStoreMenu(self, store, removable):
        l = DocLink(store.sid, store.sid)
        type = Connector().stat(l.rev(), [store.sid]).type()
        executables = Registry().getExecutables(type)
        title = struct.readTitle(l)
        if len(title) > 20:
            title = title[:20] + "..."
        title += " [" + store.label + "]"

        menu = self.__trayIconMenu.addMenu(QtGui.QIcon("icons/uti/store.png"), title)
        if removable:
            menu.aboutToShow.connect(lambda m=menu, l=l, s=store: self.__fillMenu(m, l, s))
        else:
            menu.aboutToShow.connect(lambda m=menu, l=l: self.__fillMenu(m, l))