How to use the pyhindsight.__file__ function in pyhindsight

To help you get started, we’ve selected a few pyhindsight examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github obsidianforensics / hindsight / hindsight_gui.py View on Github external
def main():

    print(banner)
    global STATIC_PATH

    # Get the hindsight module's path on disk to add to sys.path, so we can find templates and static files
    module_path = os.path.dirname(pyhindsight.__file__)
    sys.path.insert(0, module_path)

    # Loop through all paths in system path, to pick up all potential locations for templates and static files.
    # Paths can get weird when the program is run from a different directory, or when the packaged exe is unpacked.
    for potential_path in sys.path:
        potential_template_path = potential_path
        if os.path.isdir(potential_template_path):
            # Insert the current plugin location to the system path, so bottle can find the templates
            bottle.TEMPLATE_PATH.insert(0, potential_template_path)

        potential_static_path = os.path.join(potential_path, 'static')
        if os.path.isdir(potential_static_path):
            STATIC_PATH = potential_static_path

    # webbrowser.open("http://localhost:8080")
    bottle.run(host='localhost', port=8080, debug=True)