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

Only output CD read failure traceback in debug mode #801

Merged
merged 2 commits into from Jan 19, 2018

Conversation

zas
Copy link
Collaborator

@zas zas commented Jan 18, 2018

It makes the log cleaner, as most of times CD read error is due to CD not inserted.

Without debug mode, output looks like:

E: 16:58:00 Error while reading b'/dev/sr1': cannot open device `/dev/sr1'

With debug mode:

D: 16:58:17 Reading CD using device: b'/dev/sr1'
E: 16:58:17 Error while reading b'/dev/sr1': cannot open device `/dev/sr1'
E: 16:58:17 Traceback (most recent call last):
  File "./picard/util/thread.py", line 47, in run
    result = self.func()
  File "./picard/disc.py", line 55, in read
    raise e
  File "./picard/disc.py", line 50, in read
    disc = discid.read(device)
  File "/home/zas/.virtualenvs/picard2/lib/python3.5/site-packages/discid/disc.py", line 55, in read
    disc.read(device, features)
  File "/home/zas/.virtualenvs/picard2/lib/python3.5/site-packages/discid/disc.py", line 152, in read
    raise DiscError(self._get_error_msg())
discid.disc.DiscError: cannot open device `/dev/sr1'

It makes the log cleaner, as most of times CD read error is due to CD not inserted.

Without debug mode, output looks like:

```
E: 16:58:00 Error while reading b'/dev/sr1': cannot open device `/dev/sr1'
```

With debug mode:

```
D: 16:58:17 Reading CD using device: b'/dev/sr1'
E: 16:58:17 Error while reading b'/dev/sr1': cannot open device `/dev/sr1'
E: 16:58:17 Traceback (most recent call last):
  File "./picard/util/thread.py", line 47, in run
    result = self.func()
  File "./picard/disc.py", line 55, in read
    raise e
  File "./picard/disc.py", line 50, in read
    disc = discid.read(device)
  File "/home/zas/.virtualenvs/picard2/lib/python3.5/site-packages/discid/disc.py", line 55, in read
    disc.read(device, features)
  File "/home/zas/.virtualenvs/picard2/lib/python3.5/site-packages/discid/disc.py", line 152, in read
    raise DiscError(self._get_error_msg())
discid.disc.DiscError: cannot open device `/dev/sr1'
```
self.id = disc.id
self.submission_url = disc.submission_url
except discid.disc.DiscError as e:
log.error("Error while reading %r: %s" % (device, str(e)))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any reason we are using %r here?

Copy link
Collaborator

@samj1912 samj1912 Jan 19, 2018

Choose a reason for hiding this comment

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

It causes logs like

E: 16:58:17 Error while reading b'/dev/sr1': cannot open device `/dev/sr1'

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I didn't want to bother encodings etc...

@zas zas merged commit f006a5b into metabrainz:master Jan 19, 2018
@zas zas deleted the cd_lookup branch January 20, 2018 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants