Last active
September 12, 2016 22:43
-
-
Save LukeMurphey/bd2e559a3e1da711f4b16b4d59ee2ac9 to your computer and use it in GitHub Desktop.
This stub prunes items from the path that are not related to your app. #splunk
This file contains hidden or 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
| def prune_sys_path(app_name): | |
| # Prune directories from other apps so that we don't step on each other with our imports (see http://lukemurphey.net/issues/1281) | |
| paths_to_remove = [] | |
| for path in sys.path: | |
| if ('/etc/apps/' in path and not ('/etc/apps/' + app_name) in path) or ('\\etc\\apps\\' in path and not ('\\etc\\apps\\' + app_name) in path): | |
| paths_to_remove.append(path) | |
| for path in paths_to_remove: | |
| sys.path.remove(path) | |
| # Example call: | |
| #prune_sys_path('lookup_editor') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment