Bug 1074461

Summary: error messages in stdout when using rpm as a library
Product: [Fedora] Fedora Reporter: Ales Kozumplik <akozumpl>
Component: rpmAssignee: Packaging Maintenance Team <packaging-team-maint>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 20CC: jzeleny, novyjindrich, packaging-team-maint, pknirsch, pmatilai
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-03-25 10:34:06 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Ales Kozumplik 2014-03-10 10:09:20 UTC
There's the following script:

#! /usr/bin/python

import rpm

if __name__ == '__main__':
    spec = rpm.spec(__file__)

That outputs:

error: line 3: Unknown tag: import rpm

In the stdout.

If one creates an empty dir and points the rpm.spec call to it there's even more:
error: Name field must be present in package: (main package)
error: Version field must be present in package: (main package)
error: Release field must be present in package: (main package)
error: Summary field must be present in package: (main package)
error: License field must be present in package: (main package)

If the lib outputs these into stdout, the output of client programs like DNF can look overly dramatic and confusing.

Comment 1 Ales Kozumplik 2014-03-10 10:13:08 UTC
Related DNF bug 1074461.

Comment 2 Ales Kozumplik 2014-03-10 10:13:44 UTC
(In reply to Ales Kozumplik from comment #1)
> Related DNF bug 1074461.

Should be bug 1074436.

Comment 3 Panu Matilainen 2014-03-10 13:18:40 UTC
rpm libraries output to rpmlog() which defaults to stderr (not stdout), but which you can redirect to another file, including of course /dev/null:

sink = open("/dev/null", "w")
rpm.setLogFile(sink)

Comment 4 Ales Kozumplik 2014-03-10 13:48:46 UTC
Thanks Panu, updated our code.

Comment 5 Panu Matilainen 2014-03-25 10:34:06 UTC
NOTABUG as per comment #3, the output is not to stdout/stderr but to a client controllable log.