psdi-data-conversion 0.1.0__py3-none-any.whl → 0.1.2__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.
- psdi_data_conversion/app.py +56 -16
- psdi_data_conversion/templates/index.htm +2 -2
- {psdi_data_conversion-0.1.0.dist-info → psdi_data_conversion-0.1.2.dist-info}/METADATA +1 -1
- {psdi_data_conversion-0.1.0.dist-info → psdi_data_conversion-0.1.2.dist-info}/RECORD +7 -7
- {psdi_data_conversion-0.1.0.dist-info → psdi_data_conversion-0.1.2.dist-info}/WHEEL +0 -0
- {psdi_data_conversion-0.1.0.dist-info → psdi_data_conversion-0.1.2.dist-info}/entry_points.txt +0 -0
- {psdi_data_conversion-0.1.0.dist-info → psdi_data_conversion-0.1.2.dist-info}/licenses/LICENSE +0 -0
psdi_data_conversion/app.py
CHANGED
@@ -6,7 +6,6 @@ This script acts as a server for the PSDI Data Conversion Service website.
|
|
6
6
|
"""
|
7
7
|
|
8
8
|
import json
|
9
|
-
from multiprocessing import Lock
|
10
9
|
import os
|
11
10
|
import sys
|
12
11
|
from argparse import ArgumentParser
|
@@ -14,6 +13,7 @@ from collections.abc import Callable
|
|
14
13
|
from datetime import datetime
|
15
14
|
from functools import wraps
|
16
15
|
from hashlib import md5
|
16
|
+
from multiprocessing import Lock
|
17
17
|
from subprocess import run
|
18
18
|
from traceback import format_exc
|
19
19
|
from typing import Any
|
@@ -30,7 +30,9 @@ from psdi_data_conversion.database import get_format_info
|
|
30
30
|
from psdi_data_conversion.file_io import split_archive_ext
|
31
31
|
from psdi_data_conversion.main import print_wrap
|
32
32
|
|
33
|
-
# Env var for the SHA of the latest commit
|
33
|
+
# Env var for the tag and SHA of the latest commit
|
34
|
+
TAG_EV = "TAG"
|
35
|
+
TAG_SHA_EV = "TAG_SHA"
|
34
36
|
SHA_EV = "SHA"
|
35
37
|
|
36
38
|
# Env var for whether this is a production release or development
|
@@ -130,42 +132,80 @@ def limit_upload_size():
|
|
130
132
|
limit_upload_size()
|
131
133
|
|
132
134
|
|
133
|
-
def
|
135
|
+
def get_tag_and_sha() -> str:
|
134
136
|
"""Get the SHA of the last commit
|
135
137
|
"""
|
136
138
|
|
137
|
-
#
|
138
|
-
|
139
|
-
if
|
140
|
-
|
139
|
+
# Get the tag of the latest commit
|
140
|
+
ev_tag = os.environ.get(TAG_EV)
|
141
|
+
if ev_tag:
|
142
|
+
tag = ev_tag
|
143
|
+
try:
|
144
|
+
# This bash command calls `git tag` to get a sorted list of tags, with the most recent at the top, then uses
|
145
|
+
# `head` to trim it to one line
|
146
|
+
cmd = "git tag --sort -version:refname | head -n 1"
|
147
|
+
|
148
|
+
out_bytes = run(cmd, shell=True, capture_output=True).stdout
|
149
|
+
tag = str(out_bytes.decode()).strip()
|
150
|
+
|
151
|
+
except Exception:
|
152
|
+
print("ERROR: Could not determine most recent tag. Error was:\n" + format_exc(),
|
153
|
+
file=sys.stderr)
|
154
|
+
tag = ""
|
141
155
|
|
156
|
+
# Get the SHA associated with this tag
|
157
|
+
ev_tag_sha = os.environ.get(TAG_SHA_EV)
|
158
|
+
if ev_tag_sha:
|
159
|
+
tag: str | None = ev_tag_sha
|
142
160
|
try:
|
143
|
-
|
144
|
-
# uses `gawk` to get just the second word of this line, which is the SHA of this commit
|
145
|
-
cmd = "git log -n 1 | head -n 1 | gawk '{print($2)}'"
|
161
|
+
cmd = f"git show {tag}" + " | head -n 1 | gawk '{print($2)}'"
|
146
162
|
|
147
163
|
out_bytes = run(cmd, shell=True, capture_output=True).stdout
|
148
|
-
|
164
|
+
tag_sha = str(out_bytes.decode()).strip()
|
149
165
|
|
150
166
|
except Exception:
|
151
|
-
print("ERROR: Could not determine SHA
|
167
|
+
print("ERROR: Could not determine SHA for most recent tag. Error was:\n" + format_exc(),
|
152
168
|
file=sys.stderr)
|
153
|
-
|
169
|
+
tag_sha = None
|
170
|
+
|
171
|
+
# First check if the SHA is provided through an environmental variable
|
172
|
+
ev_sha = os.environ.get(SHA_EV)
|
173
|
+
if ev_sha:
|
174
|
+
sha = ev_sha
|
175
|
+
else:
|
176
|
+
try:
|
177
|
+
# This bash command calls `git log` to get info on the last commit, uses `head` to trim it to one line, then
|
178
|
+
# uses `gawk` to get just the second word of this line, which is the SHA of this commit
|
179
|
+
cmd = "git log -n 1 | head -n 1 | gawk '{print($2)}'"
|
180
|
+
|
181
|
+
out_bytes = run(cmd, shell=True, capture_output=True).stdout
|
182
|
+
sha = str(out_bytes.decode()).strip()
|
183
|
+
|
184
|
+
except Exception:
|
185
|
+
print("ERROR: Could not determine SHA of most recent commit. Error was:\n" + format_exc(),
|
186
|
+
file=sys.stderr)
|
187
|
+
sha = ""
|
188
|
+
|
189
|
+
# If the SHA of the tag is the same as the current SHA, we indicate this by returning a blank SHA
|
190
|
+
if tag_sha == sha:
|
191
|
+
sha = ""
|
154
192
|
|
155
|
-
return
|
193
|
+
return (tag, sha)
|
156
194
|
|
157
195
|
|
158
196
|
@app.route('/')
|
159
197
|
def website():
|
160
198
|
"""Return the web page along with the token
|
161
199
|
"""
|
200
|
+
tag, sha = get_tag_and_sha()
|
162
201
|
return render_template("index.htm",
|
163
202
|
token=token,
|
164
203
|
max_file_size=max_file_size,
|
165
204
|
max_file_size_ob=max_file_size_ob,
|
166
205
|
service_mode=service_mode,
|
167
206
|
production_mode=production_mode,
|
168
|
-
|
207
|
+
tag=tag,
|
208
|
+
sha=sha)
|
169
209
|
|
170
210
|
|
171
211
|
@app.route('/convert/', methods=['POST'])
|
@@ -273,7 +313,7 @@ def feedback():
|
|
273
313
|
|
274
314
|
# Write data in JSON format and send to stdout
|
275
315
|
logLock.acquire()
|
276
|
-
sys.stdout.write(f"{json.dumps(entry) +
|
316
|
+
sys.stdout.write(f"{json.dumps(entry) + '\n'}")
|
277
317
|
logLock.release()
|
278
318
|
|
279
319
|
return Response(status=201)
|
@@ -120,9 +120,9 @@
|
|
120
120
|
<div class="medGap"></div>
|
121
121
|
</div>
|
122
122
|
</form>
|
123
|
-
{% if
|
123
|
+
{% if tag %}
|
124
124
|
<div class="secondary prod-only">
|
125
|
-
<div class="max-width-box">SHA: {{ sha }}</div>
|
125
|
+
<div class="max-width-box">PSDI Data Conversion {{ tag }} {% if sha %} (SHA: {{ sha }}) {% endif %}</div>
|
126
126
|
</div>
|
127
127
|
{% endif %}
|
128
128
|
<script src="{{url_for('static', filename='/javascript/format.js')}}" type="module" language="JavaScript"></script>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: psdi_data_conversion
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.2
|
4
4
|
Summary: Chemistry file format conversion service, provided by PSDI
|
5
5
|
Project-URL: Homepage, https://data-conversion.psdi.ac.uk/
|
6
6
|
Project-URL: Documentation, https://psdi-uk.github.io/psdi-data-conversion/
|
@@ -1,5 +1,5 @@
|
|
1
1
|
psdi_data_conversion/__init__.py,sha256=urMsTqsTHTch1q4rMT9dgGnrvdPFMP9B8r-6Kr8H5sE,404
|
2
|
-
psdi_data_conversion/app.py,sha256=
|
2
|
+
psdi_data_conversion/app.py,sha256=s2Np_RcDGlouGNUq6qJI4R3MUV5ksBtl11DdqnxsOwY,17158
|
3
3
|
psdi_data_conversion/constants.py,sha256=Hq2OVbcSkcv6T87-YJlo1PVlr9ILlB4H3E9JYjzvCF4,7423
|
4
4
|
psdi_data_conversion/converter.py,sha256=Y77mqH2OKxf2YelphWDl82AKoRa-APle-l3e8wG_WZA,27315
|
5
5
|
psdi_data_conversion/database.py,sha256=XzKvtT-cFmKLWLo5OBB5CV_rGHuqEEuENNyZnbS39qE,56419
|
@@ -74,15 +74,15 @@ psdi_data_conversion/static/javascript/psdi-common.js,sha256=I0QqGQ7l_rA4KEfenQT
|
|
74
74
|
psdi_data_conversion/static/javascript/report.js,sha256=BHH5UOhXJtB6J_xk_y6woquNKt5W9hCrQapxKtGG1eA,12470
|
75
75
|
psdi_data_conversion/static/styles/format.css,sha256=PaQkUVxQfXI9nbJ-7YsN1tNIcLXfwXk8wJC-zht8nRA,3269
|
76
76
|
psdi_data_conversion/static/styles/psdi-common.css,sha256=09VY-lldoZCrohuqPKnd9fvDget5g9ybi6uh13pYeY0,17249
|
77
|
-
psdi_data_conversion/templates/index.htm,sha256=
|
77
|
+
psdi_data_conversion/templates/index.htm,sha256=Y1KlrBirqDPyleVl_Edgbm_jYMBYGnOEMdCzmDBJi3o,6842
|
78
78
|
psdi_data_conversion/testing/__init__.py,sha256=Xku7drtLTYLLPsd403eC0LIEa_iohVifyeyAITy2w7U,135
|
79
79
|
psdi_data_conversion/testing/constants.py,sha256=BtIafruSobZ9cFY0VW5Bu209eiftnN8b3ObouZBrFQU,521
|
80
80
|
psdi_data_conversion/testing/conversion_callbacks.py,sha256=ATR-_BsYCUN8KyOyUjfdWCELzySxLN5jOI0JyrQnmHQ,18858
|
81
81
|
psdi_data_conversion/testing/conversion_test_specs.py,sha256=8W97tI6dVbHE9BEW76dsKDlfsm5oTlrlntG--b0h8HU,26106
|
82
82
|
psdi_data_conversion/testing/gui.py,sha256=ul7ixYANIzmOG2ZNOZmQO6wsHmGHdiBGAlw-KuoN0j8,19085
|
83
83
|
psdi_data_conversion/testing/utils.py,sha256=YrFxjyiIx1seph0j7jCUgAVm6HvXY9QJjx0MvNJRbfw,26134
|
84
|
-
psdi_data_conversion-0.1.
|
85
|
-
psdi_data_conversion-0.1.
|
86
|
-
psdi_data_conversion-0.1.
|
87
|
-
psdi_data_conversion-0.1.
|
88
|
-
psdi_data_conversion-0.1.
|
84
|
+
psdi_data_conversion-0.1.2.dist-info/METADATA,sha256=rLiPpwWntHL1AfH8NrRqIKMkGsX6Lls7NdtKXQhrPhk,48108
|
85
|
+
psdi_data_conversion-0.1.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
86
|
+
psdi_data_conversion-0.1.2.dist-info/entry_points.txt,sha256=xL7XTzaPRr2E67WhOD1M1Q-76hB8ausQlnNiHzuZQPA,123
|
87
|
+
psdi_data_conversion-0.1.2.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
88
|
+
psdi_data_conversion-0.1.2.dist-info/RECORD,,
|
File without changes
|
{psdi_data_conversion-0.1.0.dist-info → psdi_data_conversion-0.1.2.dist-info}/entry_points.txt
RENAMED
File without changes
|
{psdi_data_conversion-0.1.0.dist-info → psdi_data_conversion-0.1.2.dist-info}/licenses/LICENSE
RENAMED
File without changes
|