16
16
"""Use command-line tools to check for audio file corruption.
17
17
"""
18
18
19
- from __future__ import (division , absolute_import , print_function ,
20
- unicode_literals )
19
+ from __future__ import (division , absolute_import , print_function )
21
20
22
21
from beets .plugins import BeetsPlugin
23
22
from beets .ui import Subcommand
32
31
33
32
class BadFiles (BeetsPlugin ):
34
33
def run_command (self , cmd ):
35
- self ._log .debug ("running command: {}" ,
34
+ self ._log .debug (u "running command: {}" ,
36
35
displayable_path (list2cmdline (cmd )))
37
36
try :
38
37
output = check_output (cmd , stderr = STDOUT )
@@ -44,7 +43,7 @@ def run_command(self, cmd):
44
43
status = e .returncode
45
44
except OSError as e :
46
45
if e .errno == errno .ENOENT :
47
- ui .print_ ("command not found: {}" .format (cmd [0 ]))
46
+ ui .print_ (u "command not found: {}" .format (cmd [0 ]))
48
47
sys .exit (1 )
49
48
else :
50
49
raise
@@ -87,9 +86,9 @@ def check_bad(self, lib, opts, args):
87
86
# First, check whether the path exists. If not, the user
88
87
# should probably run `beet update` to cleanup your library.
89
88
dpath = displayable_path (item .path )
90
- self ._log .debug ("checking path: {}" , dpath )
89
+ self ._log .debug (u "checking path: {}" , dpath )
91
90
if not os .path .exists (item .path ):
92
- ui .print_ ("{}: file does not exist" .format (
91
+ ui .print_ (u "{}: file does not exist" .format (
93
92
ui .colorize ('text_error' , dpath )))
94
93
95
94
# Run the checker against the file if one is found
@@ -102,20 +101,20 @@ def check_bad(self, lib, opts, args):
102
101
path = item .path .decode (sys .getfilesystemencoding ())
103
102
status , errors , output = checker (path )
104
103
if status > 0 :
105
- ui .print_ ("{}: checker exited withs status {}"
104
+ ui .print_ (u "{}: checker exited withs status {}"
106
105
.format (ui .colorize ('text_error' , dpath ), status ))
107
106
for line in output :
108
107
ui .print_ (" {}" .format (displayable_path (line )))
109
108
elif errors > 0 :
110
- ui .print_ ("{}: checker found {} errors or warnings"
109
+ ui .print_ (u "{}: checker found {} errors or warnings"
111
110
.format (ui .colorize ('text_warning' , dpath ), errors ))
112
111
for line in output :
113
- ui .print_ (" {}" .format (displayable_path (line )))
112
+ ui .print_ (u " {}" .format (displayable_path (line )))
114
113
else :
115
- ui .print_ ("{}: ok" .format (ui .colorize ('text_success' , dpath )))
114
+ ui .print_ (u "{}: ok" .format (ui .colorize ('text_success' , dpath )))
116
115
117
116
def commands (self ):
118
117
bad_command = Subcommand ('bad' ,
119
- help = 'check for corrupt or missing files' )
118
+ help = u 'check for corrupt or missing files' )
120
119
bad_command .func = self .check_bad
121
120
return [bad_command ]
0 commit comments