From 579a0161fc766af1c1caca4d827e1c7a6b97de73 Mon Sep 17 00:00:00 2001 From: Duduf Date: Mon, 13 Mar 2023 13:30:59 +0100 Subject: [PATCH] check if user script file exists before running --- ramses/ramses.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ramses/ramses.py b/ramses/ramses.py index c69eb24..368ca34 100644 --- a/ramses/ramses.py +++ b/ramses/ramses.py @@ -17,6 +17,7 @@ # #======================= END GPL LICENSE BLOCK ======================== +import os from subprocess import Popen, PIPE from .file_manager import RamFileManager @@ -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) @@ -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) @@ -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 ) @@ -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 ) @@ -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 )