Skip to content

Commit

Permalink
make flake8 happy
Browse files Browse the repository at this point in the history
  • Loading branch information
sellth committed May 10, 2023
1 parent f21802c commit dec3528
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
2 changes: 1 addition & 1 deletion cubi_tk/sodar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
from .add_ped import setup_argparse as setup_argparse_add_ped
from .check_remote import setup_argparse as setup_argparse_check_remote
from .download_sheet import setup_argparse as setup_argparse_download_sheet
from .ingest_fastq import setup_argparse as setup_argparse_ingest_fastq
from .ingest import setup_argparse as setup_argparse_ingest
from .ingest_fastq import setup_argparse as setup_argparse_ingest_fastq
from .lz_create import setup_argparse as setup_argparse_lz_create
from .lz_list import setup_argparse as setup_argparse_lz_list
from .lz_move import setup_argparse as setup_argparse_lz_move
Expand Down
31 changes: 18 additions & 13 deletions cubi_tk/sodar/ingest.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
"""``cubi-tk sodar ingest``: add arbitrary files to SODAR"""

import argparse
import getpass
import os
import sys
from pathlib import Path
import getpass
import sys
import typing
import attr

import attr
from irods.session import iRODSSession
from logzero import logger
from sodar_cli import api
from ..common import load_toml_config, is_uuid, compute_md5_checksum, sizeof_fmt
from ..snappy.itransfer_common import TransferJob
from tqdm import tqdm

from ..common import compute_md5_checksum, is_uuid, load_toml_config, sizeof_fmt
from ..snappy.itransfer_common import TransferJob


@attr.s(frozen=True, auto_attribs=True)
class Config:
Expand Down Expand Up @@ -125,7 +126,7 @@ def setup_argparse(cls, parser: argparse.ArgumentParser) -> None:
def get_irods_error(cls, e: Exception):
"""Return logger friendly iRODS exception."""
es = str(e)
return es if es != "None" else e.__class__.__name__
return es if es else e.__class__.__name__

@classmethod
def run(
Expand Down Expand Up @@ -181,8 +182,8 @@ def execute(self):
coll = irods_session.collections.get(self.lz_irods_path)
for c in coll.subcollections:
collections.append(c.name)
except:
logger.error("Failed to query landing zone collections.")
except Exception as e:
logger.error(f"Failed to query landing zone collections: {self.get_irods_error(e)}")
sys.exit(1)
finally:
irods_session.cleanup()
Expand Down Expand Up @@ -261,9 +262,10 @@ def execute(self):
file_log.set_description_str(f"Current file: {job.path_src}")
irods_session.data_objects.put(job.path_src, job.path_dest)
t.update(job.bytes)
except:
logger.error("Problem during transfer of " + job.path_src)
raise
except Exception as e:
logger.error(f"Problem during transfer of {job.path_src}.")
logger.error(self.get_irods_error(e))
sys.exit(1)
finally:
irods_session.cleanup()
t.clear()
Expand All @@ -284,8 +286,11 @@ def build_file_list(self):
for src in source_paths:
try:
abspath = src.resolve()
except:
logger.error("File not found:", src.name)
except FileNotFoundError:
logger.error(f"File not found: {src.name}")
continue
except RuntimeError:
logger.error(f"Infinite loop: {src.name}")
continue

if src.is_dir():
Expand Down
5 changes: 2 additions & 3 deletions tests/test_sodar_ingest.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
"""Tests for ``cubi_tk.sodar.ingest``."""

import pytest
from unittest import mock
from pyfakefs import fake_filesystem, fake_pathlib
from cubi_tk.__main__ import main, setup_argparse

from cubi_tk.__main__ import setup_argparse


def test_run_sodar_ingest_help(capsys):
Expand Down

0 comments on commit dec3528

Please sign in to comment.