Last active
December 10, 2015 14:39
-
-
Save felipe-prenholato/4449261 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import re | |
import codecs | |
from django.utils.datastructures import SortedDict | |
linhas = SortedDict() # um sorted dict é uma boa | |
with codecs.open('bacula_log.log', 'rb', 'utf8') as f: | |
achou = -1 | |
for i, linha in enumerate(f.readlines()): | |
if (re.match('^02-Jan', linha)): | |
achou = i | |
linhas[achou] = SortedDict() | |
linhas[achou][i] = linha | |
elif | |
# aqui vc ve quais linhas vc quer adicionar, mas sempre adiciona como abaixo | |
linhas[achou][i] = linha | |
""" | |
Ai vc tem tipo... | |
linhas[1][1] = "02-Jan 11:45 director-cliente JobId 3561: shell command: run BeforeJob "/etc/bacula/make_catalog_backup.pl MyCatalog" | |
linhas[2][2] = "02-Jan 11:45 director-cliente JobId 3561: Start Backup JobId 3558, Job=BackupCatalog.2013-01-01_22.45.00_30" | |
linhas[2][3] = " Non-fatal FD errors: 0" | |
linhas[2][4] = " SD Errors: 0" | |
linhas[2][5] = " FD termination status: OK" | |
linhas[2][6] = " SD termination status: OK" | |
linhas[2][7] = " Termination: Backup OK" | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import re | |
import codecs | |
from django.utils.datastructures import SortedDict | |
linhas = SortedDict() # um sorted dict é uma boa | |
with codecs.open('bacula_log.log', 'rb', 'utf8') as f: | |
achou = -1 | |
for i, linha in enumerate(f.readlines()): | |
if (re.match('^02-Jan', linha)): | |
achou = i | |
linhas[achou] = SortedDict() | |
linhas[achou]['log'] = linha | |
elif | |
# aqui vc ve quais linhas vc quer adicionar, mas sempre adiciona como abaixo | |
if "FD termination status" in linha and \ | |
linha != "FD termination status: OK": | |
linhas[achou]['fd-termination-status'] = linha | |
""" | |
Ai vc tem tipo... | |
linhas[1]['log'] = "02-Jan 11:45 director-cliente JobId 3561: shell command: run BeforeJob "/etc/bacula/make_catalog_backup.pl MyCatalog" | |
linhas[2]['log'] = "02-Jan 11:45 director-cliente JobId 3561: Start Backup JobId 3558, Job=BackupCatalog.2013-01-01_22.45.00_30" | |
linhas[2]['fd-termination-status'] = " FD termination status: OK" | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment