-
Notifications
You must be signed in to change notification settings - Fork 0
/
about.py
69 lines (57 loc) · 2.22 KB
/
about.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# SPDX-FileCopyrightText: 2024 Matthew J. Milner <[email protected]>
# SPDX-License-Identifier: BSD-3-Clause
import argparse
import json
import logging
import subprocess
import sys
from support import easyxtb
logger = logging.getLogger(__name__)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--debug", action="store_true")
parser.add_argument("--print-options", action="store_true")
parser.add_argument("--run-command", action="store_true")
parser.add_argument("--display-name", action="store_true")
parser.add_argument("--lang", nargs="?", default="en")
parser.add_argument("--menu-path", action="store_true")
args = parser.parse_args()
if args.print_options:
options = {}
print(json.dumps(options))
if args.display_name:
print("About avo_xtb")
if args.menu_path:
print("Extensions|Semi-empirical (xtb){10}")
if args.run_command:
# Read input from Avogadro
avo_input = json.loads(sys.stdin.read())
output = avo_input.copy()
if easyxtb.XTB_BIN:
xtb_version = subprocess.run(
[str(easyxtb.XTB_BIN), "--version"],
encoding="utf-8",
capture_output=True,
).stdout.splitlines()[-2].strip()
else:
xtb_version = "No xtb binary found"
if easyxtb.CREST_BIN:
crest_version = subprocess.run(
[str(easyxtb.CREST_BIN), "--version"],
encoding="utf-8",
capture_output=True,
).stdout.splitlines()[-4].strip()
else:
crest_version = "No CREST binary found"
# Do nothing to data other than add message with version and path info
output["message"] = (
"avo_xtb plugin\n"
+ f"easyxtb version: {easyxtb.conf.easyxtb_VERSION}\n"
+ f"xtb version: {xtb_version}\n"
+ f"xtb path: {easyxtb.XTB_BIN}\n"
+ f"CREST version: {crest_version}\n"
+ f"CREST path: {easyxtb.CREST_BIN}"
)
# Pass back to Avogadro
print(json.dumps(output))
logger.debug(f"The following dictionary was passed back to Avogadro: {output}")