Skip to content

Commit

Permalink
Comments + Example + Deploy + Build
Browse files Browse the repository at this point in the history
  • Loading branch information
Tchekda committed Apr 2, 2020
1 parent 89cbf22 commit fbd9fe5
Show file tree
Hide file tree
Showing 10 changed files with 214 additions and 159 deletions.
116 changes: 7 additions & 109 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,112 +1,10 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/

.idea/

dist/
build/
tests/
dummy.txt

run.py

whazzup.*
whazzup.txt
.pypi
ivao/__pycache__/
IVAOWrapper.egg-info
17 changes: 16 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
language: python
python:
- "3.6"
- "3.7-dev"
- "3.7"
- "3.8"
cache: pip
install:
- pip install -r requirements.txt
script: python -m unittest
deploy:
- provider: pypi
user: "__token__"
password:
secure: "h/0rNVT9kXykMLvRGlglE1qlVxfUAJA75y4uDytmHfnh8ZPfl14XHROF6Iw10jkRHRndJmXPoOR/3C4v9AQtqoZJUxtncl5TkDMIDHkXyL1Cy18Clwea0aoN8WqNJQrP6HL5QYqme60lnGpZ5793ayiO1j6pVlpRL+I1ucU2CDONU7xiVgUbo0kX25e3WgvS2ktjBg96me6R0eOExwznPCqgXpJ5tPlmqGYOuHhDnoa3EPmyboLp3EscxAG+UUyVxBhWIlIr95vAuwiNuLVxUS7JSS924rVoimsQoJwbOpGgB40AQx9Pe8sADNCO9rbVFJz4UIsV7G9pr402OoGwdwohCZH5yB5ccAAPSd6HBXzC7Hh+Rwsl8lN1aufXLbghNtCrRY1QpmcDDz+51SlewxlzNeeRshgPMujzS8ivH1WhDorKZzmKlJhfAYZZeP2q02fECid55zQYUF/6ktghshIXamURWoFa6FSELZLHErIpELGTnPZE4rf0sGKySVHjWeDLrhJ17l3wcYz2VXBB7uPrc/ZicsH0+b3rKS8SqNKQ68EHulZeSLlHbUdktaty2+hAa40QA9Ba7wEWQZLTT9udHycJpJMsipwZx1+zhSmS1XyKYg6qPvHXT2UN25MUjVYfk7Uwo6WqPc5gl2RUR0Wrq2kbLe11He3JMVGKXok="
on:
branch: master
- provider: pypi
server: https://test.pypi.org/legacy
user: "__token__"
password:
secure: "MX36WEARzQipU8kI9wnOVMhrKRb7RPE+BMF3uC4Cgbja6HSyG5FVL1kaoRngM+5oShDMEXqzAhSUkBhz1LGgz8CJZwNdn4sBPCUbX+Doixpq7ja14CgPp5w8YPEhSD2GG0a2WLnwgwYyXmyZngNc5pDvIr7F4qpX/qOiDmxFUiMpBd6wPzrorEo2pnjrP1dT1S0Hi85n+VffV1lpsWXLqHccmHrZPow3OUjJCIAupPZ2UDT1vgvWXlw7LR9g/So7ydi9Tze2Yz0pHXBlFs2MMzb6GjGJvUkytYxqBQqgtLFhE3JnCZGEmGsSCi71gBn+dqsGN74ZlQeJUYroJo2KJ68vL3p+dm49N4kqaCg36pWNG9SediZoYi2DIm6+K1Rw6JzUn7iRDgit1OS7ls1rbHhu2H5ZCGiUAVsV2N2nPUp+mk7UiDsAmtLrFzYOoVs2ByyhNpJwbJkFAzYM6I3q9gV/tWo2BG9A547DS+SbXtMaNXUJzWRO3dlrG/tVMkh+PLiHzVB72sth0PStftpbHK63ohq2Og3iv6/qqbWpUtfW966b+kCI/zUdR3LO3EoBZ9mHm9N8wgKQ15Zy0aEnNr+boXpFyH7l/kfg9qJR6fn94Ae9TZ1oePtdw5eNoc6K5NSOkaWpK/wRPDw7s9402Gza3blNkHit6ZO8ZSpTnpw="
on:
branch: master
notifications:
email:
recipients:
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# IVAOWrapper
## Install
Simply run ``pip install IVAOWrapper``
## Tests
- Master : [![Build Status](https://travis-ci.com/Tchekda/IVAOWrapper.svg?branch=master)](https://travis-ci.com/Tchekda/IVAOWrapper)
- Dev : [![Build Status](https://travis-ci.com/Tchekda/IVAOWrapper.svg?branch=dev)](https://travis-ci.com/Tchekda/IVAOWrapper)
- Dev : [![Build Status](https://travis-ci.com/Tchekda/IVAOWrapper.svg?branch=dev)](https://travis-ci.com/Tchekda/IVAOWrapper)

## Examples
Examples can be found the the ``example.py`` file

## Event List
* Todo
48 changes: 48 additions & 0 deletions example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
from ivao import Server

server = Server()


@server.event("updated")
def get_data(clients):
ground = 0
air = 0
pilots = 0
for vid, client in clients.items():
if client.client_type == "PILOT":
pilots += 1
if client.ground:
ground += 1
else:
air += 1
print("Data has been updated")
print("{} on ground and {} in air for {} pilots".format(ground, air, pilots))


@server.event("land")
def land(client):
print(client, " has land")


@server.event("static")
def static(client):
print(client, " is static on " + ("ground" if client.ground else "air"))


@server.event("moving")
def moving(client):
print(client, " is moving on " + ("ground" if client.ground else "air"))


@server.event("takeoff")
def land(client):
print(client, " has takeoff")


@server.event("atis_update")
def atis(client):
print(client, " has changed his ATIS")
# pass


server.run_update_stream(delay=0.5)
15 changes: 15 additions & 0 deletions ivao/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@ class Client:

def __init__(self, callsign, vid, client_type, latitude, longitude, altitude, server, connection_time, soft_name,
soft_version, admin_rating, client_rating):
"""
Create a client connection object
:param callsign: User's Callsign
:param vid: User's VID
:param client_type: PILOT, ATC or FOLLOW ME
:param latitude: User's Latitude coordinates
:param longitude: User's Longitude coordinates
:param altitude: User's Altitude
:param server: Server where the client is connected
:param connection_time: Time when Client connected
:param soft_name: User's software name
:param soft_version: User's software version
:param admin_rating: User's Staff Rank
:param client_rating: User's Type Rank
"""
self.callsign = callsign
self.vid = int(vid)
self.client_type = client_type
Expand Down
79 changes: 46 additions & 33 deletions ivao/parser.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import requests

import os
from .atc import Controller
from .client import Client
from .pilot import Pilot
Expand All @@ -8,48 +8,61 @@
class Parser:

def __init__(self):
"""
Getting latest whazzup file, and selecting only clients
"""
request = requests.get("http://api.ivao.aero/getdata/whazzup/whazzup.txt")
self.content = str(request.text)
self.clients = self.content.split('!CLIENTS\n')[1].split('!AIRPORTS')[0].split('\n')[:-1]

def get_raw_data(self):
"""
Return raw whazzup file
:return: str
"""
return self.content

def get_clients_object(self):
"""
Parsing all data
:return: dict
"""
folme = []
atc = []
pilot = []
for client in self.clients:
data = client.split(':')
if data[3] == "ATC":
if data[18] == '0' and len(data) == 47: # Observer without atis
user = Controller(callsign=data[0], vid=data[1], latitude=data[5], longitude=data[6],
server=data[14],
connection_time=data[35], soft_name=data[36], soft_version=data[37],
admin_rating=data[38], client_rating=data[39], frequencies=data[4],
facility=data[18],
visual_range=data[19], atis="", atis_time="")
else:
user = Controller(callsign=data[0], vid=data[1], latitude=data[5], longitude=data[6],
server=data[14],
connection_time=data[37], soft_name=data[38], soft_version=data[39],
admin_rating=data[40], client_rating=data[41], frequencies=data[4],
facility=data[18],
visual_range=data[19], atis=data[35], atis_time=data[36])
atc.append(user)
elif data[3] == 'PILOT':
user = Pilot(callsign=data[0], vid=data[1], latitude=data[5], longitude=data[6], altitude=data[7],
server=data[14], connection_time=data[37], soft_name=data[38], soft_version=data[39],
admin_rating=data[40], client_rating=data[41], groundspeed=data[8], aircraft=data[9],
cruise_speed=data[10], departure_airport=data[11], cruise_level=data[12],
destination_airport=data[13], transponder=data[17], flight_rule=data[21],
departure_time=data[22], actual_departure_time=data[23], alternate_airport=data[28],
fpl_remark=data[29], route=data[30], flight_type=data[43], passengers=data[44],
heading=data[45], ground=data[46], simulator=data[47])
pilot.append(user)
else: # Follow Me
user = Client(callsign=data[0], vid=data[1], latitude=data[5], longitude=data[6], altitude=data[7],
server=data[14], connection_time=data[37], soft_name=data[38], soft_version=data[39],
admin_rating=data[40], client_rating=data[41], client_type=data[3])
folme.append(user)
data = client.split(':') # Splitting by ":" to get an array of params
if len(data) == 49: # Checking if correct length of data, to prevent errors
if data[3] == "ATC": # If client is connected as ATC
if data[18] == '0' and len(data) == 47: # Observer without atis
user = Controller(callsign=data[0], vid=data[1], latitude=data[5], longitude=data[6],
server=data[14],
connection_time=data[35], soft_name=data[36], soft_version=data[37],
admin_rating=data[38], client_rating=data[39], frequencies=data[4],
facility=data[18],
visual_range=data[19], atis="", atis_time="")
else:
user = Controller(callsign=data[0], vid=data[1], latitude=data[5], longitude=data[6],
server=data[14],
connection_time=data[37], soft_name=data[38], soft_version=data[39],
admin_rating=data[40], client_rating=data[41], frequencies=data[4],
facility=data[18],
visual_range=data[19], atis=data[35], atis_time=data[36])
atc.append(user)
elif data[3] == 'PILOT': # If client is connected as Pilot
user = Pilot(callsign=data[0], vid=data[1], latitude=data[5], longitude=data[6], altitude=data[7],
server=data[14], connection_time=data[37], soft_name=data[38], soft_version=data[39],
admin_rating=data[40], client_rating=data[41], groundspeed=data[8], aircraft=data[9],
cruise_speed=data[10], departure_airport=data[11], cruise_level=data[12],
destination_airport=data[13], transponder=data[17], flight_rule=data[21],
departure_time=data[22], actual_departure_time=data[23], alternate_airport=data[28],
fpl_remark=data[29], route=data[30], flight_type=data[43], passengers=data[44],
heading=data[45], ground=data[46], simulator=data[47])
pilot.append(user)
else: # If client is connected as Follow Me
user = Client(callsign=data[0], vid=data[1], latitude=data[5], longitude=data[6], altitude=data[7],
server=data[14], connection_time=data[37], soft_name=data[38], soft_version=data[39],
admin_rating=data[40], client_rating=data[41], client_type=data[3])
folme.append(user)

return {'folme': folme, "atc": atc, "pilot": pilot}
3 changes: 2 additions & 1 deletion ivao/pilot.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ def get_simulator_name(self):
17: "X-Plane 12", # Really???
20: "Fly!",
21: "Fly! 2",
25: "Prepar3D"
25: "Prepar3D",
30: "Prepar3D 1.x"
}.get(self.simulator, 'Unknown')

def get_client_rating_name(self):
Expand Down
Loading

0 comments on commit fbd9fe5

Please sign in to comment.