commit cd6097faad1205f873065c5a280902942b84a6bc Author: Michal Srb msrb@redhat.com Date: Wed Jul 9 10:49:54 2014 +0200
Move "kill parent process" functionality to "util" module
depgenerators/maven.prov | 8 +++--- depgenerators/maven.req | 3 +- depgenerators/osgi.prov | 9 +++++++- depgenerators/osgi.req | 9 +++++++- python/javapackages/common/util.py | 39 ++++++++++++++++++++++++++++++++++++ 5 files changed, 61 insertions(+), 7 deletions(-) --- diff --git a/depgenerators/maven.prov b/depgenerators/maven.prov index 0f0cda5..c63abc0 100755 --- a/depgenerators/maven.prov +++ b/depgenerators/maven.prov @@ -37,6 +37,7 @@ import signal import sys import traceback from javapackages.metadata.metadata import Metadata +from javapackages.common.util import kill_parent
class TagBuilder: def __init__ (self, filelist=None): @@ -58,10 +59,9 @@ class TagBuilder:
if __name__ == "__main__": try: - builder = TagBuilder() - except Exception, e: + builder = TagBuilder () + except Exception: traceback.print_exc(file=sys.stderr) - sys.stderr.write(str(e)) # rpmbuild ignores non-zero exit codes but this that is bad. Make sure # the build fails and doesn't silently ignore problems - os.kill(os.getppid(), signal.SIGKILL) + kill_parent() diff --git a/depgenerators/maven.req b/depgenerators/maven.req index e0532b3..764acd6 100755 --- a/depgenerators/maven.req +++ b/depgenerators/maven.req @@ -44,6 +44,7 @@ import pickle from lxml import etree
from javapackages.common.config import get_configs, get_builddir +from javapackages.common.util import kill_parent from javapackages.maven.pom import POM from javapackages.maven.artifact import Artifact from javapackages.metadata.metadata import Metadata, MetadataInvalidException @@ -427,4 +428,4 @@ if __name__ == "__main__": traceback.print_exc(file=sys.stderr) # rpmbuild ignores non-zero exit codes but this that is bad. Make sure # the build fails and doesn't silently ignore problems - os.kill(os.getppid(), signal.SIGTERM) + kill_parent() diff --git a/depgenerators/osgi.prov b/depgenerators/osgi.prov index 5948123..11ef530 100755 --- a/depgenerators/osgi.prov +++ b/depgenerators/osgi.prov @@ -31,6 +31,7 @@ # Authors: Alexander Kurtakov akurtako@redhat.com
import javapackages.common.osgi as osgi +from javapackages.common.util import kill_parent import sys import os
@@ -51,4 +52,10 @@ class TagBuilder(object):
if __name__ == "__main__": - builder = TagBuilder() + try: + builder = TagBuilder () + except Exception: + traceback.print_exc(file=sys.stderr) + # rpmbuild ignores non-zero exit codes but this that is bad. Make sure + # the build fails and doesn't silently ignore problems + kill_parent() diff --git a/depgenerators/osgi.req b/depgenerators/osgi.req index 4de2070..0bc0cda 100755 --- a/depgenerators/osgi.req +++ b/depgenerators/osgi.req @@ -32,6 +32,7 @@
import javapackages.common.osgi as osgi import javapackages.common.config as config +from javapackages.common.util import kill_parent import sys import pickle import os @@ -98,4 +99,10 @@ def _check_path(path):
if __name__ == "__main__": - builder = TagBuilder() + try: + builder = TagBuilder () + except Exception: + traceback.print_exc(file=sys.stderr) + # rpmbuild ignores non-zero exit codes but this that is bad. Make sure + # the build fails and doesn't silently ignore problems + kill_parent() diff --git a/python/javapackages/common/util.py b/python/javapackages/common/util.py new file mode 100644 index 0000000..a1313ae --- /dev/null +++ b/python/javapackages/common/util.py @@ -0,0 +1,39 @@ +#!/usr/bin/python +# Copyright (c) 2014, Red Hat, Inc. +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the +# distribution. +# 3. Neither the name of the Red Hat nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# Authors: Michal Srb msrb@redhat.com + +import os +import signal + + +def kill_parent(): + os.kill(os.getppid(), signal.SIGTERM)
java-sig-commits@lists.fedoraproject.org