Skip to content

Commit f8a0910

Browse files
authored
Merge pull request #93 from HTTP-APIs/develop
2 parents 615dbb2 + b29b5df commit f8a0910

File tree

6 files changed

+30
-19
lines changed

6 files changed

+30
-19
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ celerybeat-schedule
8686
.venv
8787
venv/
8888
ENV/
89+
share
90+
include
91+
bin
92+
93+
# pipenv generated filespip
94+
Pipfile
95+
Pipfile.lock
8996

9097
# Spyder project settings
9198
.spyderproject
@@ -99,3 +106,6 @@ ENV/
99106

100107
# mypy
101108
.mypy_cache/
109+
110+
#build packages
111+
src

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ python:
1212
- "3.6-dev" # 3.6 development branch
1313
- "3.7-dev"
1414
install:
15-
- pip install -e git+https://github.com/HTTP-APIs/hydrus#egg=hydrus
15+
- pip install -e git+https://github.com/HTTP-APIs/hydra-python-core#egg=hydra_python_core
1616
- pip install -e .
1717

1818
script: python -m unittest discover

hydra_agent/hydra_graph.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
from redisgraph import Graph, Node
33
import urllib.request
44
import json
5-
from hydrus.hydraspec import doc_maker
6-
import hydrus
5+
from hydra_python_core import doc_maker, doc_writer
76
from graphviz import Digraph
87
from hydra_agent.classes_objects import ClassEndpoints,RequestError
98
from hydra_agent.collections_endpoint import CollectionEndpoints
@@ -21,12 +20,12 @@ def get_apistructure(self,entrypoint_node, api_doc):
2120
for support_property in api_doc.entrypoint.entrypoint.supportedProperty:
2221
if isinstance(
2322
support_property,
24-
hydrus.hydraspec.doc_writer.EntryPointClass):
23+
doc_writer.EntryPointClass):
2524
self.class_endpoints[support_property.name] = support_property.id_
2625

2726
if isinstance(
2827
support_property,
29-
hydrus.hydraspec.doc_writer.EntryPointCollection):
28+
doc_writer.EntryPointCollection):
3029
self.collection_endpoints[support_property.name] = support_property.id_
3130

3231
if len(self.class_endpoints.keys())>0:

hydra_agent/querying_mechanism.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
import logging
44
from hydra_agent.hydra_graph import InitialGraph
55
import urllib.request
6+
from urllib.parse import urljoin
67
import json
7-
from hydrus.hydraspec import doc_maker
8+
from hydra_python_core import doc_maker
89
from urllib.error import URLError, HTTPError
910
from hydra_agent.collections_endpoint import CollectionEndpoints
1011
from hydra_agent.classes_objects import ClassEndpoints,RequestError
@@ -29,18 +30,17 @@ def load_data(self, url):
2930
:return: loaded data
3031
"""
3132
try:
32-
response = urllib.request.urlopen(url)
33+
with urllib.request.urlopen(url) as response:
34+
return json.loads(response.read().decode('utf-8'))
3335
except HTTPError as e:
34-
logger.info('Error code: ', e.code)
36+
logger.error('Error Code: {}'.format(e.code))
3537
return RequestError("error")
3638
except URLError as e:
37-
logger.info('Reason: ', e.reason)
39+
logger.error('Reason: {}'.format(e.reason))
3840
return RequestError("error")
3941
except ValueError as e:
40-
logger.info("value error:", e)
42+
logger.error("Value Error: {}".format(e))
4143
return RequestError("error")
42-
else:
43-
return json.loads(response.read().decode('utf-8'))
4444

4545
def show_data(self, get_data):
4646
"""
@@ -658,7 +658,7 @@ def query(apidoc, url):
658658

659659
while True:
660660
print("press exit to quit")
661-
query = input(">>>")
661+
query = input(">>>").strip()
662662
if query == "exit":
663663
break
664664
elif query == "help":
@@ -672,7 +672,7 @@ def main():
672672
Take URL as an input and make graph using initilize function.
673673
:return: call query function for more query.
674674
"""
675-
url = input("url>>>")
675+
url = input("url>>>").strip()
676676
if url == "exit":
677677
print("exit...")
678678
return 0
@@ -681,11 +681,13 @@ def main():
681681
while True:
682682
if isinstance (apidoc, RequestError):
683683
print("enter right url")
684-
url = input("url>>>")
684+
url = input("url>>>").strip()
685685
if url == "exit":
686686
print("exit...")
687687
return 0
688-
apidoc = handle_data.load_data(url + "/vocab")
688+
url = url.rstrip('/') + '/'
689+
url = urljoin(url, 'vocab')
690+
apidoc = handle_data.load_data(url)
689691
else:
690692
break
691693
return query(apidoc, url)

redis_setup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
#It will check, if docker is not installed then install it.
33
docker -v
4-
if [ echo "$?" = "127" ]
4+
if [ "$?" = "127" ]
55
then
66
sudo apt-get update
77
sudo apt-get install docker

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ rdflib
22
rdflib-jsonld
33
uritemplate
44
httplib2
5-
redis
5+
redis==2.10.6
66
redisgraph
77
graphviz
8-
-e git+https://github.com/HTTP-APIs/hydrus.git#egg=hydrus
8+
-e git+https://github.com/HTTP-APIs/hydra-python-core.git#egg=hydra_python_core

0 commit comments

Comments
 (0)