diff --git a/ibridgesgui/login.py b/ibridgesgui/login.py index dd892fca..07b110cf 100644 --- a/ibridgesgui/login.py +++ b/ibridgesgui/login.py @@ -5,7 +5,9 @@ from pathlib import Path from ibridges import IrodsPath, Session +from ibridges.resources import Resources from ibridges.session import LoginError, PasswordError +from irods.exception import ResourceDoesNotExist from PyQt6.QtWidgets import QDialog, QLineEdit from PyQt6.uic import loadUi @@ -84,6 +86,7 @@ def login_function(self): session.home, ) session.write_pam_password() + self.session_dict["session"] = session set_last_ienv_path(env_file.name) except LoginError: self.error_label.setText("irods_environment.json not setup correctly.") @@ -102,9 +105,29 @@ def login_function(self): self.error_label.setText(f"Login failed, consult the log file(s) in {log_path}") #check irods_home - if not IrodsPath(session).collection_exists(): + fail_home = True + if not IrodsPath(self.session_dict["session"]).collection_exists(): self.error_label.setText(f'"irods_home": "{session.home}" does not exist.') self.logger.error("irods_home does not exist.") else: - self.session_dict["session"] = session + fail_home = False + + #check existance of default resource + fail_resc = True + try: + resc = Resources(self.session_dict["session"]).get_resource(session.default_resc) + if resc.parent is None: + fail_resc = False + else: + self.error_label.setText(f'"default_resource": "{session.default_resc}" not valid.') + except ResourceDoesNotExist: + self.error_label.setText( + f'"default_resource": "{session.default_resc}" does not exist.') + self.logger.error("Default resource does not exist.") + except AttributeError: + self.error_label.setText(f'"default_resource": "{session.default_resc}" not valid.') + + if fail_resc or fail_home: + del self.session_dict["session"] + else: self.close()