File: check_mccode_version.py

package info (click to toggle)
python-mcstasscript 0.0.46%2Bgit20250402111921.bfa5a26-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,440 kB
  • sloc: python: 13,421; makefile: 14
file content (30 lines) | stat: -rw-r--r-- 867 bytes parent folder | download
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
import os
import subprocess

def check_mcstas_major_version(mcstas_bin_path):
    """
    Checks installed McStas version
    """
    mcstas_command = os.path.join(mcstas_bin_path, "mcstas")
    output = subprocess.check_output([mcstas_command, "-v"])

    output = output.decode("utf-8")
    output = output.split(" (", 1)[0]
    output = output.split("version", 1)[1]
    major_version = output.split(".", 1)[0]

    return int(major_version)

def check_mcxtrace_major_version(mcstas_bin_path):
    """
    Checks installed McXtrace version
    """
    mcstas_command = os.path.join(mcstas_bin_path, "mcxtrace")
    output = subprocess.check_output([mcstas_command, "-v"])

    output = output.decode("utf-8")
    output = output.split(" (", 1)[0]
    output = output.split("version", 1)[1]
    major_version = output.split(".", 1)[0]

    return int(major_version)