cgrok / clashroyale

Async + Sync wrapper for royaleapi.com and the CR official API
MIT License
47 stars 19 forks source link

Got aiohttp error when attempting to run example (sync.py) #21

Closed danjump closed 6 years ago

danjump commented 6 years ago

I'm trying to get started using your wrapper and ran in to an error in the aiohttp library when attempting to run a copy of your sync.py code. Here is what I ran and the full error output:

example code I ran:

import clashroyale
import os

# Basic functionality
token = os.getenv('crtoken') # get your developer key somehow.

client = clashroyale.Client(token)

profile = client.get_player('#8l9l9gl') # library cleans the tag (strips #)

print(repr(profile))

print(profile.name) 
# Access data via dot notation.

print(profile.stats.favorite_card.name)
# Access API data via snake_case instead of camelCase
# Everything is exactly the same as what is 
# presented in the official API documentation
#
# {
#     "stats": {
#         "favoriteCard": {
#             "name": "P.E.K.K.A"
#         }, 
#        ...
#     },
#    ...
# 

profile.refresh() 
# Refresh model data, This means that the 
# data will be requested again from the api

clan = profile.get_clan() # Request the clan object associated with the profile
print(clan)
print(clan.clan_chest) # dot notation
clan.refresh() # Refresh clan data

member = clan.members[0] # get the member object of the top member
assert member.clan is clan # Keeps a reference to the clan
assert member.rank == 1
# This member object only contains a brief amount of data
full_player = member.get_profile() # member.get_player() is also an alias
# This function requests the full player data using the members tag.

# Getting multiple clans/profiles
clans = client.get_clans('2CCCP', '2U2GGQJ') # indefinite amount of arguments
for clan in clans:
    print(clan.members[0])

filtered = client.get_clan('2cccp', keys=['name', 'tag']) # Filtering with keys= and exclude=
print(filtered.raw_data)

print(client.get_player('2P0LYQ', keys='battles').raw_data.keys()) # battles

print(client.get_auth_stats())

error output:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-1-96e0835f5755> in <module>()
----> 1 import clashroyale
      2 import os
      3 
      4 # Basic functionality
      5 token = os.getenv('crtoken') # get your developer key somehow.

