def remove_umcicons(dn, attrs): for object_data in attrs.get('univentionUMCIcon', []): module_name = attrs.get('cn')[0] (mime_type, compression_mime_type, subdir) = imagecategory_of_buffer(object_data) targetdir = os.path.join(UMC_ICON_BASEDIR, subdir) filename_suffix = default_filename_suffix_for_mime_type(mime_type, compression_mime_type) filename = os.path.join(targetdir, "udm-%s%s" % (module_name.replace('/', '-'), filename_suffix)) ud.debug(ud.LISTENER, ud.INFO, '%s: Removing %s.' % (name, filename)) if os.path.exists(filename): os.unlink(filename) else: ud.debug(ud.LISTENER, ud.INFO, '%s: Warning: %s does not exist.' % (name, filename))
def install_umcicons(dn, attrs): for object_data in attrs.get('univentionUMCIcon', []): module_name = attrs.get('cn')[0] (mime_type, compression_mime_type, subdir) = imagecategory_of_buffer(object_data) targetdir = os.path.join(UMC_ICON_BASEDIR, subdir) filename_suffix = default_filename_suffix_for_mime_type(mime_type, compression_mime_type) filename = os.path.join(targetdir, "udm-%s%s" % (module_name.replace('/', '-'), filename_suffix)) if not os.path.exists(targetdir): ud.debug(ud.LISTENER, ud.ERROR, '%s: Error writing %s. Parent directory does not exist.' % (name, filename)) continue with open(filename, 'w') as f: f.write(object_data)