Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
RENAUD Maxence DGAC/CRNA-N committed Jul 11, 2019
1 parent deaa072 commit 4d6ce35
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 16 deletions.
File renamed without changes.
Binary file modified data/sqlite.db
Binary file not shown.
22 changes: 15 additions & 7 deletions demo.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
from manager import Manager
import json
import utils

test_manager = Manager()
test_manager.show_available_services()
test_manager.show_operations_of_service(service_name='FlightManagementService')
#test_manager.show_available_services()
#test_manager.show_operations_of_service(service_name='FlightManagementService')

test = test_manager.queryFlightsByAirspace(
airspace="LFFFUZ",
requestedFlightFields = ['aircraftOperator']
# TODO : renseigner plusieurs airspace ?
fpl_data = test_manager.queryFlightsByAirspace(
airspace="LFFFTH",
dataset='OPERATIONAL',
includeProposalFlights=False,
includeProposalFlights=True,
includeForecastFlights=True,
trafficType='LOAD',
trafficWindow={'wef': "2019-07-11 06:30", 'unt': "2019-07-11 07:00"}
trafficWindow={'wef': "2019-07-11 12:00", 'unt': "2019-07-11 14:00"},
requestedFlightFields=requestedFlightFields,
py_output=False
)
print(test)

print(fpl_data)
#utils.write_content_to_file(filename="fpl_data.json", content=json.dumps(fpl_data))
31 changes: 26 additions & 5 deletions manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from zeep import Client, Settings
from zeep.cache import SqliteCache
from zeep.transports import Transport
from zeep.helpers import serialize_object
import json

from shared_vars import (B2B_PROXY, DEFAULT_B2B_VERSION, DEFAULT_DATASET,
WSDL_PROXY, get_dataset)
Expand All @@ -30,6 +32,7 @@ def __init__(
'wsdl': self.wsdl,
'transport': self.transport
}
self.tmp_data = None

# -----------------------------------------------------------------------------------------
def set_available_services(self):
Expand Down Expand Up @@ -65,10 +68,28 @@ def show_operations_of_service(self, service_name):
# -----------------------------------------------------------------------------------------
def queryFlightsByAirspace(
self, airspace, dataset, trafficType,
includeProposalFlights, includeForecastFlights,
trafficWindow, sendTime=utils.sendTime()):
includeProposalFlights, includeForecastFlights,
trafficWindow, requestedFlightFields=[], sendTime=utils.sendTime(),
py_output=True):
client = Client(**self.conf, service_name='FlightManagementService')
return client.service.queryFlightsByAirspace(
airspace=airspace, sendTime=sendTime, dataset=self.dataset, trafficType=trafficType,
self.tmp_data = client.service.queryFlightsByAirspace(
airspace=airspace, dataset=self.dataset, trafficType=trafficType,
includeProposalFlights=includeProposalFlights, includeForecastFlights=includeForecastFlights,
trafficWindow=trafficWindow)
trafficWindow=trafficWindow, requestedFlightFields=requestedFlightFields, sendTime=sendTime)
if py_output:
return serialize_object(self.tmp_data)
return self.tmp_data

# def queryFlightsByAerodrome(
# self, aerodrome, dataset, trafficType,
# includeProposalFlights, includeForecastFlights,
# trafficWindow, sendTime=utils.sendTime(),
# py_output=True):
# client = Client(**self.conf, service_name='FlightManagementService')
# self.tmp_data = client.service.queryFlightsByAirspace(
# aerodrome=aerodrome, aerodromeRole=aerodromeRole, sendTime=sendTime, dataset=self.dataset, trafficType=trafficType,
# includeProposalFlights=includeProposalFlights, includeForecastFlights=includeForecastFlights,
# trafficWindow=trafficWindow)
# if py_output:
# return serialize_object(self.tmp_data)
# return self.tmp_data
Binary file added nm_docs/dpi-impl-guide.pdf
Binary file not shown.
5 changes: 4 additions & 1 deletion shared_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@
DEFAULT_DATASET = "OPERATIONAL"
def get_dataset(wanted_dataset):
if wanted_dataset in ALLOWED_DATASET: return wanted_dataset
return "OPERATIONAL"
return "OPERATIONAL"

ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
DATA_PATH = os.path.join(ROOT_PATH, "data")
8 changes: 5 additions & 3 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@

#from decolog import *
#from dsnaproxies import dsnaproxies
from shared_vars import DATA_PATH


# -------------------------------------------------------------------
# -------------------------------------------------------------------
# Nouveaux utilitaires par Maxence
def write_content_to_file(filename, content):
os.makedirs(os.path.dirname(filename), exist_ok=True)
with open(filename, 'w') as file_to_be_written:
def write_content_to_file(filename, content, rep=DATA_PATH):
os.makedirs(os.path.dirname(rep+filename), exist_ok=True)
full_path = os.path.join(rep, filename)
with open(full_path, 'w') as file_to_be_written:
file_to_be_written.write(content)

def get_datetime(nbr_days=0):
Expand Down

0 comments on commit 4d6ce35

Please sign in to comment.