permissions: Use proper logging (#2089)

Refactored so we can use the proper logging infrastructure instead of `print`.
This commit is contained in:
Adrian Sampson 2016-06-28 10:29:26 -07:00
parent 3a700eb2a4
commit e33c19a3e9

View file

@ -48,12 +48,11 @@ class Permissions(BeetsPlugin):
u'dir': '755'
})
self.register_listener('item_imported', permissions)
self.register_listener('album_imported', permissions)
self.register_listener('item_imported', self.fix)
self.register_listener('album_imported', self.fix)
def permissions(lib, item=None, album=None):
"""Running the permission fixer.
def fix(self, lib, item=None, album=None):
"""Fix the permissions for an imported Item or Album.
"""
# Getting the config.
file_perm = config['permissions']['file'].get()
@ -80,9 +79,10 @@ def permissions(lib, item=None, album=None):
# Checks if the destination path has the permissions configured.
if not check_permissions(util.bytestring_path(path), file_perm):
message = u'There was a problem setting permission on {}'.format(
path)
print(message)
self._log.warn(
u'There was a problem setting permissions on file {}',
path,
)
# Adding directories to the directory chmod queue.
dir_chmod_queue.update(
@ -96,6 +96,7 @@ def permissions(lib, item=None, album=None):
# Checks if the destination path has the permissions configured.
if not check_permissions(util.bytestring_path(path), dir_perm):
message = u'There was a problem setting permission on {}'.format(
path)
print(message)
self._log.warn(
u'There was a problem setting permissions on directory {}',
path,
)