# Buggy code
def get_service_name(*args):
    """
    The Display Name is what is displayed in Windows when services.msc is
    executed.  Each Display Name has an associated Service Name which is the
    actual name of the service.  This function allows you to discover the
    Service Name by returning a dictionary of Display Names and Service Names,
    or filter by adding arguments of Display Names.

    If no args are passed, return a dict of all services where the keys are the
    service Display Names and the values are the Service Names.

    If arguments are passed, create a dict of Display Names and Service Names

    CLI Example:

    .. code-block:: bash

        salt '*' service.get_service_name
        salt '*' service.get_service_name 'Google Update Service (gupdate)' 'DHCP Client'
    """
    ret = {}
    services = []
    display_names = []
    cmd = "sc query type= service state= all bufsize= {0}".format(BUFFSIZE)
    lines = __salt__["cmd.run"](cmd).splitlines()
    for line in lines:
        if "SERVICE_NAME:" in line:
            comps = line.split(":", 1)
            if not len(comps) > 1:
                continue
            services.append(comps[1].strip())
        if "DISPLAY_NAME:" in line:
            comps = line.split(":", 1)
            if not len(comps) > 1:
                continue
            display_names.append(comps[1].strip())
    if len(services) == len(display_names):
        service_dict = dict(zip(display_names, services))
    else:
        return "Service Names and Display Names mismatch"
    if len(args) == 0:
        return service_dict
    for arg in args:
        if arg in service_dict:
            ret[arg] = service_dict[arg]
    return ret


# Traceback (TypeError)
ID: check_service
Function: service.running
Name: 135f1bc0-6c6e-11e4-9803-0800200c9a66
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "salt/state.py", line 1533, in call
File "salt/states/service.py", line 290, in running
File "salt/modules/win_service.py", line 256, in status
File "subprocess.py", line 618, in list2cmdline
TypeError: argument of type 'int' is not iterable
Started: 09:06:33.825000
Duration: 2320.0 ms
Changes:

# Fixed code
def get_service_name(*args):
    """
    The Display Name is what is displayed in Windows when services.msc is
    executed.  Each Display Name has an associated Service Name which is the
    actual name of the service.  This function allows you to discover the
    Service Name by returning a dictionary of Display Names and Service Names,
    or filter by adding arguments of Display Names.

    If no args are passed, return a dict of all services where the keys are the
    service Display Names and the values are the Service Names.

    If arguments are passed, create a dict of Display Names and Service Names

    CLI Example:

    .. code-block:: bash

        salt '*' service.get_service_name
        salt '*' service.get_service_name 'Google Update Service (gupdate)' 'DHCP Client'
    """
    ret = {}
    services = []
    display_names = []
    cmd = list2cmdline(
        ["sc", "query", "type=", "service", "state=", "all", "bufsize=", str(BUFFSIZE)]
    )
    lines = __salt__["cmd.run"](cmd).splitlines()
    for line in lines:
        if "SERVICE_NAME:" in line:
            comps = line.split(":", 1)
            if not len(comps) > 1:
                continue
            services.append(comps[1].strip())
        if "DISPLAY_NAME:" in line:
            comps = line.split(":", 1)
            if not len(comps) > 1:
                continue
            display_names.append(comps[1].strip())
    if len(services) == len(display_names):
        service_dict = dict(zip(display_names, services))
    else:
        return "Service Names and Display Names mismatch"
    if len(args) == 0:
        return service_dict
    for arg in args:
        if arg in service_dict:
            ret[arg] = service_dict[arg]
    return ret