-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added bp_info to retrieve various path-information.
- Loading branch information
Showing
4 changed files
with
73 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters