pyopensky 2.3__tar.gz → 2.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyopensky-2.3 → pyopensky-2.5}/PKG-INFO +6 -35
- {pyopensky-2.3 → pyopensky-2.5}/pyproject.toml +4 -4
- {pyopensky-2.3 → pyopensky-2.5}/readme.md +4 -32
- {pyopensky-2.3 → pyopensky-2.5}/src/pyopensky/api.py +4 -8
- {pyopensky-2.3 → pyopensky-2.5}/src/pyopensky/config.py +1 -1
- {pyopensky-2.3 → pyopensky-2.5}/src/pyopensky/impala.py +4 -4
- {pyopensky-2.3 → pyopensky-2.5}/src/pyopensky/s3.py +3 -6
- {pyopensky-2.3 → pyopensky-2.5}/src/pyopensky/trino.py +36 -8
- {pyopensky-2.3 → pyopensky-2.5}/license.txt +0 -0
- {pyopensky-2.3 → pyopensky-2.5}/src/pyopensky/__init__.py +0 -0
- {pyopensky-2.3 → pyopensky-2.5}/src/pyopensky/py.typed +0 -0
- {pyopensky-2.3 → pyopensky-2.5}/src/pyopensky/rest.py +0 -0
- {pyopensky-2.3 → pyopensky-2.5}/src/pyopensky/schema.py +0 -0
- {pyopensky-2.3 → pyopensky-2.5}/src/pyopensky/time.py +0 -0
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pyopensky
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.5
|
|
4
4
|
Summary: A Python interface for OpenSky database
|
|
5
5
|
License: MIT
|
|
6
6
|
Author: Xavier Olive
|
|
7
7
|
Author-email: git@xoolive.org
|
|
8
|
-
Requires-Python: >=3.
|
|
8
|
+
Requires-Python: >=3.9,<4.0
|
|
9
9
|
Classifier: License :: OSI Approved :: MIT License
|
|
10
10
|
Classifier: Programming Language :: Python :: 3
|
|
11
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
12
11
|
Classifier: Programming Language :: Python :: 3.9
|
|
13
12
|
Classifier: Programming Language :: Python :: 3.10
|
|
14
13
|
Classifier: Programming Language :: Python :: 3.11
|
|
@@ -52,29 +51,13 @@ poetry install
|
|
|
52
51
|
|
|
53
52
|
## Credentials
|
|
54
53
|
|
|
55
|
-
|
|
56
|
-
| ------ | -------------------------------------------------------------- |
|
|
57
|
-
| Impala | https://opensky-network.org/data/impala |
|
|
58
|
-
| Trino | contact@opensky-network.org (or specify it in the Impala form) |
|
|
59
|
-
|
|
60
|
-
The first time you use the library, a configuration file named `settings.conf` is created, including the following content:
|
|
61
|
-
|
|
62
|
-
```text
|
|
63
|
-
[default]
|
|
64
|
-
username =
|
|
65
|
-
password =
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
You will identify the folder where the `settings.conf` is located:
|
|
69
|
-
|
|
70
|
-
```python
|
|
71
|
-
from pyopensky.config import opensky_config_dir
|
|
72
|
-
|
|
73
|
-
print(opensky_config_dir)
|
|
74
|
-
```
|
|
54
|
+
See details in the [documentation](https://open-aviation.github.io/pyopensky/credentials.html)
|
|
75
55
|
|
|
76
56
|
## Usage
|
|
77
57
|
|
|
58
|
+
> [!IMPORTANT]
|
|
59
|
+
> The Impala shell is now deprecated. Please upgrade to Trino.
|
|
60
|
+
|
|
78
61
|
- from the [REST API](https://open-aviation.github.io/pyopensky/rest.html):
|
|
79
62
|
|
|
80
63
|
```python
|
|
@@ -90,18 +73,6 @@ print(opensky_config_dir)
|
|
|
90
73
|
rest.departure(airport, begin, end)
|
|
91
74
|
```
|
|
92
75
|
|
|
93
|
-
- from the [Impala](https://open-aviation.github.io/pyopensky/impala.html) shell (requires authentication):
|
|
94
|
-
|
|
95
|
-
```python
|
|
96
|
-
from pyopensky.impala import Impala
|
|
97
|
-
|
|
98
|
-
impala = Impala()
|
|
99
|
-
# full description of the whole set of parameters in the documentation
|
|
100
|
-
impala.flightlist(start, stop, *, airport, callsign, icao24)
|
|
101
|
-
impala.history(start, stop, *, callsign, icao24, bounds)
|
|
102
|
-
impala.rawdata(start, stop, *, callsign, icao24, bounds)
|
|
103
|
-
```
|
|
104
|
-
|
|
105
76
|
- from the [Trino](https://open-aviation.github.io/pyopensky/trino.html) database (requires authentication):
|
|
106
77
|
|
|
107
78
|
```python
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "pyopensky"
|
|
3
|
-
version = "2.
|
|
3
|
+
version = "2.5"
|
|
4
4
|
description = "A Python interface for OpenSky database"
|
|
5
5
|
authors = ["Xavier Olive <git@xoolive.org>", "Junzi Sun <j.sun-1@tudelft.nl>"]
|
|
6
6
|
license = "MIT"
|
|
@@ -11,7 +11,7 @@ include = [
|
|
|
11
11
|
]
|
|
12
12
|
|
|
13
13
|
[tool.poetry.dependencies]
|
|
14
|
-
python = "^3.
|
|
14
|
+
python = "^3.9"
|
|
15
15
|
pandas = ">=1.5"
|
|
16
16
|
trino = { version = ">=0.322", extras = ['sqlalchemy'] }
|
|
17
17
|
minio = ">=7.1"
|
|
@@ -45,7 +45,7 @@ target_version = ['py38', 'py39', 'py310', 'py311']
|
|
|
45
45
|
include = '\.pyi?$'
|
|
46
46
|
|
|
47
47
|
[tool.ruff]
|
|
48
|
-
select = [
|
|
48
|
+
lint.select = [
|
|
49
49
|
"E", "W", # pycodestyle
|
|
50
50
|
"F", # pyflakes
|
|
51
51
|
"I", # isort
|
|
@@ -57,7 +57,7 @@ select = [
|
|
|
57
57
|
line-length = 80
|
|
58
58
|
target-version = "py38"
|
|
59
59
|
|
|
60
|
-
[tool.ruff.isort]
|
|
60
|
+
[tool.ruff.lint.isort]
|
|
61
61
|
known-first-party = ["numpy", "pandas"]
|
|
62
62
|
|
|
63
63
|
[tool.mypy]
|
|
@@ -26,29 +26,13 @@ poetry install
|
|
|
26
26
|
|
|
27
27
|
## Credentials
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
| ------ | -------------------------------------------------------------- |
|
|
31
|
-
| Impala | https://opensky-network.org/data/impala |
|
|
32
|
-
| Trino | contact@opensky-network.org (or specify it in the Impala form) |
|
|
33
|
-
|
|
34
|
-
The first time you use the library, a configuration file named `settings.conf` is created, including the following content:
|
|
35
|
-
|
|
36
|
-
```text
|
|
37
|
-
[default]
|
|
38
|
-
username =
|
|
39
|
-
password =
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
You will identify the folder where the `settings.conf` is located:
|
|
43
|
-
|
|
44
|
-
```python
|
|
45
|
-
from pyopensky.config import opensky_config_dir
|
|
46
|
-
|
|
47
|
-
print(opensky_config_dir)
|
|
48
|
-
```
|
|
29
|
+
See details in the [documentation](https://open-aviation.github.io/pyopensky/credentials.html)
|
|
49
30
|
|
|
50
31
|
## Usage
|
|
51
32
|
|
|
33
|
+
> [!IMPORTANT]
|
|
34
|
+
> The Impala shell is now deprecated. Please upgrade to Trino.
|
|
35
|
+
|
|
52
36
|
- from the [REST API](https://open-aviation.github.io/pyopensky/rest.html):
|
|
53
37
|
|
|
54
38
|
```python
|
|
@@ -64,18 +48,6 @@ print(opensky_config_dir)
|
|
|
64
48
|
rest.departure(airport, begin, end)
|
|
65
49
|
```
|
|
66
50
|
|
|
67
|
-
- from the [Impala](https://open-aviation.github.io/pyopensky/impala.html) shell (requires authentication):
|
|
68
|
-
|
|
69
|
-
```python
|
|
70
|
-
from pyopensky.impala import Impala
|
|
71
|
-
|
|
72
|
-
impala = Impala()
|
|
73
|
-
# full description of the whole set of parameters in the documentation
|
|
74
|
-
impala.flightlist(start, stop, *, airport, callsign, icao24)
|
|
75
|
-
impala.history(start, stop, *, callsign, icao24, bounds)
|
|
76
|
-
impala.rawdata(start, stop, *, callsign, icao24, bounds)
|
|
77
|
-
```
|
|
78
|
-
|
|
79
51
|
- from the [Trino](https://open-aviation.github.io/pyopensky/trino.html) database (requires authentication):
|
|
80
52
|
|
|
81
53
|
```python
|
|
@@ -14,8 +14,7 @@ ProgressbarType = Callable[[Iterable[T]], Iterable[T]]
|
|
|
14
14
|
|
|
15
15
|
class HasBounds(Protocol):
|
|
16
16
|
@property
|
|
17
|
-
def bounds(self) -> tuple[float, float, float, float]:
|
|
18
|
-
...
|
|
17
|
+
def bounds(self) -> tuple[float, float, float, float]: ...
|
|
19
18
|
|
|
20
19
|
|
|
21
20
|
class OpenSkyDBAPI(Protocol):
|
|
@@ -33,8 +32,7 @@ class OpenSkyDBAPI(Protocol):
|
|
|
33
32
|
compress: bool = False,
|
|
34
33
|
limit: None | int = None,
|
|
35
34
|
**kwargs: Any,
|
|
36
|
-
) -> None | pd.DataFrame:
|
|
37
|
-
...
|
|
35
|
+
) -> None | pd.DataFrame: ...
|
|
38
36
|
|
|
39
37
|
def history(
|
|
40
38
|
self,
|
|
@@ -57,8 +55,7 @@ class OpenSkyDBAPI(Protocol):
|
|
|
57
55
|
compress: bool = False,
|
|
58
56
|
limit: None | int = None,
|
|
59
57
|
**kwargs: Any,
|
|
60
|
-
) -> None | pd.DataFrame:
|
|
61
|
-
...
|
|
58
|
+
) -> None | pd.DataFrame: ...
|
|
62
59
|
|
|
63
60
|
def rawdata(
|
|
64
61
|
self,
|
|
@@ -76,5 +73,4 @@ class OpenSkyDBAPI(Protocol):
|
|
|
76
73
|
compress: bool = False,
|
|
77
74
|
limit: None | int = None,
|
|
78
75
|
**kwargs: Any,
|
|
79
|
-
) -> None | pd.DataFrame:
|
|
80
|
-
...
|
|
76
|
+
) -> None | pd.DataFrame: ...
|
|
@@ -136,9 +136,9 @@ class Impala(OpenSkyDBAPI):
|
|
|
136
136
|
For more information, find below the error and the buggy line:
|
|
137
137
|
"""
|
|
138
138
|
|
|
139
|
-
stdin: paramiko.ChannelFile
|
|
140
|
-
stdout: paramiko.ChannelFile
|
|
141
|
-
stderr: paramiko.ChannelFile
|
|
139
|
+
stdin: paramiko.ChannelFile
|
|
140
|
+
stdout: paramiko.ChannelFile
|
|
141
|
+
stderr: paramiko.ChannelFile
|
|
142
142
|
# actually ChannelStderrFile
|
|
143
143
|
|
|
144
144
|
def __init__(self, **kwargs: Any) -> None:
|
|
@@ -338,7 +338,7 @@ class Impala(OpenSkyDBAPI):
|
|
|
338
338
|
request = request.replace("\n", " ")
|
|
339
339
|
_log.info(request)
|
|
340
340
|
|
|
341
|
-
self.stdin.channel.send(request + ";\n")
|
|
341
|
+
self.stdin.channel.send((request + ";\n").encode())
|
|
342
342
|
# avoid messing lines in the cache file
|
|
343
343
|
time.sleep(0.1)
|
|
344
344
|
total = ""
|
|
@@ -90,8 +90,7 @@ class S3Client:
|
|
|
90
90
|
self,
|
|
91
91
|
obj: datatypes.Object,
|
|
92
92
|
filename: None | Path,
|
|
93
|
-
) -> Path:
|
|
94
|
-
...
|
|
93
|
+
) -> Path: ...
|
|
95
94
|
|
|
96
95
|
@overload
|
|
97
96
|
def download_object(
|
|
@@ -99,8 +98,7 @@ class S3Client:
|
|
|
99
98
|
obj: datatypes.Object,
|
|
100
99
|
filename: None | Path,
|
|
101
100
|
return_buffer: Literal[False],
|
|
102
|
-
) -> Path:
|
|
103
|
-
...
|
|
101
|
+
) -> Path: ...
|
|
104
102
|
|
|
105
103
|
@overload
|
|
106
104
|
def download_object(
|
|
@@ -108,8 +106,7 @@ class S3Client:
|
|
|
108
106
|
obj: datatypes.Object,
|
|
109
107
|
filename: None | Path,
|
|
110
108
|
return_buffer: Literal[True],
|
|
111
|
-
) -> BytesIO:
|
|
112
|
-
...
|
|
109
|
+
) -> BytesIO: ...
|
|
113
110
|
|
|
114
111
|
def download_object(
|
|
115
112
|
self,
|
|
@@ -119,6 +119,8 @@ class Trino(OpenSkyDBAPI):
|
|
|
119
119
|
if token is not None
|
|
120
120
|
else OAuth2Authentication(),
|
|
121
121
|
http_scheme="https",
|
|
122
|
+
# https://github.com/trinodb/trino-python-client/discussions/456
|
|
123
|
+
legacy_prepared_statements=True,
|
|
122
124
|
),
|
|
123
125
|
)
|
|
124
126
|
return engine
|
|
@@ -384,6 +386,7 @@ class Trino(OpenSkyDBAPI):
|
|
|
384
386
|
cached: bool = True,
|
|
385
387
|
compress: bool = False,
|
|
386
388
|
limit: None | int = None,
|
|
389
|
+
selected_columns: tuple[InstrumentedAttribute[Any] | str, ...] = (),
|
|
387
390
|
**kwargs: Any,
|
|
388
391
|
) -> None | pd.DataFrame:
|
|
389
392
|
"""Get Traffic from the OpenSky Trino database.
|
|
@@ -413,6 +416,10 @@ class Trino(OpenSkyDBAPI):
|
|
|
413
416
|
:param bounds: sets a geographical footprint. Either an **airspace or
|
|
414
417
|
shapely shape** (requires the bounds attribute); or a **tuple of
|
|
415
418
|
float** (west, south, east, north);
|
|
419
|
+
:param selected_columns: specify the columns you want to retrieve. When
|
|
420
|
+
empty, use all columns of the StateVectorsData4 table. You may
|
|
421
|
+
escape column names as str. **Always** escape names from the
|
|
422
|
+
FlightsData4 table.
|
|
416
423
|
|
|
417
424
|
**Airports**
|
|
418
425
|
|
|
@@ -475,7 +482,7 @@ class Trino(OpenSkyDBAPI):
|
|
|
475
482
|
)
|
|
476
483
|
.where(
|
|
477
484
|
FlightsData4.day >= start_ts.floor("1d"),
|
|
478
|
-
FlightsData4.day <=
|
|
485
|
+
FlightsData4.day <= stop_ts.ceil("1d"),
|
|
479
486
|
)
|
|
480
487
|
)
|
|
481
488
|
|
|
@@ -568,10 +575,31 @@ class Trino(OpenSkyDBAPI):
|
|
|
568
575
|
stmt = stmt.where(
|
|
569
576
|
StateVectorsData4.time >= start_ts,
|
|
570
577
|
StateVectorsData4.time <= stop_ts,
|
|
571
|
-
StateVectorsData4.hour >= start_ts.floor("
|
|
572
|
-
StateVectorsData4.hour < stop_ts.ceil("
|
|
578
|
+
StateVectorsData4.hour >= start_ts.floor("1h"),
|
|
579
|
+
StateVectorsData4.hour < stop_ts.ceil("1h"),
|
|
573
580
|
)
|
|
574
581
|
|
|
582
|
+
def transform_column(col: str) -> InstrumentedAttribute[Any]:
|
|
583
|
+
if "." in col:
|
|
584
|
+
table, column = col.split(".")
|
|
585
|
+
MATCH = {
|
|
586
|
+
"StateVectorsData4": StateVectorsData4,
|
|
587
|
+
"FlightsData4": fd4,
|
|
588
|
+
}
|
|
589
|
+
return getattr(MATCH[table], column) # type: ignore
|
|
590
|
+
if candidate := getattr(StateVectorsData4, col, None):
|
|
591
|
+
return candidate # type: ignore
|
|
592
|
+
if candidate := getattr(fd4, col, None):
|
|
593
|
+
return candidate # type: ignore
|
|
594
|
+
raise ValueError(f"Unknown column: {col}")
|
|
595
|
+
|
|
596
|
+
if len(selected_columns) > 0:
|
|
597
|
+
columns = (
|
|
598
|
+
transform_column(col) if isinstance(col, str) else col
|
|
599
|
+
for col in selected_columns
|
|
600
|
+
)
|
|
601
|
+
stmt = stmt.with_only_columns(*columns)
|
|
602
|
+
|
|
575
603
|
if limit is not None:
|
|
576
604
|
stmt = stmt.limit(limit)
|
|
577
605
|
|
|
@@ -712,7 +740,7 @@ class Trino(OpenSkyDBAPI):
|
|
|
712
740
|
)
|
|
713
741
|
.where(
|
|
714
742
|
FlightsData4.day >= start_ts.floor("1d"),
|
|
715
|
-
FlightsData4.day <=
|
|
743
|
+
FlightsData4.day <= stop_ts.ceil("1d"),
|
|
716
744
|
)
|
|
717
745
|
)
|
|
718
746
|
|
|
@@ -766,8 +794,8 @@ class Trino(OpenSkyDBAPI):
|
|
|
766
794
|
)
|
|
767
795
|
.group_by(StateVectorsData4.icao24)
|
|
768
796
|
.where(
|
|
769
|
-
StateVectorsData4.hour >= start_ts.floor("
|
|
770
|
-
StateVectorsData4.hour <= stop_ts.ceil("
|
|
797
|
+
StateVectorsData4.hour >= start_ts.floor("1h"),
|
|
798
|
+
StateVectorsData4.hour <= stop_ts.ceil("1h"),
|
|
771
799
|
StateVectorsData4.time >= start_ts,
|
|
772
800
|
StateVectorsData4.time <= stop_ts,
|
|
773
801
|
)
|
|
@@ -819,8 +847,8 @@ class Trino(OpenSkyDBAPI):
|
|
|
819
847
|
stmt = stmt.where(
|
|
820
848
|
Table.mintime >= start_ts,
|
|
821
849
|
Table.mintime <= stop_ts,
|
|
822
|
-
Table.hour >= start_ts.floor("
|
|
823
|
-
Table.hour < stop_ts.ceil("
|
|
850
|
+
Table.hour >= start_ts.floor("1h"),
|
|
851
|
+
Table.hour < stop_ts.ceil("1h"),
|
|
824
852
|
)
|
|
825
853
|
|
|
826
854
|
if limit is not None:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|