casaconfig 1.0.1__tar.gz → 1.0.3__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.
Files changed (42) hide show
  1. casaconfig-1.0.3/PKG-INFO +292 -0
  2. casaconfig-1.0.3/README.md +77 -0
  3. {casaconfig-1.0.1 → casaconfig-1.0.3}/casaconfig/__main__.py +4 -0
  4. {casaconfig-1.0.1 → casaconfig-1.0.3}/casaconfig/private/CasaconfigErrors.py +5 -0
  5. {casaconfig-1.0.1 → casaconfig-1.0.3}/casaconfig/private/data_available.py +8 -1
  6. {casaconfig-1.0.1 → casaconfig-1.0.3}/casaconfig/private/data_update.py +28 -28
  7. {casaconfig-1.0.1 → casaconfig-1.0.3}/casaconfig/private/get_data_lock.py +9 -0
  8. casaconfig-1.0.3/casaconfig/private/have_network.py +40 -0
  9. {casaconfig-1.0.1 → casaconfig-1.0.3}/casaconfig/private/measures_available.py +8 -1
  10. {casaconfig-1.0.1 → casaconfig-1.0.3}/casaconfig/private/measures_update.py +7 -3
  11. {casaconfig-1.0.1 → casaconfig-1.0.3}/casaconfig/private/pull_data.py +33 -27
  12. casaconfig-1.0.3/casaconfig.egg-info/PKG-INFO +292 -0
  13. {casaconfig-1.0.1 → casaconfig-1.0.3}/casaconfig.egg-info/SOURCES.txt +2 -1
  14. {casaconfig-1.0.1 → casaconfig-1.0.3}/casaconfig.egg-info/top_level.txt +2 -0
  15. casaconfig-1.0.3/pyproject.toml +25 -0
  16. {casaconfig-1.0.1 → casaconfig-1.0.3}/tests/test_casaconfig.py +38 -0
  17. casaconfig-1.0.1/PKG-INFO +0 -45
  18. casaconfig-1.0.1/README.md +0 -33
  19. casaconfig-1.0.1/casaconfig.egg-info/PKG-INFO +0 -45
  20. casaconfig-1.0.1/setup.py +0 -19
  21. {casaconfig-1.0.1 → casaconfig-1.0.3}/LICENSE +0 -0
  22. {casaconfig-1.0.1 → casaconfig-1.0.3}/MANIFEST.in +0 -0
  23. {casaconfig-1.0.1 → casaconfig-1.0.3}/casaconfig/__init__.py +0 -0
  24. {casaconfig-1.0.1 → casaconfig-1.0.3}/casaconfig/config.py +0 -0
  25. {casaconfig-1.0.1 → casaconfig-1.0.3}/casaconfig/private/__init__.py +0 -0
  26. {casaconfig-1.0.1 → casaconfig-1.0.3}/casaconfig/private/casasiteconfig_example.py +0 -0
  27. {casaconfig-1.0.1 → casaconfig-1.0.3}/casaconfig/private/config_defaults.py +0 -0
  28. {casaconfig-1.0.1 → casaconfig-1.0.3}/casaconfig/private/config_defaults_static.py +0 -0
  29. {casaconfig-1.0.1 → casaconfig-1.0.3}/casaconfig/private/do_auto_updates.py +0 -0
  30. {casaconfig-1.0.1 → casaconfig-1.0.3}/casaconfig/private/do_pull_data.py +0 -0
  31. {casaconfig-1.0.1 → casaconfig-1.0.3}/casaconfig/private/get_argparser.py +0 -0
  32. {casaconfig-1.0.1 → casaconfig-1.0.3}/casaconfig/private/get_config.py +0 -0
  33. {casaconfig-1.0.1 → casaconfig-1.0.3}/casaconfig/private/get_data_info.py +0 -0
  34. {casaconfig-1.0.1 → casaconfig-1.0.3}/casaconfig/private/io_redirect.py +0 -0
  35. {casaconfig-1.0.1 → casaconfig-1.0.3}/casaconfig/private/print_log_messages.py +0 -0
  36. {casaconfig-1.0.1 → casaconfig-1.0.3}/casaconfig/private/read_readme.py +0 -0
  37. {casaconfig-1.0.1 → casaconfig-1.0.3}/casaconfig/private/set_casacore_path.py +0 -0
  38. {casaconfig-1.0.1 → casaconfig-1.0.3}/casaconfig/private/summary.py +0 -0
  39. {casaconfig-1.0.1 → casaconfig-1.0.3}/casaconfig/private/update_all.py +0 -0
  40. {casaconfig-1.0.1 → casaconfig-1.0.3}/casaconfig.egg-info/dependency_links.txt +0 -0
  41. {casaconfig-1.0.1 → casaconfig-1.0.3}/casaconfig.egg-info/requires.txt +0 -0
  42. {casaconfig-1.0.1 → casaconfig-1.0.3}/setup.cfg +0 -0
