Skip to content

Commit

Permalink
refactor: moved installation of tables to _run._setup_gui() function
Browse files Browse the repository at this point in the history
  • Loading branch information
ElpadoCan committed Jul 2, 2023
1 parent 4c4bd10 commit f25706c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 40 deletions.
40 changes: 0 additions & 40 deletions cellacdc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,6 @@
import pathlib
import numpy as np

try:
import tables
except Exception as e:
while True:
txt = (
'Cell-ACDC needs to install a library called `tables`.\n\n'
'If the installation fails, you can still use Cell-ACDC, but we '
'highly recommend you report the issue (see link below) and we '
'will be very happy to help. Thank you for your patience!\n\n'
'Report issue here: https://github.com/SchmollerLab/Cell_ACDC/issues'
'\n'
)
print('-'*60)
print(txt)
answer = input('Do you want to install it now ([y]/n)? ')
if answer.lower() == 'y' or not answer:
try:
import subprocess
subprocess.check_call(
[sys.executable, '-m', 'pip', 'install', '-U', 'tables']
)
break
except Exception as err:
import traceback
traceback.print_exc()
print('*'*60)
print(
'[WARNING]: Installation of `tables` failed. '
'Please report the issue here: '
'https://github.com/SchmollerLab/Cell_ACDC/issues'
)
print('^'*60)
elif answer.lower() == 'n':
raise e
else:
print(
f'"{answer}" is not a valid answer. '
'Type "y" for "yes", or "n" for "no".'
)

cellacdc_path = os.path.dirname(os.path.abspath(__file__))
qrc_resources_path = os.path.join(cellacdc_path, 'qrc_resources.py')
qrc_resources_light_path = os.path.join(cellacdc_path, 'qrc_resources_light.py')
Expand Down
41 changes: 41 additions & 0 deletions cellacdc/_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,47 @@
import sys

def _setup_gui():
try:
import tables
except Exception as e:
while True:
txt = (
'Cell-ACDC needs to install a library called `tables`.\n\n'
'If the installation fails, you can still use Cell-ACDC, but we '
'highly recommend you report the issue (see link below) and we '
'will be very happy to help. Thank you for your patience!\n\n'
'Report issue here: https://github.com/SchmollerLab/Cell_ACDC/issues'
'\n'
)
print('-'*60)
print(txt)
answer = input('Do you want to install it now ([y]/n)? ')
if answer.lower() == 'y' or not answer:
try:
import subprocess
subprocess.check_call(
[sys.executable, '-m', 'pip', 'install', '-U', 'tables']
)
except Exception as err:
import traceback
traceback.print_exc()
print('*'*60)
print(
'[WARNING]: Installation of `tables` failed. '
'Please report the issue here: '
'https://github.com/SchmollerLab/Cell_ACDC/issues'
)
print('^'*60)
finally:
break
elif answer.lower() == 'n':
raise e
else:
print(
f'"{answer}" is not a valid answer. '
'Type "y" for "yes", or "n" for "no".'
)

from . import qrc_resources_path, qrc_resources_light_path

warn_restart = False
Expand Down

0 comments on commit f25706c

Please sign in to comment.