# Buggy code
def main(argv):
    """Sets up all the component in their own threads."""
    config_lib.CONFIG.AddContext(
        "Demo Context",
        "The demo runs all functions in a single process using the "
        "in memory data store.",
    )

    config_lib.CONFIG.AddContext("Test Context", "Context applied when we run tests.")

    flags.FLAGS.config = config_lib.Resource().Filter(
        "install_data/etc/grr-server.yaml"
    )

    flags.FLAGS.secondary_configs = [
        config_lib.Resource().Filter("test_data/grr_test.yaml")
    ]

    startup.Init()

    # pylint: disable=unused-import,unused-variable,g-import-not-at-top
    from grr.gui import gui_plugins
    # pylint: enable=unused-import,unused-variable,g-import-not-at-top

    # This is the worker thread.
    worker_thread = threading.Thread(target=worker.main, args=[argv], name="Worker")
    worker_thread.daemon = True
    worker_thread.start()

    # This is the http server Frontend that clients communicate with.
    http_thread = threading.Thread(
        target=http_server.main, args=[argv], name="HTTP Server"
    )
    http_thread.daemon = True
    http_thread.start()

    client_thread = threading.Thread(target=client.main, args=[argv], name="Client")
    client_thread.daemon = True
    client_thread.start()

    # The UI is running in the main thread.
    runtests.main(argv)


# Traceback (IOError)
Traceback (most recent call last):
File "/home/dev/GRR_ENV/local/lib/python2.7/site-packages/grr/gui/http_api.py", line 415, in HandleRequest
rendered_data = self.CallApiHandler(handler, args, token=token)
File "/home/dev/GRR_ENV/local/lib/python2.7/site-packages/grr/gui/http_api.py", line 225, in CallApiHandler
return handler.Render(args, token=token)
File "/home/dev/GRR_ENV/local/lib/python2.7/site-packages/grr/gui/api_plugins/config.py", line 80, in Render
parameter_data = RenderConfigOption(parameter)
File "/home/dev/GRR_ENV/local/lib/python2.7/site-packages/grr/gui/api_plugins/config.py", line 25, in RenderConfigOption
option_value = config_lib.CONFIG.Get(name)
File "/home/dev/GRR_ENV/local/lib/python2.7/site-packages/grr/lib/config_lib.py", line 1162, in Get
type_info_obj=type_info_obj, context=calc_context)
File "/home/dev/GRR_ENV/local/lib/python2.7/site-packages/grr/lib/config_lib.py", line 1291, in InterpolateValue
parameter=type_info_obj.name, context=context).Parse()
File "/home/dev/GRR_ENV/local/lib/python2.7/site-packages/grr/lib/config_lib.py", line 671, in Parse
self.Close()
File "/home/dev/GRR_ENV/local/lib/python2.7/site-packages/grr/lib/lexer.py", line 187, in Close
while self.NextToken():
File "/home/dev/GRR_ENV/local/lib/python2.7/site-packages/grr/lib/lexer.py", line 127, in NextToken
possible_next_state = cb(string=m.group(0), match=m)
File "/home/dev/GRR_ENV/local/lib/python2.7/site-packages/grr/lib/config_lib.py", line 657, in ExpandArg
final_value = self.config.Get(parameter_name, context=self.context)
File "/home/dev/GRR_ENV/local/lib/python2.7/site-packages/grr/lib/config_lib.py", line 1162, in Get
type_info_obj=type_info_obj, context=calc_context)
File "/home/dev/GRR_ENV/local/lib/python2.7/site-packages/grr/lib/config_lib.py", line 1291, in InterpolateValue
parameter=type_info_obj.name, context=context).Parse()
File "/home/dev/GRR_ENV/local/lib/python2.7/site-packages/grr/lib/config_lib.py", line 671, in Parse
self.Close()
File "/home/dev/GRR_ENV/local/lib/python2.7/site-packages/grr/lib/lexer.py", line 187, in Close
while self.NextToken():
File "/home/dev/GRR_ENV/local/lib/python2.7/site-packages/grr/lib/lexer.py", line 127, in NextToken
possible_next_state = cb(string=m.group(0), match=m)
File "/home/dev/GRR_ENV/local/lib/python2.7/site-packages/grr/lib/config_lib.py", line 640, in Filter
arg = filter_object().Filter(arg)
File "/home/dev/GRR_ENV/local/lib/python2.7/site-packages/grr/lib/config_lib.py", line 220, in Filter
raise IOError("Unable to find resource %s" % filename)
IOError: Unable to find resource test_data

# Fixed code
def main(argv):
    """Sets up all the component in their own threads."""
    config_lib.CONFIG.AddContext(
        "Demo Context",
        "The demo runs all functions in a single process using the "
        "in memory data store.",
    )

    config_lib.CONFIG.AddContext("Test Context", "Context applied when we run tests.")

    flags.FLAGS.config = config_lib.Resource().Filter(
        "install_data/etc/grr-server.yaml"
    )

    flags.FLAGS.secondary_configs = [
        config_lib.Resource().Filter("test_data/grr_test.yaml@grr-response-test")
    ]

    startup.Init()

    # pylint: disable=unused-import,unused-variable,g-import-not-at-top
    from grr.gui import gui_plugins
    # pylint: enable=unused-import,unused-variable,g-import-not-at-top

    # This is the worker thread.
    worker_thread = threading.Thread(target=worker.main, args=[argv], name="Worker")
    worker_thread.daemon = True
    worker_thread.start()

    # This is the http server Frontend that clients communicate with.
    http_thread = threading.Thread(
        target=http_server.main, args=[argv], name="HTTP Server"
    )
    http_thread.daemon = True
    http_thread.start()

    client_thread = threading.Thread(target=client.main, args=[argv], name="Client")
    client_thread.daemon = True
    client_thread.start()

    # The UI is running in the main thread.
    runtests.main(argv)