@@ -0,0 +1,292 @@
1
+ Metadata-Version: 2.2
2
+ Name: casaconfig
3
+ Version: 1.0.3
4
+ Summary: CASA Operational Configuration Package
5
+ Author-email: National Radio Astronomy Observatory <casa-feedback@nrao.edu>
6
+ License: Apache License
7
+ Version 2.0, January 2004
8
+ http://www.apache.org/licenses/
9
+
10
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
11
+
12
+ 1. Definitions.
13
+
14
+ "License" shall mean the terms and conditions for use, reproduction,
15
+ and distribution as defined by Sections 1 through 9 of this document.
16
+
17
+ "Licensor" shall mean the copyright owner or entity authorized by
18
+ the copyright owner that is granting the License.
19
+
20
+ "Legal Entity" shall mean the union of the acting entity and all
21
+ other entities that control, are controlled by, or are under common
22
+ control with that entity. For the purposes of this definition,
23
+ "control" means (i) the power, direct or indirect, to cause the
24
+ direction or management of such entity, whether by contract or
25
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
26
+ outstanding shares, or (iii) beneficial ownership of such entity.
27
+
28
+ "You" (or "Your") shall mean an individual or Legal Entity
29
+ exercising permissions granted by this License.
30
+
31
+ "Source" form shall mean the preferred form for making modifications,
32
+ including but not limited to software source code, documentation
33
+ source, and configuration files.
34
+
35
+ "Object" form shall mean any form resulting from mechanical
36
+ transformation or translation of a Source form, including but
37
+ not limited to compiled object code, generated documentation,
38
+ and conversions to other media types.
39
+
40
+ "Work" shall mean the work of authorship, whether in Source or
41
+ Object form, made available under the License, as indicated by a
42
+ copyright notice that is included in or attached to the work
43
+ (an example is provided in the Appendix below).
44
+
45
+ "Derivative Works" shall mean any work, whether in Source or Object
46
+ form, that is based on (or derived from) the Work and for which the
47
+ editorial revisions, annotations, elaborations, or other modifications
48
+ represent, as a whole, an original work of authorship. For the purposes
49
+ of this License, Derivative Works shall not include works that remain
50
+ separable from, or merely link (or bind by name) to the interfaces of,
51
+ the Work and Derivative Works thereof.
52
+
53
+ "Contribution" shall mean any work of authorship, including
54
+ the original version of the Work and any modifications or additions
55
+ to that Work or Derivative Works thereof, that is intentionally
56
+ submitted to Licensor for inclusion in the Work by the copyright owner
57
+ or by an individual or Legal Entity authorized to submit on behalf of
58
+ the copyright owner. For the purposes of this definition, "submitted"
59
+ means any form of electronic, verbal, or written communication sent
60
+ to the Licensor or its representatives, including but not limited to
61
+ communication on electronic mailing lists, source code control systems,
62
+ and issue tracking systems that are managed by, or on behalf of, the
63
+ Licensor for the purpose of discussing and improving the Work, but
64
+ excluding communication that is conspicuously marked or otherwise
65
+ designated in writing by the copyright owner as "Not a Contribution."
66
+
67
+ "Contributor" shall mean Licensor and any individual or Legal Entity
68
+ on behalf of whom a Contribution has been received by Licensor and
69
+ subsequently incorporated within the Work.
70
+
71
+ 2. Grant of Copyright License. Subject to the terms and conditions of
72
+ this License, each Contributor hereby grants to You a perpetual,
73
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
74
+ copyright license to reproduce, prepare Derivative Works of,
75
+ publicly display, publicly perform, sublicense, and distribute the
76
+ Work and such Derivative Works in Source or Object form.
77
+
78
+ 3. Grant of Patent License. Subject to the terms and conditions of
79
+ this License, each Contributor hereby grants to You a perpetual,
80
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
81
+ (except as stated in this section) patent license to make, have made,
82
+ use, offer to sell, sell, import, and otherwise transfer the Work,
83
+ where such license applies only to those patent claims licensable
84
+ by such Contributor that are necessarily infringed by their
85
+ Contribution(s) alone or by combination of their Contribution(s)
86
+ with the Work to which such Contribution(s) was submitted. If You
87
+ institute patent litigation against any entity (including a
88
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
89
+ or a Contribution incorporated within the Work constitutes direct
90
+ or contributory patent infringement, then any patent licenses
91
+ granted to You under this License for that Work shall terminate
92
+ as of the date such litigation is filed.
93
+
94
+ 4. Redistribution. You may reproduce and distribute copies of the
95
+ Work or Derivative Works thereof in any medium, with or without
96
+ modifications, and in Source or Object form, provided that You
97
+ meet the following conditions:
98
+
99
+ (a) You must give any other recipients of the Work or
100
+ Derivative Works a copy of this License; and
101
+
102
+ (b) You must cause any modified files to carry prominent notices
103
+ stating that You changed the files; and
104
+
105
+ (c) You must retain, in the Source form of any Derivative Works
106
+ that You distribute, all copyright, patent, trademark, and
107
+ attribution notices from the Source form of the Work,
108
+ excluding those notices that do not pertain to any part of
109
+ the Derivative Works; and
110
+
111
+ (d) If the Work includes a "NOTICE" text file as part of its
112
+ distribution, then any Derivative Works that You distribute must
113
+ include a readable copy of the attribution notices contained
114
+ within such NOTICE file, excluding those notices that do not
115
+ pertain to any part of the Derivative Works, in at least one
116
+ of the following places: within a NOTICE text file distributed
117
+ as part of the Derivative Works; within the Source form or
118
+ documentation, if provided along with the Derivative Works; or,
119
+ within a display generated by the Derivative Works, if and
120
+ wherever such third-party notices normally appear. The contents
121
+ of the NOTICE file are for informational purposes only and
122
+ do not modify the License. You may add Your own attribution
123
+ notices within Derivative Works that You distribute, alongside
124
+ or as an addendum to the NOTICE text from the Work, provided
125
+ that such additional attribution notices cannot be construed
126
+ as modifying the License.
127
+
128
+ You may add Your own copyright statement to Your modifications and
129
+ may provide additional or different license terms and conditions
130
+ for use, reproduction, or distribution of Your modifications, or
131
+ for any such Derivative Works as a whole, provided Your use,
132
+ reproduction, and distribution of the Work otherwise complies with
133
+ the conditions stated in this License.
134
+
135
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
136
+ any Contribution intentionally submitted for inclusion in the Work
137
+ by You to the Licensor shall be under the terms and conditions of
138
+ this License, without any additional terms or conditions.
139
+ Notwithstanding the above, nothing herein shall supersede or modify
140
+ the terms of any separate license agreement you may have executed
141
+ with Licensor regarding such Contributions.
142
+
143
+ 6. Trademarks. This License does not grant permission to use the trade
144
+ names, trademarks, service marks, or product names of the Licensor,
145
+ except as required for reasonable and customary use in describing the
146
+ origin of the Work and reproducing the content of the NOTICE file.
147
+
148
+ 7. Disclaimer of Warranty. Unless required by applicable law or
149
+ agreed to in writing, Licensor provides the Work (and each
150
+ Contributor provides its Contributions) on an "AS IS" BASIS,
151
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
152
+ implied, including, without limitation, any warranties or conditions
153
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
154
+ PARTICULAR PURPOSE. You are solely responsible for determining the
155
+ appropriateness of using or redistributing the Work and assume any
156
+ risks associated with Your exercise of permissions under this License.
157
+
158
+ 8. Limitation of Liability. In no event and under no legal theory,
159
+ whether in tort (including negligence), contract, or otherwise,
160
+ unless required by applicable law (such as deliberate and grossly
161
+ negligent acts) or agreed to in writing, shall any Contributor be
162
+ liable to You for damages, including any direct, indirect, special,
163
+ incidental, or consequential damages of any character arising as a
164
+ result of this License or out of the use or inability to use the
165
+ Work (including but not limited to damages for loss of goodwill,
166
+ work stoppage, computer failure or malfunction, or any and all
167
+ other commercial damages or losses), even if such Contributor
168
+ has been advised of the possibility of such damages.
169
+
170
+ 9. Accepting Warranty or Additional Liability. While redistributing
171
+ the Work or Derivative Works thereof, You may choose to offer,
172
+ and charge a fee for, acceptance of support, warranty, indemnity,
173
+ or other liability obligations and/or rights consistent with this
174
+ License. However, in accepting such obligations, You may act only
175
+ on Your own behalf and on Your sole responsibility, not on behalf
176
+ of any other Contributor, and only if You agree to indemnify,
177
+ defend, and hold each Contributor harmless for any liability
178
+ incurred by, or claims asserted against, such Contributor by reason
179
+ of your accepting any such warranty or additional liability.
180
+
181
+ END OF TERMS AND CONDITIONS
182
+
183
+ APPENDIX: How to apply the Apache License to your work.
184
+
185
+ To apply the Apache License to your work, attach the following
186
+ boilerplate notice, with the fields enclosed by brackets "[]"
187
+ replaced with your own identifying information. (Don't include
188
+ the brackets!) The text should be enclosed in the appropriate
189
+ comment syntax for the file format. We also recommend that a
190
+ file or class name and description of purpose be included on the
191
+ same "printed page" as the copyright notice for easier
192
+ identification within third-party archives.
193
+
194
+ Copyright 2020 AUI, Inc. Washington DC, USA
195
+
196
+ Licensed under the Apache License, Version 2.0 (the "License");
197
+ you may not use this file except in compliance with the License.
198
+ You may obtain a copy of the License at
199
+
200
+ http://www.apache.org/licenses/LICENSE-2.0
201
+
202
+ Unless required by applicable law or agreed to in writing, software
203
+ distributed under the License is distributed on an "AS IS" BASIS,
204
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
205
+ See the License for the specific language governing permissions and
206
+ limitations under the License.
207
+
208
+ Project-URL: Homepage, https://casa.nrao.edu/
209
+ Project-URL: Documentation, https://casadocs.readthedocs.io/
210
+ Project-URL: Repository, https://github.com/casangi/casaconfig.git
211
+ Requires-Python: >=3.8
212
+ Description-Content-Type: text/markdown
213
+ License-File: LICENSE
214
+ Requires-Dist: certifi>=2023.5.7
215
+
216
+ # casaconfig
217
+ Runtime data necessary for CASA operation.
218
+
219
+ - [latest casaconfig API on casadocs](https://casadocs.readthedocs.io/en/latest/api/casaconfig.html)
220
+ - [stable casaconfig API on casadocs](https://casadocs.readthedocs.io/en/stable/api/casaconfig.html)
221
+
222
+
223
+ ## Release Instructions
224
+ 1. Create a release branch with a version name (ie v1.6.2)
225
+ 2. Ensure the version number in pyproject.toml on the branch is set correctly
226
+ 3. Create a tag of the release branch (ie v1.6.2-1)
227
+ 4. Github Action runs automatically to publish a pip package to pypi
228
+
229
+ ## Installation
230
+
231
+ ```
232
+ $: pip install casaconfig
233
+ ```
234
+
235
+ ## Usage
236
+
237
+ See the casaconfig API documentation on casadocs (links above).
238
+
239
+ Also see the External Data section of casadocs for additional details
240
+
241
+ - [latext External Data section on casadocs](https://casadocs.readthedocs.io/en/latest/notebooks/external-data.html)
242
+ - [stable External Data section on casadocs](https://casadocs.readthedocs.io/en/latest/notebooks/external-data.html)
243
+
244
+ ## Developers Instructions
245
+ 1. every push to the casaconfig repository will push a new wheel to [test pypi](https://test.pypi.org/project/casaconfig/#history)
246
+ 2. the version in pyproject.toml must be updated before each push so that the wheel has a unique name (e.g. "1.2.3dev2", where "dev?" could be incremented during development; see the [specification](https://packaging.python.org/en/latest/specifications/version-specifiers/#version-specifiers) for more information about valid version signifiers)
247
+ 3. When testing with a casatools build, "pip install" the development casaconfig wheel before running any tests - it may be installed before casatools is installed or after since the casatools build does not depend on casasconfig (uninstall any already installed casaconfig if necessary).
248
+ 4. For release, follow the above instructions.
249
+
250
+ Wheels can be built locally following the same process used by the CI actions. To install the build-system dependencies as defined in pyproject.toml and then generate a source distribution and wheel:
251
+ ```
252
+ python3 -m pip install build setuptools --user
253
+ python3 -m build
254
+ ```
255
+ This will create:
256
+ ```
257
+ casaconfig.egg-info
258
+ ├── PKG-INFO
259
+ ├── SOURCES.txt
260
+ ├── dependency_links.txt
261
+ ├── requires.txt
262
+ └── top_level.txt
263
+ dist
264
+ ├── casaconfig-[VERSION]-py3-none-any.whl
265
+ └── casaconfig-[VERSION].tar.gz
266
+ ```
267
+
268
+ ### Setting up CASA branches for casaconfig development
269
+
270
+ The casaconfig build process publishes test wheels to test.pypi.org
271
+
272
+ In order to test these with Casa packages, two changes are needed in the casa6 repository branch.
273
+
274
+ 1) Add a line to casa6/build.conf with the appropriate wheel version. For example:
275
+
276
+ ```
277
+ casaconfig==1.0.3.dev2
278
+ ```
279
+ 2) Add the following line with the apppropriate branch name to casa6/casatools/setup.py
280
+
281
+ ```
282
+ META_DATA["install_requires"] = "casaconfig@git+https://github.com/casangi/casaconfig@CAS-14512"
283
+ ```
284
+
285
+ This adds the casaconfig branch as a casatools install time dependency. It will not use the wheel, but rather build the branch in place. This is required in order to avoid adding test.pypi.org as a pip extra-index-url, which might cause other development packages to be installed inadvertently. Note that casaconfig dependency is typically defined in setup.cfg, but the syntax above does not work with setup.cfg.
286
+
287
+
288
+ ### Preparing the casa6 branch for merge
289
+
290
+ 1) Merge the casaconfig branch to main and create a wheel
291
+ 2) Update casa6/build.conf to use that wheel
292
+ 3) Comment out the extra "install_requires" line from setup.py
@@ -0,0 +1,77 @@
1
+ # casaconfig
2
+ Runtime data necessary for CASA operation.
3
+
4
+ - [latest casaconfig API on casadocs](https://casadocs.readthedocs.io/en/latest/api/casaconfig.html)
5
+ - [stable casaconfig API on casadocs](https://casadocs.readthedocs.io/en/stable/api/casaconfig.html)
6
+
7
+
8
+ ## Release Instructions
9
+ 1. Create a release branch with a version name (ie v1.6.2)
10
+ 2. Ensure the version number in pyproject.toml on the branch is set correctly
11
+ 3. Create a tag of the release branch (ie v1.6.2-1)
12
+ 4. Github Action runs automatically to publish a pip package to pypi
13
+
14
+ ## Installation
15
+
16
+ ```
17
+ $: pip install casaconfig
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ See the casaconfig API documentation on casadocs (links above).
23
+
24
+ Also see the External Data section of casadocs for additional details
25
+
26
+ - [latext External Data section on casadocs](https://casadocs.readthedocs.io/en/latest/notebooks/external-data.html)
27
+ - [stable External Data section on casadocs](https://casadocs.readthedocs.io/en/latest/notebooks/external-data.html)
28
+
29
+ ## Developers Instructions
30
+ 1. every push to the casaconfig repository will push a new wheel to [test pypi](https://test.pypi.org/project/casaconfig/#history)
31
+ 2. the version in pyproject.toml must be updated before each push so that the wheel has a unique name (e.g. "1.2.3dev2", where "dev?" could be incremented during development; see the [specification](https://packaging.python.org/en/latest/specifications/version-specifiers/#version-specifiers) for more information about valid version signifiers)
32
+ 3. When testing with a casatools build, "pip install" the development casaconfig wheel before running any tests - it may be installed before casatools is installed or after since the casatools build does not depend on casasconfig (uninstall any already installed casaconfig if necessary).
33
+ 4. For release, follow the above instructions.
34
+
35
+ Wheels can be built locally following the same process used by the CI actions. To install the build-system dependencies as defined in pyproject.toml and then generate a source distribution and wheel:
36
+ ```
37
+ python3 -m pip install build setuptools --user
38
+ python3 -m build
39
+ ```
40
+ This will create:
41
+ ```
42
+ casaconfig.egg-info
43
+ ├── PKG-INFO
44
+ ├── SOURCES.txt
45
+ ├── dependency_links.txt
46
+ ├── requires.txt
47
+ └── top_level.txt
48
+ dist
49
+ ├── casaconfig-[VERSION]-py3-none-any.whl
50
+ └── casaconfig-[VERSION].tar.gz
51
+ ```
52
+
53
+ ### Setting up CASA branches for casaconfig development
54
+
55
+ The casaconfig build process publishes test wheels to test.pypi.org
56
+
57
+ In order to test these with Casa packages, two changes are needed in the casa6 repository branch.
58
+
59
+ 1) Add a line to casa6/build.conf with the appropriate wheel version. For example:
60
+
61
+ ```
62
+ casaconfig==1.0.3.dev2
63
+ ```
64
+ 2) Add the following line with the apppropriate branch name to casa6/casatools/setup.py
65
+
66
+ ```
67
+ META_DATA["install_requires"] = "casaconfig@git+https://github.com/casangi/casaconfig@CAS-14512"
68
+ ```
69
+
70
+ This adds the casaconfig branch as a casatools install time dependency. It will not use the wheel, but rather build the branch in place. This is required in order to avoid adding test.pypi.org as a pip extra-index-url, which might cause other development packages to be installed inadvertently. Note that casaconfig dependency is typically defined in setup.cfg, but the syntax above does not work with setup.cfg.
71
+
72
+
73
+ ### Preparing the casa6 branch for merge
74
+
75
+ 1) Merge the casaconfig branch to main and create a wheel
76
+ 2) Update casa6/build.conf to use that wheel
77
+ 3) Comment out the extra "install_requires" line from setup.py
@@ -131,6 +131,10 @@ except casaconfig.RemoteError as exc:
131
131
  print("This is likely due to no network connection or bad connectivity to a remote site, wait and try again")
132
132
  sys.exit(1)
133
133
 
134
+ except casaconfig.NoNetwork as exc:
135
+ print("No network seen, can not continue.")
136
+ sys.exit(1)
137
+
134
138
  except casaconfig.BadLock as exc:
135
139
  # the output produced by the update functions is sufficient, just re-echo the exception text itself
136
140
  print(str(exc))
@@ -36,7 +36,12 @@ class RemoteError(Exception):
36
36
 
37
37
  class NotWritable(Exception):
38
38
  """Raised when the path is not writable by the user"""
39
+ pass
39
40
 
40
41
  class UnsetMeasurespath(Exception):
41
42
  """Raised when a path argument is None"""
42
43
  pass
44
+
45
+ class NoNetwork(Exception):
46
+ """Raised when there is no network connection."""
47
+ pass
@@ -36,7 +36,8 @@ def data_available():
36
36
  list - version names returned as list of strings
37
37
 
38
38
  Raises
39
- - casaconfig.RemoteError - Raised when there is an error fetching some remote content
39
+ - casaconfig.NoNetwork - Raised where there is no network seen, can not continue
40
+ - casaconfig.RemoteError - Raised when there is an error fetching some remote content for some reason other than no network
40
41
  - Exception - Unexpected exception while getting list of available casarundata versions
41
42
 
42
43
  """
@@ -48,6 +49,12 @@ def data_available():
48
49
  import certifi
49
50
 
50
51
  from casaconfig import RemoteError
52
+ from casaconfig import NoNetwork
53
+
54
+ from .have_network import have_network
55
+
56
+ if not have_network():
57
+ raise NoNetwork("No network, can not find the list of available data.")
51
58
 
52
59
  class LinkParser(html.parser.HTMLParser):
53
60
  def reset(self):
@@ -17,7 +17,7 @@ this module will be included in the api
17
17
 
18
18
  def data_update(path=None, version=None, force=False, logger=None, auto_update_rules=False, verbose=None):
19
19
  """
20
- Check for updates to the installed casarundata and install the update or change to
20
+ Check for updates to the installed casarundata and install the update or change to
21
21
  the requested version when appropriate.
22
22
 
23
23
  The verbose argument controls the level of information provided when this function when the data
@@ -26,19 +26,19 @@ def data_update(path=None, version=None, force=False, logger=None, auto_update_r
26
26
 
27
27
  The path must contain a previously installed version of casarundata.
28
28
  Use pull_data to install casarundata into a new path (empty or does not exist).
29
-
29
+
30
30
  If path is None then config.measurespath is used.
31
31
 
32
- If the version is None (the default) then the most recent version returned by
32
+ If the version is None (the default) then the most recent version returned by
33
33
  data_available is used.
34
34
 
35
- If version is "release" then the version associated with the release in
35
+ If version is "release" then the version associated with the release in
36
36
  the dictionary returned by get_data_info is used. If there is no release
37
- version information available to casaconfig then an error message is printed
37
+ version information available to casaconfig then an error message is printed
38
38
  and nothing is updated. Release version information is only available in
39
39
  monolithic CASA installations.
40
40
 
41
- If a specific version is not requested (the default) and a check for the
41
+ If a specific version is not requested (the default) and a check for the
42
42
  versions available for installation at path has been done within the past
43
43
  24 hours then this function does nothing even if there is a more
44
44
  recent version available from the CASA server unless force is True.
@@ -47,7 +47,7 @@ def data_update(path=None, version=None, force=False, logger=None, auto_update_r
47
47
  now) is installed even if that version is already installed or a check for the
48
48
  latest version has been done within the past 24 hours.
49
49
 
50
- A text file (readme.txt at path) records the version string, the date
50
+ A text file (readme.txt at path) records the version string, the date
51
51
  when that version was installed in path, and the files installed into path. That file
52
52
  must already exist in path in order to use this function. Use pull_data to install
53
53
  casarundata into a new location.
@@ -57,31 +57,31 @@ def data_update(path=None, version=None, force=False, logger=None, auto_update_r
57
57
  data_auto_update is True. Automatic updating happens during casatools initialization
58
58
  so that the updated casarundata and measures are in place before any tool needs to use them.
59
59
 
60
- If an update is to be installed the previously installed files, as listed in the
61
- readme.txt file at path, are removed before the contents of the version
60
+ If an update is to be installed the previously installed files, as listed in the
61
+ readme.txt file at path, are removed before the contents of the version
62
62
  being installed are unpacked. If the measures contents of path have been updated since
63
63
  the previously installed version of casarundata then those updates will also be removed
64
64
  by this data update while preparing to install the requested version of casarundata (which
65
- includes a copy of the measures data that is likely older than today). A data update is
66
- typically followed by a measures_update to ensure that the most recent measures data
65
+ includes a copy of the measures data that is likely older than today). A data update is
66
+ typically followed by a measures_update to ensure that the most recent measures data
67
67
  are installed.
68
68
 
69
69
  A file lock is used to prevent more that one data update (pull_data, measures_update,
70
- or data_update) from updating any files in path at the same time. When locked, the
70
+ or data_update) from updating any files in path at the same time. When locked, the
71
71
  lock file (data_update.lock in path) contains information about the process that
72
72
  has the lock. When data_update gets the lock it checks the readme.txt file in path
73
- to make sure that an update is still necessary (if force is True then an update
73
+ to make sure that an update is still necessary (if force is True then an update
74
74
  always happens). If the lock file is not empty then a previous update of path (pull_data,
75
75
  data_update, or measures_update) did not exit as expected or is still in process (via a
76
- separate instance of CASA) and the contents of path may be suspect. In that case,
77
- an error will be reported and nothing will be updated. The lock file can be checked to
78
- see the details of when that file was locked. The lock file can be removed and data_update
76
+ separate instance of CASA) and the contents of path may be suspect. In that case,
77
+ an error will be reported and nothing will be updated. The lock file can be checked to
78
+ see the details of when that file was locked. The lock file can be removed and data_update
79
79
  can be tried again. It may be safest in that case to remove path completely or use a
80
80
  different path and use pull_data to install a fresh copy of the desired version.
81
81
 
82
- Some of the tables installed by data_update are only read when casatools starts. Use of
83
- data_update except during CASA startup by the auto update proess should typically be
84
- followed by a restart of CASA so that any changes are seen by the tools and tasks that
82
+ Some of the tables installed by data_update are only read when casatools starts. Use of
83
+ data_update except during CASA startup by the auto update proess should typically be
84
+ followed by a restart of CASA so that any changes are seen by the tools and tasks that
85
85
  use this data.
86
86
 
87
87
  **Note:** data_update requires that the expected readme.txt file already exists at the top-level
@@ -101,10 +101,10 @@ def data_update(path=None, version=None, force=False, logger=None, auto_update_r
101
101
  - logger (casatools.logsink=None) - Instance of the casalogger to use for writing messages. Default None writes messages to the terminal.
102
102
  - auto_update_rules (bool=False) - If True then the user must be the owner of path, version must be None, and force must be False.
103
103
  - verbose (int) - Level of output, 0 is none, 1 is to logger, 2 is to logger and terminal, defaults to casaconfig_verbose in the config dictionary.
104
-
104
+
105
105
  Returns
106
106
  None
107
-
107
+
108
108
  Raises
109
109
  - casaconfig.AutoUpdatesNotAllowed - raised when path does not exist as a directory or is not owned by the user
110
110
  - casaconfig.BadLock - raised when the lock file was not empty when an attempt was made to obtain the lock
@@ -167,7 +167,7 @@ def data_update(path=None, version=None, force=False, logger=None, auto_update_r
167
167
  # path must be writable with execute bit set
168
168
  if (not os.access(path, os.W_OK | os.X_OK)) :
169
169
  raise NotWritable('data_update: No permission to write to %s, cannot update.' % path)
170
-
170
+
171
171
  # try and digest the readme file
172
172
 
173
173
  installed_files = []
@@ -177,7 +177,7 @@ def data_update(path=None, version=None, force=False, logger=None, auto_update_r
177
177
 
178
178
  # already checked that path is OK, type is OK here, no need to trap for exceptions here
179
179
  dataReadmeInfo = get_data_info(path, logger, type='casarundata')
180
-
180
+
181
181
  if dataReadmeInfo is None or dataReadmeInfo['version'] == 'invalid':
182
182
  msgs = []
183
183
  msgs.append('The readme.txt file at path could not be read as expected')
@@ -262,7 +262,7 @@ def data_update(path=None, version=None, force=False, logger=None, auto_update_r
262
262
  else:
263
263
  if verbose > 0:
264
264
  print_log_messages('Requested casarundata version is already installed in %s, %s' % (path, currentVersion), logger, verbose=verbose)
265
-
265
+
266
266
  # no lock has been set yet, safe to simply return here
267
267
  return
268
268
 
@@ -307,7 +307,7 @@ def data_update(path=None, version=None, force=False, logger=None, auto_update_r
307
307
  # always verbose here because the lock file is in use
308
308
  print_log_messages('requested version is already installed.', logger)
309
309
  do_update = False
310
-
310
+
311
311
  if do_update:
312
312
  # update is still on, check the manifest
313
313
  if len(installed_files) == 0:
@@ -330,7 +330,7 @@ def data_update(path=None, version=None, force=False, logger=None, auto_update_r
330
330
 
331
331
  except BadLock as exc:
332
332
  # the path is known to exist so this means that the lock file was not empty and it's not locked
333
- msgs = str(exc)
333
+ msgs = [str(exc)]
334
334
  msgs.append('data_update: the lock file at %s is not empty.' % path)
335
335
  msgs.append('A previous attempt to update path may have failed or exited prematurely.')
336
336
  msgs.append('Remove the lock file and set force to True with the desired version (default to most recent).')
@@ -341,7 +341,7 @@ def data_update(path=None, version=None, force=False, logger=None, auto_update_r
341
341
 
342
342
  except BadReadme as exc:
343
343
  # something is wrong in the readme after an update was triggered, this shouldn't happen, print more context reraise this
344
- msgs = str(exc)
344
+ msgs = [str(exc)]
345
345
  msgs.append('This should not happen unless multiple sessions are trying to update data at the same time and one experienced problems or was done out of sequence')
346
346
  msgs.append('Check for other updates in progress or choose a different path or clear out this path and try again using pull_data or update_all')
347
347
  print_log_messages(msgs, logger, True)
@@ -360,5 +360,5 @@ def data_update(path=None, version=None, force=False, logger=None, auto_update_r
360
360
  if clean_lock:
361
361
  lock_fd.truncate(0)
362
362
  lock_fd.close()
363
-
363
+
364
364
  return
@@ -29,6 +29,9 @@ def get_data_lock(path, fn_name):
29
29
 
30
30
  This function is intended for internal casaconfig use.
31
31
 
32
+ If there is not network (have_network returns False) then the lock file is not
33
+ set or initialized and a NoNetwork exception is raised.
34
+
32
35
  Parameters
33
36
  - path (str) - The location where 'data_update.log' is to be found.
34
37
  - fn_name (str) - A string giving the name of the calling function to be recorded in the lock file.
@@ -37,6 +40,7 @@ def get_data_lock(path, fn_name):
37
40
  - the open file descriptor holding the lock. Close this file descriptor to release the lock.
38
41
 
39
42
  Raises:
43
+ - casaconfig.NoNetwork - raised wheren there is no network, nothing can be downloaded so nothing should be locked.
40
44
  - casaconfig.BadLock - raised when the path to the lock file does not exist or the lock file is not empty as found
41
45
  - Exception - an unexpected exception was seen while writing the lock information to the file
42
46
 
@@ -48,6 +52,11 @@ def get_data_lock(path, fn_name):
48
52
  from datetime import datetime
49
53
 
50
54
  from casaconfig import BadLock
55
+ from casaconfig import NoNetwork
56
+ from .have_network import have_network
57
+
58
+ if not have_network():
59
+ raise NoNetwork("No network, lock file has not been set, unable to continue.")
51
60
 
52
61
  if not os.path.exists(path):
53
62
  raise BadLock("path to contain lock file does not exist : %s" % path)
@@ -0,0 +1,40 @@
1
+ # Copyright 2025 AUI, Inc. Washington DC, USA
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ import urllib.request
16
+ import urllib.error
17
+
18
+ def have_network():
19
+ """
20
+ check to see if an active network with general internet connectivity
21
+ is available. returns True if we have internet connectivity and
22
+ False if we do not.
23
+ """
24
+ ###
25
+ ### see: https://stackoverflow.com/questions/50558000/test-internet-connection-for-python3
26
+ ###
27
+ ### copied from in casagui/utils/__init__.py
28
+ ###
29
+ try:
30
+ with urllib.request.urlopen('http://clients3.google.com/generate_204') as response:
31
+ return response.status == 204
32
+ except urllib.error.HTTPError:
33
+ ### http error
34
+ return False
35
+ except urllib.error.ContentTooShortError:
36
+ return False
37
+ except urllib.error.URLError:
38
+ return False
39
+ except Exception:
40
+ return False