Skip to content

Commit

Permalink
Merge pull request #106 from JeffersonLab/105-rcdn-has-wrong-path
Browse files Browse the repository at this point in the history
Fix rcnd executable
  • Loading branch information
DraTeots authored Aug 30, 2024
2 parents 94cba89 + 0518729 commit ae623b9
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ jobs:
run: |
source environment.bash
echo "rcnd command is running"
rcnd
rcnd --help
echo "rcdb command is running"
rcdb
rcdb --help
16 changes: 14 additions & 2 deletions bin/rcdb
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
#!/bin/sh
#!/usr/bin/env python3

/usr/bin/env python3 $RCDB_HOME/python/rcdb/rcdb_cli "$@"
import os
import sys

# Figure out where is python directory
this_file_dir = os.path.dirname(os.path.abspath(__file__))
python_dir = os.path.join(this_file_dir, '..', 'python')

# Add the directory to the Python modules search path
sys.path.insert(0, python_dir)

# Import and run rcdb
from rcdb.rcdb_cli.app import rcdb_cli
rcdb_cli(prog_name="rcdb")
25 changes: 23 additions & 2 deletions bin/rcnd
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
#!/bin/sh
#!/usr/bin/env python3

/usr/bin/env python $RCDB_HOME/python/rcdb/rcnd.py "$@"
import os
import sys
import importlib.util

# Figure out where is rcnd.py located
this_file_dir = os.path.dirname(os.path.abspath(__file__))

this_file_dir = os.path.dirname(os.path.abspath(__file__))
python_dir = os.path.join(this_file_dir, '..', 'python')

# Add the directory to the Python modules search path
sys.path.insert(0, python_dir)

module_path = os.path.join(this_file_dir, '..', 'python', 'utilites', 'rcnd.py')
module_path = os.path.abspath(module_path)

# Load the module from the specified file
spec = importlib.util.spec_from_file_location('rcnd', module_path)
rcnd = importlib.util.module_from_spec(spec)
spec.loader.exec_module(rcnd)

# Now you can use functions from the module
rcnd.main()
4 changes: 1 addition & 3 deletions python/rcdb/rcdb_cli/ls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
def ls(context, search, is_long):
"""Lists conditions"""

print(context)
exit(0)


db = context.db
assert isinstance(db, RCDBProvider)
cnd_types = db.get_condition_types_by_name()
Expand Down
5 changes: 4 additions & 1 deletion python/utilites/rcnd.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def new_run(db, run_number):
print("Created run number {}".format(run_number))


if __name__ == "__main__":
def main():
parser = argparse.ArgumentParser(description=help_text, epilog=examples,
formatter_class=RawDescriptionHelpFormatter)
parser.add_argument("-c", "--connection", help="Connection string to database", metavar='<string>', default="")
Expand Down Expand Up @@ -320,3 +320,6 @@ def new_run(db, run_number):
log.debug("No run_number, no condition_name. Show stats")
print_stats(rcdb_db)
exit(0)

if __name__ == "__main__":
main()

0 comments on commit ae623b9

Please sign in to comment.