Skip to content

Commit

Permalink
Use utils.get_script_dir() instead of os.get_cwd()
Browse files Browse the repository at this point in the history
  • Loading branch information
malleoz committed Sep 27, 2023
1 parent 1fc5ca3 commit 9a2f725
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions scripts/Modules/TTK_Lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def writeToCSV(inputs: FrameSequence, playerType: PlayerType) -> None:
# Get csv file path
playerStr = "Player" if playerType == PlayerType.PLAYER else "Ghost"
relativePath = config.textFilePath(playerStr)
absolutePath = os.path.join(os.getcwd(), "User/Load/Scripts/", relativePath)
absolutePath = os.path.join(utils.get_script_dir(), relativePath)

# Write to csv, error if cannot write
if inputs.writeToFile(absolutePath):
Expand All @@ -273,7 +273,7 @@ def writeToCSV(inputs: FrameSequence, playerType: PlayerType) -> None:
def writeToBackupCSV(inputs: FrameSequence, backupNumber: int) -> None:
relativePath = config.textFilePath("Backup")
relativePath = relativePath.replace("##", "{:02d}".format(backupNumber))
inputs.writeToFile(os.path.join(os.getcwd(), "User/Load/Scripts/", relativePath))
inputs.writeToFile(os.path.join(utils.get_script_dir(), relativePath))

def getMetadataAndWriteToRKG(inputs: FrameSequence, playerType: PlayerType) -> None:
# Get metadata
Expand All @@ -295,7 +295,7 @@ def writeToRKG(fileBytes: bytearray, playerType: PlayerType) -> None:
# Get csv file path
playerStr = "Player" if playerType == PlayerType.PLAYER else "Ghost"
relativePath = config.rkgFilePath[playerStr]
absolutePath = os.path.join(os.getcwd(), "User/Load/Scripts/", relativePath)
absolutePath = os.path.join(utils.get_script_dir(), relativePath)

try:
with open(absolutePath, "wb") as f:
Expand All @@ -310,7 +310,7 @@ def getInputSequenceFromCSV(playerType: PlayerType) -> FrameSequence:
# Get csv file path
playerStr = "Player" if playerType == PlayerType.PLAYER else "Ghost"
relativePath = config.textFilePath(playerStr)
absolutePath = os.path.join(os.getcwd(), "User/Load/Scripts/", relativePath)
absolutePath = os.path.join(utils.get_script_dir(), relativePath)

# Get the frame sequence
return FrameSequence(absolutePath)
Expand Down

0 comments on commit 9a2f725

Please sign in to comment.