Skip to content
This repository has been archived by the owner on Oct 10, 2024. It is now read-only.

Commit

Permalink
check if user script file exists before running
Browse files Browse the repository at this point in the history
  • Loading branch information
Nico-Duduf committed Mar 13, 2023
1 parent 7f65c0d commit 579a016
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions ramses/ramses.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#
#======================= END GPL LICENSE BLOCK ========================

import os
from subprocess import Popen, PIPE

from .file_manager import RamFileManager
Expand Down Expand Up @@ -290,6 +291,9 @@ def publish(self, item, step, filePath, publishOptions=None, showPublishOptions=
script(item, step, filePath, publishOptions, showPublishOptions)
# Load user scripts
for s in SETTINGS.userScripts:
if not os.path.isfile(s):
log("Sorry, I can't find and run this user script: " + s, LogLevel.Critical)
continue
m = load_module_from_path(s)
if "on_publish" in dir(m):
m.on_publish(item, step, filePath, publishOptions, showPublishOptions)
Expand All @@ -300,6 +304,9 @@ def updateStatus(self, item, status, step=None):
script( item, status, step)
# Load user scripts
for s in SETTINGS.userScripts:
if not os.path.isfile(s):
log("Sorry, I can't find and run this user script: " + s, LogLevel.Critical)
continue
m = load_module_from_path(s)
if "on_update_status" in dir(m):
m.on_update_status(item, status, step)
Expand All @@ -322,6 +329,9 @@ def openFile( self, filePath, item=None, step=None ):
script( item, filePath, step )

for s in SETTINGS.userScripts:
if not os.path.isfile(s):
log("Sorry, I can't find and run this user script: " + s, LogLevel.Critical)
continue
m = load_module_from_path(s)
if "on_open" in dir(m):
m.on_open( item, filePath, step )
Expand All @@ -332,6 +342,9 @@ def importItem(self, item, file_paths, step=None, importOptions=None, showImport
script( item, file_paths, step, importOptions, showImportOptions )

for s in SETTINGS.userScripts:
if not os.path.isfile(s):
log("Sorry, I can't find and run this user script: " + s, LogLevel.Critical)
continue
m = load_module_from_path(s)
if "on_import_item" in dir(m):
m.on_import_item( item, file_paths, step, importOptions, showImportOptions )
Expand All @@ -342,6 +355,9 @@ def replaceItem(self, item, filePath, step=None, importOptions=None, showImportO
script( item, filePath, step, importOptions, showImportOptions )

for s in SETTINGS.userScripts:
if not os.path.isfile(s):
log("Sorry, I can't find and run this user script: " + s, LogLevel.Critical)
continue
m = load_module_from_path(s)
if "on_replace_item" in dir(m):
m.on_replace_item( item, filePath, step, importOptions, showImportOptions )

0 comments on commit 579a016

Please sign in to comment.