cellpy 1.0.1.post3__tar.gz → 1.0.2__tar.gz
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.
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/HISTORY.md +13 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/PKG-INFO +30 -3
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/README.md +1 -1
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/__init__.py +10 -5
- cellpy-1.0.2/cellpy/_version.py +1 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/exceptions.py +6 -0
- cellpy-1.0.2/cellpy/internals/__init__.py +10 -0
- cellpy-1.0.2/cellpy/internals/core.py +170 -0
- cellpy-1.0.2/cellpy/internals/otherpath.py +1238 -0
- cellpy-1.0.2/cellpy/libs/apipkg/__init__.py +39 -0
- cellpy-1.0.2/cellpy/libs/apipkg/_alias_module.py +40 -0
- cellpy-1.0.2/cellpy/libs/apipkg/_importing.py +41 -0
- cellpy-1.0.2/cellpy/libs/apipkg/_module.py +184 -0
- cellpy-1.0.2/cellpy/libs/apipkg/_syncronized.py +18 -0
- cellpy-1.0.2/cellpy/libs/apipkg/_version.py +1 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/log.py +6 -14
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/logging.json +1 -1
- cellpy-1.0.2/cellpy/parameters/__init__.py +12 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/parameters/internal_settings.py +25 -37
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/parameters/legacy/update_headers.py +17 -23
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/parameters/prmreader.py +7 -10
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/parameters/prms.py +26 -20
- cellpy-1.0.2/cellpy/readers/__init__.py +18 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/readers/cellreader.py +741 -980
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/readers/core.py +165 -120
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/readers/dbreader.py +31 -55
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/readers/filefinder.py +30 -40
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/readers/instruments/arbin_res.py +49 -130
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/readers/instruments/arbin_sql.py +0 -2
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/readers/instruments/arbin_sql_7.py +0 -2
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/readers/instruments/base.py +82 -12
- cellpy-1.0.2/cellpy/readers/instruments/configurations/neware_txt_one.py +82 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/readers/instruments/configurations/neware_txt_zero.py +3 -3
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/readers/instruments/custom.py +13 -2
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/readers/instruments/maccor_txt.py +0 -2
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/readers/instruments/neware_txt.py +1 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/readers/instruments/neware_xlsx.py +17 -41
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/readers/instruments/processors/post_processors.py +51 -41
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/utils/batch.py +220 -115
- cellpy-1.0.2/cellpy/utils/batch_tools/__init__.py +0 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/utils/batch_tools/batch_core.py +27 -28
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/utils/batch_tools/batch_experiments.py +68 -61
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/utils/batch_tools/batch_helpers.py +53 -9
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/utils/batch_tools/batch_journals.py +217 -83
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/utils/batch_tools/batch_plotters.py +177 -114
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/utils/batch_tools/engines.py +41 -17
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/utils/collectors.py +247 -137
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/utils/helpers.py +78 -112
- cellpy-1.0.2/cellpy/utils/plotutils.py +2438 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy.egg-info/PKG-INFO +30 -3
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy.egg-info/SOURCES.txt +10 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy.egg-info/requires.txt +1 -0
- cellpy-1.0.2/pyproject.toml +31 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/setup.py +2 -0
- cellpy-1.0.1.post3/cellpy/_version.py +0 -1
- cellpy-1.0.1.post3/cellpy/internals/core.py +0 -913
- cellpy-1.0.1.post3/cellpy/parameters/__init__.py +0 -1
- cellpy-1.0.1.post3/cellpy/readers/__init__.py +0 -1
- cellpy-1.0.1.post3/cellpy/utils/plotutils.py +0 -936
- cellpy-1.0.1.post3/pyproject.toml +0 -14
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/AUTHORS.md +0 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/CONTRIBUTING.md +0 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/LICENSE.md +0 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/MANIFEST.in +0 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/cli.py +0 -0
- {cellpy-1.0.1.post3/cellpy/internals → cellpy-1.0.2/cellpy/libs}/__init__.py +0 -0
- /cellpy-1.0.1.post3/cellpy/parameters/legacy/__init__.py → /cellpy-1.0.2/cellpy/libs/apipkg/py.typed +0 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/parameters/.cellpy_prms_default.conf +0 -0
- {cellpy-1.0.1.post3/cellpy/readers/instruments → cellpy-1.0.2/cellpy/parameters/legacy}/__init__.py +0 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/readers/do.py +0 -0
- {cellpy-1.0.1.post3/cellpy/readers/instruments/loader_specific_modules → cellpy-1.0.2/cellpy/readers/instruments}/__init__.py +0 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/readers/instruments/arbin_sql_csv.py +0 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/readers/instruments/arbin_sql_h5.py +0 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/readers/instruments/arbin_sql_xlsx.py +0 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/readers/instruments/biologics_mpr.py +0 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/readers/instruments/configurations/__init__.py +0 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/readers/instruments/configurations/maccor_txt_one.py +0 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/readers/instruments/configurations/maccor_txt_three.py +0 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/readers/instruments/configurations/maccor_txt_two.py +0 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/readers/instruments/configurations/maccor_txt_zero.py +0 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/readers/instruments/ext_nda_reader.py +0 -0
- {cellpy-1.0.1.post3/cellpy/readers/instruments/processors → cellpy-1.0.2/cellpy/readers/instruments/loader_specific_modules}/__init__.py +0 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/readers/instruments/loader_specific_modules/biologic_file_format.py +0 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/readers/instruments/local_instrument.py +0 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/readers/instruments/pec_csv.py +0 -0
- {cellpy-1.0.1.post3/cellpy/utils/batch_tools → cellpy-1.0.2/cellpy/readers/instruments/processors}/__init__.py +0 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/readers/instruments/processors/pre_processors.py +0 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/readers/sql_dbreader.py +0 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/utils/__init__.py +0 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/utils/batch_tools/batch_analyzers.py +0 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/utils/batch_tools/batch_exporters.py +0 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/utils/batch_tools/batch_reporters.py +0 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/utils/batch_tools/dumpers.py +0 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/utils/batch_tools/sqlite_from_excel_db.py +0 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/utils/diagnostics.py +0 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/utils/easyplot.py +0 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/utils/example_data.py +0 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/utils/ica.py +0 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/utils/live.py +0 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/utils/ocv_rlx.py +0 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy/utils/processor.py +0 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy.egg-info/dependency_links.txt +0 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy.egg-info/entry_points.txt +0 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy.egg-info/not-zip-safe +0 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/cellpy.egg-info/top_level.txt +0 -0
- {cellpy-1.0.1.post3 → cellpy-1.0.2}/setup.cfg +0 -0
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# History
|
|
2
2
|
|
|
3
|
+
## 1.0.2
|
|
4
|
+
|
|
5
|
+
* Batch: `only_selected` keyword added for concatenating summaries choosing only selected cells in the pages (selected==1)
|
|
6
|
+
* General: Add option to specify custom_log_path and path to logging config json in get() (#326) by @morrowrasmus
|
|
7
|
+
* Batch: implement wide format for collectors to csv
|
|
8
|
+
* Batch: adding more columns to pages (model, selected, nom_cap_specifics)
|
|
9
|
+
* General: Implemented lazy import to speed up loading of cellpy
|
|
10
|
+
* General: Added _absolute cols in the summary
|
|
11
|
+
* General: Add basic support for reading parquet for custom instruments (#322) by @morrowrasmus
|
|
12
|
+
* Utils: General improvements in plotutils
|
|
13
|
+
* General: Dropped support for python 3.9 and added support for python 3.12 (and probably beyond) by upgrading `OtherPaths`
|
|
14
|
+
* Bug fixes.
|
|
15
|
+
|
|
3
16
|
## 1.0.1
|
|
4
17
|
|
|
5
18
|
* Utils: `example_data` now includes auto-download of example data
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: cellpy
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.2
|
|
4
4
|
Summary: Extract and manipulate data from battery data testers.
|
|
5
5
|
Home-page: https://github.com/jepegit/cellpy
|
|
6
6
|
Author: Jan Petter Maehlen
|
|
@@ -13,6 +13,7 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
13
13
|
Classifier: Natural Language :: English
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.10
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
17
|
Description-Content-Type: text/markdown
|
|
17
18
|
License-File: LICENSE.md
|
|
18
19
|
License-File: AUTHORS.md
|
|
@@ -40,6 +41,7 @@ Requires-Dist: jinja2_time
|
|
|
40
41
|
Requires-Dist: tables
|
|
41
42
|
Requires-Dist: ipykernel
|
|
42
43
|
Requires-Dist: rich
|
|
44
|
+
Requires-Dist: charset-normalizer
|
|
43
45
|
Provides-Extra: batch
|
|
44
46
|
Requires-Dist: ipython; extra == "batch"
|
|
45
47
|
Requires-Dist: jupyter; extra == "batch"
|
|
@@ -55,6 +57,18 @@ Requires-Dist: plotly; extra == "all"
|
|
|
55
57
|
Requires-Dist: seaborn; extra == "all"
|
|
56
58
|
Requires-Dist: kaleido==0.1.*; extra == "all"
|
|
57
59
|
Requires-Dist: lmfit; extra == "all"
|
|
60
|
+
Dynamic: author
|
|
61
|
+
Dynamic: author-email
|
|
62
|
+
Dynamic: classifier
|
|
63
|
+
Dynamic: description
|
|
64
|
+
Dynamic: description-content-type
|
|
65
|
+
Dynamic: home-page
|
|
66
|
+
Dynamic: keywords
|
|
67
|
+
Dynamic: license
|
|
68
|
+
Dynamic: license-file
|
|
69
|
+
Dynamic: provides-extra
|
|
70
|
+
Dynamic: requires-dist
|
|
71
|
+
Dynamic: summary
|
|
58
72
|
|
|
59
73
|
<img src="https://raw.githubusercontent.com/jepegit/cellpy/master/docs/_static/cellpy-icon-long.svg" height="100" alt="cellpy-icon">
|
|
60
74
|
|
|
@@ -67,7 +81,7 @@ Requires-Dist: lmfit; extra == "all"
|
|
|
67
81
|
|
|
68
82
|
This Python Package was developed to help the
|
|
69
83
|
researchers at IFE, Norway, in their cumbersome task of
|
|
70
|
-
interpreting and handling data from cycling tests of
|
|
84
|
+
interpreting and handling data from cycling tests of batteries and cells.
|
|
71
85
|
|
|
72
86
|
## Features
|
|
73
87
|
|
|
@@ -122,6 +136,19 @@ please have a look at [Contributing Guidelines](CONTRIBUTING.md).
|
|
|
122
136
|
|
|
123
137
|
# History
|
|
124
138
|
|
|
139
|
+
## 1.0.2
|
|
140
|
+
|
|
141
|
+
* Batch: `only_selected` keyword added for concatenating summaries choosing only selected cells in the pages (selected==1)
|
|
142
|
+
* General: Add option to specify custom_log_path and path to logging config json in get() (#326) by @morrowrasmus
|
|
143
|
+
* Batch: implement wide format for collectors to csv
|
|
144
|
+
* Batch: adding more columns to pages (model, selected, nom_cap_specifics)
|
|
145
|
+
* General: Implemented lazy import to speed up loading of cellpy
|
|
146
|
+
* General: Added _absolute cols in the summary
|
|
147
|
+
* General: Add basic support for reading parquet for custom instruments (#322) by @morrowrasmus
|
|
148
|
+
* Utils: General improvements in plotutils
|
|
149
|
+
* General: Dropped support for python 3.9 and added support for python 3.12 (and probably beyond) by upgrading `OtherPaths`
|
|
150
|
+
* Bug fixes.
|
|
151
|
+
|
|
125
152
|
## 1.0.1
|
|
126
153
|
|
|
127
154
|
* Utils: `example_data` now includes auto-download of example data
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
This Python Package was developed to help the
|
|
11
11
|
researchers at IFE, Norway, in their cumbersome task of
|
|
12
|
-
interpreting and handling data from cycling tests of
|
|
12
|
+
interpreting and handling data from cycling tests of batteries and cells.
|
|
13
13
|
|
|
14
14
|
## Features
|
|
15
15
|
|
|
@@ -21,22 +21,27 @@ import logging
|
|
|
21
21
|
import warnings
|
|
22
22
|
|
|
23
23
|
import cellpy._version
|
|
24
|
+
|
|
25
|
+
|
|
24
26
|
from cellpy.parameters import prms # TODO: this might give circular ref
|
|
25
27
|
from cellpy.parameters import prmreader
|
|
26
|
-
from cellpy.readers import cellreader, dbreader, filefinder, do
|
|
27
|
-
from cellpy.readers.core import Q, ureg
|
|
28
28
|
|
|
29
29
|
__version__ = cellpy._version.__version__
|
|
30
30
|
|
|
31
|
+
from cellpy.readers import cellreader, dbreader, filefinder, do
|
|
32
|
+
|
|
33
|
+
# from cellpy.readers.core import Q, ureg
|
|
34
|
+
|
|
31
35
|
logging.getLogger(__name__).addHandler(logging.NullHandler())
|
|
32
36
|
|
|
33
37
|
# TODO: (v2.0) remove this and enforce using for example `import cellpy.session as clp` and then
|
|
34
38
|
# run `prmreader.initialize` in that `__init__` instead:
|
|
35
|
-
init = prmreader.initialize
|
|
39
|
+
init = parameters.prmreader.initialize
|
|
36
40
|
init()
|
|
37
41
|
|
|
38
42
|
# TODO: (v2.0) remove this and enforce using `cellpy.get` (or `cellpy.cellreader.get`) instead:
|
|
39
43
|
get = cellreader.get
|
|
44
|
+
print_instruments = readers.cellreader.print_instruments
|
|
40
45
|
|
|
41
46
|
__all__ = [
|
|
42
47
|
"cellreader",
|
|
@@ -47,6 +52,6 @@ __all__ = [
|
|
|
47
52
|
"get",
|
|
48
53
|
"do",
|
|
49
54
|
"init",
|
|
50
|
-
"ureg",
|
|
51
|
-
"Q",
|
|
55
|
+
# "ureg",
|
|
56
|
+
# "Q",
|
|
52
57
|
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "1.0.2"
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"""This module contains div classes etc that are not really connected to cellpy."""
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
import fnmatch
|
|
5
|
+
import logging
|
|
6
|
+
import os
|
|
7
|
+
import pathlib
|
|
8
|
+
import shutil
|
|
9
|
+
import stat
|
|
10
|
+
import sys
|
|
11
|
+
import tempfile
|
|
12
|
+
import time
|
|
13
|
+
import warnings
|
|
14
|
+
from typing import (
|
|
15
|
+
Any,
|
|
16
|
+
Tuple,
|
|
17
|
+
Dict,
|
|
18
|
+
List,
|
|
19
|
+
Union,
|
|
20
|
+
TypeVar,
|
|
21
|
+
Generator,
|
|
22
|
+
Optional,
|
|
23
|
+
Iterable,
|
|
24
|
+
Callable,
|
|
25
|
+
Type,
|
|
26
|
+
cast,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
# import fabric
|
|
30
|
+
from . import externals as externals
|
|
31
|
+
from cellpy.exceptions import UnderDefined
|
|
32
|
+
from cellpy.internals import otherpath
|
|
33
|
+
from cellpy.internals.otherpath import (
|
|
34
|
+
URI_PREFIXES,
|
|
35
|
+
IMPLEMENTED_PROTOCOLS,
|
|
36
|
+
ENV_VAR_CELLPY_KEY_FILENAME,
|
|
37
|
+
ENV_VAR_CELLPY_PASSWORD,
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
OtherPath = otherpath.get_otherpath_class()
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def check_connection(
|
|
44
|
+
p=None,
|
|
45
|
+
):
|
|
46
|
+
"""Check if the connection works.
|
|
47
|
+
|
|
48
|
+
This is a helper function for cellpy v1.0 only and should be removed in later versions after
|
|
49
|
+
the OtherPath class has been updated to work with python >= 3.12.
|
|
50
|
+
|
|
51
|
+
Args:
|
|
52
|
+
p (str, pathlib.Path or OtherPath, optional): The path to check. Defaults to prms.Paths.rawdatadir.
|
|
53
|
+
|
|
54
|
+
"""
|
|
55
|
+
# Note: users run this function from helpers.py
|
|
56
|
+
from pprint import pprint
|
|
57
|
+
|
|
58
|
+
logging.debug("checking connection")
|
|
59
|
+
if p is None:
|
|
60
|
+
print("No path given. Checking rawdatadir from prms.")
|
|
61
|
+
|
|
62
|
+
# need to import prms here to avoid circular imports:
|
|
63
|
+
from cellpy import prms
|
|
64
|
+
|
|
65
|
+
p = prms.Paths.rawdatadir
|
|
66
|
+
|
|
67
|
+
# recreating the OtherPath object to OtherPath since core is imported in the top __init__.py
|
|
68
|
+
# file resulting in isinstance(p, OtherPath) to be False
|
|
69
|
+
p = OtherPath(p)
|
|
70
|
+
logging.debug(f"p: {p}")
|
|
71
|
+
|
|
72
|
+
print("\nCollecting connection information:")
|
|
73
|
+
|
|
74
|
+
if not p.is_external:
|
|
75
|
+
print(f" - {p} is not external. Returning.")
|
|
76
|
+
return {}
|
|
77
|
+
|
|
78
|
+
info = {
|
|
79
|
+
"is_external": p.is_external,
|
|
80
|
+
"uri_prefix": p.uri_prefix,
|
|
81
|
+
"location": p.location,
|
|
82
|
+
"raw_path": p.raw_path,
|
|
83
|
+
"full_path": p.full_path,
|
|
84
|
+
"host": p.location,
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
uri_prefix = p.uri_prefix.replace("//", "")
|
|
88
|
+
info["uri_prefix"] = uri_prefix
|
|
89
|
+
if uri_prefix not in URI_PREFIXES:
|
|
90
|
+
print(f" - uri_prefix {uri_prefix} not recognized")
|
|
91
|
+
if uri_prefix not in IMPLEMENTED_PROTOCOLS:
|
|
92
|
+
print(f" - uri_prefix {uri_prefix.replace(':', '')} not implemented yet")
|
|
93
|
+
|
|
94
|
+
password = os.getenv(ENV_VAR_CELLPY_PASSWORD, None)
|
|
95
|
+
info["password"] = "********" if password is not None else None
|
|
96
|
+
|
|
97
|
+
key_filename = os.getenv(ENV_VAR_CELLPY_KEY_FILENAME, None)
|
|
98
|
+
if password is None and key_filename is None:
|
|
99
|
+
print(
|
|
100
|
+
f" - You must define either {ENV_VAR_CELLPY_PASSWORD} "
|
|
101
|
+
f"or {ENV_VAR_CELLPY_KEY_FILENAME} environment variables."
|
|
102
|
+
)
|
|
103
|
+
if key_filename is not None:
|
|
104
|
+
key_filename = pathlib.Path(key_filename).expanduser().resolve()
|
|
105
|
+
info["key_filename"] = str(key_filename)
|
|
106
|
+
if not pathlib.Path(key_filename).is_file():
|
|
107
|
+
print(f" - Could not find key file {key_filename}")
|
|
108
|
+
else:
|
|
109
|
+
print(" - Using password")
|
|
110
|
+
|
|
111
|
+
for k, v in info.items():
|
|
112
|
+
print(f" {k}: {v}")
|
|
113
|
+
|
|
114
|
+
print("\nChecking connection:")
|
|
115
|
+
connect_kwargs, host = p.connection_info()
|
|
116
|
+
|
|
117
|
+
path_separator = "/" # only supports unix-like systems
|
|
118
|
+
with externals.fabric.Connection(host, connect_kwargs=connect_kwargs) as conn:
|
|
119
|
+
try:
|
|
120
|
+
t1 = time.perf_counter()
|
|
121
|
+
try:
|
|
122
|
+
sftp_conn = conn.sftp()
|
|
123
|
+
except Exception as e:
|
|
124
|
+
print(f" - Could not connect to {host}")
|
|
125
|
+
print(f" {e}")
|
|
126
|
+
return info
|
|
127
|
+
|
|
128
|
+
print(f" connecting [{time.perf_counter() - t1:.2f} seconds] OK")
|
|
129
|
+
sftp_conn.chdir(p.raw_path)
|
|
130
|
+
print(f" chdir [{time.perf_counter() - t1:.2f} seconds] OK")
|
|
131
|
+
files = [
|
|
132
|
+
f"{p.raw_path}{path_separator}{f}"
|
|
133
|
+
for f in sftp_conn.listdir()
|
|
134
|
+
if not stat.S_ISDIR(sftp_conn.stat(f).st_mode)
|
|
135
|
+
]
|
|
136
|
+
print(f" listing files [{time.perf_counter() - t1:.2f} seconds] OK")
|
|
137
|
+
sub_dirs = [
|
|
138
|
+
f"{p.raw_path}{path_separator}{f}"
|
|
139
|
+
for f in sftp_conn.listdir()
|
|
140
|
+
if stat.S_ISDIR(sftp_conn.stat(f).st_mode)
|
|
141
|
+
]
|
|
142
|
+
n_files = len(files)
|
|
143
|
+
n_sub_dirs = len(sub_dirs)
|
|
144
|
+
info["number_of_files"] = n_files
|
|
145
|
+
info["number_of_sub_directories"] = n_sub_dirs
|
|
146
|
+
print(f" found {n_files} files and {n_sub_dirs} sub directories")
|
|
147
|
+
|
|
148
|
+
except FileNotFoundError as e:
|
|
149
|
+
print(
|
|
150
|
+
f" - FileNotFoundError: Could not perform directory listing in {p.raw_path} on {host}." f"\n {e}"
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
return info
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def _check():
|
|
157
|
+
print("Testing OtherPath-connection")
|
|
158
|
+
# info = check_connection()
|
|
159
|
+
p0 = "scp://odin/home/jepe@ad.ife.no/projects"
|
|
160
|
+
# info = check_connection(p0)
|
|
161
|
+
p1 = "scp://odin/home/jepe@ad.ife.no/this-folder-does-not-exist"
|
|
162
|
+
# info = check_connection(p1)
|
|
163
|
+
p2 = pathlib.Path(".").resolve()
|
|
164
|
+
info = check_connection(p2)
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
if __name__ == "__main__":
|
|
168
|
+
print("------------------")
|
|
169
|
+
logging.debug("testing OtherPath")
|
|
170
|
+
_check()
|