コード例 #1
0
    def test_metadata_writeMetaData_1(self):
        """verify writeMetaData write a file and copies it remotely"""
        json_str = """{"backup-today": "2019-01-02", "latest-complete": "2019-01-02-012345"}"""
        metadata = MetaData(self.log, self.comms, self.settings, json_str)
        self.assertEqual(self.log.getVal('info'), '')
        with patch("builtins.open", mock_open(read_data="data")) as mock_file:
            metadata.writeMetaData()
            mock_file.assert_called_with('/Users/judge/.metadata', 'w')
            handle = mock_file()
            handle.write.assert_called_once_with(
                '{"backup-today": "2019-01-02", "latest-complete": "2019-01-02-012345"}\n'
            )

        self.assertEqual(self.comms.getFilename(), '/Users/judge/.metadata')
コード例 #2
0
    def finishUp(self):
        """write .metadata file"""
        if self.backup_successful:
            meta2 = MetaData(self.log, self.comms, self.settings, "")
            meta2.set("latest-complete", TimeDate.datedir())
            meta2.set("backup-today", TimeDate.today())

            try:
                meta2.writeMetaData()

                # move WORKING to Latest Complete Date
                src = os.path.join(self.settings('backup-destination'),
                                   self.settings('local-hostname'), "WORKING")
                dest = os.path.join(self.settings('backup-destination'),
                                    self.settings('local-hostname'),
                                    TimeDate.datedir())
                self.comms.remoteCommand(f"mv {src} {dest}")
            except CrashPlanError as exc:
                print(exc)
                self.log.error(exc)