Skip to content

Commit

Permalink
config.py gets run first + typo fix
Browse files Browse the repository at this point in the history
  • Loading branch information
trainb0y committed May 18, 2022
1 parent 1713ba0 commit 96ebeae
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
16 changes: 2 additions & 14 deletions PyMultibound/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,6 @@

from paths import *

logging.basicConfig(
format="%(asctime)s: %(levelname)s - %(module)s - %(funcName)s: %(message)s",
level=logging.DEBUG,
filename=join(os.path.dirname(os.path.realpath(__file__)), "PyMultibound.log"),
filemode="w"
)

VERSION = "v1.0.1"

logging.info(f"PyMultibound Version: {VERSION}, Platform: {platform.system()}")


def safe_move(src, dst):
"""
Attempt to move a directory or file using shutil.move()
Expand All @@ -24,15 +12,15 @@ def safe_move(src, dst):
shutil.move(src, dst)
return True
except Exception as e:
logging.error(f"An error occured while trying to move {src} to {dst}: {e}")
logging.error(f"An error occurred while trying to move {src} to {dst}: {e}")
return False


def runStarbound(profile: str):
"""
Run Starbound with the given profile
"""
logging.info("Starting starbound...")
logging.info("Starting Starbound...")
cmd = f'"{paths["starboundExecutable"]}" ' \
f'-bootconfig "{join(paths["profiles"], profile, "sbinit.config")}"'
logging.info(f"Launch command: {cmd}")
Expand Down
13 changes: 13 additions & 0 deletions PyMultibound/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import logging, os, platform

# This is imported into paths.py, and is therefore the first thing ran on startup

logging.basicConfig(
format="%(asctime)s: %(levelname)s - %(module)s - %(funcName)s: %(message)s",
level=logging.DEBUG,
filename=os.path.join(os.path.dirname(os.path.realpath(__file__)), "PyMultibound.log"),
filemode="w"
)

VERSION = "v1.0.1"
logging.info(f"PyMultibound Version: {VERSION}, Platform: {platform.system()}")
5 changes: 4 additions & 1 deletion PyMultibound/paths.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import logging, os, platform, sys, json
from os.path import join
from config import *# Just sets up logging


# About the two sbinits:
# When I switched to Linux I noticed the sbinit.config looked different.
Expand Down Expand Up @@ -96,11 +98,12 @@ def savePaths(paths: {}):
with open(settings, "r") as f:
paths = json.load(f)
logging.info("Loaded settings from file")
logging.info(f"Paths: {paths}")

if not os.path.exists(paths["profiles"]):
os.mkdir(paths["profiles"])
logging.info("Created profiles directory")
if not os.path.exists(paths["templates"]):
os.mkdir(paths["templates"])
logging.info("Created templates directory")

logging.info(f"Paths: {paths}")

0 comments on commit 96ebeae

Please sign in to comment.