# Path: debugger/util.py
# class Dispatcher(object):
#     """
#     Helper class for dynamically dispatching methods on a given object.
# 
#     The functions are invoked by name.
#     """
#     @staticmethod
#     def dispatch(root_object, properties=None, arguments=None):
#         target_prop = root_object
# 
#         if properties is None:
#             properties = []
# 
#         if arguments is not None and not isinstance(arguments, (list, tuple)):
#             arguments = [arguments]
# 
#         for prop in properties:
#             target_prop = getattr(target_prop, prop)
# 
#         if hasattr(target_prop, "__call__"):
#             if arguments is not None:
#                 result = target_prop(*arguments)
#             else:
#                 result = target_prop()
# 
#             return result
#         else:
#             return target_prop


import select
import socket
import threading
import traceback
from command import Command, CommandType
from debugger.util import Dispatcher

    def run_server_thread(self):
        """
        Loop that is run by the server thread.
        """
        while self.is_running():
            try:
                if (self.is_data_available(self.server, 0.1) and
                        not self.is_client_connected()):
                    client, address = self.server.accept()
                    self.handle_client(client, address)
            except:
                traceback.print_exc()

    def handle_command(self, command):
        """
        Handles an incoming command from the client.
        @type command: net.Command
        """
        if command.type == CommandType.Loopback:
            self.send_result(command, "ok")
        elif command.type == CommandType.StopServer:
            self.server.close()
            self.running = False
        elif command.type == CommandType.Execute:
            arguments = command.data["arguments"] if "arguments"\
                                                     in command.data else None
            properties = command.data["properties"]

            try:

# Path: debugger/util.py
# class Dispatcher(object):
#     """
#     Helper class for dynamically dispatching methods on a given object.
# 
#     The functions are invoked by name.
#     """
#     @staticmethod
#     def dispatch(root_object, properties=None, arguments=None):
#         target_prop = root_object
# 
#         if properties is None:
#             properties = []
# 
#         if arguments is not None and not isinstance(arguments, (list, tuple)):
#             arguments = [arguments]
# 
#         for prop in properties:
#             target_prop = getattr(target_prop, prop)
# 
#         if hasattr(target_prop, "__call__"):
#             if arguments is not None:
#                 result = target_prop(*arguments)
#             else:
#                 result = target_prop()
# 
#             return result
#         else:
#             return target_prop


# Path: debugger/net/server.py
import select
import socket
import threading
import traceback
from command import Command, CommandType
from debugger.util import Dispatcher


    def run_server_thread(self):
        """
        Loop that is run by the server thread.
        """
        while self.is_running():
            try:
                if (self.is_data_available(self.server, 0.1) and
                        not self.is_client_connected()):
                    client, address = self.server.accept()
                    self.handle_client(client, address)
            except:
                traceback.print_exc()

    def handle_command(self, command):
        """
        Handles an incoming command from the client.
        @type command: net.Command
        """
        if command.type == CommandType.Loopback:
            self.send_result(command, "ok")
        elif command.type == CommandType.StopServer:
            self.server.close()
            self.running = False
        elif command.type == CommandType.Execute:
            arguments = command.data["arguments"] if "arguments"\
                                                     in command.data else None
            properties = command.data["properties"]

            try:

                result = Dispatcher.dispatch(self.debugger, properties,