Skip to content

Commit

Permalink
updates and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
searscr committed Apr 25, 2024
1 parent 0d3a349 commit 515e524
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 33 deletions.
5 changes: 4 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"sphinx.ext.githubpages",
"sphinx.ext.intersphinx",
"sphinx.ext.napoleon",
"sphinxcontrib.mermaid",
]

autodoc_mock_imports = [
Expand Down Expand Up @@ -77,7 +78,9 @@
napoleon_google_docstring = False
napoleon_numpy_docstring = True

# html_static_path = ["_static"]
# html_static_path = ["source/_static"]

html_theme_options = {"page_width": "75%"}

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True
25 changes: 0 additions & 25 deletions docs/source/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,3 @@ ONCatLogin
.. module:: ONCatLogin
.. automodule:: pyoncatqt.login.ONCatLogin
:members:


.. .. automodule:: garnet.home.view
.. :members:
.. .. automodule:: garnet.home.model
.. :members:
.. Base Qt Objects
.. ---------------
.. .. automodule:: garnet.helpers.ui_elements.base_lineedit
.. :members:
.. .. automodule:: garnet.helpers.ui_elements.base_statusbar
.. :members:
.. .. automodule:: garnet.helpers.ui_elements.base_tablewidget
.. :members:
.. .. automodule:: garnet.helpers.ui_elements.base_checkbox
.. :members:
.. .. automodule:: garnet.helpers.ui_elements.base_listwidget
.. :members:
2 changes: 2 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ dependencies:
- pytest-cov
- pytest-qt
- setuptools
- sphinx
- sphinxcontrib-mermaid
- versioningit
23 changes: 16 additions & 7 deletions src/pyoncatqt/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def __init__(self: QDialog, agent: pyoncat.ONCat = None, parent: QWidget = None,

self.button_login = QPushButton("&Login")
self.button_cancel = QPushButton("Cancel")
self.button_login.setEnabled(False)

self.setMinimumSize(QSize(400, 100))
layout = QVBoxLayout()
Expand Down Expand Up @@ -107,15 +108,21 @@ def __init__(self: QDialog, agent: pyoncat.ONCat = None, parent: QWidget = None,
# connect signals and slots
self.button_login.clicked.connect(self.accept)
self.button_cancel.clicked.connect(self.reject)
self.user_pwd.returnPressed.connect(self.accept)
self.user_name.textChanged.connect(self.update_button_status)
self.user_pwd.textChanged.connect(self.update_button_status)

self.user_pwd.setFocus()

self.error = QErrorMessage(self)

def show_message(self: QDialog, msg: str) -> None:
"""Will show a error dialog with the given message"""
error = QErrorMessage(self)
error.showMessage(msg)
error.exec_()
self.error.showMessage(msg)
# self.error.exec_()

def update_button_status(self: QDialog) -> None:
"""Update the button status"""
self.button_login.setEnabled(bool(self.user_name.text() and self.user_pwd.text()))

def accept(self: QDialog) -> None:
"""Accept"""
Expand Down Expand Up @@ -211,8 +218,7 @@ def __init__(self: QGroupBox, key: str = None, parent: QWidget = None, **kwargs:
self.oncat_url = get_data("login.oncat", "oncat_url")
self.client_id = get_data("login.oncat", f"{key}_id")
if not self.client_id:
raise ValueError(f"Invalid key: {key}, ONCat client ID not found")
return
raise ValueError(f"Invalid module {key}. No OnCat client Id is found for this application.")

self.token_path = os.path.abspath(f"{os.path.expanduser('~')}/.pyoncatqt/{key}_token.json")

Expand Down Expand Up @@ -294,7 +300,10 @@ def read_token(self: QGroupBox) -> dict:
return None

with open(self.token_path, encoding="UTF-8") as storage:
return json.load(storage)
try:
return json.load(storage)
except json.JSONDecodeError:
return None

def write_token(self: QGroupBox, token: dict) -> None:
"""
Expand Down

0 comments on commit 515e524

Please sign in to comment.