Example #1
0
	def test_BareGitRepo_GotTempDir_TempDirIsCleaned(self, processRunnerMock):
		repoPath = super(self.__class__, self)._getBareRepoPath()
		tempDir = mkdtemp()
		try:
			backuper = Backuper(repoPath, tempDir)
			backuper.run()

			tempDirContents = listdir(tempDir)
			self.assertEqual(len(tempDirContents), 0)
		finally:
			rmtree(tempDir)
Example #2
0
	def test_BareGitRepo_GotTempDir_NoTempDirCreated(self, processRunnerMock):
		repoPath = super(self.__class__, self)._getBareRepoPath()
		tempDir = mkdtemp()
		try:
			with patch('tempfile.mkdtemp') as mkdtemp_mock:
				backuper = Backuper(repoPath, tempDir)
				backuper.run()

			self.assertFalse(mkdtemp_mock.called)
		finally:
			rmtree(tempDir)
Example #3
0
	def test_BareGitRepo_NoTempDir_TempDirIsCleaned(self, processRunnerMock):
		tempDir = mkdtemp()
		self.assertTrue(path.exists(tempDir))

		repoPath = super(self.__class__, self)._getBareRepoPath()
		with patch('tempfile.mkdtemp') as mkdtemp_mock:
			mkdtemp_mock.return_value = tempDir
			backuper = Backuper(repoPath)
			backuper.run()

		mkdtemp_mock.assert_called_once_with()
		self.assertFalse(path.exists(tempDir))
Example #4
0
    def on_startBackup_clicked(self, widget):
        print("Starting backup")
        backuper = Backuper.Backuper()
        sources = self.pathToFolders.text().split(";")
        destination = self.pathToBackupFolder.text()

        progress = QProgressBar()
        progress.setMinimum(0)
        progress.setMaximum(len(sources))
        self.mainLayout.addWidget(progress)

        for source in sources:
            backuper.make_backup(source, destination)
            progress.setValue(sources.index(source))
            QApplication.processEvents()
        doneDialog = QMessageBox()

        doneDialog.setIcon(QMessageBox.Information)
        doneDialog.setText("Copying data is completed")
        doneDialog.setWindowTitle("Copy event")
        doneDialog.setStandardButtons(QMessageBox.Ok)

        index = self.mainLayout.indexOf(progress)
        self.mainLayout.itemAt(index).widget().setParent(None)

        doneDialog.exec()
Example #5
0
def main():
	fileConfig("logging.conf")
	log = getLogger(__name__)
	log.info("PyBackup %s by %s" % (__version__, __author__))

	try:
		parser = OptionParser()
		parser.add_option("-r", "--repo", dest="repoPath", help="path to repository")
		parser.add_option("-t", "--temp", dest="tempDir", help="path to temp directory")
		(options, args) = parser.parse_args()

		backuper = Backuper(options.repoPath, options.tempDir)
		backuper.run()
	except Exception as exception:
		log.exception(exception)

	log.info("Execution finished")
Example #6
0
	def test_CommonGitRepo_Success(self, processRunnerMock):
		repoPath = super(self.__class__, self)._getCommonRepoPath()
		backuper = Backuper(repoPath)
		backuper.run()