summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorAlon Levy <alon@pobox.com>2015-02-05 15:43:06 +0200
committerAlon Levy <alon@pobox.com>2015-02-05 15:43:06 +0200
commit0c770a62f4bb0cc201bf624947d96c0d012fa916 (patch)
tree44e54a9bcc9770db705e5a30e77887742ce23dd0 /tools
parentc6082885373acee08ecd746ddfa3b8dce1a0f8da (diff)
mv tools to src/local (next remove external curl util)
Diffstat (limited to 'tools')
-rwxr-xr-xtools/neo4j-cypher34
-rw-r--r--tools/rhizi_tools_neo4j.py43
2 files changed, 0 insertions, 77 deletions
diff --git a/tools/neo4j-cypher b/tools/neo4j-cypher
deleted file mode 100755
index c2aee707..00000000
--- a/tools/neo4j-cypher
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/usr/bin/python
-
-import json
-import sys
-import time
-import argparse
-
-help = """Welcome to neo4j-cypher, a tool to submit cypher queries to neo4j
-This tool follows the neo4j REST API and allows submitting queries from command
-line or standard in without using neo4j-shell since that doesn't work on all machines.
-It relies on curl right now although this could be replaced with straight python.
-"""
-
-import rhizi_tools_neo4j
-
-def main(statements):
- one_at_a_time = False
- if len(statements) == 0:
- statements = [l.strip() for l in sys.stdin.readlines() if l.strip()[:2] != '//' and l.strip() != ""]
- one_at_a_time = True
- print("----------------------------------------------------------------------")
- print "\n".join(statements)
- print("----------------------------------------------------------------------")
- results = rhizi_tools_neo4j.run(statements=statements, one_at_a_time=one_at_a_time)
- for result in results:
- json.dump(result, sys.stdout, sort_keys=True, indent=4, separators=(',', ': '))
- print()
-
-if __name__ == '__main__':
- parser = argparse.ArgumentParser(description=help, add_help=True)
- parser.add_argument('--verbose', action='store_true', default=False)
- args, statements = parser.parse_known_args(sys.argv[1:])
- verbose = args.verbose
- main(statements)
diff --git a/tools/rhizi_tools_neo4j.py b/tools/rhizi_tools_neo4j.py
deleted file mode 100644
index be8b4a5d..00000000
--- a/tools/rhizi_tools_neo4j.py
+++ /dev/null
@@ -1,43 +0,0 @@
-import subprocess
-import re
-import json
-
-verbose = False
-
-BASE="http://rhizi.local:7474/db/data"
-
-def c(cmd, incoming=None):
- if verbose:
- print("executing %r" % cmd)
- print(incoming)
- p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- if incoming:
- p.stdin.write(incoming)
- if p.stdin:
- p.stdin.close()
- p.wait()
- ret = p.stdout.read()
- return ret
-
-def curl(path, incoming):
- return c(["curl", "-H", 'Accept: application/json', "-H", 'Content-Type: application/json', '-XPOST', '-d@-', path],
- incoming=incoming)
-
-def transact(datum):
- transaction_output = curl(BASE + "/transaction/", '{"statements": [ ] }')
- commit = re.search("http://.*commit", transaction_output).group()
- ret = curl(commit, json.dumps(datum))
- obj = json.loads(ret)
- return obj
-
-def run(statements, one_at_a_time):
- def single_request_data(statements):
- return {'statements': [{'statement': s} for s in statements]}
- results = []
- if one_at_a_time:
- data = [single_request_data([statement]) for statement in statements]
- else:
- data = [single_request_data(statements)]
- for datum in data:
- results.append(transact(datum))
- return results