-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy path__main__.py
executable file
·167 lines (143 loc) · 5.13 KB
/
__main__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#!/usr/bin/env python
import os
import logging
import os
import numpy as np
import site
sitepackages = site.getsitepackages()
site_packages = [p for p in sitepackages if p.endswith('site-packages')][0]
cellacdc_path = os.path.dirname(os.path.abspath(__file__))
cellacdc_installation_path = os.path.dirname(cellacdc_path)
if cellacdc_installation_path != site_packages:
# Running developer version. Delete cellacdc folder from site_packages
# if present from a previous installation of cellacdc from PyPi
cellacdc_path_pypi = os.path.join(site_packages, 'cellacdc')
if os.path.exists(cellacdc_path_pypi):
import shutil
try:
shutil.rmtree(cellacdc_path_pypi)
except Exception as err:
print(err)
print(
'[ERROR]: Previous Cell-ACDC installation detected. '
f'Please, manually delete this folder and re-start the software '
f'"{cellacdc_path_pypi}". '
'Thank you for you patience!'
)
exit()
print('*'*60)
input(
'[WARNING]: Cell-ACDC had to clean-up and older installation. '
'Please, re-start the software. Thank you for your patience! '
'(Press any key to exit). '
)
exit()
from cellacdc import _run
def run():
from cellacdc.config import parser_args
PARAMS_PATH = parser_args['params']
if parser_args['version'] or parser_args['info']:
import platform, sys
from cellacdc import cellacdc_path
from cellacdc.myutils import get_date_from_version, read_version
version = read_version()
release_date = get_date_from_version(version, package='cellacdc')
py_ver = sys.version_info
python_version = f'{py_ver.major}.{py_ver.minor}.{py_ver.micro}'
print('='*100)
print(f'Cell-ACDC version {version}')
print(f'Released on: {release_date}')
print(f'Installed in "{cellacdc_path}"')
print(f'Python {python_version}')
print(f'Platform: {platform.platform()}')
try:
from qtpy import QtCore
print(f'Qt {QtCore.__version__}')
except Exception as err:
print(f'Qt: Not installed')
print('='*100)
exit()
if PARAMS_PATH:
_run.run_cli(PARAMS_PATH)
else:
run_gui()
def main():
# Keep compatibility with users that installed older versions
# where the entry point was main()
run()
def run_gui():
from ._run import _setup_gui_libraries, _setup_symlink_app_name_macos
_setup_symlink_app_name_macos()
_setup_gui_libraries()
from qtpy import QtGui, QtWidgets, QtCore
# from . import qrc_resources
if os.name == 'nt':
try:
# Set taskbar icon in windows
import ctypes
myappid = 'schmollerlab.cellacdc.pyqt.v1' # arbitrary string
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
except Exception as e:
pass
# Needed by pyqtgraph with display resolution scaling
try:
QtWidgets.QApplication.setAttribute(
QtCore.Qt.HighDpiScaleFactorRoundingPolicy.PassThrough
)
except Exception as e:
pass
import pyqtgraph as pg
# Interpret image data as row-major instead of col-major
pg.setConfigOption('imageAxisOrder', 'row-major')
try:
import numba
pg.setConfigOption("useNumba", True)
except Exception as e:
pass
try:
import cupy as cp
pg.setConfigOption("useCupy", True)
except Exception as e:
pass
# Create the application
app, splashScreen = _run._setup_app(splashscreen=True)
from cellacdc import myutils, printl
from cellacdc import qrc_resources
print('Launching application...')
from cellacdc._main import mainWin
if not splashScreen.isVisible():
splashScreen.show()
win = mainWin(app)
try:
myutils.check_matplotlib_version(qparent=win)
except Exception as e:
pass
version, success = myutils.read_version(
logger=win.logger.info, return_success=True
)
if not success:
error = myutils.check_install_package(
'setuptools_scm', pypi_name='setuptools-scm'
)
if error:
win.logger.info(error)
else:
version = myutils.read_version(logger=win.logger.info)
win.setVersion(version)
win.launchWelcomeGuide()
win.show()
try:
win.welcomeGuide.showPage(win.welcomeGuide.welcomeItem)
except AttributeError:
pass
win.logger.info('**********************************************')
win.logger.info(f'Welcome to Cell-ACDC v{version}')
win.logger.info('**********************************************')
win.logger.info('----------------------------------------------')
win.logger.info('NOTE: If application is not visible, it is probably minimized\n'
'or behind some other open windows.')
win.logger.info('----------------------------------------------')
splashScreen.close()
# splashScreenApp.quit()
# modernWin.show()
app.exec_()