Skip to content

Instantly share code, notes, and snippets.

@moylop260
Last active August 29, 2015 14:05
Show Gist options
  • Save moylop260/c8b43a04ed55fe16f219 to your computer and use it in GitHub Desktop.
Save moylop260/c8b43a04ed55fe16f219 to your computer and use it in GitHub Desktop.
import time
import os
def grep_attemps(fname, grep, wait_sec=3, attemps=30):
#import pdb;pdb.set_trace()
with open(fname, "r") as f:
where = f.tell()
for i in range(attemps):
lines = f.readlines()
if not lines:
f.seek(where)
else:
for line in lines:
if grep in line:
return True
time.sleep(wait_sec)
return False
path = "/Users/moylop260/openerp/instancias/odoo_git_clone/community-addons/odoo-extra/runbot/static/build/"
build = "00526-7-0-7-0-od"
fname = os.path.join(path, build, "logs", "job_20_test_all.txt")
#fname = "/Users/moylop260/openerp/instancias/odoo_git_clone/start/log/trunk-odoo-runbot.log"
print grep_attemps(fname, '.modules.loading: Modules loaded.', 3, 600)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment