Poodletooth-iLand/toontown/toonbase/ToontownStartRemoteDB.py

39 lines
1.2 KiB
Python
Raw Normal View History

import json, os, sys
import urllib, urllib2, cookielib, socket
2015-07-08 07:15:51 -05:00
from panda3d.core import *
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']
distribution = 'qa'
accountServerEndpoint = 'https://toontownstride.com/api/'
2015-07-08 07:15:51 -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:
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:
import toontown.toonbase.ToontownStart