def stop_neo4j(): if NEO4J_PROCESS: print("Stopping Neo4j server with PID %d" % NEO4J_PROCESS["pid"]) NEO4J_PROCESS["installation"].server.stop() NEO4J_PROCESS["warehouse"].uninstall(NEO4J_PROCESS["name"]) NEO4J_PROCESS.clear() GraphService.forget_all()
def graph_service(uri): return GraphService(uri)
def test_profile(request): GraphService.forget_all() test_profile = request.param yield test_profile
def __init__(self, profile=None, *_, **settings): super(ClientConsole, self).__init__("py2neo", verbosity=settings.pop("verbosity", 0)) self.output_file = settings.pop("file", None) welcome = settings.pop("welcome", True) if welcome: self.write(TITLE) self.write() self.write(dedent(QUICK_HELP)) self.write() self.profile = ServiceProfile(profile, **settings) self.graph_name = None try: self.dbms = GraphService( self.profile) # TODO: use Connector instead except OSError as error: self.critical("Could not connect to <%s> (%s)", self.profile.uri, " ".join(map(str, error.args))) raise else: self.debug("Connected to <%s>", self.dbms.uri) try: makedirs(HISTORY_FILE_DIR) except OSError: pass self.history = FileHistory(path_join(HISTORY_FILE_DIR, HISTORY_FILE)) self.lexer = CypherLexer() self.result_writer = Table.write self.commands = { "//": self.set_multi_line, "::": self.set_multi_line, "/e": self.edit, "/edit": self.edit, ":e": self.edit, ":edit": self.edit, "/?": self.help, "/h": self.help, "/help": self.help, ":?": self.help, ":h": self.help, ":help": self.help, "/x": self.exit, "/exit": self.exit, ":x": self.exit, ":q": self.exit, ":q!": self.exit, ":wq": self.exit, ":exit": self.exit, "/use": self.use, ":use": self.use, "/play": self.play, ":play": self.play, "/csv": self.set_csv_result_writer, ":csv": self.set_csv_result_writer, "/table": self.set_tabular_result_writer, ":table": self.set_tabular_result_writer, "/tsv": self.set_tsv_result_writer, ":tsv": self.set_tsv_result_writer, "/config": self.config, ":config": self.config, "/kernel": self.kernel, ":kernel": self.kernel, } self.tx = None self.qid = 0