2015-08-15 18:36:05 -05:00
|
|
|
import json, os, sys
|
|
|
|
import urllib, urllib2, cookielib, socket
|
2015-07-08 07:15:51 -05:00
|
|
|
from panda3d.core import *
|
|
|
|
|
|
|
|
|
2015-08-15 18:36:05 -05:00
|
|
|
req_version = (2,7,9)
|
|
|
|
cur_version = sys.version_info
|
|
|
|
if cur_version < req_version:
|
|
|
|
print 'Your version of python is too old. Please upgrade to 2.7.9.'
|
|
|
|
sys.exit()
|
|
|
|
|
2015-07-08 07:15:51 -05:00
|
|
|
username = os.environ['ttsUsername']
|
|
|
|
password = os.environ['ttsPassword']
|
2015-08-15 18:36:05 -05:00
|
|
|
distribution = 'qa'
|
|
|
|
|
|
|
|
accountServerEndpoint = 'https://toontownstride.com/api/'
|
2015-07-08 07:15:51 -05:00
|
|
|
|
2015-08-15 18:36:05 -05:00
|
|
|
data = urllib.urlencode({'username': username, 'password': password, 'distribution': distribution})
|
|
|
|
cookie_jar = cookielib.LWPCookieJar()
|
|
|
|
cookie = urllib2.HTTPCookieProcessor(cookie_jar)
|
|
|
|
opener = urllib2.build_opener(cookie)
|
|
|
|
req = urllib2.Request(accountServerEndpoint + 'login', data,
|
|
|
|
headers={"Content-Type" : "application/x-www-form-urlencoded"})
|
|
|
|
req.get_method = lambda: "POST"
|
|
|
|
_response = opener.open(req).read()
|
2015-07-08 07:15:51 -05:00
|
|
|
|
|
|
|
try:
|
2015-08-15 18:36:05 -05:00
|
|
|
response = json.loads(_response)
|
2015-07-08 07:15:51 -05:00
|
|
|
except ValueError:
|
|
|
|
print "Couldn't verify account credentials."
|
|
|
|
else:
|
|
|
|
if response['status'] != 7:
|
|
|
|
print response['message']
|
|
|
|
else:
|
|
|
|
os.environ['TTS_PLAYCOOKIE'] = response['token']
|
|
|
|
os.environ['TTS_GAMESERVER'] = response['gameserver']
|
|
|
|
|
|
|
|
# Start the game:
|
2015-08-15 18:36:05 -05:00
|
|
|
import toontown.toonbase.ToontownStart
|