From 864957742be37ec5d6ce1a2b2984eebe1fa9ab87 Mon Sep 17 00:00:00 2001 From: AwesomeLogic <36323763+Awesome-Logic@users.noreply.github.com> Date: Thu, 7 May 2020 18:57:26 +0530 Subject: [PATCH 1/2] Added os.chdir() in ballistica_server.py I realized the script couldn't be executed from other directories so I added the chdir function. Now the script can be properly executed from anywhere. If that was intended, feel free to reject the request. Also first pull request :) --- assets/src/server/ballisticacore_server.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/assets/src/server/ballisticacore_server.py b/assets/src/server/ballisticacore_server.py index 8ce43e83..b8a42dae 100755 --- a/assets/src/server/ballisticacore_server.py +++ b/assets/src/server/ballisticacore_server.py @@ -31,6 +31,10 @@ from threading import Thread, Lock, current_thread from pathlib import Path from typing import TYPE_CHECKING +# We change our working directory according to file's path +# so that the script can be properly executed from anywhere +os.chdir(os.path.abspath(os.path.dirname(__file__))) + # We make use of the bacommon and efro packages as well as site-packages # included with our bundled Ballistica dist. sys.path += [ From 7b50b1e3b5d70fe39f7f6c5aa0197669c53de4e4 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 7 May 2020 20:00:40 +0530 Subject: [PATCH 2/2] Fixed Formatting --- assets/src/server/ballisticacore_server.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/assets/src/server/ballisticacore_server.py b/assets/src/server/ballisticacore_server.py index b8a42dae..f3933baa 100755 --- a/assets/src/server/ballisticacore_server.py +++ b/assets/src/server/ballisticacore_server.py @@ -22,16 +22,21 @@ """BallisticaCore server manager.""" from __future__ import annotations -import sys -import os import json +import os import subprocess +import sys import time -from threading import Thread, Lock, current_thread from pathlib import Path +from threading import Lock, Thread, current_thread from typing import TYPE_CHECKING -# We change our working directory according to file's path +from bacommon.servermanager import ServerConfig, StartServerModeCommand +from efro.dataclasses import dataclass_assign, dataclass_validate +from efro.error import CleanError +from efro.terminal import Clr + +# We change our working directory according to file's path # so that the script can be properly executed from anywhere os.chdir(os.path.abspath(os.path.dirname(__file__))) @@ -42,10 +47,6 @@ sys.path += [ str(Path(os.getcwd(), 'dist', 'ba_data', 'python-site-packages')) ] -from efro.terminal import Clr -from efro.error import CleanError -from efro.dataclasses import dataclass_assign, dataclass_validate -from bacommon.servermanager import (ServerConfig, StartServerModeCommand) if TYPE_CHECKING: from typing import Optional, List, Dict, Union, Tuple