~/anaconda3/lib/python3.6/site-packages/clashroyale/__init__.py in <module>()
     23 '''
     24 
---> 25 from .client import Client
     26 from .errors import *
     27 from .models import *

~/anaconda3/lib/python3.6/site-packages/clashroyale/client.py in <module>()
     29 from urllib.parse import urlencode
     30 
---> 31 import aiohttp
     32 import requests
     33 

~/anaconda3/lib/python3.6/site-packages/aiohttp/__init__.py in <module>()
      4 
      5 from . import hdrs  # noqa
----> 6 from .client import *  # noqa
      7 from .formdata import *  # noqa
      8 from .helpers import *  # noqa

~/anaconda3/lib/python3.6/site-packages/aiohttp/client.py in <module>()
     13 from yarl import URL
     14 
---> 15 from . import connector as connector_mod
     16 from . import client_exceptions, client_reqrep, hdrs, http, payload
     17 from .client_exceptions import *  # noqa

~/anaconda3/lib/python3.6/site-packages/aiohttp/connector.py in <module>()
     15                                 ClientProxyConnectionError,
     16                                 ServerFingerprintMismatch)
---> 17 from .client_proto import ResponseHandler
     18 from .client_reqrep import ClientRequest
     19 from .helpers import SimpleCookie, is_ip_address, noop, sentinel

~/anaconda3/lib/python3.6/site-packages/aiohttp/client_proto.py in <module>()
      4 from .client_exceptions import (ClientOSError, ClientPayloadError,
      5                                 ServerDisconnectedError)
----> 6 from .http import HttpResponseParser, StreamWriter
      7 from .streams import EMPTY_PAYLOAD, DataQueue
      8 

~/anaconda3/lib/python3.6/site-packages/aiohttp/http.py in <module>()
      6 from . import __version__
      7 from .http_exceptions import HttpProcessingError
----> 8 from .http_parser import (HttpParser, HttpRequestParser, HttpResponseParser,
      9                           RawRequestMessage, RawResponseMessage)
     10 from .http_websocket import (WS_CLOSED_MESSAGE, WS_CLOSING_MESSAGE, WS_KEY,

~/anaconda3/lib/python3.6/site-packages/aiohttp/http_parser.py in <module>()
     13                               ContentLengthError, InvalidHeader, LineTooLong,
     14                               TransferEncodingError)
---> 15 from .http_writer import HttpVersion, HttpVersion10
     16 from .log import internal_logger
     17 from .streams import EMPTY_PAYLOAD, FlowControlStreamReader

~/anaconda3/lib/python3.6/site-packages/aiohttp/http_writer.py in <module>()
    302 
    303 
--> 304 class URL(yarl.URL):
    305 
    306     def __init__(self, schema, netloc, port, path, query, fragment, userinfo):

~/anaconda3/lib/python3.6/site-packages/yarl/__init__.py in __init_subclass__(cls)
    230     def __init_subclass__(cls):
    231         raise TypeError("Inheritance a class {!r} from URL "
--> 232                         "is forbidden".format(cls))
    233 
    234     def __str__(self):

TypeError: Inheritance a class <class 'aiohttp.http_writer.URL'> from URL is forbidden

here is a list from my conda environment:

$ conda list
# packages in environment at /Users/jok589/anaconda3:
#
# Name                    Version                   Build  Channel
_license                  1.1                      py36_1
aiohttp                   2.2.5                     <pip>
alabaster                 0.7.10           py36h174008c_0
anaconda                  custom           py36ha4fed55_0
anaconda-client           1.6.14                   py36_0
anaconda-navigator        1.8.3                    py36_0
anaconda-project          0.8.2            py36h9ee5d53_0
ansible                   2.5.2                     <pip>
appnope                   0.1.0            py36hf537a9a_0
appscript                 1.0.1            py36h9e71e49_1
asn1crypto                0.24.0                   py36_0
astroid                   1.6.3                    py36_0
astropy                   3.0.1            py36h1de35cc_1
async-timeout             3.0.0                     <pip>
asynctest                 0.12.0                    <pip>
attrs                     17.4.0                   py36_0
babel                     2.5.3                    py36_0
backcall                  0.1.0                    py36_0
backports                 1.0              py36ha3c1827_1
backports.shutil_get_terminal_size 1.0.0            py36hd7a2ee4_2
bcrypt                    3.1.3                     <pip>
beautifulsoup4            4.6.0            py36h72d3c9f_1
bitarray                  0.8.1            py36h1de35cc_1
blaze                     0.11.3           py36h02e7a37_0
bleach                    2.1.3                    py36_0
bokeh                     0.12.15                  py36_0
boto                      2.48.0           py36hdbc59ac_1
boto3                     1.7.21                    <pip>
botocore                  1.10.21                   <pip>
bottleneck                1.2.1            py36hbd380ad_0
bzip2                     1.0.6                hd86a083_4
ca-certificates           2018.4.16                     0    conda-forge
cctools                   895                  h7512d6f_0
certifi                   2018.4.16                py36_0    conda-forge
certifi                   2017.4.17                 <pip>
cffi                      1.11.5           py36h342bebf_0
chardet                   3.0.4            py36h96c241c_1
clang                     4.0.1                h662ec87_0
clang_osx-64              4.0.1               h1ce6c1d_10
clangxx                   4.0.1                hc9b4283_0
clangxx_osx-64            4.0.1               h22b1bf0_10
click                     6.7              py36hec950be_0
cloudpickle               0.5.2                    py36_1
clyent                    1.2.2            py36hae3ad88_0
colorama                  0.3.9            py36hd29a30c_0
colorama                  0.3.7                     <pip>
compiler-rt               4.0.1                h5487866_0
conda                     4.5.1                    py36_0    conda-forge
conda-env                 2.6.0                h36134e3_0
configparser              3.5.0                     <pip>
contextlib2               0.5.5            py36hd66e5e7_0
cryptography              2.2.2            py36h1de35cc_0
curl                      7.59.0               ha441bb4_0
cycler                    0.10.0           py36hfc81398_0
cython                    0.28.2           py36h1de35cc_0
cytoolz                   0.9.0.1          py36h1de35cc_0
dask                      0.17.2                   py36_0
dask-core                 0.17.2                   py36_0
databricks-cli            0.7.1                     <pip>
datashape                 0.5.4            py36hfb22df8_0
DateTime                  4.2                       <pip>
dbus                      1.13.2               h760590f_1
decorator                 4.3.0                    py36_0
distributed               1.21.6                   py36_0
docopt                    0.6.2                     <pip>
docutils                  0.14             py36hbfde631_0
entrypoints               0.2.3            py36hd81d71f_2
et_xmlfile                1.0.1            py36h1315bdc_0
expat                     2.2.5                hb8e80ba_0
fastcache                 1.0.2            py36h1de35cc_2
fbprophet                 0.2.1                    py36_0    conda-forge
flask                     0.12.2           py36h5658096_0
flask-cors                3.0.3            py36h7387b97_0
freetype                  2.8                  h12048fb_1
future                    0.16.0                    <pip>
get_terminal_size         1.0.0                h7520d66_0
gettext                   0.19.8.1             h15daf44_3
gevent                    1.2.2            py36ha70b9d6_0
gitdb2                    2.0.2                     <pip>
GitPython                 2.1.5                     <pip>
glib                      2.56.1               h35bc53a_0
gmp                       6.1.2                hb37e062_1
gmpy2                     2.0.8            py36hf9c35bd_2
greenlet                  0.4.13           py36h1de35cc_0
h5py                      2.7.1            py36h39cdac5_0
hdf5                      1.10.1               ha036c08_1
heapdict                  1.0.0                    py36_2
html5lib                  1.0.1            py36h2f9c1c0_0
icu                       58.2                 h4b95b61_1
idna                      2.6              py36h8628d0a_1
imageio                   2.3.0                    py36_0
imagesize                 1.0.0                    py36_0
intel-openmp              2018.0.0                      8
ipdb                      0.11                      <pip>
ipykernel                 4.8.2                    py36_0
ipython                   6.3.1                    py36_0
ipython_genutils          0.2.0            py36h241746c_0
ipywidgets                7.2.1                    py36_0
isort                     4.3.4                    py36_0
itsdangerous              0.24             py36h49fbb8d_1
jbig                      2.1                  h4d881f8_0
jdcal                     1.4                      py36_0
jedi                      0.12.0                   py36_0
Jinja2                    2.8.1                     <pip>
jinja2                    2.10             py36hd36f9c5_0
jmespath                  0.9.3                     <pip>
joblib                    0.11                     py36_0
jpeg                      9b                   he5867d9_2
jsonschema                2.6.0            py36hb385e00_0
jupyter                   1.0.0                    py36_4
jupyter_client            5.2.3                    py36_0
jupyter_console           5.2.0            py36hccf5b1c_1
jupyter_core              4.4.0            py36h79cf704_0
kiwisolver                1.0.1            py36h792292d_0
lazy-object-proxy         1.3.1            py36h2fbbe47_0
ld64                      274.2                h7c2db76_0
libcurl                   7.59.0               hf30b1f0_0
libcxx                    4.0.1                h579ed51_0
libcxxabi                 4.0.1                hebd6815_0
libedit                   3.1                  hb4e282d_0
libffi                    3.2.1                h475c297_4
libgfortran               3.0.1                h93005f0_2
libiconv                  1.15                 hdd342a3_7
libpng                    1.6.34               he12f830_0
libsodium                 1.0.16               h3efe00b_0
libssh2                   1.8.0                h322a93b_4
libtiff                   4.0.9                h0dac147_0
libxml2                   2.9.8                h2866646_0
libxslt                   1.1.32               hb819dd2_0
llvm                      4.0.1                hc748206_0
llvm-lto-tapi             4.0.1                h6701bc3_0
llvmlite                  0.22.0           py36h35728e8_0
locket                    0.2.0            py36hca03003_1
lxml                      4.2.1            py36h7166777_0
lzo                       2.10                 h362108e_2
markupsafe                1.0              py36h3a1e703_1
matplotlib                2.2.2            py36ha7267d0_0
mccabe                    0.6.1            py36hdaeb55d_0
mistune                   0.8.3                    py36_0
mkl                       2018.0.2                      1
mkl-service               1.1.2            py36h7ea6df4_4
mkl_fft                   1.0.1            py36h917ab60_0
mkl_random                1.0.1            py36h78cc56f_0
more-itertools            4.1.0                    py36_0
mpc                       1.0.3                h7a72875_5
mpfr                      3.1.5                h711e7fd_2
mpmath                    1.0.0            py36hf1b8295_2
msgpack-python            0.5.6            py36h04f5b5a_0
multidict                 4.3.1                     <pip>
multipledispatch          0.5.0                    py36_0
navigator-updater         0.1.0            py36h7aee5fb_0
nbconvert                 5.3.1            py36h810822e_0
nbformat                  4.4.0            py36h827af21_0
ncurses                   6.0                  hd04f020_2
networkx                  2.1                      py36_0
nltk                      3.2.5            py36h1190bce_0
nose                      1.3.7            py36h73fae2b_2
notebook                  5.4.1                    py36_0
numba                     0.37.0          np114py36h210bcc1_0
numexpr                   2.6.4            py36habcfcfe_0
numpy                     1.14.0                    <pip>
numpy                     1.14.2           py36ha9ae307_1
numpydoc                  0.8.0                    py36_0
odo                       0.5.1            py36hc1af34a_0
olefile                   0.45.1                   py36_0
openpyxl                  2.5.2                    py36_0
openssl                   1.0.2o                        0    conda-forge
packaging                 17.1                     py36_0
pandas                    0.22.0           py36h0a44026_0
pandas                    0.22.0                    <pip>
pandoc                    1.19.2.1             ha5e8f32_1
pandocfilters             1.4.2            py36h3b0b094_1
paramiko                  2.2.1                     <pip>
parso                     0.2.0                    py36_0
partd                     0.3.8            py36hf5c4cb8_0
path.py                   11.0.1                   py36_0
pathlib2                  2.3.0            py36h877a6d8_0
patsy                     0.5.0                    py36_0
pcre                      8.42                 h378b8a2_0
pep8                      1.7.1                    py36_0
pexpect                   4.5.0                    py36_0
pickleshare               0.7.4            py36hf512f8e_0
pillow                    5.1.0            py36hfcce615_0
pip                       9.0.3                    py36_0
pip                       10.0.0                    <pip>
pluggy                    0.6.0            py36hb1d0581_0
ply                       3.11                     py36_0
prompt_toolkit            1.0.15           py36haeda067_0
psutil                    5.4.5            py36h1de35cc_0
ptyprocess                0.5.2            py36he6521c3_0
py                        1.5.3                    py36_0
py4j                      0.10.6           py36hde0549a_1
py4j                      0.10.4                    <pip>
pyasn1                    0.2.3                     <pip>
pycodestyle               2.4.0                    py36_0
pycosat                   0.6.3            py36hee92d8f_0
pycparser                 2.18             py36h724b2fc_1
pycrypto                  2.6.1            py36h1de35cc_7
pycurl                    7.43.0.1         py36hdbc3d79_0
pyflakes                  1.6.0            py36hea45e83_0
pygments                  2.2.0            py36h240cd3f_0
pylint                    1.8.4                    py36_0
pymc3                     3.3                      py36_0
PyNaCl                    1.1.2                     <pip>
pyodbc                    4.0.23           py36h0a44026_0
pyopenssl                 17.5.0           py36h51e4350_0
pyparsing                 2.2.0            py36hb281f35_0
pyqt                      5.9.2            py36h11d3b92_0
pysocks                   1.6.8                    py36_0
pyspark                   2.3.0                    py36_0
pystan                    2.17.1.0                 py36_0    conda-forge
pytables                  3.4.2            py36hfbd7ab0_2
pytest                    3.5.0                    py36_0
pytest-arraydiff          0.2                      py36_0
pytest-astropy            0.2.1                    py36_0
pytest-doctestplus        0.1.2                    py36_0
pytest-openfiles          0.2.0                    py36_0
pytest-remotedata         0.2.0                    py36_0
python                    3.6.5                hc167b69_0
python-box                3.1.1                     <pip>
python-dateutil           2.7.2                    py36_0
python-dateutil           2.6.1                     <pip>
python-keyczar            0.716                     <pip>
python.app                2                        py36_8
pytz                      2017.3                    <pip>
pytz                      2018.4                   py36_0
pywavelets                0.5.2            py36h2710a04_0
pyyaml                    3.12             py36h2ba1e63_1
pyzmq                     17.0.0           py36h1de35cc_1
qt                        5.9.5                h02808f3_0
qtawesome                 0.4.4            py36h468c6fb_0
qtconsole                 4.3.1            py36hd96c0ff_0
qtpy                      1.4.0                    py36_0
readline                  7.0                  hc1231fa_4
requests                  2.18.1                    <pip>
requests                  2.18.4           py36h4516966_1
rope                      0.10.7           py36h68959ac_0
rsa                       3.4.2                     <pip>
ruamel_yaml               0.15.35          py36h1de35cc_1
s3transfer                0.1.10                    <pip>
scikit-image              0.13.1           py36h1de35cc_1
scikit-learn              0.19.1           py36hffbff8c_0
scipy                     1.0.1            py36hcaad992_0
seaborn                   0.8.1            py36h595ecd9_0
send2trash                1.5.0                    py36_0
setuptools                39.0.1                   py36_0
simplegeneric             0.8.1                    py36_2
singledispatch            3.4.0.3          py36hf20db9d_0
sip                       4.19.8           py36h0a44026_0
six                       1.11.0           py36h0e22d5e_1
six                       1.11.0                    <pip>
smmap2                    2.0.3                     <pip>
snowballstemmer           1.2.1            py36h6c7b616_0
sortedcollections         0.6.1                    py36_0
sortedcontainers          1.5.9                    py36_0
sphinx                    1.7.2                    py36_0
sphinxcontrib             1.0              py36h9364dc8_1
sphinxcontrib-websupport  1.0.1            py36h92f4a7a_1
spyder                    3.2.8                    py36_0
sqlalchemy                1.2.6            py36h1de35cc_0
sqlite                    3.22.0               h3efe00b_0
statsmodels               0.8.0            py36h9c68fc9_0
svn                       0.3.44                    <pip>
sympy                     1.1.1            py36h7f3cf04_0
tabulate                  0.8.2                     <pip>
tblib                     1.3.2            py36hda67792_0
terminado                 0.8.1                    py36_1
testpath                  0.3.1            py36h625a49b_0
theano                    1.0.1            py36h04f5b5a_0
tk                        8.6.7                h35a86e2_3
toolz                     0.9.0                    py36_0
tornado                   5.0.1                    py36_1
tqdm                      4.23.0                   py36_0
traitlets                 4.3.2            py36h65bd3ce_0
troposphere               1.9.4                     <pip>
typing                    3.6.4                    py36_0
unicodecsv                0.14.1           py36he531d66_0
unixodbc                  2.3.6                h3efe00b_0
urllib3                   1.22             py36h68b9469_0
urllib3                   1.21.1                    <pip>
wcwidth                   0.1.7            py36h8c6ec74_0
webencodings              0.5.1            py36h3b9701d_1
werkzeug                  0.14.1                   py36_0
wheel                     0.31.0                   py36_0
widgetsnbextension        3.2.1                    py36_0
wrapt                     1.10.11          py36hc29e774_0
xgboost                   0.71                      <pip>
xlrd                      1.1.0            py36h336f4a2_1
xlsxwriter                1.0.4                    py36_0
xlwings                   0.11.7                   py36_0
xlwt                      1.2.0            py36h5ad1178_0
xz                        5.2.3                h0278029_2
yaml                      0.1.7                hc338f04_2
yarl                      1.2.5                     <pip>
zeromq                    4.2.5                h378b8a2_0
zict                      0.1.3            py36h71da714_0
zlib                      1.2.11               hf3cbc9b_2
zope.interface            4.4.2                     <pip>

Do you notice any obvious dependency issues? Can you suggest how to troubleshoot this problem otherwise?

fourjr commented 6 years ago

Please install yarl<1.2 or update aiohttp to the latest version.

fourjr commented 6 years ago

bumped aiohttp up, should be fixed in 3.4.2