Skip to content

Instantly share code, notes, and snippets.

@LukeMurphey
Last active September 12, 2016 22:43
Show Gist options
  • Select an option

  • Save LukeMurphey/bd2e559a3e1da711f4b16b4d59ee2ac9 to your computer and use it in GitHub Desktop.

Select an option

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
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