[Pkg-debile-commits] [debile-slave] 02/100: Sweet daddy yankee.
Sylvestre Ledru
sylvestre at alioth.debian.org
Mon Aug 19 14:52:58 UTC 2013
This is an automated email from the git hooks/post-receive script.
sylvestre pushed a commit to branch master
in repository debile-slave.
commit a53d577f80fc89b9437a9232356b3e490b51d966
Author: Paul Tagliamonte <tag at pault.ag>
Date: Wed May 22 09:15:14 2013 -0400
Sweet daddy yankee.
---
ethel/chroot.py | 44 ++++++-----------------------
ethel/commands/adequate.py | 67 ++++++++++++++++++++++++++++++++++++++++++++
setup.py | 1 +
3 files changed, 77 insertions(+), 35 deletions(-)
diff --git a/ethel/chroot.py b/ethel/chroot.py
index 2fabca1..74975de 100644
--- a/ethel/chroot.py
+++ b/ethel/chroot.py
@@ -17,13 +17,16 @@ def get_mount_point(session):
def safe_run(cmd, expected=0):
out, err, ret = run_command(cmd)
+ out, err = (x.decode('utf-8') for x in (out, err))
+
if ret != expected:
- print(cmd)
- print(out.decode('utf-8'))
- print(err.decode('utf-8'))
- print(ret)
+ e = Exception("Bad command")
+ e.out = out
+ e.err = err
+ e.ret = ret
+ e.cmd = cmd
+ raise e
- raise Exception("Bad command")
return out, err
@@ -39,9 +42,9 @@ def scmd(session, command, expected=0, user=None):
def schroot(chroot):
session = "ethel-%s" % (os.getpid())
out, err = safe_run(['schroot', '-b', '-n', session, '-c', chroot])
- session = out.strip().decode('utf-8')
try:
+ session = out.strip()
print("[ethel] Started session: %s" % (session))
yield session
finally:
@@ -52,32 +55,3 @@ def copy(session, source, dest):
root = get_mount_point(session)
dest = os.path.join(root, dest)
return shutil.copy2(source, dest)
-
-
-def adequate(chroot, package):
- with schroot(chroot) as session:
- deb = os.path.basename(package)
- if not deb.endswith('.deb'):
- raise ValueError("Stop with the crack smoking")
-
- where = '/tmp/%s' % (deb)
- copy(session, package, where)
-
- out, err = scmd(session, [
- 'apt-get', 'install', '-y', 'adequate'
- ], user='root')
-
- out, err = scmd(session, [
- 'dpkg', '-i', where
- ], user='root', expected=1)
-
- out, err = scmd(session, [
- 'apt-get', 'install', '-y', '-f'
- ], user='root')
-
- out, err = scmd(session, ['adequate', deb.split("_", 1)[0]])
- print(out, err)
-
-
-adequate('unstable-amd64',
- '/home/tag/dev/debian/fluxbox/fluxbox_1.3.5-1_amd64.deb')
diff --git a/ethel/commands/__init__.py b/ethel/commands/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/ethel/commands/adequate.py b/ethel/commands/adequate.py
new file mode 100644
index 0000000..b2f01d6
--- /dev/null
+++ b/ethel/commands/adequate.py
@@ -0,0 +1,67 @@
+from ethel.chroot import schroot, copy, scmd
+from storz.wrapper import generate_analysis
+from firehose.model import Issue, Message, File, Location
+
+import os
+import re
+
+OUTPUT_REGEX = re.compile(r"(?P<package>.*): (?P<tag>[^\s]*) (?P<info>.*)")
+
+
+def parse_output(lines):
+ for line in lines:
+ info = OUTPUT_REGEX.match(line).groupdict()
+
+ testid = info['tag']
+ severity = "error"
+ pth = info['info'].split(" ", 1)
+ pth = pth[0] if pth else None
+
+ if pth is None:
+ continue
+
+ yield Issue(cwe=None,
+ testid=testid,
+ location=Location(file=File(pth, None),
+ function=None,
+ point=None),
+ severity=severity,
+ message=Message(text=line),
+ notes=None,
+ trace=None)
+
+
+def adequate(chroot, package):
+ analysis = generate_analysis("adequate", "unstable", package)
+
+ with schroot(chroot) as session:
+ deb = os.path.basename(package)
+ if not deb.endswith('.deb'):
+ raise ValueError("Stop with the crack smoking")
+
+ where = '/tmp/%s' % (deb)
+ copy(session, package, where)
+
+ out, err = scmd(session, [
+ 'apt-get', 'install', '-y', 'adequate'
+ ], user='root')
+
+ out, err = scmd(session, [
+ 'dpkg', '-i', where
+ ], user='root', expected=1)
+
+ out, err = scmd(session, [
+ 'apt-get', 'install', '-y', '-f'
+ ], user='root')
+
+ #out, err = scmd(session, ['adequate', deb.split("_", 1)[0]])
+ out, err = scmd(session, ['adequate', '--all'])
+ for issue in parse_output(out.splitlines()):
+ analysis.results.append(issue)
+ return analysis
+
+def main():
+ import sys
+ output = open(sys.argv[3], 'wb')
+ info = adequate(sys.argv[1], sys.argv[2])
+ output.write(info.to_xml_bytes())
diff --git a/setup.py b/setup.py
index 903a98a..bf3b3f9 100755
--- a/setup.py
+++ b/setup.py
@@ -23,6 +23,7 @@ setup(
'ethel-submit = ethel.cli:submit',
'ethel-next = ethel.cli:next',
'ethel-close = ethel.cli:close',
+ 'ethel-adequate = ethel.commands.adequate:main',
],
}
)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-debile/debile-slave.git
More information about the Pkg-debile-commits
mailing list