cgrok / clashroyale Goto Github PK
View Code? Open in Web Editor NEWAsync + Sync wrapper for royaleapi.com and the CR official API
License: MIT License
Async + Sync wrapper for royaleapi.com and the CR official API
License: MIT License
The install process is currently broken. it's trying to download some settings from a url that is apparently broken. maybe include those setting in the repo to remove this dependancy?
Traceback (most recent call last):
File "setup.py", line 34, in <module>
data = json.loads(urllib.request.urlopen('https://fourjr-webserver.herokuapp.com/cr/constants').read())
File "/home/danielj/anaconda3/lib/python3.6/urllib/request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "/home/danielj/anaconda3/lib/python3.6/urllib/request.py", line 532, in open
response = meth(req, response)
File "/home/danielj/anaconda3/lib/python3.6/urllib/request.py", line 642, in http_response
'http', request, response, code, msg, hdrs)
File "/home/danielj/anaconda3/lib/python3.6/urllib/request.py", line 570, in error
return self._call_chain(*args)
File "/home/danielj/anaconda3/lib/python3.6/urllib/request.py", line 504, in _call_chain
result = func(*args)
File "/home/danielj/anaconda3/lib/python3.6/urllib/request.py", line 650, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 503: Service Unavailable
docs in readme that links to api docs + basic instructions on sync/async
@kyb3r opinions
I am using clashroyale module for a while to do some custom analysis of the data.
recently I tried to run my scripts, which were working with no problem before, I dont do anything special, just:
initialize the client with my api key:
client = clashroyale.RoyaleAPI(royale_api_key)
parts of the api work like expected:
client.get_clan('8LYJ0UYC')
returns:
[<Refreshable: {'tag': '8LYJ0UYC', 'name': 'Sylvanas Legion', 'description': 'Gente activa y donadora, guerras obligatorias 3/3, mínimo 100 victorias.', 'type': 'open', 'score': 58822, 'warTrophies': 9374, 'memberCount': 49, 'requiredScore': 6000, 'donations': 13470, ...]
so seems like api key is not an issue.
but trying to use:
client.get_top_players()
raises an exception:
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.2.3\helpers\pydev_pydevd_bundle\pydevd_exec2.py", line 3, in Exec
exec(exp, global_vars, local_vars)
File "", line 1, in
File "C:\Users\stephan\Documents\WPy64-3760\python-3.7.6.amd64\lib\site-packages\clashroyale\royaleapi\utils.py", line 35, in wrapper
return func(*new_args, **new_kwargs)
File "C:\Users\stephan\Documents\WPy64-3760\python-3.7.6.amd64\lib\site-packages\clashroyale\royaleapi\client.py", line 644, in get_top_players
return self._get_model(url, PartialPlayerClan, **params)
File "C:\Users\stephan\Documents\WPy64-3760\python-3.7.6.amd64\lib\site-packages\clashroyale\royaleapi\client.py", line 219, in _get_model
raise e
File "C:\Users\stephan\Documents\WPy64-3760\python-3.7.6.amd64\lib\site-packages\clashroyale\royaleapi\client.py", line 212, in _get_model
data, cached, ts, resp = self._request(url, **params)
File "C:\Users\stephan\Documents\WPy64-3760\python-3.7.6.amd64\lib\site-packages\clashroyale\royaleapi\client.py", line 173, in _request
return self._raise_for_status(resp, resp.text, method='GET')
File "C:\Users\stephan\Documents\WPy64-3760\python-3.7.6.amd64\lib\site-packages\clashroyale\royaleapi\client.py", line 137, in _raise_for_status
raise NotFoundError(resp, data)
clashroyale.errors.NotFoundError: Not Found (404): True
Any Idea here what might cause the problem ?
I am using current master branch commit 3184c74
I used python 3.6, clashroyale 4.0.1, in win 10 console and pasted the sync example lines, except adding my api token. I ran into the following error,
>>> profile = client.get_player('#8l9l9gl')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python\Python36-32\lib\site-packages\clashroyale\official_api\utils.py", line 35, in wrapper
return func(*new_args, **new_kwargs)
File "C:\Python\Python36-32\lib\site-packages\clashroyale\official_api\client.py", line 248, in get_player
return self._get_model(url, FullPlayer, timeout=timeout)
File "C:\Python\Python36-32\lib\site-packages\clashroyale\official_api\client.py", line 231, in _get_model
raise e
File "C:\Python\Python36-32\lib\site-packages\clashroyale\official_api\client.py", line 224, in _get_model
data, cached, ts, resp = self._request(url, **params)
File "C:\Python\Python36-32\lib\site-packages\clashroyale\official_api\client.py", line 178, in _request
method, url, timeout=timeout, headers=self.headers, params=params, json=json_data
AttributeError: __enter__
apparently 4jr made me do this cuz im sharpBIT?
Describe the bug
I get the full response of all clan groups as expected, followed by:
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x00000146808E10D0>
Traceback (most recent call last):
File "C:\Program Files\Python38\lib\asyncio\proactor_events.py", line 116, in __del__
self.close()
File "C:\Program Files\Python38\lib\asyncio\proactor_events.py", line 108, in close
self._loop.call_soon(self._call_connection_lost, None)
File "C:\Program Files\Python38\lib\asyncio\base_events.py", line 715, in call_soon
self._check_closed()
File "C:\Program Files\Python38\lib\asyncio\base_events.py", line 508, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x00000146808E10D0>
Traceback (most recent call last):
File "C:\Program Files\Python38\lib\asyncio\proactor_events.py", line 116, in __del__
self.close()
File "C:\Program Files\Python38\lib\asyncio\proactor_events.py", line 108, in close
self._loop.call_soon(self._call_connection_lost, None)
File "C:\Program Files\Python38\lib\asyncio\base_events.py", line 715, in call_soon
self._check_closed()
File "C:\Program Files\Python38\lib\asyncio\base_events.py", line 508, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x00000146808E10D0>
Traceback (most recent call last):
File "C:\Program Files\Python38\lib\asyncio\proactor_events.py", line 116, in __del__
self.close()
File "C:\Program Files\Python38\lib\asyncio\proactor_events.py", line 108, in close
self._loop.call_soon(self._call_connection_lost, None)
File "C:\Program Files\Python38\lib\asyncio\base_events.py", line 715, in call_soon
self._check_closed()
File "C:\Program Files\Python38\lib\asyncio\base_events.py", line 508, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Process finished with exit code 0
Full Code
import clashroyale
import asyncio
# Define Tokens
officialAPIToken = "token"
unofficialAPIToken = "token"
clan_groups = [
['PPCLCJG9', '2LRU2J', 'PGLQ0VQ', 'YU2RQG9', '2LVRQ29'],
['PYP8UPJV', 'P9L0CYY0', 'Y2RGQPJ', '8P2GYJ8', '9VQJPL2L'],
['RYPRGCJ', '809R8PG8', 'PJY9PP98', '2GCQLC', '2GL2QPPL']
]
async def get_clans(cr, clan_groups):
return await asyncio.gather(*[
cr.get_clan(*group)
for group in clan_groups
])
async def main():
cr = clashroyale.RoyaleAPI(
unofficialAPIToken,
is_async=True,
timeout=30
)
try:
results = await get_clans(cr, clan_groups)
print(results)
finally:
await cr.close()
print('end')
asyncio.run(main())
Any thoughts?
I am running Python3.5.4 on Windows 10 and am getting an error when trying to use OfficialAPI, stack-trace below :
File "C:\Users\...\pull.py", line 14, in <module>
APIClient = clashroyale.OfficialAPI(settings.API_KEY, timeout=30)
File "C:\Users\...\venv\lib\site-packages\clashroyale\official_api\client.py", line 104, in __init__
with open(os.path.join(Path(__file__).parent.parent, 'constants.json'), encoding='utf8') as f:
File "C:\Users\Username\AppData\Local\Programs\Python\Python35\lib\ntpath.py", line 113, in join
genericpath._check_arg_types('join', path, *paths)
File "C:\Users\Username\AppData\Local\Programs\Python\Python35\lib\genericpath.py", line 143, in _check_arg_types
(funcname, s.__class__.__name__)) from None
TypeError: join() argument must be str or bytes, not 'WindowsPath'
Hello,
Not sure what's happening but the object returned from get_top_clans seems to bug when iterated through. When I print the object, I get this single item I requested (limit=1). But when I iterate through it I get a near infinite loop of objects.
CODE
officialClient = clashroyale.official_api.Client(officialAPIToken)
lTopClans = officialClient.get_top_clans(limit=1)
print('Number of Clans:', len(lTopClans))
for i in lTopClans:
print(i.tag)
EXPECTED:
Number of Clans: 1
#GYUQQCLV
ACTUAL:
Number of Clans: 1
#GYUQQCLV
#GYUQQCLV
#2CLV2RP0
#GYUQQCLV
#2CLV2RP0
#2GGR2GPQ0
#GYUQQCLV
#2CLV2RP0
#2GGR2GPQ0
#2LJ0ULYCC
#GYUQQCLV
#2CLV2RP0
#2GGR2GPQ0
#2LJ0ULYCC
#GUPYJ2
You'll see there's actually a pattern to it: it's returning like this:
item1
item1
item2
item1
item2
item3
item1
item2
item3
item4
But obviously, it was only supposed to return 1 item altogether.
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?
The error occurs in the get_player(*tags: crtag, **params: keys)
method which fails to filter specified fields.
Here's the code
@commands.cooldown(2,5,commands.BucketType.user)
@commands.command(name="test")
async def _test(self, ctx, *, tag=None):
async with ctx.typing():
if tag is None:
return
try:
player = await self.client.get_player(tag, keys = ["name","trophies"])
except ValueError as f:
return await ctx.send(f)
else:
print(player)
The player object with the filtered fields, name and trophies.
The player object with all the stats in it.
python3.5 examples/async.py / sync.py / etc. Still runs but returns:
Traceback (most recent call last): File "async.py", line 32, in <module> loop.run_until_complete(main()) File "/usr/lib64/python3.5/asyncio/base_events.py", line 467, in run_until_complete return future.result() File "/usr/lib64/python3.5/asyncio/futures.py", line 294, in result raise self._exception File "/usr/lib64/python3.5/asyncio/tasks.py", line 240, in _step result = coro.send(None) File "async.py", line 16, in main await profile.refresh() File "/usr/lib/python3.5/site-packages/clashroyale/models.py", line 141, in _arefresh data, cached, ts = await self.client.request(self.url, refresh=True) TypeError: request() missing 1 required positional argument: 'timeout' Unclosed client session client_session: <aiohttp.client.ClientSession object at 0x7f677eb19eb8> Unclosed connector connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x7f676fe42f60>, 144031.235123359)]'] connector: <aiohttp.connector.TCPConnector object at 0x7f6772f005c0>
Sorry if this is expected
Describe the bug
I'm making Discord bot using your API.
When I try to get all the cards I get an exception
Full Code
import asyncio
import discord
from discord.ext import commands
import clashroyale
from const import *
bot = commands.Bot(command_prefix='$', description='Бот для MGC', command_not_found='Команды {} не существует', command_has_no_subcommands='У команды {} нет подкоманд')
cr_client = clashroyale.official_api.Client(CR_TOKEN, is_async=True)
@bot.group()
async def clashroyale():
pass
@clashroyale.command()
async def cards():
c = await cr_client.get_all_cards()
await bot.say(c)
bot.run(TOKEN)
Expected behavior
A clear and concise description of what you expected to happen.
Actual behavior
Traceback (most recent call last):
File "C:\Users\iVan\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\ext\commands\core.py", line 50, in wrapped
ret = yield from coro(*args, **kwargs)
File "x-wingide-python-shell://102272144/2", line 19, in cards
File "C:\Users\iVan\AppData\Local\Programs\Python\Python36\lib\site-packages\clashroyale\official_api\client.py", line 215, in _aget_model
raise e
File "C:\Users\iVan\AppData\Local\Programs\Python\Python36\lib\site-packages\clashroyale\official_api\client.py", line 208, in _aget_model
data, cached, ts, resp = await self._request(url, **params)
File "C:\Users\iVan\AppData\Local\Programs\Python\Python36\lib\site-packages\clashroyale\official_api\client.py", line 157, in _arequest
return self._raise_for_status(resp, await resp.text())
File "C:\Users\iVan\AppData\Local\Programs\Python\Python36\lib\site-packages\clashroyale\official_api\client.py", line 125, in _raise_for_status
log.debug(self.REQUEST_LOG.format(method=method or resp.request_info.method, url=resp.url, text=text, status=code))
AttributeError: 'ClientResponse' object has no attribute 'request_info'
Additional context
Add any other context about the problem here.
The RoyaleAPI (unofficial) supports searching multiple tags up to 25:
e.g. https://api.royaleapi.com/players/tag1,tag2,tag3
note: the official API does not
When I try this feature in your wrapper I get an error.
Traceback (most recent call last): File "C:/Users/Adam/PycharmProjects/ClashRoyaleMeta/getTags.py", line 22, in <module> lClan = unofficialClient.get_clan(sClanTags) File "C:\Users\Adam\PycharmProjects\ClashRoyaleMeta\venv\lib\site-packages\clashroyale\royaleapi\utils.py", line 30, in wrapper new_args.append(converter(a)) File "C:\Users\Adam\PycharmProjects\ClashRoyaleMeta\venv\lib\site-packages\clashroyale\royaleapi\utils.py", line 83, in crtag raise ValueError('Invalid tag characters passed: {}'.format(', '.join(bad))) ValueError: Invalid tag characters passed: ,
I suspect support is just not added for it in the wrapper since only certain characters are allowed in a tag. I think this would be an easy fix.
Cheers!
~Bub
When I try to import clashroyale, I get the following error:
`(CRActivityBot-LU2alj18) bash-3.2$ python
Python 3.6.5 (default, Apr 29 2018, 09:02:36)
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
import clashroyale
Traceback (most recent call last):
File "", line 1, in
File "/Users/sayeghr/.local/share/virtualenvs/CRActivityBot-LU2alj18/lib/python3.6/site-packages/clashroyale/init.py", line 25, in
from .client import Client
File "/Users/sayeghr/.local/share/virtualenvs/CRActivityBot-LU2alj18/lib/python3.6/site-packages/clashroyale/client.py", line 31, in
import aiohttp
File "/Users/sayeghr/.local/share/virtualenvs/CRActivityBot-LU2alj18/lib/python3.6/site-packages/aiohttp/init.py", line 6, in
from .client import * # noqa
File "/Users/sayeghr/.local/share/virtualenvs/CRActivityBot-LU2alj18/lib/python3.6/site-packages/aiohttp/client.py", line 15, in
from . import connector as connector_mod
File "/Users/sayeghr/.local/share/virtualenvs/CRActivityBot-LU2alj18/lib/python3.6/site-packages/aiohttp/connector.py", line 17, in
from .client_proto import ResponseHandler
File "/Users/sayeghr/.local/share/virtualenvs/CRActivityBot-LU2alj18/lib/python3.6/site-packages/aiohttp/client_proto.py", line 6, in
from .http import HttpResponseParser, StreamWriter
File "/Users/sayeghr/.local/share/virtualenvs/CRActivityBot-LU2alj18/lib/python3.6/site-packages/aiohttp/http.py", line 8, in
from .http_parser import (HttpParser, HttpRequestParser, HttpResponseParser,
File "/Users/sayeghr/.local/share/virtualenvs/CRActivityBot-LU2alj18/lib/python3.6/site-packages/aiohttp/http_parser.py", line 15, in
from .http_writer import HttpVersion, HttpVersion10
File "/Users/sayeghr/.local/share/virtualenvs/CRActivityBot-LU2alj18/lib/python3.6/site-packages/aiohttp/http_writer.py", line 304, in
class URL(yarl.URL):
File "/Users/sayeghr/.local/share/virtualenvs/CRActivityBot-LU2alj18/lib/python3.6/site-packages/yarl/init.py", line 232, in init_subclass
"is forbidden".format(cls))
TypeError: Inheritance a class <class 'aiohttp.http_writer.URL'> from URL is forbidden
`
aiohttp version 2.2.5
clashroyale version 3.4.1
Python 3.6.5
Should we put equality tests for models?
player1 = client.get_profile('2CCP')
player2 = client.get_profile('2CCP')
assert player1 == player2
Should we test by tag or if the data is the exact same?
Exception in command 'save'
Traceback (most recent call last):
File "lib/discord/ext/commands/core.py", line 50, in wrapped
ret = yield from coro(*args, **kwargs)
File "/home/pokemonfanscool/Red-DiscordBot/cogs/clashroyale.py", line 474, in save
profiledata = await self.clash.get_player(profiletag)
File "lib/clashroyale/official_api/client.py", line 215, in _aget_model
raise e
File "lib/clashroyale/official_api/client.py", line 208, in _aget_model
data, cached, ts, resp = await self._request(url, **params)
File "lib/clashroyale/official_api/client.py", line 157, in _arequest
return self._raise_for_status(resp, await resp.text())
File "lib/clashroyale/official_api/client.py", line 125, in _raise_for_status
log.debug(self.REQUEST_LOG.format(method=method or resp.request_info.method, url=resp.url, text=text, status=code))
AttributeError: 'ClientResponse' object has no attribute 'request_info'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "lib/discord/ext/commands/bot.py", line 846, in process_commands
yield from command.invoke(ctx)
File "lib/discord/ext/commands/core.py", line 374, in invoke
yield from injected(*ctx.args, **ctx.kwargs)
File "lib/discord/ext/commands/core.py", line 54, in wrapped
raise CommandInvokeError(e) from e
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'ClientResponse' object has no attribute 'request_info'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.