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