Skip to content

Commit

Permalink
205 freeze (#209)
Browse files Browse the repository at this point in the history
* Adding more logging information

* Fix while loop

* Update docs to new pypi package

* Ruff

* Ruff format

* add output to irods_tree_model

* more infowq

* bug info

* Fix double listing of the iRODS root

* fix README

* filter out root from subcollections efficiently

* Do not try to delete key "" if not present

* Remove print statements

---------

Co-authored-by: Staiger, Christine <christine.staiger@wur.nl>
  • Loading branch information
chStaiger and Staiger, Christine committed Jun 25, 2024
1 parent 9323f60 commit 49aea96
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 11 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,18 @@ The git repository contains a generic *iRODS* graphical user interface. The iRO
- Safe default options when working with your data.

## Installation
- As python package
- The python package

```bash
pip install ibridgesgui
```

- A specific branch of the git repository (testers, developers)

```bash
pip install git+https://github.com/chStaiger/iBridges-Gui.git@branch-name
```

- Locally from code (for developers)

```bash
Expand Down
3 changes: 1 addition & 2 deletions docs/getting-started.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
## Install iBridges-gui

```
pip install ibridges==0.1.6
pip install pip install git+https://github.com/chStaiger/iBridges-Gui.git@main
pip install ibridgesgui
```

## Start the program
Expand Down
3 changes: 3 additions & 0 deletions ibridgesgui/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,16 @@ def connect(self):
login_window = Login(self.session_dict, self.app_name)
login_window.exec()
# Trick to get the session object from the QDialog

if "session" in self.session_dict:
self.session = self.session_dict["session"]
try:
self.setup_tabs()
except:
self.session = None
raise
else:
self.logger.exception("No session created. %s", self.session_dict)

def exit(self):
"""Quit program."""
Expand Down
1 change: 1 addition & 0 deletions ibridgesgui/gui_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
UI_FILE_DIR = files(__package__) / "ui_files"
LOGO_DIR = files(__package__) / "icons"


# Widget utils
def populate_table(table_widget, rows: int, data_by_row: list):
"""Populate a table-like pyqt widget with data."""
Expand Down
5 changes: 4 additions & 1 deletion ibridgesgui/irods_tree_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,12 @@ def add_subtree(self, tree_item, tree_item_data: list):
_, level, _, _, _, abs_irods_path = tree_item_data
parent_coll = IrodsPath(self.session, abs_irods_path).collection

# the irods root also contains the irods root as subcollection
subcolls = [c for c in parent_coll.subcollections if c.path != "/"]
dataobjs = parent_coll.data_objects
# we assume that tree_item has no children yet.
new_nodes = {}
for item in parent_coll.subcollections + parent_coll.data_objects:
for item in subcolls + dataobjs:
row = self._tree_row_from_irods_item(item, parent_coll.id, int(level))
tree_item.appendRow(row)
new_nodes[item.id] = tree_item.child(tree_item.rowCount() - 1)
Expand Down
3 changes: 3 additions & 0 deletions ibridgesgui/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,15 @@ def login_function(self):
self.close()
except LoginError:
self.error_label.setText("irods_environment.json not setup correctly.")
self.logger.error("irods_environment.json not setup correctly.")
except PasswordError:
self.error_label.setText("Wrong password!")
self.logger.error("Wrong password provided.")
except ConnectionError:
self.error_label.setText(
"Cannot connect to server. Check Internet, host name and port."
)
self.logger.exception("Network error.")
except Exception as err:
log_path = Path("~/.ibridges")
self.logger.exception("Failed to login: %s", repr(err))
Expand Down
3 changes: 2 additions & 1 deletion ibridgesgui/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ def _validate_search_params(self) -> tuple[str, dict, str, str]:
key.text(): "%" if val.text() == "" else val.text()
for key, val in zip(self.keys, self.vals)
}
del key_vals[""]
if "" in key_vals:
del key_vals[""]

path = self.path_field.text() if self.path_field.text() != "" else None
checksum = self.checksum_field.text() if self.checksum_field.text() != "" else None
Expand Down
12 changes: 7 additions & 5 deletions ibridgesgui/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def _init_irods_tree(self):
def irods_root(self):
"""Retrieve lowest visible level in the iRODS tree for the user."""
lowest = IrodsPath(self.session).absolute()
while lowest.parent.exists():
while lowest.parent.exists() and str(lowest) != "/":
lowest = lowest.parent
return lowest

Expand Down Expand Up @@ -276,10 +276,12 @@ def _sync_diff_end(self, thread_output: dict):
return

self.error_label.clear()
table_data = [(ipath, lpath, ipath.size)
for ipath, lpath in thread_output["result"]["download"]] + \
[(lpath, ipath, lpath.stat().st_size)
for lpath, ipath in thread_output["result"]["upload"]]
table_data = [
(ipath, lpath, ipath.size) for ipath, lpath in thread_output["result"]["download"]
] + [
(lpath, ipath, lpath.stat().st_size)
for lpath, ipath in thread_output["result"]["upload"]
]
populate_table(self.diff_table, len(table_data), table_data)
if len(table_data) == 0:
self.error_label.setText("Data is already synchronised.")
Expand Down
3 changes: 2 additions & 1 deletion ibridgesgui/welcome.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Welcome tab."""

import sys

import PyQt6.QtCore
Expand Down Expand Up @@ -37,6 +38,6 @@ def __init__(self):
self.grid.addWidget(self.tag, 2, 1)
self.setLayout(self.grid)

self.setGeometry(150,150,300,300)
self.setGeometry(150, 150, 300, 300)

self.show()

0 comments on commit 49aea96

Please sign in to comment.