def get_service_from_port(port, all_services=None):
if port is None or not isinstance(port, int):<EOL><INDENT>return None<EOL><DEDENT>if all_services is None:<EOL><INDENT>all_services = read_services_configuration()<EOL><DEDENT>for name, info in all_services.items():<EOL><INDENT>srv_port = info.get('<STR_LIT:port>')<EOL>if srv_port is not None and port == int(srv_port):<EOL><INDENT>return name<EOL><DEDENT>for elem in info.get('<STR_LIT>', {}).values():<EOL><INDENT>elem_port = elem.get('<STR_LIT>')<EOL>if elem_port is not None and port == int(elem_port):<EOL><INDENT>return name<EOL><DEDENT><DEDENT><DEDENT>
Gets the name of the service from the port
    all_services allows you to feed in the services to look through, pass
    in a dict of service names to service information eg.
    {
        'service_name': {
            'port': port_number
        }
    }

    Returns the name of the service