-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_push.py
More file actions
90 lines (67 loc) · 2.6 KB
/
data_push.py
File metadata and controls
90 lines (67 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
from gql import gql, Client
from gql.transport.requests import RequestsHTTPTransport
from pkg_resources import ContextualVersionConflict
# from rich.console import Console
import requests
import json
import time
from sqlalchemy import delete
from tqdm import tqdm
# console = Console()
sample_transport=RequestsHTTPTransport(
url='http://localhost:4001/graphql',
use_json=True,
headers={
"Content-type": "application/json",
},
verify=False
)
client = Client(
#execute_timeout=20,
transport=sample_transport,
fetch_schema_from_transport=True,
)
session = requests.Session()
session.auth = ('admin', "secret")
hostname = 'http://ec2-3-64-237-95.eu-central-1.compute.amazonaws.com:8080/tilt/tilt'
auth = session.post(hostname)
response = json.loads(session.get(hostname).content)
#tilt = json.loads(requests.get('http://ec2-3-64-237-95.eu-central-1.compute.amazonaws.com:8080/tilt/tilt').content)
#print("Fetch Successful!", response)
json_file = open('/Users/johannes/Desktop/TU/playground/tilt')
tilt = json.load(json_file)
print('Purposes:')
tilt_nodes = []
tilt_edges = []
"""for i in tilt:
#print(i)
#record node
tilt_nodes.append([str.lower(i['meta']['name']), str.lower(i['meta']['url'])])
#loop through outgoing data
for e in i['dataDisclosed']:
#loop through recipients
for r in e['recipients']:
#record the egde
#print(e['purposes'][0]['purpose'])
try:
if r['name'] != [] and len(r['name'])<100:
tilt_edges.append([str.lower(i['meta']['name']), str.lower(r['name']), str.lower(e['purposes'][0]['purpose'])])
if str.lower(r['name']) not in tilt_nodes:
tilt_nodes.append([str.lower(r['name']), ''])
except:
continue
print(i['meta']['name'])
query_string = "mutation {createDataProtectionOfficers(input: { name: \""+i['meta']['name']+"\"}) {dataProtectionOfficers {name}}}"
query = gql(query_string)
client_response = client.execute(query)
print(client_response)
for i in tqdm(range(1, len(purposes) + 1)):
p = purposes['%s' % (i)]
description = p['description'].replace('"', '\\"').replace(':', '\:"')
descriptionLegal = p['descriptionLegal'].replace('"', '\\"').replace('\n', '')
query_string = 'mutation { CreatePurpose(id: %s, name: "%s", description: "%s", descriptionLegal: "%s") { _id }}' % (p['id'], p['name'], description, descriptionLegal)
print("Query String: ", query_string)
query = gql(query_string)
client.execute(query)
i = i + 1
"""