mirror of
https://github.com/RYDE-WORK/ballistica.git
synced 2026-02-07 08:03:30 +08:00
Ctrl-C and quitting in general now behave well everywhere
This commit is contained in:
parent
466f97e623
commit
763d5aa5c3
@ -4132,16 +4132,16 @@
|
|||||||
"assets/build/windows/x64/python.exe": "https://files.ballistica.net/cache/ba1/25/a7/dc87c1be41605eb6fefd0145144c",
|
"assets/build/windows/x64/python.exe": "https://files.ballistica.net/cache/ba1/25/a7/dc87c1be41605eb6fefd0145144c",
|
||||||
"assets/build/windows/x64/python37.dll": "https://files.ballistica.net/cache/ba1/b9/e4/d912f56e42e9991bcbb4c804cfcb",
|
"assets/build/windows/x64/python37.dll": "https://files.ballistica.net/cache/ba1/b9/e4/d912f56e42e9991bcbb4c804cfcb",
|
||||||
"assets/build/windows/x64/pythonw.exe": "https://files.ballistica.net/cache/ba1/6c/bb/b6f52c306aa4e88061510e96cefe",
|
"assets/build/windows/x64/pythonw.exe": "https://files.ballistica.net/cache/ba1/6c/bb/b6f52c306aa4e88061510e96cefe",
|
||||||
"build/prefab/linux-server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/6d/34/c17e186c1ab6a21f9c27250ec522",
|
"build/prefab/linux-server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/7a/c6/7bc8b2eeae7439ff56f01cc88090",
|
||||||
"build/prefab/linux-server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/24/01/cdf0206ccaaa4999d887631683d9",
|
"build/prefab/linux-server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/35/65/12d682473b0092cfc423146e4100",
|
||||||
"build/prefab/linux/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/20/ec/0cf2db1fccd23db8813353ead7b5",
|
"build/prefab/linux/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/94/33/a0dbcd5d1f77bde4bf1a8952d329",
|
||||||
"build/prefab/linux/release/ballisticacore": "https://files.ballistica.net/cache/ba1/71/f3/fe9bc55d33255ad3197795da820f",
|
"build/prefab/linux/release/ballisticacore": "https://files.ballistica.net/cache/ba1/aa/f3/253f73cf509c39a930ca041eb455",
|
||||||
"build/prefab/mac-server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/48/3c/8eb7975b35d68e2303d3fee4e949",
|
"build/prefab/mac-server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/fa/4d/83dd706c3ea327cbf89504130197",
|
||||||
"build/prefab/mac-server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/2b/05/11fc566e712691f90a7d3db207f2",
|
"build/prefab/mac-server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/33/f0/9687bdb5b1dac0dbb934261e987b",
|
||||||
"build/prefab/mac/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/aa/1a/642123b5642b33b91570c3dd0c1d",
|
"build/prefab/mac/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/f0/d4/ef1e004aefe9a2a45cfb98d53df1",
|
||||||
"build/prefab/mac/release/ballisticacore": "https://files.ballistica.net/cache/ba1/49/53/28acc8c627c2c22e8f7a20e38321",
|
"build/prefab/mac/release/ballisticacore": "https://files.ballistica.net/cache/ba1/f3/d3/189e54e5de63411b66dae4851add",
|
||||||
"build/prefab/windows-server/debug/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/1d/cd/35b9a612245a642f36f5ec1b0966",
|
"build/prefab/windows-server/debug/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/f1/41/8203dd42e85b8cfde0141715de3b",
|
||||||
"build/prefab/windows-server/release/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/1e/98/d1156cd3718aa52c59ed972170ca",
|
"build/prefab/windows-server/release/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/56/46/86ea1b38475a43dc95a65db0623a",
|
||||||
"build/prefab/windows/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/e1/73/cf488e42313eb5cef34d9f2eacd5",
|
"build/prefab/windows/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/8f/28/7d7560edfe6b862003a699cd72d9",
|
||||||
"build/prefab/windows/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/d2/65/7f2e288a5cfb7ffe566691175784"
|
"build/prefab/windows/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/d8/f0/03642738f87df03341a196132cc8"
|
||||||
}
|
}
|
||||||
2
.idea/dictionaries/ericf.xml
generated
2
.idea/dictionaries/ericf.xml
generated
@ -360,6 +360,7 @@
|
|||||||
<w>cpus</w>
|
<w>cpus</w>
|
||||||
<w>cpython</w>
|
<w>cpython</w>
|
||||||
<w>crashlytics</w>
|
<w>crashlytics</w>
|
||||||
|
<w>creationflags</w>
|
||||||
<w>creditslist</w>
|
<w>creditslist</w>
|
||||||
<w>cryptmodule</w>
|
<w>cryptmodule</w>
|
||||||
<w>cssclass</w>
|
<w>cssclass</w>
|
||||||
@ -1456,6 +1457,7 @@
|
|||||||
<w>rcfile</w>
|
<w>rcfile</w>
|
||||||
<w>rdict</w>
|
<w>rdict</w>
|
||||||
<w>rdir</w>
|
<w>rdir</w>
|
||||||
|
<w>readline</w>
|
||||||
<w>readlines</w>
|
<w>readlines</w>
|
||||||
<w>realpath</w>
|
<w>realpath</w>
|
||||||
<w>realsies</w>
|
<w>realsies</w>
|
||||||
|
|||||||
1
.idea/inspectionProfiles/Default.xml
generated
1
.idea/inspectionProfiles/Default.xml
generated
@ -33,6 +33,7 @@
|
|||||||
<option value="E125" />
|
<option value="E125" />
|
||||||
<option value="E128" />
|
<option value="E128" />
|
||||||
<option value="E741" />
|
<option value="E741" />
|
||||||
|
<option value="E402" />
|
||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
</inspection_tool>
|
</inspection_tool>
|
||||||
|
|||||||
@ -34,7 +34,7 @@ NOTE: This file was autogenerated by gendummymodule; do not edit by hand.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# (hash we can use to see if this file is out of date)
|
# (hash we can use to see if this file is out of date)
|
||||||
# SOURCES_HASH=177701719410791819540343481052188120508
|
# SOURCES_HASH=10577028919433802623543258674047257154
|
||||||
|
|
||||||
# I'm sorry Pylint. I know this file saddens you. Be strong.
|
# I'm sorry Pylint. I know this file saddens you. Be strong.
|
||||||
# pylint: disable=useless-suppression
|
# pylint: disable=useless-suppression
|
||||||
@ -3491,6 +3491,14 @@ def set_ui_input_device(input_device: Optional[ba.InputDevice]) -> None:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def setup_sigint() -> None:
|
||||||
|
"""setup_sigint() -> None
|
||||||
|
|
||||||
|
(internal)
|
||||||
|
"""
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def show_ad(purpose: str,
|
def show_ad(purpose: str,
|
||||||
on_completion_call: Callable[[], None] = None) -> None:
|
on_completion_call: Callable[[], None] = None) -> None:
|
||||||
"""show_ad(purpose: str, on_completion_call: Callable[[], None] = None)
|
"""show_ad(purpose: str, on_completion_call: Callable[[], None] = None)
|
||||||
|
|||||||
@ -42,7 +42,7 @@ from bacommon.serverutils import (ServerConfig, ServerCommand,
|
|||||||
make_server_command)
|
make_server_command)
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Optional, List
|
from typing import Optional, List, Dict
|
||||||
from types import FrameType
|
from types import FrameType
|
||||||
|
|
||||||
|
|
||||||
@ -86,6 +86,17 @@ class ServerManagerApp:
|
|||||||
return path
|
return path
|
||||||
raise RuntimeError('Unable to locate ballisticacore_headless binary.')
|
raise RuntimeError('Unable to locate ballisticacore_headless binary.')
|
||||||
|
|
||||||
|
def _enable_tab_completion(self, locs: Dict) -> None:
|
||||||
|
"""Enable tab-completion on platforms where available (linux/mac)."""
|
||||||
|
try:
|
||||||
|
import readline
|
||||||
|
import rlcompleter
|
||||||
|
readline.set_completer(rlcompleter.Completer(locs).complete)
|
||||||
|
readline.parse_and_bind('tab:complete')
|
||||||
|
except ImportError:
|
||||||
|
# readline doesn't exist under windows; this is expected.
|
||||||
|
pass
|
||||||
|
|
||||||
def run_interactive(self) -> None:
|
def run_interactive(self) -> None:
|
||||||
"""Run the app loop to completion."""
|
"""Run the app loop to completion."""
|
||||||
import code
|
import code
|
||||||
@ -116,6 +127,9 @@ class ServerManagerApp:
|
|||||||
# https://docs.python.org/3/library/code.html
|
# https://docs.python.org/3/library/code.html
|
||||||
locs = {'__name__': '__console__', '__doc__': None, 'mgr': self}
|
locs = {'__name__': '__console__', '__doc__': None, 'mgr': self}
|
||||||
|
|
||||||
|
# Enable tab-completion if possible.
|
||||||
|
self._enable_tab_completion(locs)
|
||||||
|
|
||||||
# Now just sit in an interpreter.
|
# Now just sit in an interpreter.
|
||||||
try:
|
try:
|
||||||
code.interact(local=locs, banner='', exitmsg='')
|
code.interact(local=locs, banner='', exitmsg='')
|
||||||
@ -176,26 +190,27 @@ class ServerManagerApp:
|
|||||||
# we'll use this to feed it commands.
|
# we'll use this to feed it commands.
|
||||||
self._process_launch_time = time.time()
|
self._process_launch_time = time.time()
|
||||||
|
|
||||||
|
# Set an environment var so the server process knows its being
|
||||||
|
# run under us. This causes it to ignore ctrl-c presses and other
|
||||||
|
# slight behavior tweaks.
|
||||||
|
os.environ['BA_SERVER_WRAPPER_MANAGED'] = '1'
|
||||||
|
|
||||||
# We don't want our subprocess to respond to Ctrl-C; we want to handle
|
# We don't want our subprocess to respond to Ctrl-C; we want to handle
|
||||||
# that ourself. So we need to do a bit of magic to accomplish that.
|
# that ourself. So we need to do a bit of magic to accomplish that.
|
||||||
|
# FIXME: should just have the server itself handle that
|
||||||
args = [self._binary_path, '-cfgdir', 'ba_root']
|
args = [self._binary_path, '-cfgdir', 'ba_root']
|
||||||
if sys.platform.startswith('win'):
|
if sys.platform.startswith('win'):
|
||||||
# https://msdn.microsoft.com/en-us/library/windows/
|
# https://msdn.microsoft.com/en-us/library/windows/
|
||||||
# desktop/ms684863(v=vs.85).aspx
|
# desktop/ms684863(v=vs.85).aspx
|
||||||
# CREATE_NEW_PROCESS_GROUP=0x00000200 -> If this flag is
|
# CREATE_NEW_PROCESS_GROUP=0x00000200 -> If this flag is
|
||||||
# specified, CTRL+C signals will be disabled
|
# specified, CTRL+C signals will be disabled
|
||||||
self._process = subprocess.Popen(args,
|
self._process = subprocess.Popen(
|
||||||
stdin=subprocess.PIPE,
|
|
||||||
creationflags=0x00000200)
|
|
||||||
else:
|
|
||||||
# Note: Python docs tell us preexec_fn is unsafe with threads.
|
|
||||||
# https://docs.python.org/3/library/subprocess.html
|
|
||||||
# Perhaps we should just give the ballistica binary itself an
|
|
||||||
# option to ignore interrupt signals.
|
|
||||||
self._process = subprocess.Popen( # pylint: disable=W1509
|
|
||||||
args,
|
args,
|
||||||
stdin=subprocess.PIPE,
|
stdin=subprocess.PIPE,
|
||||||
preexec_fn=self._subprocess_pre_exec)
|
# creationflags=0x00000200
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
self._process = subprocess.Popen(args, stdin=subprocess.PIPE)
|
||||||
|
|
||||||
# Set quit to True any time after launching the server
|
# Set quit to True any time after launching the server
|
||||||
# to gracefully quit it at the next clean opportunity
|
# to gracefully quit it at the next clean opportunity
|
||||||
@ -210,10 +225,10 @@ class ServerManagerApp:
|
|||||||
finally:
|
finally:
|
||||||
self._kill_process()
|
self._kill_process()
|
||||||
|
|
||||||
def _subprocess_pre_exec(self) -> None:
|
# def _subprocess_pre_exec(self) -> None:
|
||||||
"""To ignore CTRL+C signal in the new process."""
|
# """To ignore CTRL+C signal in the new process."""
|
||||||
import signal
|
# import signal
|
||||||
signal.signal(signal.SIGINT, signal.SIG_IGN)
|
# signal.signal(signal.SIGINT, signal.SIG_IGN)
|
||||||
|
|
||||||
def _prep_process_environment(self) -> None:
|
def _prep_process_environment(self) -> None:
|
||||||
"""Write files that must exist at process launch."""
|
"""Write files that must exist at process launch."""
|
||||||
@ -280,7 +295,7 @@ class ServerManagerApp:
|
|||||||
if self._process is None:
|
if self._process is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
print('Stopping server subprocess...')
|
print('Stopping server process...')
|
||||||
|
|
||||||
# First, ask it nicely to die and give it a moment.
|
# First, ask it nicely to die and give it a moment.
|
||||||
# If that doesn't work, bring down the hammer.
|
# If that doesn't work, bring down the hammer.
|
||||||
@ -290,7 +305,7 @@ class ServerManagerApp:
|
|||||||
except subprocess.TimeoutExpired:
|
except subprocess.TimeoutExpired:
|
||||||
self._process.kill()
|
self._process.kill()
|
||||||
self._process = self._process_launch_time = None
|
self._process = self._process_launch_time = None
|
||||||
print('Server subprocess stopped.')
|
print('Server process stopped.')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<!-- THIS FILE IS AUTO GENERATED; DO NOT EDIT BY HAND -->
|
<!-- THIS FILE IS AUTO GENERATED; DO NOT EDIT BY HAND -->
|
||||||
<h4><em>last updated on 2020-04-27 for Ballistica version 1.5.0 build 20001</em></h4>
|
<h4><em>last updated on 2020-04-29 for Ballistica version 1.5.0 build 20001</em></h4>
|
||||||
<p>This page documents the Python classes and functions in the 'ba' module,
|
<p>This page documents the Python classes and functions in the 'ba' module,
|
||||||
which are the ones most relevant to modding in Ballistica. If you come across something you feel should be included here or could be better explained, please <a href="mailto:support@froemling.net">let me know</a>. Happy modding!</p>
|
which are the ones most relevant to modding in Ballistica. If you come across something you feel should be included here or could be better explained, please <a href="mailto:support@froemling.net">let me know</a>. Happy modding!</p>
|
||||||
<hr>
|
<hr>
|
||||||
|
|||||||
@ -115,9 +115,6 @@ def resize_image() -> None:
|
|||||||
if not src.endswith('.png'):
|
if not src.endswith('.png'):
|
||||||
raise Exception('src must be a png')
|
raise Exception('src must be a png')
|
||||||
print('Creating: ' + os.path.basename(dst), file=sys.stderr)
|
print('Creating: ' + os.path.basename(dst), file=sys.stderr)
|
||||||
|
|
||||||
# Switching to imagemagick from sips - hopefully this goes well
|
|
||||||
# so we'll be nice and cross-platform...
|
|
||||||
efrotools.run('convert "' + src + '" -resize ' + str(width) + 'x' +
|
efrotools.run('convert "' + src + '" -resize ' + str(width) + 'x' +
|
||||||
str(height) + ' "' + dst + '"')
|
str(height) + ' "' + dst + '"')
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user