def _run_server(self): """Run server.""" try: from snippy.server.server import Server if Config.defaults: AllContent(self.storage).import_all() self.server = Server(self.storage) self.server.run() except ImportError: Cause.push( Cause.HTTP_INTERNAL_SERVER_ERROR, 'install snippy as a server in order to run api server') Cause.print_message()
def _run_cli(self): """Run CLI command.""" if Config.is_category_snippet: Snippet(self.storage).run() elif Config.is_category_solution: Solution(self.storage).run() elif Config.is_category_reference: Reference(self.storage).run() elif Config.is_multi_category and (Config.is_operation_search or Config.is_operation_export or Config.is_operation_import): AllContent(self.storage).run() else: Cause.push( Cause.HTTP_BAD_REQUEST, 'content category \'all\' is supported only with search, import or export operations' ) Cause.print_message()