# Buggy code
def _sendNMA(
    self, nma_api=None, nma_priority=None, event=None, message=None, force=False
):
    title = "Medusa"

    if not app.USE_NMA and not force:
        return False

    if nma_api is None:
        nma_api = app.NMA_API
    else:
        nma_api = nma_api.split(",")

    if nma_priority is None:
        nma_priority = app.NMA_PRIORITY

    batch = False

    p = pynma.PyNMA()
    keys = nma_api
    p.addkey(keys)

    if len(keys) > 1:
        batch = True

    log.debug(
        'NMA: Sending notice with details: event="{0}, message="{1}", priority={2}, batch={3}',
        event,
        message,
        nma_priority,
        batch,
    )
    response = p.push(
        application=title,
        event=event,
        description=message,
        priority=nma_priority,
        batch_mode=batch,
    )

    if not response[nma_api]["code"] == "200":
        log.error("Could not send notification to NotifyMyAndroid")
        return False
    else:
        log.info("NMA: Notification sent to NotifyMyAndroid")
        return True


# Traceback (TypeError)
Error
unhashable type: 'list'
Traceback
Traceback (most recent call last):
File "/home/pi/Medusa/ext/tornado/web.py", line 1509, in _execute result = method(*self.path_args, **self.path_kwargs)
File "/home/pi/Medusa/medusa/server/web/core/authentication.py", line 73, in post notifiers.notify_login(self.request.remote_ip)
File "/home/pi/Medusa/medusa/notifiers/__init__.py", line 127, in notify_login n.notify_login(ipaddress)
File "/home/pi/Medusa/medusa/notifiers/nma.py", line 44, in notify_login self._sendNMA(nma_api=None, nma_priority=None, event=title, message=update_text.format(ipaddress))
File "/home/pi/Medusa/medusa/notifiers/nma.py", line 74, in _sendNMA if not response[nma_api][u'code'] == u'200':
TypeError: unhashable type: 'list'
Request Info
body: username=supergonkas&amp;password=&amp;remember_me=1&amp;submit=Login
files: {}
protocol: http
connection:
body_arguments: {'username': ['supergonkas'], 'remember_me': ['1'], 'password': [''], 'submit': ['Login']}
uri: /login/?next=%2Fhistory%2F
query_arguments: {'next': ['/history/']}
_start_time: 1505997382.06
headers: Origin: http://:8081 Save-Data: on Content-Length: 61 Accept-Language: pt-PT,pt;q=0.8,en-US;q=0.6,en;q=0.4,es;q=0.2 Accept-Encoding: gzip, deflate Connection: keep-alive Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8 Upgrade-Insecure-Requests: 1 Dnt: 1 Host::8081 Referer: http://:8081/login/?next=%2Fhistory%2F Cache-Control: max-age=0 User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.116 Safari/537.36 Content-Type: application/x-www-form-urlencoded
host: :8081
version: HTTP/1.1
server_connection:
host_name: s
_finish_time: None
query: next=%2Fhistory%2F
arguments: {'username': ['supergonkas'], 'remember_me': ['1'], 'password': [''], 'submit': ['Login'], 'next': ['/history/']}
path: /login/
method: POST
remote_ip: 194.210.190.12
View Log(Errors)

# Fixed code
def _sendNMA(
    self, nma_api=None, nma_priority=None, event=None, message=None, force=False
):
    title = "Medusa"

    if not app.USE_NMA and not force:
        return False

    if nma_api is None:
        nma_api = app.NMA_API
    elif isinstance(nma_api, text_type):
        nma_api = [nma_api]

    if nma_priority is None:
        nma_priority = app.NMA_PRIORITY

    batch = False

    p = pynma.PyNMA()
    keys = nma_api
    p.addkey(keys)

    if len(keys) > 1:
        batch = True

    log.debug(
        'NMA: Sending notice with details: event="{0}, message="{1}", priority={2}, batch={3}',
        event,
        message,
        nma_priority,
        batch,
    )
    response = p.push(
        application=title,
        event=event,
        description=message,
        priority=nma_priority,
        batch_mode=batch,
    )

    if not response[",".join(nma_api)]["code"] == "200":
        log.error("Could not send notification to NotifyMyAndroid")
        return False
    else:
        log.info("NMA: Notification sent to NotifyMyAndroid")
        return True