def setUp(self, unused_handler): super(LogCopyTest, self).setUp() self.log_file = r'C:\Windows\Logs\Glazier\glazier.log' self.lc = log_copy.LogCopy() # win32 modules self.win32netcon = mock.Mock() sys.modules['win32netcon'] = self.win32netcon self.win32wnet = mock.Mock() sys.modules['win32wnet'] = self.win32wnet
def testGetLogFileName(self, gv, unused_log, dt): lc = log_copy.LogCopy() gv.return_value = 'WORKSTATION1-W' now = datetime.datetime.utcnow() out_date = now.replace(microsecond=0).isoformat().replace(':', '') dt.return_value = now result = lc._GetLogFileName() self.assertEqual(result, r'l:\WORKSTATION1-W-' + out_date + '.log') gv.assert_called_with('name', path=constants.REG_ROOT)
def testGetLogFileName(self, reg, unused_log, dt): lc = log_copy.LogCopy() reg.return_value.GetKeyValue.return_value = 'WORKSTATION1-W' now = datetime.datetime.utcnow() out_date = now.replace(microsecond=0).isoformat().replace(':', '') dt.utcnow.return_value = now result = lc._GetLogFileName() self.assertEqual(result, r'l:\WORKSTATION1-W-' + out_date + '.log') reg.assert_called_with(root_key='HKLM') reg.return_value.GetKeyValue.assert_called_with( constants.REG_ROOT, 'name')
def Run(self): file_name = str(self._args[0]) share = None if len(self._args) > 1: share = str(self._args[1]) logging.debug('Found log copy event for file %s to %s.', file_name, share) copier = log_copy.LogCopy() # EventLog try: copier.EventLogCopy(file_name) except log_copy.LogCopyError as e: logging.warning('Unable to complete log copy to EventLog. %s', e) # CIFS if share: try: copier.ShareCopy(file_name, share) except log_copy.LogCopyError as e: logging.warning('Unable to complete log copy via CIFS. %s', e)