Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

packages: add option to suppress warning messages printed directly to console #114

Merged

Conversation

jbohren
Copy link
Contributor

@jbohren jbohren commented Mar 16, 2015

No description provided.

@wjwwood
Copy link
Contributor

wjwwood commented Mar 16, 2015

The changes look reasonable, but there is a reason the warnings are being printed... For building locally, I think this is a valid scenario for ignoring warnings like this.

It would be nice to get the warnings rather than only having them printed to the screen or completely avoided. Maybe rather than suppress_warning you could pass warnings, which defaults to None. If it is None then messages are printed, but if it is a list then the warnings are appended to the list but not printed.

@@ -357,18 +359,19 @@ def parse_package(path):

with open(filename, 'r') as f:
try:
return parse_package_string(f.read(), filename)
return parse_package_string(f.read(), filename, suppress_warnings)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please pass kwargs as kwargs instead of positional. Same below.

@dirk-thomas
Copy link
Member

Very good point from William, changing the new parameter to "collect" the warnings would be even better.

@jbohren
Copy link
Contributor Author

jbohren commented Mar 17, 2015

It would be nice to get the warnings rather than only having them printed to the screen or completely avoided. Maybe rather than suppress_warning you could pass warnings, which defaults to None. If it is None then messages are printed, but if it is a list then the warnings are appended to the list but not printed.

Yeah, I'm down.

@jbohren
Copy link
Contributor Author

jbohren commented Mar 17, 2015

Ok. c9dfa9b adds warnings to a list passed into the warnings param if it isn't set to None

@wjwwood
Copy link
Contributor

wjwwood commented Mar 17, 2015

Other than the comment, lgtm.

if warnings is None:
print('WARNING: ' + warning, file=sys.stderr)
elif warning not in warnings:
warnings += warning
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If warnings is a list and warning is a string than this operation won't do the right thing?

@dirk-thomas
Copy link
Member

Can you please add a unit test for this new feature to ensure it works as expected.

@jbohren
Copy link
Contributor Author

jbohren commented Mar 17, 2015

Yeah I'll add a test.

@jbohren
Copy link
Contributor Author

jbohren commented Mar 18, 2015

Test added.

pkgs_dict = find_packages(test_data_dir, warnings=warnings)

for w, we in zip(warnings, test_expected_warnings):
assert(w == we)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should try to give a second argument to assert when ever you use it, because this line is failing on the farm, but I don't know why exactly.

You can also just do self.assertEqual(sorted(w), sorted(we)), or if you are certain what the order should be self.assertEqual(w, we). The self.assertEqual will automatically give you a nice comparison out if it fails.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'll get it working on the farm.

@jbohren jbohren force-pushed the suppress-warnings branch 3 times, most recently from 3c2bf26 to 994db97 Compare March 18, 2015 02:37
@wjwwood
Copy link
Contributor

wjwwood commented Mar 19, 2015

lgtm, @dirk-thomas?

@@ -357,18 +367,19 @@ def parse_package(path):

with open(filename, 'r') as f:
try:
return parse_package_string(f.read(), filename)
return parse_package_string(f.read(), filename, warnings)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please always pass kwargs with the explicit keyword instead of relying on the position. Same below.

@jbohren jbohren force-pushed the suppress-warnings branch 2 times, most recently from 02238fd to 6e8adca Compare March 24, 2015 05:13
@jbohren
Copy link
Contributor Author

jbohren commented Mar 24, 2015

Ready for review again.

@@ -529,7 +540,7 @@ def parse_package_string(data, filename=None):
if errors:
raise InvalidPackage('Error(s) in %s:%s' % (filename, ''.join(['\n- %s' % e for e in errors])))

pkg.validate()
pkg.validate(warnings)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last comment - promise 😉
This one should use the keyword too: warnings=warnings.

@jbohren
Copy link
Contributor Author

jbohren commented Mar 24, 2015

Ready again again.

@dirk-thomas
Copy link
Member

Thank you for making all the changes for the numerous small comments. LGTM.

dirk-thomas added a commit that referenced this pull request Mar 24, 2015
packages: add option to suppress warning messages printed directly to console
@dirk-thomas dirk-thomas merged commit fc10bd1 into ros-infrastructure:master Mar 24, 2015
k-okada added a commit to k-okada/catkin_pkg that referenced this pull request Jul 7, 2017
`catkin_generate_changelog`  outputs changelog with what we called with `--skip-merge` option, and reason is that `git show` does not show files for merged commit, we need '-m' option

```
k-okada@p40-yoga:/tmp/jsk_3rdparty$ git show 6a0bfaaf29bcc9a8e07e6edfccd230ad7f003070 --name-only --format=format:""

k-okada@p40-yoga:/tmp/jsk_3rdparty$ git show 6a0bfaaf29bcc9a8e07e6edfccd230ad7f003070
commit 6a0bfaaf29bcc9a8e07e6edfccd230ad7f003070
Merge: 5f6888c 54ea9bd
Author: Kei Okada <k-okada@jsk.t.u-tokyo.ac.jp>
Date:   Fri Jul 7 11:32:32 2017 +0900

    Merge pull request ros-infrastructure#114 from k-okada/add_unzip
    
    add unzip to build_depend
```
dirk-thomas pushed a commit that referenced this pull request Jul 10, 2017
*  "--skip-merge"  does not change any outputs

`catkin_generate_changelog`  outputs changelog with what we called with `--skip-merge` option, and reason is that `git show` does not show files for merged commit, we need '-m' option

```
k-okada@p40-yoga:/tmp/jsk_3rdparty$ git show 6a0bfaaf29bcc9a8e07e6edfccd230ad7f003070 --name-only --format=format:""

k-okada@p40-yoga:/tmp/jsk_3rdparty$ git show 6a0bfaaf29bcc9a8e07e6edfccd230ad7f003070
commit 6a0bfaaf29bcc9a8e07e6edfccd230ad7f003070
Merge: 5f6888c 54ea9bd
Author: Kei Okada <k-okada@jsk.t.u-tokyo.ac.jp>
Date:   Fri Jul 7 11:32:32 2017 +0900

    Merge pull request #114 from k-okada/add_unzip
    
    add unzip to build_depend
```

* use --first-parent, instead of -m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants