示例#1
0
def run_callbacks(cbtype, *args, **kws):
    if not cbtype in callbacks:
        raise koji.PluginError('"%s" is not a valid callback type' % cbtype)
    for func in callbacks[cbtype]:
        try:
            func(cbtype, *args, **kws)
        except:
            msg = 'Error running %s callback from %s' % (cbtype,
                                                         func.__module__)
            if getattr(func, 'failure_is_an_option', False):
                logging.getLogger('koji.plugin').warn(msg, exc_info=True)
            else:
                tb = ''.join(traceback.format_exception(*sys.exc_info()))
                raise koji.CallbackError('%s:\n%s' % (msg, tb))
示例#2
0
def expand_rpm(filepath, tmpdir):
    devnull = open('/dev/null', 'r+')
    rpm2cpio = subprocess.Popen(['/usr/bin/rpm2cpio', filepath],
                                stdout=subprocess.PIPE,
                                stdin=devnull, stderr=devnull,
                                close_fds=True)
    cpio = subprocess.Popen(['/bin/cpio', '-id'],
                            stdin=rpm2cpio.stdout,
                            cwd=tmpdir,
                            stdout=devnull, stderr=devnull,
                            close_fds=True)
    if rpm2cpio.wait() != 0 or cpio.wait() != 0:
        raise koji.CallbackError('error extracting files from %s, ' \
              'rpm2cpio returned %s, cpio returned %s' % \
              (filepath, rpm2cpio.wait(), cpio.wait()))
    devnull.close()