Download:
child 11:86067e7580c6
parent 9:ac48bb613c6f
10:3e63f239a827
Anton Shestakov <av6@dwimlabs.net>, Mon, 13 Jun 2016 23:35:59 +0800
checker: get file list using hg files

1 файлов изменено, 30 вставок(+), 9 удалений(-) [+]
checker.py file | annotate | diff | comparison | revisions
--- a/checker.py Mon Jun 13 23:05:22 2016 +0800
+++ b/checker.py Mon Jun 13 23:35:59 2016 +0800
@@ -5,7 +5,7 @@
from argparse import ArgumentParser, FileType
from datetime import datetime
from shutil import rmtree
-from subprocess import check_call, CalledProcessError
+from subprocess import check_call, check_output, CalledProcessError
from tempfile import mkdtemp
import yaml
@@ -21,23 +21,29 @@
def run_ignore_1(fn, args):
try:
- fn(args)
+ return fn(args)
except CalledProcessError as e:
if e.returncode != 1:
raise
+ return e.output
-def run(args, silent=False, ignore_1=False):
- if silent:
+def run(args, silent=False, get_output=False, ignore_1=False):
+ if get_output:
+ fn = check_output
+ else:
fn = check_call
- else:
- fn = print_and_run
try:
+ if not silent:
+ print('$ ' + ' '.join(args))
if ignore_1:
- run_ignore_1(fn, args)
+ result = run_ignore_1(fn, args)
else:
- fn(args)
- return True
+ result = fn(args)
+ if get_output:
+ return result
+ else:
+ return True
except Exception as e:
print('# C&O error: {}'.format(e))
print('# C&O job failed')
@@ -89,6 +95,21 @@
ok = False
break
+ if ok:
+ print('# C&O task: checks')
+ for linter in config['linters']:
+ if 'cmd' not in linter or 'files' not in linter:
+ continue
+
+ args = []
+ for fpat in linter['files']:
+ args.extend(['-I', fpat])
+ cmd = ['hg', 'files'] + args
+ files = run(cmd, silent=True, get_output=True, ignore_1=True)
+ if files is False:
+ ok = False
+ break
+
print('# C&O task: cleanup')
rmtree(tmp)