Inconsistent printing of warnings/errors in ringbuilder cli

Bug #1511139 reported by Paul Dardeau
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Object Storage (swift)
In Progress
Low
shravya Gaddam

Bug Description

Most printing statements use print function, while a couple use stderr.write. There should be more consistent printing of warning errors.

Example of most common printing of a warning:

    print('Warning: Writing an empty ring')

Example of less common printing of a warning:

    stderr.write("WARNING: default min_part_hours may not match the value in the lost builder.")

This inconsistency also bleeds over into the unit tests.

Revision history for this message
shravya Gaddam (shravya-g90) wrote :

Hi

Can you please explain more clearly on this.
Do we need to modify with print where there is stderr.write.

Could you please confirm this

Thanks

Revision history for this message
Paul Dardeau (paul-dardeau) wrote :

Instead of:

stderr.write("WARNING: default min_part_hours may not match the value in the lost builder.")

it should be:

print("WARNING: default min_part_hours may not match the value in the lost builder.", file=sys.stderr)

This change will provide greater consistency and will allow unit tests to more easily mock print statement (suppress logging to console during testing).

Revision history for this message
Paul Dardeau (paul-dardeau) wrote :

Additionally, some statements use all caps (WARNING) and others use mixed case (Warning). Warning and error severity tokens should have consistent capitalization rules.

Changed in swift:
assignee: nobody → shravya Gaddam (shravya-g90)
status: New → In Progress
clayg (clay-gerrard)
Changed in swift:
importance: Undecided → Low
Revision history for this message
shravya Gaddam (shravya-g90) wrote :

Do i need to check each and every file for the stderr.write to print or specific to any file.

Thanks

Revision history for this message
Paul Dardeau (paul-dardeau) wrote :

It would be nice to have all of them converted, but it's not necessary to have to them all done in a single patch.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.