def reset_plugin(options): plugin = options.plugin_name[0] try: reset_schema(plugin) console("The database for `%s` has been reset." % plugin) except ValueError as e: console("Unable to reset %s: %s" % (plugin, e.message))
def reset_plugin(options): plugin = options.plugin_name[0] try: reset_schema(plugin) console('The database for `%s` has been reset.' % plugin) except ValueError as e: console('Unable to reset %s: %s' % (plugin, e.message))
def reset_plugin(options): plugin = options.reset_plugin if not plugin: if options.porcelain: console('%-20s | Ver | Tables' % 'Name') else: console('-' * 79) console('%-20s Ver Tables' % 'Name') console('-' * 79) for k, v in sorted(plugin_schemas.items()): tables = '' line_len = 0 for name in v['tables']: if options.porcelain: pass else: if line_len + len(name) + 2 >= 53: tables += '\n' tables += ' ' * 26 line_len = len(name) + 2 else: line_len += len(name) + 2 tables += name + ', ' tables = tables.rstrip(', ') if options.porcelain: console('%-20s %s %-3s %s %s' % (k, '|', v['version'], '|', tables)) else: console('%-20s %-2s %s' % (k, v['version'], tables)) else: try: reset_schema(plugin) console('The database for `%s` has been reset.' % plugin) except ValueError as e: console('Unable to reset %s: %s' % (plugin, e.message))
def post(self, session: Session = None) -> Response: """Perform DB operations""" msg = '' data = request.json operation = data['operation'] if operation == 'cleanup': self.manager.db_cleanup(force=True) msg = 'DB Cleanup finished' elif operation == 'vacuum': session.execute('VACUUM') session.commit() msg = 'DB VACUUM finished' elif operation == 'plugin_reset': plugin_name = data.get('plugin_name') if not plugin_name: raise BadRequest( "'plugin_name' attribute must be used when trying to reset plugin" ) try: reset_schema(plugin_name) msg = f'Plugin {plugin_name} DB reset was successful' except ValueError: raise BadRequest( f'The plugin {plugin_name} has no stored schema to reset') return success_response(msg)
def reset_plugin(manager): if not manager.options.reset_plugin: return manager.disable_tasks() plugin = manager.options.reset_plugin if plugin == '__list__': console('%-20s Ver Tables' % 'Name') console('-' * 79) for k, v in sorted(plugin_schemas.iteritems()): tables = '' line_len = 0 for name in v['tables']: if line_len + len(name) + 2 >= 53: tables += '\n' tables += ' ' * 25 line_len = len(name) + 2 else: line_len += len(name) + 2 tables += name + ', ' tables = tables.rstrip(', ') console('%-20s %s %s' % (k, v['version'], tables)) else: try: reset_schema(plugin) console('The database for `%s` has been reset.' % plugin) except ValueError as e: console('Unable to reset %s: %s' % (plugin, e.message))
def get(self, session=None): """ Reset the DB of a specific plugin """ args = plugin_parser.parse_args() plugin = args['plugin_name'] try: reset_schema(plugin) except ValueError: raise BadRequest('The plugin {} has no stored schema to reset'.format(plugin)) return success_response('Plugin {} DB reset was successful'.format(plugin))
def get(self, session=None): """ Reset the DB of a specific plugin """ args = plugin_parser.parse_args() plugin = args['plugin_name'] try: reset_schema(plugin) except ValueError: return {'status': 'error', 'message': 'The plugin {} has no stored schema to reset'.format(plugin)}, 400 return {'status': 'success', 'message': 'Plugin {} DB reset was successful'.format(plugin)}, 200
def get(self, session=None): """ Reset the DB of a specific plugin """ args = plugin_parser.parse_args() plugin = args['plugin_name'] try: reset_schema(plugin) except ValueError: return { 'status': 'error', 'message': 'The plugin {} has no stored schema to reset'.format(plugin) }, 400 return { 'status': 'success', 'message': 'Plugin {} DB reset was successful'.format(plugin) }, 200
def post(self, session=None): """Perform DB operations""" data = request.json operation = data['operation'] if operation == 'cleanup': self.manager.db_cleanup(force=True) msg = 'DB Cleanup finished' elif operation == 'vacuum': session.execute('VACUUM') session.commit() msg = 'DB VACUUM finished' elif operation == 'plugin_reset': plugin_name = data.get('plugin_name') if not plugin_name: raise BadRequest('\'plugin_name\' attribute must be used when trying to reset plugin') try: reset_schema(plugin_name) msg = 'Plugin {} DB reset was successful'.format(plugin_name) except ValueError: raise BadRequest('The plugin {} has no stored schema to reset'.format(plugin_name)) return success_response(msg)
def reset_plugin(options): plugin = options.reset_plugin if not plugin: console("%-20s Ver Tables" % "Name") console("-" * 79) for k, v in sorted(plugin_schemas.iteritems()): tables = "" line_len = 0 for name in v["tables"]: if line_len + len(name) + 2 >= 53: tables += "\n" tables += " " * 25 line_len = len(name) + 2 else: line_len += len(name) + 2 tables += name + ", " tables = tables.rstrip(", ") console("%-20s %s %s" % (k, v["version"], tables)) else: try: reset_schema(plugin) console("The database for `%s` has been reset." % plugin) except ValueError as e: console("Unable to reset %s: %s" % (plugin, e.message))