MCPcopy Create free account
hub / github.com/jipegit/OSXAuditor / AggregateLogsDir

Function AggregateLogsDir

osxauditor.py:857–873  ·  view source on GitHub ↗

Aggregate all logs found in a directory to a zipball

(ZipHandle, LogDirPath)

Source from the content-addressed store, hash-verified

855 ParsePackagesDir(os.path.join(ROOT_PATH, 'System/Library/Extensions/'))
856
857def AggregateLogsDir(ZipHandle, LogDirPath):
858 ''' Aggregate all logs found in a directory to a zipball '''
859
860 NbLogFiles = 0
861
862 for Root, Dirs, Files in os.walk(LogDirPath):
863 for File in Files:
864 FilePath = os.path.join(Root, File)
865 try:
866 ZipHandle.write(FilePath)
867 PrintAndLog(u'Log file ' + FilePath.decode('utf-8') + u' added to the logs zipball', 'INFO')
868 except:
869 PrintAndLog(FilePath.decode('utf-8') + u' aggregation FAILED', 'ERROR')
870 NbLogFiles += 1
871
872 if NbLogFiles == 0:
873 PrintAndLog(LogDirPath.decode('utf-8') + u' is empty', 'INFO')
874
875def AggregateLogs(ZipLogsFile):
876 ''' Walk in the different log directories to add all logs to a zipball '''

Callers 1

AggregateLogsFunction · 0.85

Calls 1

PrintAndLogFunction · 0.85

Tested by

no test coverage detected