Skip to content

Commit

Permalink
fix #326 catch market locked exception - thanks to syndac
Browse files Browse the repository at this point in the history
  • Loading branch information
oczkers committed Oct 27, 2017
1 parent 10aa848 commit fe19380
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
28 changes: 15 additions & 13 deletions fut/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
UnknownError, PermissionDenied, Captcha,
Conflict, MaxSessions, MultipleSession,
Unauthorized, FeatureDisabled, doLoginFail,
NoUltimateTeam)
NoUltimateTeam, MarketLocked)
from .EAHashingAlgorithm import EAHashingAlgorithm


Expand Down Expand Up @@ -624,16 +624,14 @@ def __request__(self, method, url, data={}, params={}, fast=False):
rc = self.r.delete(url, data=data, params=params, timeout=self.timeout)
self.logger.debug("response: {0}".format(rc.content))
if not rc.ok: # status != 200
if rc.status_code == 429:
raise FutError('429 Too many requests')
if rc.status_code == 401:
# TODO?: send pinEvent https://gist.github.com/oczkers/7e5de70915b87262ddea961c49180fd6
print(rc.content)
raise ExpiredSession()
elif rc.status_code == 426:
raise FutError('426 Too many requests')
elif rc.status_code in (512, 521):
raise FutError('512/521 Temporary ban or just too many requests.')
elif rc.status_code == 461:
raise PermissionDenied(461) # You are not allowed to bid on this trade TODO: add code, reason etc
elif rc.status_code == 460:
raise PermissionDenied(460)
elif rc.status_code == 429:
raise FutError('429 Too many requests')
elif rc.status_code == 458:
print(rc.headers)
print(rc.status_code)
Expand All @@ -643,10 +641,14 @@ def __request__(self, method, url, data={}, params={}, fast=False):
events = [self.pin.event('error')]
self.pin.send(events)
raise Captcha()
elif rc.status_code == 401:
# TODO?: send pinEvent https://gist.github.com/oczkers/7e5de70915b87262ddea961c49180fd6
print(rc.content)
raise ExpiredSession()
elif rc.status_code == 460:
raise PermissionDenied(460)
elif rc.status_code == 461:
raise PermissionDenied(461) # You are not allowed to bid on this trade TODO: add code, reason etc
elif rc.status_code == 494:
raise MarketLocked()
elif rc.status_code in (512, 521):
raise FutError('512/521 Temporary ban or just too many requests.')
# it makes sense to print headers, status_code, etc. only when we don't know what happened
print(rc.headers)
print(rc.status_code)
Expand Down
6 changes: 6 additions & 0 deletions fut/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ class InternalServerError(FutError):
"""[500] Internal Server Error (ut). (invalid parameters?)"""


class MarketLocked(FutError):
"""[494] If this is a new account, you need to unlock the transfer market
by playing games and completing the starter objectives.
If this is an older account, you may be banned from using the transfer market on the web app."""


'''
class InvalidCookie(FutError):
"""[482] Invalid cookie."""
Expand Down

0 comments on commit fe19380

Please sign in to comment.