def delete(serial_number, controller_ip, name): res = None tag = get_tag_by_name(serial_number, controller_ip, name) if tag: res = tag_dao.delete_tag(serial_number, controller_ip, name) if res: print('Deleted a tag with name: ' + name) sync = {} sync['installation'] = tag['installation'] sync['method'] = sync_methods.DELETE sync['table'] = 'tags' sync['data'] = tag sync['prev'] = None res = syncHandler.insert(sync) return res
def update(tag): res = False current_tag = get_tag_by_name(tag.get('installation'), tag.get('controller_ip'), tag.get('name')) if current_tag and current_tag != tag: res = tag_dao.update_tag(tag) if res: print('Updated tag with name: ' + tag['name']) sync = {} sync['installation'] = tag['installation'] sync['method'] = sync_methods.UPDATE sync['table'] = 'tags' sync['data'] = tag sync['prev'] = None res = syncHandler.insert(sync) return res