import requests import time from threading import Thread import json import os import sys # def get_result(index): # # URL = "http://127.0.0.1:8000/Tierra_2/alm01/savephoto" # r = requests.post(url=URL, json={"user": 'I6', 'steps': 60}) # result = r.json() # print(result, index) # # request_num = 16000 # time_step = 1/request_num # for i in range(request_num): # # t = Thread(target=get_result, args=(i, )) # t.start() # time.sleep(time_step) # start = time.time() # for i in range(15000): # URL = "http://127.0.0.1:8000/Tierra_2/alm01/savephoto" # print(i) # r = requests.post(url=URL, json={"user": 'I6', 'steps': 60}) # result = r.json() # print(result, i, time.time()-start) # post(0,0,graph) # URL = "http://127.0.0.1:1114/GMS/raster/create_vrt" # params = {'user': 'user_test', # 'raster_dir': {'ip': 'localnet.ftp', # 'driver_type': 'FTP', # 'file_type': 'ECW', # 'port': 21, # 'user': 'username', # 'password': 'mypass', # 'source': '/ORTO' # }, # 'output': {'ip': 'localnet.ftp', # 'driver_type': 'FTP', # 'file_type': 'ZIP', # 'port': 21, # 'user': 'username', # 'password': 'mypass', # 'source': '/output.zip' # } # # } # r = requests.post(url=URL, json=params) # task_json = r.json() # print(task_json) # URL = "http://127.0.0.1:1114/GMS/raster/edit" # params = {'user': 'user_test', # 'raster': {'ip': 'localnet.ftp', # 'driver_type': 'FTP', # 'file_type': 'GeoTIFF', # 'port': 21, # 'user': 'username', # 'password': 'mypass', # 'source': '/PNOA_2015_GAL-W_476-4752_ORT-CLA-CIR.tif' # } # # } # r = requests.post(url=URL, json=params) # task_json = r.json() # print(task_json) # URL = "http://127.0.0.1:1114/GMS/raster/merge_bands" # params = {'user': 'user_test', # 'raster_dir': {'ip': 'localnet.ftp', # 'driver_type': 'FTP', # 'file_type': 'JP2', # 'port': 21, # 'user': 'username', # 'password': 'mypass', # 'source': '/merge_bands' # }, # 'output': {'ip': 'localnet.ftp', # 'driver_type': 'FTP', # 'file_type': 'GeoTIFF', # 'port': 21, # 'user': 'username', # 'password': 'mypass', # 'source': '/merged_bands.tif' # } # } # r = requests.post(url=URL, json=params) # task_json = r.json() # print(task_json) URL = "http://192.168.1.166:8000/AI/skyNet/new_entities" params = {'user': 'user_test', 'AOI': {'ip': '192.168.1.43', 'driver_type': 'FTP', 'file_type': 'KML', 'port': 30018, 'user': 'admin_maps', 'password': 'srm-d01', 'source': '/AOI_little.kml', 'layer_name': 'AOI_little' }, 'orthophoto': {'ip': '192.168.1.43', 'driver_type': 'FTP', 'port': 30018, 'file_type': 'ECW', 'user': 'admin_maps', 'password': 'srm-d01', 'source': '/ORTO' }, 'lidar': {'ip': '192.168.1.43', 'driver_type': 'FTP', 'port': 30018, 'file_type': 'GeoTIFF', 'user': 'admin_maps', 'password': 'srm-d01', 'source': '/PointCloud' }, 'ms': {'ip': '192.168.1.43', 'driver_type': 'FTP', 'port': 30018, 'file_type': 'GeoTIFF', 'user': 'admin_maps', 'password': 'srm-d01', 'source': '/MS' }, 'output_layer': {'ip': '192.168.1.43', 'driver_type': 'FTP', 'port': 30018, 'file_type': 'SHAPE', 'user': 'admin_maps', 'password': 'srm-d01', 'source': '/test_result.shp'}, 'indexes': ['camino', 'piscina'], 'confident': 0.4 } r = requests.post(url=URL, json=params) task_json = r.json() print(task_json) # params = {"_id": "ZAkxsKatyBgXf5x9Z", # "owner": "Xk6k7HLnQGo7KwDg9", # "label": "IANewFeatures", # "name": "IA_New_Features", # "group": "AI", # "links": [{"source": "AOI", "target": "newFeature"}, # {"source": "orthophoto", "target": "newFeature"}, # {"source": "PointCloud", "target": "newFeature"}, # {"source": "SentinelImage", "target": "newFeature"}, # {"source": "newFeature", "target": "outoputfile"}], # "nodes": [{"x": 50, # "y": 50, # "id": "AOI", # "label": "Area of interest", # "argName": "AOI", # "nodeType": "CONNECTION", # "connectionParams": {"allowedPGTypes": [], # "allowedFileTypes": ["KML"], # "allowedMapServerElementTypes": [], # "temporal": False, # "createMapServerElement": False, # "connector": {"_id": "wvKAJoe7GGAsFfFxN", "owner": "Xk6k7HLnQGo7KwDg9", # "name": "AI_connector", "type": "FTP", "ip": "localnet.ftp", # "port": 21, "user": "username", "password": "mypass", # "createdAt": "2019-07-10T11:45:52.911Z", # "updatedAt": "2019-07-10T11:45:52.912Z", "deleted": "no"}, # "source": {"_id": "BiwWXirMcN9EY2kFe", "owner": "Xk6k7HLnQGo7KwDg9", "name": "AOI", # "type": "VECTOR", "connectorId": "wvKAJoe7GGAsFfFxN", # "filePath": "/AOI_little.kml", "fileType": "KML", "layerName": "AOI_little", # "createdAt": "2019-07-10T11:45:52.914Z", # "updatedAt": "2019-07-10T11:45:52.914Z", "deleted": "no"}}}, # {"x": 50, "y": 150, "id": "orthophoto", "label": "orthophoto to extract new features", # "argName": "orthophoto", "nodeType": "CONNECTION", # "connectionParams": {"allowedPGTypes": [], "allowedFileTypes": ["ECW", "GeoTIFF"], # "allowedMapServerElementTypes": [], "temporal": False, "createMapServerElement": False, # "connector": {"_id": "wvKAJoe7GGAsFfFxN", "owner": "Xk6k7HLnQGo7KwDg9", # "name": "AI_connector", "type": "FTP", "ip": "localnet.ftp", # "port": 21, "user": "username", "password": "mypass", # "createdAt": "2019-07-10T11:45:52.911Z", # "updatedAt": "2019-07-10T11:45:52.912Z", "deleted": "no"}, # "source": {"_id": "GyYKmTXbwjvgDMwt4", "owner": "Xk6k7HLnQGo7KwDg9", "name": "Orto", # "type": "RASTER", "connectorId": "wvKAJoe7GGAsFfFxN", "filePath": "/ORTO", # "fileType": "ECW", "createdAt": "2019-07-10T11:45:52.914Z", # "updatedAt": "2019-07-10T11:45:52.914Z", "deleted": "no"}}}, # {"x": 50, "y": 250, "id": "PointCloud", "label": "PointCloud to extract new features", "argName": "lidar", # "nodeType": "CONNECTION", "connectionParams": {"allowedPGTypes": [], "allowedFileTypes": ["GeoTIFF"], # "allowedMapServerElementTypes": [], "temporal": False, # "createMapServerElement": False, # "connector": {"_id": "wvKAJoe7GGAsFfFxN", # "owner": "Xk6k7HLnQGo7KwDg9", # "name": "AI_connector", "type": "FTP", # "ip": "localnet.ftp", "port": 21, # "user": "username", "password": "mypass", # "createdAt": "2019-07-10T11:45:52.911Z", # "updatedAt": "2019-07-10T11:45:52.912Z", # "deleted": "no"}, # "source": {"_id": "JP8PaK7obqrRKRxLA", # "owner": "Xk6k7HLnQGo7KwDg9", "name": "Lidar", # "type": "RASTER", # "connectorId": "wvKAJoe7GGAsFfFxN", # "filePath": "/PointCloud", "fileType": "GeoTIFF", # "createdAt": "2019-07-10T11:45:52.914Z", # "updatedAt": "2019-07-10T11:45:52.914Z", # "deleted": "no"}}}, # {"x": 50, "y": 350, "id": "SentinelImage", "label": "Sentinel Image to extract new features", # "argName": "ms", "nodeType": "CONNECTION", # "connectionParams": {"allowedPGTypes": [], "allowedFileTypes": ["GeoTIFF"], # "allowedMapServerElementTypes": [], "temporal": False, "createMapServerElement": False, # "connector": {"_id": "wvKAJoe7GGAsFfFxN", "owner": "Xk6k7HLnQGo7KwDg9", # "name": "AI_connector", "type": "FTP", "ip": "localnet.ftp", # "port": 21, "user": "username", "password": "mypass", # "createdAt": "2019-07-10T11:45:52.911Z", # "updatedAt": "2019-07-10T11:45:52.912Z", "deleted": "no"}, # "source": {"_id": "epeQRKN6ZRqsq4YR2", "owner": "Xk6k7HLnQGo7KwDg9", # "name": "Sentinel", "type": "RASTER", "connectorId": "wvKAJoe7GGAsFfFxN", # "filePath": "/MS", "fileType": "GeoTIFF", # "createdAt": "2019-07-10T11:45:52.914Z", # "updatedAt": "2019-07-10T11:45:52.914Z", "deleted": "no"}}}, # {"x": 350, "y": 200, "id": "outoputfile", "label": "outoputfile", "argName": "outoputfile", # "nodeType": "CONNECTION", # "connectionParams": {"allowedPGTypes": [], "allowedFileTypes": ["SHAPE", "GeoTIFF"], # "allowedMapServerElementTypes": ["WMS", "TMS", "GeoJSON"], "temporal": False, # "createMapServerElement": True, "mapServerElementType": "WMS", "autorefresh": False, # "connector": {"_id": "wvKAJoe7GGAsFfFxN", "owner": "Xk6k7HLnQGo7KwDg9", # "name": "AI_connector", "type": "FTP", "ip": "localnet.ftp", # "port": 21, "user": "username", "password": "mypass", # "createdAt": "2019-07-10T11:45:52.912Z", # "updatedAt": "2019-07-10T11:45:52.912Z", "deleted": "no"}, # "source": {"_id": "wrDjaFqJuJbuN6qLY", "owner": "Xk6k7HLnQGo7KwDg9", # "name": "AI_output_shp", "type": "VECTOR", "connectorId": "wvKAJoe7GGAsFfFxN", # "filePath": "/AOI_result_shp.shp", "fileType": "SHAPE", # "createdAt": "2019-07-10T11:45:52.914Z", # "updatedAt": "2019-07-10T11:45:52.914Z", "deleted": "no"}}}, # {"x": 200, "y": 200, "id": "newFeature", "label": "newFeature", "nodeType": "SUBTASK", # "methodUrl": "/AI/skyNet/new_entities", "argName": "newFeature", "paramList": [ # {"id": "indexes", "label": "origin_model", "type": "STRING", "multiValue": True, # "options": ["edificios", "piscinas"], "value": ["edificios", "piscinas"]}]}], # "createdAt": "2019-07-10T11:45:52.910Z", "updatedAt": "2019-07-10T11:45:52.910Z", "deleted": "no"} # URL = "http://127.0.0.1:1114/MG/itasker/run_task" # r = requests.post(url=URL, json={"user": 'xk6k7hlnqgo7kwdg9', 'json_graph': params}) # URL = "http://127.0.0.1:1114/MG/pg/create_foreing_table_pg" # params = {'user': 'user_test', 'input_layer': {'ip': 'localnet.ftp', # 'driver_type': 'FTP', # 'file_type': 'KML', # 'port': '21', # 'user': 'username', # 'password': 'mypass', # 'source': '/AOI_WEIRD.kml', # 'layer_name': 'AOI_WEIRD' # } # } # r = requests.post(url=URL, json=params) # task_json = r.json() # print(task_json) # URL = "http://192.168.1.43:30009/MG/update/staticBase" # params = {'user': 'test', # 'aoi': {'ip': '192.168.1.214', # 'driver_type': 'FTP', # 'port': 8001, # 'user': '', # 'password': '', # 'source': '/AOI_little.kml' # }, # 'output_layer': {'ip': '192.168.1.214', # 'driver_type': 'FTP', # 'port': 8001, # 'file_type': 'ZIP', # 'user': '', # 'password': '', # 'source': '/MS_NEW' # }, # 'base_type': 'sentinel', # 'user_ms': 'rpsntnl', # 'password_ms': 'RpM#12_rPm#12sentinel', # 'cloud_coverage_max': 10, # 'sort': False # } # r = requests.post(url=URL, json=params) # task_json = r.json() # json_file = open('/media/roberto/X/Usuarios/Roberto/MisDocumentos/WORKSPACES/PyCharmProyects/GMS_WORKSPACE/MG/itasker/good_json.json', 'rb') # graph = json.load(json_file)[1] # # # # URL = "http://192.168.1.214:8000/MG/itasker/get_task_list" # # r = requests.post(url=URL, json={"user": 'test'}) # # task_json = r.json()[1] # # print(task_json['label']) # # # time.sleep(10) # # # # # time.sleep(1) # # # # print(graph) # URL = "http://127.0.0.1:8000/MG/itasker/run_task" # r = requests.post(url=URL, json={"user": 'xk6k7hlnqgo7kwdg9', 'json_graph': graph}) # print(r.json()) # # # # time.sleep(1) # # task_id = 'vg/"&TCKBn' # URL = "http://192.168.1.214:8000/MG/itasker/get_result" # r = requests.post(url=URL, json={"user": 'xk6k7hlnqgo7kwdg9'}) # print(r.json()) # # # def status_parser(task_monitor_json): # print_string = '' # lines = 0 # for task in task_monitor_json: # print_string += 'Task {}: {} \n'.format(task['label'], task['status']) # lines += 1 # for node in task['nodes']: # print_string += '\t{} node {}: {} {} \n'.format(node['nodeType'], node['label'], node['status'], node['progress']) # print_string += '\t\t{}'.format(node['comments']) # lines += 2 # print(u"\u001b[1000D\u001b[1000A".format(lines)+print_string) # # # # # # # while True: # time.sleep(1) # URL = "http://192.168.1.43:30015/MG/itasker/get_task_monitor" # r = requests.post(url=URL, json={"user": 'xk6k7hlnqgo7kwdg9'}) # status_parser(r.json()) # URL = "http://127.0.0.1:8003/MG/itasker/get_result" # r = requests.post(url=URL, json={"user": 'xk6k7hlnqgo7kwdg9'}) # print(r.json()) # task_id = 'dLz6Q3qj¿H' # URL = "http://127.0.0.1:8000/monitor/result" # r = requests.post(url=URL, json={"user": 'I6', 'task_id':task_id}) # print(r.json()) # # URL = "http://127.0.0.1:8000/GMS/test_app/test_task" # r = requests.post(url=URL, json={"user": 'I6', 'steps': 60}) # result = r.json() # print(result) # task_id = 'jkqFICT>W&' # URL = "http://127.0.0.1:8000/monitor/result" # r = requests.post(url=URL, json={"user": 'I6', 'task_id':task_id}) # print(r.json()) # # URL = "http://127.0.0.1:8000/monitor/list" # r = requests.post(url=URL, json={"user": 'I6'}) # print(r.json()) # URL = "http://127.0.0.1:1114/monitor/info" # r = requests.post(url=URL, json={"user": 'user_test', 'task_id': 'D<"QtFBgl>'}) # print(r.json()) # # URL = "http://127.0.0.1:8000/monitor/pause" # r = requests.post(url=URL, json={"user": 'I6', 'task_id': task_id}) # print(r.json()) # URL = "http://127.0.0.1:8000/monitor/start" # r = requests.post(url=URL, json={"user": 'I6', 'task_id': task_id}) # print(r.json()) # URL = "http://127.0.0.1:8000/monitor/cancel" # r = requests.post(url=URL, json={"user": 'I6', 'task_id': task_id}) # print(r.json()) # URL = "http://127.0.0.1:8000/monitor/info" # r = requests.post(url=URL, json={"user": 'I6', 'task_id': task_id}) # print(r.json())