Skip to content

Commit

Permalink
Added bp_info to retrieve various path-information.
Browse files Browse the repository at this point in the history
  • Loading branch information
safl committed Apr 1, 2015
1 parent 9bb519a commit 2eb0730
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 1 deletion.
43 changes: 43 additions & 0 deletions benchpress/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,45 @@
import inspect
import os

APP_NAME = 'benchpress'
APP_VERSION = '0.5'

def module_path():
return os.path.dirname(__file__)

def get_paths():
"""Get a dict of paths for the various things in benchpress."""

home = module_path()
dirs = home.split(os.sep)

share_path = os.sep.join(dirs[:-1]) # When running from checkout
bin_path = share_path
from_checkout = len(dirs) > 2 and \
dirs[-1] == "benchpress" and \
dirs[-2] == "benchpress"

# Find the share folder and bin folders when not running from checkout
while(len(dirs) > 2 and not from_checkout):
dirs.pop()
path = os.sep.join(dirs)
ls = os.listdir(path)
if 'share' in ls and 'bin' in ls:
share_path = os.sep.join([path, "share", "benchpress"])
bin_path = os.sep.join([path, "bin"])
break

paths = { # Construct the path dict
'module': home,
'benchmarks': os.sep.join([share_path, "benchmarks"]),
'suites': os.sep.join([share_path, "suites"]),
'hooks': bin_path,
'bins': bin_path
}

for entity in paths: # Validate it
if not os.path.exists(paths[entity]):
raise IOError("Path for %s (%s) does not exist" % (entity, paths[entity]))

return paths

26 changes: 26 additions & 0 deletions bp_info
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env python
import argparse
from benchpress.version import get_paths

def main():
parser = argparse.ArgumentParser(description="Retrieve misc. info on Benchpress.")

parser.add_argument('--module', action='store_true', help="Location of the Python module")
parser.add_argument('--benchmarks', action='store_true', help="Location of benchmarks")
parser.add_argument('--suites', action='store_true', help="Location of suites")
parser.add_argument('--hooks', action='store_true', help="Location of hooks")
parser.add_argument('--bins', action='store_true', help="Location of commands")

args = parser.parse_args() # Parse arguments

paths = get_paths() # Grab the path configuration
args_dict = args.__dict__
for arg in args_dict:
if args_dict[arg]:
print paths[arg]
return

parser.print_help()

if __name__ == "__main__":
main()
3 changes: 3 additions & 0 deletions record.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
/home/safl/.local/lib/python2.7/site-packages/benchpress/press.pyc
/home/safl/.local/bin/bp_times
/home/safl/.local/bin/bp_run
/home/safl/.local/bin/bp_info
/home/safl/.local/bin/bp_compile
/home/safl/.local/bin/bp_grapher
/home/safl/.local/bin/proxy-VEM-pre-hook.sh
/home/safl/.local/share/benchpress/benchmarks/README.rst
Expand Down Expand Up @@ -143,6 +145,7 @@
/home/safl/.local/share/benchpress/benchmarks/jacobi/cil/bin/empty
/home/safl/.local/share/benchpress/benchmarks/jacobi/cil/src/empty
/home/safl/.local/share/benchpress/benchmarks/lbm_2d/readme.rst
/home/safl/.local/share/benchpress/benchmarks/lbm_2d/python_numpy/issues.rst
/home/safl/.local/share/benchpress/benchmarks/lbm_2d/python_numpy/lbm_2d.py
/home/safl/.local/share/benchpress/benchmarks/lbm_2d/cil/bin/empty
/home/safl/.local/share/benchpress/benchmarks/lbm_2d/cil/src/empty
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ def make_dfiles(prefix, directory):
data_files = make_dfiles('share/benchpress', 'benchmarks') +\
make_dfiles('share/benchpress', 'suites'),
packages = ['benchpress'],
scripts = ["bp_run", "bp_times", "bp_grapher", "bp_compile", "hooks/proxy-VEM-pre-hook.sh"]
scripts = ["bp_run", "bp_info", "bp_times", "bp_grapher", "bp_compile", "hooks/proxy-VEM-pre-hook.sh"]
)

0 comments on commit 2eb0730

Please sign in to comment.