コード例 #1
0
ファイル: launchbox.py プロジェクト: edwardt/hotchpotch
	def sync(self):
		self._updateFileName(self._rev)
		s = Connector().stat(self._rev)
		fileHash = s.hash('FILE')
		if fileHash != self._hashFile():
			self._syncToFilesystem()
			os.chmod(self._path, stat.S_IREAD)
コード例 #2
0
ファイル: launchbox.py プロジェクト: edwardt/hotchpotch
	def __init__(self, parent=None):
		super(Launchbox, self).__init__(parent)

		self.__server = LauchServer()

		self.setSizePolicy(
			QtGui.QSizePolicy.Preferred,
			QtGui.QSizePolicy.Minimum )
		self.progressWidgets = {}
		self.progressContainer = QtGui.QWidget()

		self.progressLayout = QtGui.QVBoxLayout()
		self.progressLayout.setMargin(0)
		self.progressContainer.setLayout(self.progressLayout)

		self.mainLayout = QtGui.QVBoxLayout()
		self.mainLayout.setSizeConstraint(QtGui.QLayout.SetMinimumSize)
		enum = Connector().enum()
		for store in enum.allStores():
			if not enum.isSystem(store):
				self.mainLayout.addWidget(StoreWidget(store))

		syncButton = QtGui.QPushButton("Synchronization")
		syncButton.clicked.connect(lambda: SyncEditor().exec_())
		setupLayout = QtGui.QHBoxLayout()
		setupLayout.addWidget(syncButton)
		setupLayout.addStretch()
		hLine = QtGui.QFrame()
		hLine.setFrameStyle(QtGui.QFrame.HLine | QtGui.QFrame.Raised)
		self.mainLayout.addWidget(hLine)
		self.mainLayout.addLayout(setupLayout)

		hLine = QtGui.QFrame()
		hLine.setFrameStyle(QtGui.QFrame.HLine | QtGui.QFrame.Raised)
		self.mainLayout.addWidget(hLine)
		self.mainLayout.addWidget(self.progressContainer)
		self.mainLayout.addStretch()

		self.setLayout(self.mainLayout)
		self.setWindowTitle("Hotchpotch launch box")
		self.setWindowIcon(QtGui.QIcon("icons/launch.png"))
		self.setWindowFlags(QtCore.Qt.Window
			| QtCore.Qt.WindowCloseButtonHint
			| QtCore.Qt.WindowMinimizeButtonHint)

		Connector().regProgressHandler(start=self.progressStart,
			stop=self.progressStop)
コード例 #3
0
ファイル: launchbox.py プロジェクト: edwardt/hotchpotch
	def update(self):
		if self.watch:
			Connector().unwatch(self.watch)
			self.watch = None

		enum = Connector().enum()
		self.mountBtn.setEnabled(enum.isRemovable(self.mountId))
		if enum.isMounted(self.mountId):
			doc = enum.doc(self.mountId)
			self.mountBtn.setText("Unmount")
			self.storeBtn.setDocument(doc)
			self.watch = StoreWidget.StoreWatch(doc, self.update)
			Connector().watch(self.watch)
			self.mounted = True
		else:
			self.mountBtn.setText("Mount")
			self.storeBtn.setText(enum.name(self.mountId))
			self.mounted = False
コード例 #4
0
ファイル: launchbox.py プロジェクト: edwardt/hotchpotch
	def __init__(self, parent=None):
		super(SyncEditor, self).__init__(parent)
		self.setAttribute(QtCore.Qt.WA_DeleteOnClose)

		self.__changed = False
		self.__buttons = []
		self.__rules = SyncRules()
		enum = Connector().enum()
		stores = zip(itertools.count(1), [enum.doc(s) for s in enum.allStores()
			if not enum.isSystem(s) and enum.isMounted(s)])

		mainLayout = QtGui.QVBoxLayout()

		layout = QtGui.QGridLayout()
		layout.addWidget(QtGui.QLabel("From \\ To"), 0, 0)
		for (pos, store) in stores:
			button = DocButton(store, True)
			self.__buttons.append(button)
			layout.addWidget(button, 0, pos)
			button = DocButton(store, True)
			self.__buttons.append(button)
			layout.addWidget(button, pos, 0)
		for (row, store) in stores:
			for (col, peer) in stores:
				if store==peer:
					continue
				box = QtGui.QComboBox()
				box.addItems([SyncEditor.MAP[m] for m in SyncEditor.MODES])
				box.setCurrentIndex(SyncEditor.MODES.index(self.__rules.mode(store, peer)))
				box.currentIndexChanged.connect(
					lambda i, store=store, peer=peer: self.__setRule(store, peer, i))
				layout.addWidget(box, row, col)

		mainLayout.addLayout(layout)

		buttonBox = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok
			| QtGui.QDialogButtonBox.Cancel);
		buttonBox.accepted.connect(self.accept)
		buttonBox.rejected.connect(self.reject)
		mainLayout.addWidget(buttonBox)

		self.setLayout(mainLayout)
		self.setWindowTitle("Synchronization rules")
コード例 #5
0
ファイル: launchbox.py プロジェクト: edwardt/hotchpotch
	def __update(self):
		revs = Connector().lookup_doc(self.__doc).revs()
		if self._rev in revs:
			return
		# FIXME: prompt if more than one version
		self._rev = revs[0]

		s = Connector().stat(self._rev)
		# FIXME: META and/or FILE part may be missing
		metaHash = s.hash('META')
		fileHash = s.hash('FILE')

		if metaHash != self.__metaHash:
			self.__metaHash = metaHash
			self._updateFileName()

		if fileHash != self.__fileHash:
			if self.__fileHash is None:
				if self._hashFile() != fileHash:
					self._syncToFilesystem()
			else:
				self._syncToFilesystem()
			self.__fileHash = fileHash