Giter Club home page Giter Club logo

fr24's Issues

crashing when retrieving feed today

Seems to have stopped working today

(grpc) [root@smj-centos-6 grpc]# fr24 feed
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /root/e1radar/grpc/lib64/python3.11/site-packages/fr24/cli.py:98 in feed │
│ │
│ 95 │ │ │ lf.data.save_parquet() │
│ 96 │ │ │ rich.print(get_success_message(lf)) │
│ 97 │ │
│ ❱ 98 │ asyncio.run(feed_()) │
│ 99 │
│ 100 │
│ 101 if name == "main": │
│ │
│ ╭─────────────────────────── locals ───────────────────────────╮ │
│ │ feed_ = <function feed..feed_ at 0x7fddb33f3b00> │ │
│ │ time = None │ │
│ │ timestamp = None │ │
│ ╰──────────────────────────────────────────────────────────────╯ │
│ │
│ /usr/lib64/python3.11/asyncio/runners.py:190 in run │
│ │
│ 187 │ │ │ "asyncio.run() cannot be called from a running event loop") │
│ 188 │ │
│ 189 │ with Runner(debug=debug) as runner: │
│ ❱ 190 │ │ return runner.run(main) │
│ 191 │
│ 192 │
│ 193 def cancel_all_tasks(loop): │
│ │
│ ╭───────────────────────────── locals ──────────────────────────────╮ │
│ │ debug = None │ │
│ │ main = <coroutine object feed..feed
at 0x7fddb3400c70> │ │
│ │ runner = <asyncio.runners.Runner object at 0x7fddb321fd50> │ │
│ ╰───────────────────────────────────────────────────────────────────╯ │
│ │
│ /usr/lib64/python3.11/asyncio/runners.py:118 in run │
│ │
│ 115 │ │ │
│ 116 │ │ self.interrupt_count = 0 │
│ 117 │ │ try: │
│ ❱ 118 │ │ │ return self.loop.run_until_complete(task) │
│ 119 │ │ except exceptions.CancelledError: │
│ 120 │ │ │ if self.interrupt_count > 0: │
│ 121 │ │ │ │ uncancel = getattr(task, "uncancel", None) │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ context = <contextvars.Context object at 0x7fddb3a2dec0> │ │
│ │ coro = <coroutine object feed..feed
at 0x7fddb3400c70> │ │
│ │ self = <asyncio.runners.Runner object at 0x7fddb321fd50> │ │
│ │ sigint_handler = functools.partial(<bound method Runner.on_sigint of │ │
│ │ <asyncio.runners.Runner object at 0x7fddb321fd50>>, main_task=<Task │ │
│ │ finished name='Task-1' coro=<feed..feed
() done, defined at │ │
│ │ /root/e1radar/grpc/lib64/python3.11/site-packages/fr24/cli.py:91> │ │
│ │ exception=AssertionError()>) │ │
│ │ task = <Task finished name='Task-1' coro=<feed..feed
() done, defined at │ │
│ │ /root/e1radar/grpc/lib64/python3.11/site-packages/fr24/cli.py:91> │ │
│ │ exception=AssertionError()> │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /usr/lib64/python3.11/asyncio/base_events.py:653 in run_until_complete │
│ │
│ 650 │ │ if not future.done(): │
│ 651 │ │ │ raise RuntimeError('Event loop stopped before Future completed.') │
│ 652 │ │ │
│ ❱ 653 │ │ return future.result() │
│ 654 │ │
│ 655 │ def stop(self): │
│ 656 │ │ """Stop running the event loop. │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ future = <Task finished name='Task-1' coro=<feed..feed
() done, defined at │ │
│ │ /root/e1radar/grpc/lib64/python3.11/site-packages/fr24/cli.py:91> │ │
│ │ exception=AssertionError()> │ │
│ │ new_task = False │ │
│ │ self = <UnixSelectorEventLoop running=False closed=True debug=False> │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /root/e1radar/grpc/lib64/python3.11/site-packages/fr24/cli.py:94 in feed

│ │
│ 91 │ async def feed
() -> None: │
│ 92 │ │ async with FR24() as fr24: │
│ 93 │ │ │ lf = fr24.livefeed(timestamp) │
│ ❱ 94 │ │ │ lf.data.add_api_response(await lf.api.fetch()) │
│ 95 │ │ │ lf.data.save_parquet() │
│ 96 │ │ │ rich.print(get_success_message(lf)) │
│ 97 │
│ │
│ ╭───────────────────────────── locals ─────────────────────────────╮ │
│ │ fr24 = <fr24.core.FR24 object at 0x7fddb3228710> │ │
│ │ lf = <fr24.core.LiveFeedService object at 0x7fddb3228dd0> │ │
│ │ timestamp = None │ │
│ ╰──────────────────────────────────────────────────────────────────╯ │
│ │
│ /root/e1radar/grpc/lib64/python3.11/site-packages/fr24/core.py:366 in fetch │
│ │
│ 363 │ │ │ │ **kw, # type: ignore[arg-type] │
│ 364 │ │ │ │ auth=self.http.auth, │
│ 365 │ │ │ ) │
│ ❱ 366 │ │ resp = await livefeed_world_data(self.http.client, self.http.auth) │
│ 367 │ │ self.ctx["timestamp"] = int(time.time()) │
│ 368 │ │ return resp │
│ 369 │
│ │
│ ╭──────────────────────── locals ─────────────────────────╮ │
│ │ self = <fr24.core.LiveFeedAPI object at 0x7fddb3228e50> │ │
│ │ ts = None │ │
│ ╰─────────────────────────────────────────────────────────╯ │
│ │
│ /root/e1radar/grpc/lib64/python3.11/site-packages/fr24/livefeed.py:224 in livefeed_world_data │
│ │
│ 221 │ client: httpx.AsyncClient, auth: None | Authentication = None │
│ 222 ) -> list[LiveFeedRecord]: │
│ 223 │ """Retrieve live feed data for the entire world, in chunks.""" │
│ ❱ 224 │ results = await asyncio.gather( │
│ 225 │ │ *[ │
│ 226 │ │ │ livefeed_post( │
│ 227 │ │ │ │ client, │
│ │
│ ╭─────────────────────── locals ────────────────────────╮ │
│ │ auth = None │ │
│ │ client = <httpx.AsyncClient object at 0x7fddb3228850> │ │
│ ╰───────────────────────────────────────────────────────╯ │
│ │
│ /root/e1radar/grpc/lib64/python3.11/site-packages/fr24/livefeed.py:176 in livefeed_post │
│ │
│ 173 │ """Send the request and extract the raw protobuf message.""" │
│ 174 │ response = await client.send(request) │
│ 175 │ data = response.content │
│ ❱ 176 │ assert len(data) and data[0] == 0 │
│ 177 │ data_len = int.from_bytes(data[1:5], byteorder="big") │
│ 178 │ return data[5 : 5 + data_len] │
│ 179 │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ client = <httpx.AsyncClient object at 0x7fddb3228850> │ │
│ │ data = b'' │ │
│ │ request = <Request('POST', │ │
│ │ 'https://data-feed.flightradar24.com/fr24.feed.api.v1.Feed/LiveFeed')> │ │
│ │ response = <Response [464 ]> │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯

How to pull back squawk code from live feed

Assuming I am using the example world feed code and I am authenticated...

from fr24.core import FR24

async def my_feed() -> None:
    async with FR24() as fr24:
        lf = fr24.livefeed()
        response = await lf.api.fetch()
        print(response)
        lf.data.add_api_response(response)
        print(lf.data.df)
        lf.data.save_parquet()
        print(lf.data.fp)

await my_feed()

I can see that there is reference in one of the lower level functions ( livefeed_message_create) to return optional extra fields if I am authenticated

When authenticated, squawk, vspeed, airspace, logo_id and age can be included

Is there a way to do this from the higher level core calls? I want to pull back the squawk code for all aircraft in the livefeed.

Thanks ( I am sure there is - I'm just not sure how i would do it from the top level)

Authentication issues

I don't have time to dig much more into this right now, so let me document it here first before I forget. I currently have some authentication issues (context: trying to port my code from the older version to the newer API, and struggling to find where I could just get the JSON before the pyarrow...)

More generally, it would be nice to have an extra option as I could prefer to run anonymously by default, and login only when necessary:

async with FR24(login: bool | {'username': user, 'password': pass}) as fr24:
    ...

Currently, on my side, authentication in the asynccontextmanager fails with

ConnectError: All connection attempts failed

Surprisingly, in the TUI part of the code, I just use the following (without the FR24 client) and it still works:

self.auth = await login(self.client)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.