mirror of
https://github.com/archlinux-jerry/buildbot
synced 2024-11-22 04:50:41 +08:00
extra.py: do sub
This commit is contained in:
parent
3b0d45dfb1
commit
4a577db1ac
1 changed files with 8 additions and 2 deletions
10
extra.py
10
extra.py
|
@ -12,6 +12,10 @@ from utils import print_exc_plus
|
||||||
from config import PKGBUILD_DIR, MAIN_LOGFILE, CONSOLE_LOGFILE, \
|
from config import PKGBUILD_DIR, MAIN_LOGFILE, CONSOLE_LOGFILE, \
|
||||||
PKG_UPDATE_LOGFILE, MAKEPKG_LOGFILE
|
PKG_UPDATE_LOGFILE, MAKEPKG_LOGFILE
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
|
ASCII_CRL_REPL = re.compile('\x1B[@-_][0-?]*[ -/]*[@-~]')
|
||||||
|
|
||||||
logger = logging.getLogger(f'buildbot.{__name__}')
|
logger = logging.getLogger(f'buildbot.{__name__}')
|
||||||
|
|
||||||
abspath=os.path.abspath(__file__)
|
abspath=os.path.abspath(__file__)
|
||||||
|
@ -36,9 +40,11 @@ def gen_pkglist(pkgconfigs, pkgvers, pkgerrs):
|
||||||
namelist = [k for k in pkgall]
|
namelist = [k for k in pkgall]
|
||||||
return (namelist, pkgall)
|
return (namelist, pkgall)
|
||||||
|
|
||||||
def __simpleread(fpath, limit=4096-100):
|
def __simpleread(fpath, limit=4096-100, dosub=False):
|
||||||
with open(fpath, 'r') as f:
|
with open(fpath, 'r') as f:
|
||||||
c = f.read()
|
c = f.read()
|
||||||
|
if dosub:
|
||||||
|
c = ASCII_CRL_REPL.sub('', c[-2*limit:])
|
||||||
if len(c) > limit:
|
if len(c) > limit:
|
||||||
c = c[-limit:]
|
c = c[-limit:]
|
||||||
return c
|
return c
|
||||||
|
@ -48,7 +54,7 @@ def readpkglog(pkgdirname, update=False):
|
||||||
logfile = PKG_UPDATE_LOGFILE if update else MAKEPKG_LOGFILE
|
logfile = PKG_UPDATE_LOGFILE if update else MAKEPKG_LOGFILE
|
||||||
if cwd.exists() and (cwd / logfile).exists():
|
if cwd.exists() and (cwd / logfile).exists():
|
||||||
logger.debug(f'formatting {"update" if update else "build"} logs in {pkgdirname}')
|
logger.debug(f'formatting {"update" if update else "build"} logs in {pkgdirname}')
|
||||||
return __simpleread(cwd / logfile)
|
return __simpleread(cwd / logfile, dosub=True)
|
||||||
else:
|
else:
|
||||||
logger.debug(f'not found: {"update" if update else "build"} log in dir {pkgdirname}')
|
logger.debug(f'not found: {"update" if update else "build"} log in dir {pkgdirname}')
|
||||||
return f"{cwd / logfile} cannot be found"
|
return f"{cwd / logfile} cannot be found"
|
||||||
|
|
Loading…
Reference in a new issue