scipion-pyworkflow 3.7.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyworkflow/__init__.py +33 -0
- pyworkflow/apps/__init__.py +29 -0
- pyworkflow/apps/pw_manager.py +37 -0
- pyworkflow/apps/pw_plot.py +51 -0
- pyworkflow/apps/pw_project.py +113 -0
- pyworkflow/apps/pw_protocol_list.py +143 -0
- pyworkflow/apps/pw_protocol_run.py +51 -0
- pyworkflow/apps/pw_run_tests.py +267 -0
- pyworkflow/apps/pw_schedule_run.py +322 -0
- pyworkflow/apps/pw_sleep.py +37 -0
- pyworkflow/apps/pw_sync_data.py +439 -0
- pyworkflow/apps/pw_viewer.py +78 -0
- pyworkflow/config.py +536 -0
- pyworkflow/constants.py +212 -0
- pyworkflow/exceptions.py +18 -0
- pyworkflow/gui/__init__.py +36 -0
- pyworkflow/gui/browser.py +726 -0
- pyworkflow/gui/canvas.py +1190 -0
- pyworkflow/gui/dialog.py +976 -0
- pyworkflow/gui/form.py +2627 -0
- pyworkflow/gui/graph.py +247 -0
- pyworkflow/gui/graph_layout.py +271 -0
- pyworkflow/gui/gui.py +566 -0
- pyworkflow/gui/matplotlib_image.py +233 -0
- pyworkflow/gui/plotter.py +247 -0
- pyworkflow/gui/project/__init__.py +25 -0
- pyworkflow/gui/project/base.py +192 -0
- pyworkflow/gui/project/constants.py +139 -0
- pyworkflow/gui/project/labels.py +205 -0
- pyworkflow/gui/project/project.py +484 -0
- pyworkflow/gui/project/searchprotocol.py +154 -0
- pyworkflow/gui/project/searchrun.py +181 -0
- pyworkflow/gui/project/steps.py +166 -0
- pyworkflow/gui/project/utils.py +332 -0
- pyworkflow/gui/project/variables.py +179 -0
- pyworkflow/gui/project/viewdata.py +472 -0
- pyworkflow/gui/project/viewprojects.py +510 -0
- pyworkflow/gui/project/viewprotocols.py +2093 -0
- pyworkflow/gui/project/viewprotocols_extra.py +560 -0
- pyworkflow/gui/text.py +771 -0
- pyworkflow/gui/tooltip.py +185 -0
- pyworkflow/gui/tree.py +684 -0
- pyworkflow/gui/widgets.py +307 -0
- pyworkflow/mapper/__init__.py +26 -0
- pyworkflow/mapper/mapper.py +222 -0
- pyworkflow/mapper/sqlite.py +1578 -0
- pyworkflow/mapper/sqlite_db.py +145 -0
- pyworkflow/object.py +1512 -0
- pyworkflow/plugin.py +712 -0
- pyworkflow/project/__init__.py +31 -0
- pyworkflow/project/config.py +451 -0
- pyworkflow/project/manager.py +179 -0
- pyworkflow/project/project.py +1990 -0
- pyworkflow/project/scripts/clean_projects.py +77 -0
- pyworkflow/project/scripts/config.py +92 -0
- pyworkflow/project/scripts/create.py +77 -0
- pyworkflow/project/scripts/edit_workflow.py +90 -0
- pyworkflow/project/scripts/fix_links.py +39 -0
- pyworkflow/project/scripts/load.py +87 -0
- pyworkflow/project/scripts/refresh.py +83 -0
- pyworkflow/project/scripts/schedule.py +111 -0
- pyworkflow/project/scripts/stack2volume.py +41 -0
- pyworkflow/project/scripts/stop.py +81 -0
- pyworkflow/protocol/__init__.py +38 -0
- pyworkflow/protocol/bibtex.py +48 -0
- pyworkflow/protocol/constants.py +86 -0
- pyworkflow/protocol/executor.py +334 -0
- pyworkflow/protocol/hosts.py +313 -0
- pyworkflow/protocol/launch.py +270 -0
- pyworkflow/protocol/package.py +42 -0
- pyworkflow/protocol/params.py +744 -0
- pyworkflow/protocol/protocol.py +2554 -0
- pyworkflow/resources/Imagej.png +0 -0
- pyworkflow/resources/chimera.png +0 -0
- pyworkflow/resources/fa-exclamation-triangle_alert.png +0 -0
- pyworkflow/resources/fa-info-circle_alert.png +0 -0
- pyworkflow/resources/fa-search.png +0 -0
- pyworkflow/resources/fa-times-circle_alert.png +0 -0
- pyworkflow/resources/file_vol.png +0 -0
- pyworkflow/resources/loading.gif +0 -0
- pyworkflow/resources/no-image128.png +0 -0
- pyworkflow/resources/scipion_bn.png +0 -0
- pyworkflow/resources/scipion_icon.png +0 -0
- pyworkflow/resources/scipion_icon.svg +397 -0
- pyworkflow/resources/scipion_icon_proj.png +0 -0
- pyworkflow/resources/scipion_icon_projs.png +0 -0
- pyworkflow/resources/scipion_icon_prot.png +0 -0
- pyworkflow/resources/scipion_logo.png +0 -0
- pyworkflow/resources/scipion_logo_normal.png +0 -0
- pyworkflow/resources/scipion_logo_small.png +0 -0
- pyworkflow/resources/sprites.png +0 -0
- pyworkflow/resources/sprites.xcf +0 -0
- pyworkflow/resources/wait.gif +0 -0
- pyworkflow/template.py +322 -0
- pyworkflow/tests/__init__.py +29 -0
- pyworkflow/tests/test_utils.py +25 -0
- pyworkflow/tests/tests.py +341 -0
- pyworkflow/utils/__init__.py +38 -0
- pyworkflow/utils/dataset.py +414 -0
- pyworkflow/utils/echo.py +104 -0
- pyworkflow/utils/graph.py +196 -0
- pyworkflow/utils/log.py +284 -0
- pyworkflow/utils/path.py +527 -0
- pyworkflow/utils/process.py +132 -0
- pyworkflow/utils/profiler.py +92 -0
- pyworkflow/utils/progressbar.py +154 -0
- pyworkflow/utils/properties.py +627 -0
- pyworkflow/utils/reflection.py +129 -0
- pyworkflow/utils/utils.py +877 -0
- pyworkflow/utils/which.py +229 -0
- pyworkflow/viewer.py +328 -0
- pyworkflow/webservices/__init__.py +8 -0
- pyworkflow/webservices/config.py +11 -0
- pyworkflow/webservices/notifier.py +162 -0
- pyworkflow/webservices/repository.py +59 -0
- pyworkflow/webservices/workflowhub.py +74 -0
- pyworkflow/wizard.py +64 -0
- pyworkflowtests/__init__.py +51 -0
- pyworkflowtests/bibtex.py +51 -0
- pyworkflowtests/objects.py +830 -0
- pyworkflowtests/protocols.py +154 -0
- pyworkflowtests/tests/__init__.py +0 -0
- pyworkflowtests/tests/test_canvas.py +72 -0
- pyworkflowtests/tests/test_domain.py +45 -0
- pyworkflowtests/tests/test_logs.py +74 -0
- pyworkflowtests/tests/test_mappers.py +392 -0
- pyworkflowtests/tests/test_object.py +507 -0
- pyworkflowtests/tests/test_project.py +42 -0
- pyworkflowtests/tests/test_protocol_execution.py +72 -0
- pyworkflowtests/tests/test_protocol_export.py +78 -0
- pyworkflowtests/tests/test_protocol_output.py +158 -0
- pyworkflowtests/tests/test_streaming.py +47 -0
- pyworkflowtests/tests/test_utils.py +210 -0
- scipion_pyworkflow-3.7.0.dist-info/LICENSE.txt +674 -0
- scipion_pyworkflow-3.7.0.dist-info/METADATA +107 -0
- scipion_pyworkflow-3.7.0.dist-info/RECORD +140 -0
- scipion_pyworkflow-3.7.0.dist-info/WHEEL +5 -0
- scipion_pyworkflow-3.7.0.dist-info/dependency_links.txt +1 -0
- scipion_pyworkflow-3.7.0.dist-info/entry_points.txt +5 -0
- scipion_pyworkflow-3.7.0.dist-info/top_level.txt +2 -0
@@ -0,0 +1,145 @@
|
|
1
|
+
# **************************************************************************
|
2
|
+
# *
|
3
|
+
# * Authors: J.M. De la Rosa Trevin (jmdelarosa@cnb.csic.es)
|
4
|
+
# *
|
5
|
+
# * Unidad de Bioinformatica of Centro Nacional de Biotecnologia , CSIC
|
6
|
+
# *
|
7
|
+
# * This program is free software; you can redistribute it and/or modify
|
8
|
+
# * it under the terms of the GNU General Public License as published by
|
9
|
+
# * the Free Software Foundation; either version 3 of the License, or
|
10
|
+
# * (at your option) any later version.
|
11
|
+
# *
|
12
|
+
# * This program is distributed in the hope that it will be useful,
|
13
|
+
# * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# * GNU General Public License for more details.
|
16
|
+
# *
|
17
|
+
# * You should have received a copy of the GNU General Public License
|
18
|
+
# * along with this program; if not, write to the Free Software
|
19
|
+
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
20
|
+
# * 02111-1307 USA
|
21
|
+
# *
|
22
|
+
# * All comments concerning this program package may be sent to the
|
23
|
+
# * e-mail address 'scipion@cnb.csic.es'
|
24
|
+
# *
|
25
|
+
# **************************************************************************
|
26
|
+
|
27
|
+
|
28
|
+
"""
|
29
|
+
This module contains some sqlite basic tools to handle Databases.
|
30
|
+
"""
|
31
|
+
|
32
|
+
import logging
|
33
|
+
logger = logging.getLogger(__name__)
|
34
|
+
from sqlite3 import dbapi2 as sqlite
|
35
|
+
from sqlite3 import OperationalError as OperationalError
|
36
|
+
from pyworkflow.utils import STATUS, getExtraLogInfo, Config
|
37
|
+
|
38
|
+
|
39
|
+
class SqliteDb:
|
40
|
+
"""Class to handle a Sqlite database.
|
41
|
+
It will create connection, execute queries and commands.
|
42
|
+
"""
|
43
|
+
OPEN_CONNECTIONS = {} # Store all connections made
|
44
|
+
|
45
|
+
def __init__(self):
|
46
|
+
self._reuseConnections = False
|
47
|
+
|
48
|
+
def _createConnection(self, dbName, timeout):
|
49
|
+
"""Establish db connection"""
|
50
|
+
self._dbName = dbName
|
51
|
+
if self._reuseConnections and dbName in self.OPEN_CONNECTIONS:
|
52
|
+
self.connection = self.OPEN_CONNECTIONS[dbName]
|
53
|
+
else:
|
54
|
+
# self.closeConnection(dbName) # Close the connect if exists for this db
|
55
|
+
self.connection = sqlite.Connection(dbName, timeout, check_same_thread=False)
|
56
|
+
self.connection.row_factory = sqlite.Row
|
57
|
+
self.OPEN_CONNECTIONS[dbName] = self.connection
|
58
|
+
logger.debug("Connection open for %s" % dbName, extra=getExtraLogInfo(
|
59
|
+
"CONNECTIONS",
|
60
|
+
STATUS.START,
|
61
|
+
dbfilename=dbName))
|
62
|
+
|
63
|
+
self.cursor = self.connection.cursor()
|
64
|
+
# Define some shortcuts functions
|
65
|
+
if Config.debugSQLOn():
|
66
|
+
self.executeCommand = self._debugExecute
|
67
|
+
else:
|
68
|
+
self.executeCommand = self.cursor.execute
|
69
|
+
self.commit = self.connection.commit
|
70
|
+
|
71
|
+
@classmethod
|
72
|
+
def closeConnection(cls, dbName):
|
73
|
+
if dbName in cls.OPEN_CONNECTIONS:
|
74
|
+
connection = cls.OPEN_CONNECTIONS[dbName]
|
75
|
+
del cls.OPEN_CONNECTIONS[dbName]
|
76
|
+
connection.close()
|
77
|
+
logger.debug("Connection closed for %s" % dbName,
|
78
|
+
extra=getExtraLogInfo('CONNECTIONS', STATUS.STOP, dbfilename=dbName))
|
79
|
+
|
80
|
+
def getDbName(self):
|
81
|
+
return self._dbName
|
82
|
+
|
83
|
+
def close(self):
|
84
|
+
self.connection.close()
|
85
|
+
logger.debug("Connection closed for %s" % self._dbName,
|
86
|
+
extra=getExtraLogInfo(
|
87
|
+
"CONNECTIONS",
|
88
|
+
STATUS.STOP,
|
89
|
+
dbfilename=self._dbName))
|
90
|
+
if self._dbName in self.OPEN_CONNECTIONS:
|
91
|
+
del self.OPEN_CONNECTIONS[self._dbName]
|
92
|
+
|
93
|
+
def _debugExecute(self, *args):
|
94
|
+
try:
|
95
|
+
logger.debug("COMMAND: %s; %s" %(args[0] , self._dbName),
|
96
|
+
extra=getExtraLogInfo("QUERY", STATUS.EVENT, dbfilename=self._dbName)
|
97
|
+
)
|
98
|
+
logger.debug("ARGUMENTS: " + str(args[1:]))
|
99
|
+
return self.cursor.execute(*args)
|
100
|
+
except Exception as ex:
|
101
|
+
print(">>>> FAILED cursor.execute on db: '%s'" % self._dbName)
|
102
|
+
raise ex
|
103
|
+
|
104
|
+
def _iterResults(self):
|
105
|
+
row = self.cursor.fetchone()
|
106
|
+
while row is not None:
|
107
|
+
yield row
|
108
|
+
row = self.cursor.fetchone()
|
109
|
+
|
110
|
+
def _results(self, iterate=False):
|
111
|
+
""" Return the results to which cursor, point to.
|
112
|
+
If iterates=True, iterate yielding each result independently"""
|
113
|
+
if not iterate:
|
114
|
+
return self.cursor.fetchall()
|
115
|
+
else:
|
116
|
+
return self._iterResults()
|
117
|
+
|
118
|
+
def getTables(self, tablePattern=None):
|
119
|
+
""" Return the table names existing in the Database.
|
120
|
+
If tablePattern is not None, only tables matching
|
121
|
+
the pattern will be returned.
|
122
|
+
"""
|
123
|
+
self.executeCommand("SELECT name FROM sqlite_master "
|
124
|
+
"WHERE type='table' "
|
125
|
+
"AND name NOT LIKE 'sqlite_%';")
|
126
|
+
return [str(row['name']) for row in self._iterResults()]
|
127
|
+
|
128
|
+
def hasTable(self, tableName):
|
129
|
+
return tableName in self.getTables()
|
130
|
+
|
131
|
+
def getTableColumns(self, tableName):
|
132
|
+
self.executeCommand('PRAGMA table_info(%s)' % tableName)
|
133
|
+
return self.cursor.fetchall()
|
134
|
+
|
135
|
+
def getVersion(self):
|
136
|
+
""" Return the database 'version' that is used.
|
137
|
+
Internally it make use of the SQLite PRAGMA database.user_version;
|
138
|
+
"""
|
139
|
+
self.executeCommand('PRAGMA user_version')
|
140
|
+
return self.cursor.fetchone()[0]
|
141
|
+
|
142
|
+
def setVersion(self, version):
|
143
|
+
self.executeCommand('PRAGMA user_version=%d' % version)
|
144
|
+
self.commit()
|
145
|
+
|