Skip to content

Commit

Permalink
fixed file exists test for custom files
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaae committed Oct 5, 2019
1 parent 372ffc5 commit 54d92ac
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions lib/overlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,19 @@ def Send(self, event, jsonData, init = 0):
return 1

if 'mascot' in jsonData:
if os.path.exists(jsonData["mascot"]):
if os.path.isfile(jsonData["mascot"]):
jsonData["mascot"] = "file:///" + jsonData["mascot"]
else:
jsonData["mascot"] = ""

if 'audio' in jsonData:
if os.path.exists(jsonData["audio"]):
if os.path.isfile(jsonData["audio"]):
jsonData["audio"] = "file:///" + jsonData["audio"]
else:
jsonData["audio"] = ""

if 'image' in jsonData:
if os.path.exists(jsonData["image"]):
if os.path.isfile(jsonData["image"]):
jsonData["image"] = "file:///" + jsonData["image"]
else:
if jsonData["image"].find('https://') != 0:
Expand All @@ -94,11 +94,11 @@ async def Connection(self, websocket, path):
self.active = self.active + 1
if not self.sendQueue:
mascotIdleImage = self.settings.mascotImages['Idle']['Image']
if not os.path.exists(mascotIdleImage):
if not os.path.isfile(mascotIdleImage):
mascotIdleImage = ""
if 'Idle' in self.settings.PoseMapping and self.settings.PoseMapping['Idle']['Image'] in self.settings.mascotImages:
tmp = self.settings.mascotImages[self.settings.PoseMapping['Idle']['Image']]['Image']
if os.path.exists(tmp):
if os.path.isfile(tmp):
mascotIdleImage = tmp
jsonData = {
"mascot": mascotIdleImage
Expand Down
4 changes: 2 additions & 2 deletions lib/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ def __init__(self, pathRoot=None):
if not os.path.isdir(self.pathRoot):
print("Working directory not detected.")
exit(1)
if not os.path.exists(self.pathRoot + "wooferbot.py"):
if not os.path.isfile(self.pathRoot + "wooferbot.py"):
print("Working directory incorrect.")
exit(1)
if not os.path.exists(self.pathRoot + "settings.json"):
if not os.path.isfile(self.pathRoot + "settings.json"):
print("Configuration file \"settings.json\" is missing.")
exit(1)

Expand Down
8 changes: 4 additions & 4 deletions lib/woofer.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,12 @@ def woofer_queue(self, queue_id, jsonData):
# default_woofer
def default_woofer(queue_id):
mascotIdleImage = self.settings.mascotImages['Idle']['Image']
if not os.path.exists(mascotIdleImage):
if not os.path.isfile(mascotIdleImage):
mascotIdleImage = ""

if 'Idle' in self.settings.PoseMapping and self.settings.PoseMapping['Idle']['Image'] in self.settings.mascotImages:
tmp = self.settings.mascotImages[self.settings.PoseMapping['Idle']['Image']]['Image']
if os.path.exists(tmp):
if os.path.isfile(tmp):
mascotIdleImage = tmp

jsonData = {
Expand Down Expand Up @@ -542,7 +542,7 @@ def twitchGetLastActivity(self, userId):
def mascotImagesFile(self, action):
if action in self.settings.PoseMapping and self.settings.PoseMapping[action]['Image'] in self.settings.mascotImages:
tmp = self.settings.mascotImages[self.settings.PoseMapping[action]['Image']]['Image']
if os.path.exists(tmp):
if os.path.isfile(tmp):
return tmp

return self.settings.mascotImages[self.settings.PoseMapping['DEFAULT']['Image']]['Image']
Expand Down Expand Up @@ -575,7 +575,7 @@ def mascotImagesTime(self, action):
def mascotAudioFile(self, action):
if action in self.settings.PoseMapping and self.settings.PoseMapping[action]['Audio'] in self.settings.mascotAudio:
tmp = random.SystemRandom().choice(self.settings.mascotAudio[self.settings.PoseMapping[action]['Audio']]['Audio'])
if os.path.exists(tmp):
if os.path.isfile(tmp):
return tmp

if self.settings.PoseMapping['DEFAULT']['Audio'] in self.settings.mascotAudio:
Expand Down

0 comments on commit 54d92ac

Please sign in to comment.