V0.5.2 commit
not done
This commit is contained in:
parent
d20567c80d
commit
fd769140e1
@ -30,21 +30,29 @@ if __name__ == '__main__':
|
|||||||
sys.path.append('Difficult_Rocket/libs')
|
sys.path.append('Difficult_Rocket/libs')
|
||||||
|
|
||||||
print(hi)
|
print(hi)
|
||||||
|
|
||||||
|
DEBUGGING = False
|
||||||
|
from Difficult_Rocket.api.Exp import *
|
||||||
try:
|
try:
|
||||||
from Difficult_Rocket import crash
|
from Difficult_Rocket import crash
|
||||||
from Difficult_Rocket import main
|
from Difficult_Rocket import main
|
||||||
|
|
||||||
game = main.Game()
|
game = main.Game()
|
||||||
game.start()
|
game.start()
|
||||||
except:
|
|
||||||
print('the game has error , now outputting error message')
|
if DEBUGGING:
|
||||||
|
raise TestError('debugging')
|
||||||
|
except TestError:
|
||||||
|
print('the game is debugging. this crash is raise by TestError')
|
||||||
error = traceback.format_exc()
|
error = traceback.format_exc()
|
||||||
print(error)
|
print(error)
|
||||||
from Difficult_Rocket.api import thread
|
crash.create_crash_report(error)
|
||||||
|
except:
|
||||||
crash_thread = thread.Threads(target=crash.create_crash_report, args=(error,), name='Crash report thread')
|
print('the game has unknown error , now outputting error message')
|
||||||
crash_thread.start()
|
error = traceback.format_exc()
|
||||||
crash_thread.join()
|
print(error)
|
||||||
|
crash.create_crash_report(error)
|
||||||
else:
|
else:
|
||||||
crash.record_thread = False
|
crash.record_thread = False
|
||||||
print(crash.all_thread)
|
print(crash.all_thread)
|
||||||
|
sys.exit(1)
|
||||||
|
@ -206,5 +206,4 @@ class ClientWindow(pyglet.window.Window):
|
|||||||
config_file['window']['width'] = str(self.width)
|
config_file['window']['width'] = str(self.width)
|
||||||
config_file['window']['height'] = str(self.height)
|
config_file['window']['height'] = str(self.height)
|
||||||
config_file.write(open('configs/main.config', 'w', encoding='utf-8'))
|
config_file.write(open('configs/main.config', 'w', encoding='utf-8'))
|
||||||
create_crash_report()
|
|
||||||
super(ClientWindow, self).on_close()
|
super(ClientWindow, self).on_close()
|
||||||
|
@ -13,11 +13,15 @@ gitee: @shenjackyuanjie
|
|||||||
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import threading
|
|
||||||
import time
|
import time
|
||||||
|
import platform
|
||||||
import traceback
|
import traceback
|
||||||
|
import threading
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
# import psutil
|
||||||
|
# for more system info
|
||||||
|
|
||||||
# where the crash report from
|
# where the crash report from
|
||||||
# this can't be crash , or the game will really crash!
|
# this can't be crash , or the game will really crash!
|
||||||
|
|
||||||
@ -30,9 +34,13 @@ Head_message = """# ----- Difficult Rocket Crash Report -----
|
|||||||
Thread_message = """## Thread info
|
Thread_message = """## Thread info
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
Python_message = """## Python info
|
||||||
|
"""
|
||||||
|
|
||||||
System_message = """## System info
|
System_message = """## System info
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
all_thread = [threading.main_thread()]
|
all_thread = [threading.main_thread()]
|
||||||
record_thread = True
|
record_thread = True
|
||||||
|
|
||||||
@ -40,32 +48,30 @@ record_thread = True
|
|||||||
def crash_info_handler(info: str = None) -> str:
|
def crash_info_handler(info: str = None) -> str:
|
||||||
if not info:
|
if not info:
|
||||||
info = traceback.format_exc()
|
info = traceback.format_exc()
|
||||||
format_info = '- {}'.format(info.replace('\n', '\n- '))
|
format_info = f"<pre>\n{info}</pre>\n"
|
||||||
if (format_info.rfind('- ') + 2) == len(format_info):
|
|
||||||
format_info = format_info[:-2]
|
|
||||||
return format_info
|
return format_info
|
||||||
|
|
||||||
|
|
||||||
def markdown_line_handler(string: Optional[str or bool or int or float], code: bool = False, level: int = 1) -> str:
|
def markdown_line_handler(string: Optional[str or bool or int or float], code: bool = False, level: int = 1, end: str = '\n') -> str:
|
||||||
lvl = '- ' * level
|
lvl = '- ' * level
|
||||||
f_string = string
|
f_string = string
|
||||||
if code:
|
if code:
|
||||||
f_string = '`{}`'.format(f_string)
|
f_string = '`{}`'.format(f_string)
|
||||||
return '{}{}\n'.format(lvl, f_string)
|
return '{}{}{}'.format(lvl, f_string, end)
|
||||||
|
|
||||||
|
|
||||||
def create_crash_report(info: str = None) -> None:
|
def create_crash_report(info: str = None) -> None:
|
||||||
if info:
|
crash_info = crash_info_handler(info)
|
||||||
crash_info = crash_info_handler(info)
|
|
||||||
else:
|
|
||||||
crash_info = crash_info_handler(traceback.format_exc())
|
|
||||||
if 'crash_report' not in os.listdir('./'):
|
if 'crash_report' not in os.listdir('./'):
|
||||||
os.mkdir('./crash_report')
|
os.mkdir('./crash_report')
|
||||||
date_time = time.strftime('%Y-%m-%d %H-%M-%S', time.gmtime(time.time()))
|
date_time = time.strftime('%Y-%m-%d %H-%M-%S', time.gmtime(time.time()))
|
||||||
filename = 'crash-{}.md'.format(date_time)
|
filename = 'crash-{}.md'.format(date_time)
|
||||||
with open('./crash_report/{}'.format(filename), 'w+') as crash_file:
|
with open('./crash_report/{}'.format(filename), 'w+') as crash_file:
|
||||||
crash_file.write(Head_message) # 开头信息
|
# 开头信息
|
||||||
|
crash_file.write(Head_message)
|
||||||
|
# 崩溃信息
|
||||||
crash_file.write(crash_info)
|
crash_file.write(crash_info)
|
||||||
|
# 运行线程信息
|
||||||
crash_file.write(Thread_message)
|
crash_file.write(Thread_message)
|
||||||
for thread in all_thread:
|
for thread in all_thread:
|
||||||
thread: threading.Thread
|
thread: threading.Thread
|
||||||
@ -74,7 +80,21 @@ def create_crash_report(info: str = None) -> None:
|
|||||||
crash_file.write(markdown_line_handler(f'Ident: {thread.ident}', level=2))
|
crash_file.write(markdown_line_handler(f'Ident: {thread.ident}', level=2))
|
||||||
crash_file.write(markdown_line_handler(f'Daemon: {thread.isDaemon()}', level=2))
|
crash_file.write(markdown_line_handler(f'Daemon: {thread.isDaemon()}', level=2))
|
||||||
crash_file.write(markdown_line_handler(f'Running: {thread.is_alive()}', level=2))
|
crash_file.write(markdown_line_handler(f'Running: {thread.is_alive()}', level=2))
|
||||||
|
# Python 信息
|
||||||
|
crash_file.write(Python_message)
|
||||||
|
crash_file.write(markdown_line_handler(f'Version: {platform.python_version()}', code=True, level=1))
|
||||||
|
# crash_file.write(markdown_line_handler(f'Version tuple: {platform.python_version_tuple()}', code=True, level=1))
|
||||||
|
# crash_file.write(markdown_line_handler(f'Build: {platform.python_build()}', code=True, level=1))
|
||||||
|
crash_file.write(markdown_line_handler(f'Implementation: {platform.python_implementation()}', code=True, level=1))
|
||||||
|
crash_file.write(markdown_line_handler(f'Compiler: {platform.python_compiler()}', code=True, level=1))
|
||||||
|
# 电脑系统信息
|
||||||
crash_file.write(System_message)
|
crash_file.write(System_message)
|
||||||
|
crash_file.write(markdown_line_handler(f'System: {platform.platform()}', code=True, level=1))
|
||||||
|
crash_file.write(markdown_line_handler(f'Computer name: {platform.node()}', code=True, level=1))
|
||||||
|
crash_file.write(markdown_line_handler(f'machine: {platform.machine()}', code=True, level=1))
|
||||||
|
crash_file.write(markdown_line_handler(f'processor: {platform.processor()}', code=True, level=1))
|
||||||
|
crash_file.write(markdown_line_handler(f'release: {platform.release()}', code=True, level=1))
|
||||||
|
crash_file.write(markdown_line_handler(f'version: {platform.version()}', code=True, level=1))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -16,7 +16,9 @@
|
|||||||
|
|
||||||
- now bin folder use the name `Difficult_Rocket`
|
- now bin folder use the name `Difficult_Rocket`
|
||||||
- now test files no longer have `_test_` prefix
|
- now test files no longer have `_test_` prefix
|
||||||
- now will always use local `pyglet`
|
- now will always use local `pyglet` # may change
|
||||||
|
- now fitting `pypy3.10`
|
||||||
|
- now `crash-report` have more information
|
||||||
|
|
||||||
### Add
|
### Add
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
-i https://pypi.tuna.tsinghua.edu.cn/simple
|
-i https://pypi.tuna.tsinghua.edu.cn/simple
|
||||||
semver
|
semver
|
||||||
|
psutil
|
||||||
pyglet
|
pyglet
|
||||||
pillow
|
pillow
|
||||||
json5
|
json5
|
||||||
|
Loading…
Reference in New Issue
Block a user