Skip to content

Commit

Permalink
Merge 1052daa into 721f3d6
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-janssen committed Jun 13, 2023
2 parents 721f3d6 + 1052daa commit 0f57e2d
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
1 change: 1 addition & 0 deletions pyiron_base/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from pyiron_base.jobs.job.extension.server.queuestatus import validate_que_request
from pyiron_base.state.settings import Settings
from pyiron_base.state.install import install_dialog
from pyiron_base.state.check import check_executables_status
from pyiron_base.jobs.datamining import PyironTable, TableJob
from pyiron_base.interfaces.object import HasDatabase, HasStorage, PyironObject
from pyiron_base.database.performance import get_database_statistics
Expand Down
70 changes: 70 additions & 0 deletions pyiron_base/state/check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import os
import stat
import glob
import pandas

try:
from conda.cli import python_api
conda_imported_successful = True
except ImportError:
conda_imported_successful = False

from pyiron_base import state

conda_package_dict = {
"mlip": "mlip",
"atomicrex": "atomicrex",
"damask": "damask",
"runner": "runner",
"randspg": "randspg",
"sphinx": "sphinxdft",
"lammps": "lammps"
}


def check_for_conda_package(name):
lst = [l for l in python_api.run_command("list")[0].split("\n") if name + " " in l]
if len(lst) == 0:
return False
else:
return True


def check_executable_bit(resource_paths):
def check_bit(script_path):
filemode = os.stat(script_path).st_mode
return bool(filemode & stat.S_IXUSR or filemode & stat.S_IXGRP or filemode & stat.S_IXOTH)

path_lst = []
for res_path in resource_paths:
path_lst += glob.glob(res_path + "/*/*/*.sh")
return {p: check_bit(script_path=p) for p in path_lst}


def check_executables_status():
executables_dict = check_executable_bit(
resource_paths=state.settings.configuration['resource_paths']
)
if conda_imported_successful:
conda_lst = [
check_for_conda_package(name=conda_package_dict[f])
if f is not None and f in conda_package_dict.keys()
else False
for f in [
p.split("/")[-3]
if "/share/pyiron/" in p else None
for p in executables_dict.keys()
]
]
return pandas.DataFrame({
"name": [p.split("/")[-3] for p in executables_dict.keys()],
"path": list(executables_dict.keys()),
"executable_bit": list(executables_dict.values()),
"conda_package_installed": conda_lst,
})
else:
return pandas.DataFrame({
"name": [p.split("/")[-3] for p in executables_dict.keys()],
"path": list(executables_dict.keys()),
"executable_bit": list(executables_dict.values()),
})

0 comments on commit 0f57e2d

Please sign in to comment.