Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot create future dated tournament #22

Closed
tranq2 opened this issue Jan 31, 2021 · 1 comment
Closed

Cannot create future dated tournament #22

tranq2 opened this issue Jan 31, 2021 · 1 comment

Comments

@tranq2
Copy link

tranq2 commented Jan 31, 2021

  • berserk version:
  • Python version: 3.8
  • Operating System: Windows

Description

I am trying to create a future dated tournament. I am having trouble passing a date. I have created a future date using date_time, converted it to timestamp, then cast to integer and string. The call fails saying the date is not in the future.

Love the work being done here with Berserk BTW and I am also new to Python so apologies if i have missed something obvious ...

What I Did

this was run on 31/1/21

relevant code fragments as follows

tourney_date = datetime(2021, 2, 1, 8, 00, 00)
datetime.fromtimestamp(int(tourney_date.timestamp())))
td_int = int(tourney_date.timestamp())
td_int_as_str = str(td_int)
tournament = client.tournaments.create(clock_time=2, clock_increment=3, minutes=30,
                                       berserkable = "true",
                                       start_date = td_int_as_str ,
                                       password="mdntest",
                                       conditions=myconditions)

Traceback (most recent call last):
  File "d:\users\nigel\appdata\local\programs\python\python38-32\lib\site-packages\berserk\exceptions.py", line 63, in _catch_exception
    response.raise_for_status()
  File "d:\users\nigel\appdata\local\programs\python\python38-32\lib\site-packages\requests\models.py", line 943, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://lichess.org/api/tournament

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "D:\Users\Nigel\AppData\Local\Programs\Python\Python38-32\Requests.py", line 117, in <module>
    tournament = client.tournaments.create(clock_time=2, clock_increment=3, minutes=30,
  File "d:\users\nigel\appdata\local\programs\python\python38-32\lib\site-packages\berserk\clients.py", line 933, in create
    return self._r.post(path, json=payload,
  File "d:\users\nigel\appdata\local\programs\python\python38-32\lib\site-packages\berserk\session.py", line 64, in post
    return self.request('POST', *args, **kwargs)
  File "d:\users\nigel\appdata\local\programs\python\python38-32\lib\site-packages\berserk\session.py", line 54, in request
    raise exceptions.ResponseError(response)
berserk.exceptions.ResponseError: HTTP 400: Bad Request: {'startDate': ['**The date must be set in the future'**], 'error': {'startDate': ['The date must be set in the future']}}
@tranq2
Copy link
Author

tranq2 commented Mar 8, 2021

Finally managed to sort this as follows using some utils in the berserk package
tourney_date = datetime(2021, 3, 9, 18, 00, 000)
tourney_date_millis = berserk.utils.to_millis(tourney_date)
tourney_date_int = int(tourney_date_millis)
tourney_date_string = str(tourney_date_int)

and pass tourney_date_string in to tournament create call

@tranq2 tranq2 closed this as completed Mar 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant