Skip to content

Commit

Permalink
Check file existance early, before running
Browse files Browse the repository at this point in the history
  • Loading branch information
emanuelegissi committed Aug 21, 2023
1 parent 19db9db commit 5eaa382
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions qgis2fds_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ def get(cls, algo, parameters, context, feedback, project):
if not project_path:
raise QgsProcessingException("Save QGIS project to disk, cannot proceed.")
value = os.path.join(project_path, value)
# Check existance
if not os.path.isdir(value):
raise QgsProcessingException(f"Folder <{value}> not found, cannot proceed.")
feedback.setProgressText(f"{cls.desc}: <{value}>")
return value

Expand Down Expand Up @@ -283,6 +286,9 @@ def get(cls, algo, parameters, context, feedback, project):
"Save QGIS project to disk, cannot proceed."
)
value = os.path.join(project_path, value)
# Check existance
if not os.path.isfile(value):
raise QgsProcessingException(f"File <{value}> not found.")
feedback.setProgressText(f"{cls.desc}: <{value}>")
return value

Expand Down Expand Up @@ -353,6 +359,9 @@ def get(cls, algo, parameters, context, feedback, project):
"Save QGIS project to disk, cannot proceed."
)
value = os.path.join(project_path, value)
# Check existance
if not os.path.isfile(value):
raise QgsProcessingException(f"File <{value}> not found.")
feedback.setProgressText(f"{cls.desc}: <{value}>")
return value

Expand Down Expand Up @@ -595,5 +604,8 @@ def get(cls, algo, parameters, context, feedback, project):
"Save QGIS project to disk, cannot proceed."
)
value = os.path.join(project_path, value)
# Check existance
if not os.path.isfile(value):
raise QgsProcessingException(f"File <{value}> not found.")
feedback.setProgressText(f"{cls.desc}: <{value}>")
return value

0 comments on commit 5eaa382

Please sign in to comment.