Skip to content

Commit 78937fa

Browse files
authored
Merge pull request #40 from nemocrys:arvedes/issue39
Catch exception with missing git
2 parents 9050026 + d5159fd commit 78937fa

File tree

2 files changed

+25
-13
lines changed

2 files changed

+25
-13
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,13 @@ For the discord bot there are the following additional dependencies:
148148

149149
- pyoptris and dependencies installed according to https://github.com/nemocrys/pyOptris/blob/dev/README.md
150150

151+
### Logging of own version
152+
153+
- git (will be called as a subprocess if available)
154+
151155
## NOMAD support
152156

153-
NOMAD support and the option to uploade measurement data to [NOMAD](https://nomad-lab.eu/) is under implementation. Currently, various yaml-files containing a machine-readable description of the measurement data are generated.
157+
NOMAD support and the option to upload measurement data to [NOMAD](https://nomad-lab.eu/) is under implementation. Currently, various yaml-files containing a machine-readable description of the measurement data are generated.
154158

155159
## Documentation
156160

multilog/main.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -314,13 +314,17 @@ def write_nomad_file(self):
314314
with open("./multilog/nomad/archive_template_main.yml") as f:
315315
nomad_dict = yaml.safe_load(f)
316316
data = nomad_dict.pop("data")
317-
multilog_version = (
318-
subprocess.check_output(
319-
["git", "describe", "--tags", "--dirty", "--always"]
317+
try:
318+
multilog_version = (
319+
subprocess.check_output(
320+
["git", "describe", "--tags", "--dirty", "--always"]
321+
)
322+
.strip()
323+
.decode("utf-8")
320324
)
321-
.strip()
322-
.decode("utf-8")
323-
)
325+
except FileNotFoundError:
326+
logger.warning("Unable to determine multilog version.", exc_info=True)
327+
multilog_version = "unknown"
324328
data["timestamp"] = datetime.datetime.now(datetime.timezone.utc).astimezone().isoformat(timespec='milliseconds').replace('T', ' ')
325329
data["tasks"][0].update(
326330
{
@@ -357,13 +361,17 @@ def write_metadata(self):
357361
"""Write a csv file with information about multilog version,
358362
python version and operating system.
359363
"""
360-
multilog_version = (
361-
subprocess.check_output(
362-
["git", "describe", "--tags", "--dirty", "--always"]
364+
try:
365+
multilog_version = (
366+
subprocess.check_output(
367+
["git", "describe", "--tags", "--dirty", "--always"]
368+
)
369+
.strip()
370+
.decode("utf-8")
363371
)
364-
.strip()
365-
.decode("utf-8")
366-
)
372+
except FileNotFoundError:
373+
logger.warning("Unable to determine multilog version.", exc_info=True)
374+
multilog_version = "unknown"
367375
metadata = f"multilog version,python version,system information,\n"
368376
metadata += f"{multilog_version},{platform.python_version()},{str(platform.uname()).replace(',',';')},\n"
369377
with open(f"{self.directory}/config.yml", "w", encoding="utf-8") as f:

0 commit comments

Comments
 (0)