mirror of
https://github.com/gooba42/adventureland.git
synced 2026-10-14 18:39:28 -05:00
python3 fixes and patches
This commit is contained in:
@@ -61,7 +61,15 @@ def serve_executor_post():
|
||||
output="executor_task triggered"
|
||||
else:
|
||||
try:
|
||||
exec(the_code)
|
||||
if 1/2!=0:
|
||||
ld={}
|
||||
exec(the_code,globals(),ld)
|
||||
output=ld.get("output",output)
|
||||
json_output=ld.get("json_output",json_output)
|
||||
html_output=ld.get("html_output",html_output)
|
||||
output_html=ld.get("output_html",output_html)
|
||||
inspect=ld.get("inspect",inspect)
|
||||
else: exec(the_code)
|
||||
except DeadlineExceededError: logging.error("Deadline Exceeded")
|
||||
except:
|
||||
log_trace_i("",logging)
|
||||
|
||||
@@ -979,12 +979,13 @@ def pull_mail_api(**args):
|
||||
else:
|
||||
mails,new_cursor,new_more=Mail.query(Mail.owner==user.k()).order(-Mail.created).fetch_page(page)
|
||||
for mail in mails:
|
||||
mail_data={"fro":mail.fro,"to":mail.to,"message":mail.info.message,"subject":mail.info.subject,"sent":"%s"%mail.created,"id":mail.k()}
|
||||
#logging.info("%s"%mail.created)
|
||||
mail_data={"fro":py3_safe_string(mail.fro),"to":py3_safe_string(mail.to),"message":py3_safe_string(mail.info.message),"subject":py3_safe_string(mail.info.subject),"sent":"%s"%mail.created,"id":mail.k()}
|
||||
if mail.item:
|
||||
mail_data["item"]=simplify_item(mail.info.item)
|
||||
mail_data["taken"]=mail.taken
|
||||
data["mail"].append(mail_data)
|
||||
if new_cursor: data["cursor"]=new_cursor.urlsafe()
|
||||
if new_cursor: data["cursor"]=py3_safe_string(new_cursor.urlsafe())
|
||||
if new_more: data["more"]=True
|
||||
jhtml(self,[data])
|
||||
|
||||
@@ -1073,10 +1074,10 @@ def pull_messages_api(**args):
|
||||
else:
|
||||
messages,new_cursor,new_more=query.fetch_page(page)
|
||||
for message in messages:
|
||||
m_data={"fro":message.fro,"to":message.to,"message":message.info.message,"type":message.type,"id":message.k(),"server":message.server,"date":"%s"%message.created.strftime('%Y-%m-%dT%H:%M:%SZ')}
|
||||
m_data={"fro":py3_safe_string(message.fro),"to":py3_safe_string(message.to),"message":py3_safe_string(message.info.message),"type":py3_safe_string(message.type),"id":message.k(),"server":py3_safe_string(message.server),"date":"%s"%message.created.strftime('%Y-%m-%dT%H:%M:%SZ')}
|
||||
data["messages"].append(m_data)
|
||||
#logging.info(m_data)
|
||||
if new_cursor: data["cursor"]=new_cursor.urlsafe()
|
||||
if new_cursor: data["cursor"]=py3_safe_string(new_cursor.urlsafe())
|
||||
if new_more: data["more"]=True
|
||||
jhtml(self,[data])
|
||||
|
||||
|
||||
@@ -35,15 +35,25 @@ else: #python3
|
||||
from libraries import stripe3 as stripe
|
||||
from libraries import amazon_ses3 as amazon_ses
|
||||
import _pickle as cPickle
|
||||
|
||||
from google.appengine.api import memcache,urlfetch,urlfetch_errors,mail,taskqueue,images,namespace_manager,search,modules
|
||||
from google.appengine.ext import ndb,blobstore,deferred
|
||||
from google.appengine.runtime import DeadlineExceededError
|
||||
from google.appengine.runtime.apiproxy_errors import DeadlineExceededError as DeadlineExceededError2
|
||||
from google.appengine.datastore.datastore_query import Cursor
|
||||
|
||||
from flask import Flask, render_template, request, make_response
|
||||
def _from_base_type(self, value):
|
||||
try:
|
||||
return pickle.loads(value)
|
||||
except:
|
||||
return pickle.loads(value,encoding='latin1')
|
||||
ndb.model.PickleProperty._from_base_type=_from_base_type
|
||||
|
||||
from flask import Flask, render_template, request, make_response, redirect
|
||||
|
||||
app = Flask(__name__)
|
||||
# app = ndb.toplevel(app) # sadly doesn't work this way
|
||||
|
||||
if 1/2 != 0:
|
||||
app.wsgi_app = wrap_wsgi_app(app.wsgi_app, use_deferred=True)
|
||||
|
||||
@@ -104,12 +114,14 @@ if is_production:
|
||||
#maps["desertland"]["key"]="jayson_desertland_copy"
|
||||
pass
|
||||
|
||||
game_version=786
|
||||
game_version=787
|
||||
SALES=4+5+388+5101+125/20 #donation+manual+macos+steam+sales
|
||||
update_notes=[
|
||||
"Lunar New Year Event",
|
||||
"Last Update [19th of January]",
|
||||
"Last Update [6th of February]",
|
||||
"Switched to Python3",
|
||||
"All major issues fixed",
|
||||
|
||||
]
|
||||
ip_to_subdomain={ #IMPORTANT: SPECIAL PAGE RULES ARE NEEDED: https://dash.cloudflare.com/b6f5a13bded5fdd273e4a1cd3777162d/adventure.land/page-rules - uss1 / eus1 was best
|
||||
"35.187.255.184":"asia1",
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ drops={
|
||||
#[0.0001,"redenvelopev3"],
|
||||
[0.00005,"greenenvelope"],
|
||||
#[0.0001,"redenvelopev4"],
|
||||
#[0.001,"candypop"],
|
||||
[0.001,"candypop"],
|
||||
],
|
||||
"main":[
|
||||
[0.0007,"ringsj"],
|
||||
|
||||
File diff suppressed because one or more lines are too long
+15
-6
@@ -276,6 +276,7 @@ def selection_info(self,user,domain):
|
||||
return {"type":"content","html":shtml("htmls/contents/selection.html",user=user,domain=domain,server=server,servers=servers,characters=get_characters(user))}
|
||||
|
||||
def security_threat(request,domain):
|
||||
return False
|
||||
referer=request.headers.get('Referer') or request.headers.get('Origin') or ""
|
||||
if not referer: return False
|
||||
|
||||
@@ -1203,7 +1204,7 @@ def select_server(self,user,servers):
|
||||
return servers[0]
|
||||
|
||||
def get_servers(no_cache=False):
|
||||
servers=memcache.get("servers")
|
||||
servers=memcache.get("servers"+(1/2!=0 and "v3" or ""))
|
||||
if not servers or no_cache:
|
||||
servers=[]
|
||||
for server in Server.query(Server.online == True):
|
||||
@@ -1220,7 +1221,7 @@ def set_servers(current=None):
|
||||
if msince(server.last_update)<5 and server.online and not (current and current.k()==server.k()):
|
||||
del server.info.data # otherwise easily exceeds 1MB [13/06/19]
|
||||
servers.append(server)
|
||||
memcache.set("servers",servers)
|
||||
memcache.set("servers"+(1/2!=0 and "v3" or ""),servers)
|
||||
|
||||
def check_servers():
|
||||
offlines=[]; servers=[]
|
||||
@@ -1242,7 +1243,7 @@ def check_servers():
|
||||
del server.info.data
|
||||
servers.append(server)
|
||||
logging.info("Server Alive: %s"%server)
|
||||
memcache.set("servers",servers)
|
||||
memcache.set("servers"+(1/2!=0 and "v3" or ""),servers)
|
||||
if offlines:
|
||||
send_email(gdi(),"kaansoral@gmail.com",html="%s"%offlines,title="OFFLINE SERVERS DETECTED")
|
||||
enforce_limitations()
|
||||
@@ -1528,6 +1529,14 @@ def to_string_key(element):
|
||||
if is_string(element): return element
|
||||
return element.k()
|
||||
|
||||
def py3_safe_string(s):
|
||||
#Because App Engine is run by a bunch of idiots now. Random things return bytes. Even something like .urlsafe() ... [06/02/24]
|
||||
if 1/2==0: return s
|
||||
try:
|
||||
return s.decode("utf-8")
|
||||
except:
|
||||
return s
|
||||
|
||||
def str_or_unicode(s):
|
||||
try: return str(s)
|
||||
except:
|
||||
@@ -1743,8 +1752,8 @@ def jhtml(request,jsn=[]):
|
||||
if not request: return
|
||||
if getattr(request,"_cjsons",0):
|
||||
request._cjsons.extend(jsn)
|
||||
#logging.info("CJSONS %s"%self._cjsons)
|
||||
request.response.set_data(json.dumps(self._cjsons))
|
||||
#logging.info("CJSONS %s"%request._cjsons)
|
||||
request.response.set_data(json.dumps(request._cjsons))
|
||||
else:
|
||||
request.response.set_data(json.dumps(jsn))
|
||||
return request.response
|
||||
@@ -2041,7 +2050,7 @@ def ginspect(o,id="root",force_inspection=0):
|
||||
str+="</ul>"
|
||||
elif type(o)==type({}):
|
||||
str+="<ul>"
|
||||
keys=o.keys(); keys.sort()
|
||||
keys=sorted(o)
|
||||
for k in keys:
|
||||
e=o[k]
|
||||
cid=randomStr(20)
|
||||
|
||||
@@ -95,6 +95,12 @@
|
||||
<p>User "foldM_" on Discord stumbled onto this issue on NixOS - his solution was to set Steam to launch the game with: LD_LIBRARY_PATH=/lib:$LD_LIBRARY_PATH %command% (from Steam's Game Properties > Launch Options)</p>
|
||||
</div>
|
||||
|
||||
<div style="background: #EEF1F1; color: #3B3B3C; padding: 10px 10px 10px 10px; margin: 10px -10px 10px -10px;">
|
||||
<div style="color: #4DA9DF">[01/02/24]: [15629:1229/162230.657405:FATAL:gpu_data_manager_impl_private.cc(1034)] The display compositor is frequently crashing. Goodbye.
|
||||
(see it via launching from CLI)</div>
|
||||
<p>Richard found a fix for this issue, the fix is to use the <b>`--no-sandbox`</b> flag.</p>
|
||||
</div>
|
||||
|
||||
<p>If you find and solve an issue, or just stumble onto an issue you can't solve, please email hello@adventure.land with details</p>
|
||||
|
||||
</div>
|
||||
|
||||
+1
-1
@@ -171,7 +171,7 @@ var events = {
|
||||
// SEASONS
|
||||
holidayseason: false,
|
||||
lunarnewyear: true,
|
||||
valentines: false,
|
||||
valentines: true,
|
||||
pinkgoo: 0, // every N minutes - 60
|
||||
snowman: 20 * 60, // 1200 normally - 60 - at sprocess_game_data
|
||||
egghunt: 0, // every N minutes - 60
|
||||
|
||||
@@ -8,9 +8,13 @@ The python3 dev_appserver uses Java objects, test it according to your needs and
|
||||
|
||||
Useful: https://cloud.google.com/appengine/docs/standard/tools/local-devserver-command?tab=python
|
||||
|
||||
Useful for testing, creates a copy: node ~/gscripts/create_python3_copy.js
|
||||
|
||||
alias run_thegame3="python3.11 /Users/kaan/Desktop/APPENGINE/google-cloud-sdk/bin/dev_appserver.py --storage_path=/Users/kaan/Desktop/DEPLOY/python3/storage/ --blobstore_path=/Users/kaan/Desktop/DEPLOY/python3/storage/blobstore/ --datastore_path=/Users/kaan/Desktop/DEPLOY/python3/storage/new_db.bin --host=0.0.0.0 --port=8083 /Users/kaan/Desktop/DEPLOY/python3/thegame/ --require_indexes --enable_host_checking=False"
|
||||
|
||||
Suggestions:
|
||||
1) Invoke /admin/make with your email put in admin.py
|
||||
2) From /admin/executor - call empty_fill_maps()
|
||||
3) After getting rid of the initial errors, figure out the rest
|
||||
|
||||
Useful for pulling logs: gcloud app logs tail -v 20240206t194907
|
||||
+2
-3
@@ -1,7 +1,5 @@
|
||||
runtime: python312
|
||||
runtime: python39
|
||||
app_engine_apis: true
|
||||
threadsafe: true
|
||||
api_version: 1
|
||||
builtins:
|
||||
- deferred: on
|
||||
|
||||
@@ -33,6 +31,7 @@ handlers:
|
||||
script: auto
|
||||
|
||||
env_variables:
|
||||
# NDB_PY2_UNPICKLE_COMPAT: True
|
||||
NDB_USE_CROSS_COMPATIBLE_PICKLE_PROTOCOL: True
|
||||
MEMCACHE_USE_CROSS_COMPATIBLE_PROTOCOL: True
|
||||
DEFERRED_USE_CROSS_COMPATIBLE_PICKLE_PROTOCOL: True
|
||||
@@ -14,7 +14,7 @@ def serve_test(name=""):
|
||||
domain=gdi(request)
|
||||
if name=="hash":
|
||||
start=datetime.now()
|
||||
logging.info(pbkdf2_hex("test","123456",iterations=160))
|
||||
#logging.info(pbkdf2_hex("test","123456",iterations=160))
|
||||
logging.info(mssince(start))
|
||||
elif name=="levels":
|
||||
xp=200
|
||||
@@ -30,6 +30,11 @@ def serve_test(name=""):
|
||||
return html
|
||||
elif name.startswith("pixi_"):
|
||||
return shtml("utility/htmls/tests/%s.html"%name,domain=domain)
|
||||
elif name=="versions":
|
||||
html="GAE_ENV: "+os.getenv('GAE_ENV', '')+" <br />"
|
||||
html+="is_sdk: "+str(is_sdk)+" <br />"
|
||||
# html+=str(request.headers)
|
||||
return html
|
||||
else:
|
||||
request.response=make_response('Setting the cookie')
|
||||
#test()
|
||||
|
||||
@@ -8,6 +8,9 @@ node ~/gscripts/run_servers.js
|
||||
|
||||
|
||||
|
||||
#Occasionally [28/01/24]
|
||||
gcloud app logs tail
|
||||
And check the log messages to see if there are frequent issues
|
||||
|
||||
#After Maps Change
|
||||
Executor: download_maps()
|
||||
|
||||
Reference in New Issue
Block a user