Skip to content

Commit

Permalink
Merge pull request #247 from chStaiger/develop
Browse files Browse the repository at this point in the history
v1.0.4
  • Loading branch information
chStaiger authored Aug 13, 2024
2 parents 438d893 + 437b475 commit 87e654c
Show file tree
Hide file tree
Showing 29 changed files with 1,950 additions and 770 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pypi_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@7eb3b701d11256e583f5b49899c5e7203deab573
uses: pypa/gh-action-pypi-publish@v1.9.0
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
Binary file modified docs/screenshots/browser.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/screenshots/delete.png
Binary file not shown.
6 changes: 4 additions & 2 deletions docs/userdoc.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ You can **navigate to another part of the iRODS collection tree** by editing thi

- The `Create Collection` button will create a collection in the path shown in the navigation field above.

- The buttons `Upload File` and `Upload Folder` open a file dialog to select data to upload. The destination will be the path shown in the navigation field.
- The `Upload` button opens a new popup window to select data to upload. The destination will be the path shown in the navigation field.

- The `Download` button will download data to your `Downloads` folder. To download data you will need to select an item in the table below.
- The `Download` button opens a popup window to select the destination on your computer. You will also be able to export the metadata and store it in a separate file along your download. To download data you will need to select an item in the table below.

- With the `Delete` button you can delete the selected collection or data object in the table. **Note, The data will be deleted completely from the iRODS instance.**

### Listing

Expand Down
1 change: 1 addition & 0 deletions ibridgesgui/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def setup_tabs(self):
for tab_fun in self.ui_tabs_lookup.values():
tab_fun()
# self.ui_tabs_lookup[tab_name]()
self.tab_widget.setCurrentIndex(1)

def welcome_tab(self):
"""Create first tab."""
Expand Down
550 changes: 227 additions & 323 deletions ibridgesgui/browser.py

Large diffs are not rendered by default.

19 changes: 18 additions & 1 deletion ibridgesgui/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

CONFIG_DIR = Path("~", ".ibridges").expanduser()
CONFIG_FILE = CONFIG_DIR.joinpath("ibridges_gui.json")

IRODSA = Path.home() / ".irods" / ".irodsA"

def ensure_log_config_location():
"""Ensure the location for logs and config files."""
Expand Down Expand Up @@ -131,6 +131,23 @@ def _get_config() -> Union[None, dict]:
print(f"CANNOT START APP: {CONFIG_FILE} incorrectly formatted.")
sys.exit(1)

def save_current_settings(env_path_name: Path):
"""Store the environment with the currently scrambled password in irodsA."""
with open(IRODSA, "r", encoding="utf-8") as f:
pw = f.read()
config = _get_config()
if config is not None:
if "settings" not in config:
config["settings"] = {}
config["settings"][str(env_path_name)] = pw
_save_config(config)

def get_prev_settings():
"""Extract the settings from the configuration."""
config = _get_config()
if config is None:
return {}
return config.get("settings", {})

# irods config functions

Expand Down
30 changes: 11 additions & 19 deletions ibridgesgui/gui_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

import irods
import PyQt6
from ibridges import IrodsPath, download
from ibridges import IrodsPath
from ibridges.executor import Operations

from ibridgesgui.config import get_last_ienv_path, is_session_from_config

Expand Down Expand Up @@ -82,25 +83,16 @@ def prep_session_for_copy(session, error_label) -> pathlib.Path:
return None


def combine_diffs(session, sources: list, destination: Union[IrodsPath, pathlib.Path]) -> dict:
"""Combine the diffs of several upload or download dry-runs."""
combined_diffs = {
"create_dir": set(),
"create_collection": set(),
"upload": [],
"download": [],
"resc_name": "",
"options": None,
}
if isinstance(destination, pathlib.Path):
for ipath in sources:
diff = download(session, ipath, destination, dry_run=True, overwrite=True)
combined_diffs["download"].extend(diff["download"])
combined_diffs["create_dir"] = combined_diffs["create_dir"].union(diff["create_dir"])
elif isinstance(destination, IrodsPath):
print("not implemented yet")
return combined_diffs
def combine_operations(operations: list[Operations]) -> Operations:
"""Combine the operations of several upload or download dry-runs."""
ops = operations[0]
ops.create_dir = set().union(*[o.create_dir for o in operations])
ops.create_collection = set().union(*[o.create_collection for o in operations])
for op in operations[1:]:
ops.download.extend(op.download)
ops.upload.extend(op.upload)

return ops

# OS utils
def get_downloads_dir() -> pathlib.Path:
Expand Down
21 changes: 17 additions & 4 deletions ibridgesgui/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@
from PyQt6.QtWidgets import QDialog, QLineEdit
from PyQt6.uic import loadUi

from ibridgesgui.config import get_last_ienv_path, set_last_ienv_path
from ibridgesgui.config import (
IRODSA,
get_last_ienv_path,
get_prev_settings,
save_current_settings,
set_last_ienv_path,
)
from ibridgesgui.gui_utils import UI_FILE_DIR
from ibridgesgui.ui_files.irodsLogin import Ui_irodsLogin

Expand All @@ -32,6 +38,7 @@ def __init__(self, session_dict, app_name):

self.session_dict = session_dict
self._init_envbox()
self.prev_settings = get_prev_settings()
self.cached_pw = self._init_password()
self._load_gui()
self.setWindowTitle("Connect to iRODS server")
Expand All @@ -40,6 +47,7 @@ def _load_gui(self):
self.connect_button.clicked.connect(self.login_function)
self.cancel_button.clicked.connect(self.close)
self.password_field.setEchoMode(QLineEdit.EchoMode.Password)
self.envbox.currentTextChanged.connect(self._init_password)

def _init_envbox(self):
env_jsons = [path.name for path in self.irods_config_dir.glob("irods_environment*json")]
Expand All @@ -57,11 +65,12 @@ def _init_envbox(self):
self.envbox.setCurrentIndex(0)

def _init_password(self):
# Check if there is a cached password
passwd_file = self.irods_config_dir.joinpath(".irodsA")
if passwd_file.is_file():
# Check if there is a cached password in the ibridges_gui config file
env_file = self.irods_config_dir.joinpath(self.envbox.currentText())
if str(env_file) in self.prev_settings:
self.password_field.setText("***********")
return True
self.password_field.clear()
return False

def close(self):
Expand All @@ -86,6 +95,9 @@ def login_function(self):
try:
if self.cached_pw is True and self.password_field.text() == "***********":
self.logger.debug("Login with %s and cached password.", env_file)
with open(IRODSA, "w", encoding="utf-8") as f:
f.write(self.prev_settings[str(env_file)])

session = Session(irods_env=env_file)
else:
session = Session(irods_env=env_file, password=self.password_field.text())
Expand All @@ -97,6 +109,7 @@ def login_function(self):
session.home,
)
session.write_pam_password()
save_current_settings(env_file)
if self._check_home(session) and self._check_resource(session):
self.session_dict["session"] = session
set_last_ienv_path(env_file.name)
Expand Down
Loading

0 comments on commit 87e654c

Please sign in to comment.