leonhard-s / auraxium

A high-level Python wrapper for the PlanetSide 2 API.
https://auraxium.readthedocs.io/
MIT License
28 stars 8 forks source link

Issues with the example code #33

Closed lukas-ba-github closed 3 years ago

lukas-ba-github commented 3 years ago
import asyncio
import auraxium
from auraxium import ps2

async def main():
    async with auraxium.Client() as client:

        char = await client.get_by_name(ps2.Character, 'SYSTEMICSHOCK')
        print(char.name())
        print(char.data.prestige_level)

        # NOTE: Any methods that might incur network traffic are asynchronous.
        # If the data type has been cached locally, no network communication
        # is required.

        # This will only generate a request once per faction, as the faction
        # data type is cached forever by default.
        print(await char.faction())

        # The outfit data type is only cached for a few seconds before being
        # required as it might change.
        outfit = await char.outfit()
        print(outfit.name())

asyncio.run(main())

There are some issues with the example code

  1. Typos that i fixed in my example above 1.1 NameError: name 'character' is not defined 1.1 'CharacterData' object has no attribute 'asp_rank'

  2. 2 AttributeError: module 'asyncio' has no attribute 'run_until_complete'

  3. The example character you provided as an example is not part of an outfit and thus outfit is None, thus outfit.name() raises an Exception. I added a character that is in an outfit in my example. AttributeError: 'NoneType' object has no attribute 'name'

  4. While the first warning regarding the default service ID makes sense, I also get the following warning that you might want to investigate further.

src/auraxium/auraxium/census/urlgen.py:43: UserWarning: The default service ID is heavily rate-limited. Consider applying for your own service ID at https://census.daybreakgames.com/#devSignup
  warnings.warn('The default service ID is heavily rate-limited. '
SYSTEMICSHOCK
1
Vanu Sovereignty
src/auraxium/auraxium/base.py:145: UserWarning: Unexpected keykeys in payload: []
Please report this error as it hints at a mismatch between the auraxium object model and the API.
  warnings.warn(
  1. The last line of the example code doesn't actually run because of the previous Exception.
lukas-ba-github commented 3 years ago

Issue Number 4. also happens when a service_id is provided.

leonhard-s commented 3 years ago

Hey, thanks for the report!

I looked over the example files and corrected any errors I could find in both the RST sources and README file. I did not want to use characters other than my own for the .outfit() example (and they'd still be at risk of losing their outfit), so I replaced that portion with .is_online() to avoid the issue down the road.

I was not able to reproduce the unexpected keys warning and providing service IDs does prevent the associated error on my test systems (Debian and Win10, both running 3.8.9).

What platform/version are you on? Is there any additional code involved beyond what you posted above?

leonhard-s commented 3 years ago

(Closing this issue due to inactivity.)