Repository: pymedusa/Medusa

Issue:
Login error
```
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&password=&remember_me=1&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)
```


Discussion:

Resolving patch:
diff --git a/medusa/notifiers/nma.py b/medusa/notifiers/nma.py
--- a/medusa/notifiers/nma.py
+++ b/medusa/notifiers/nma.py
@@ -4,8 +4,8 @@
 
 from medusa import app, common
 from medusa.logger.adapters.style import BraceAdapter
-
 from pynma import pynma
+from six import text_type
 
 log = BraceAdapter(logging.getLogger(__name__))
 log.logger.addHandler(logging.NullHandler())
@@ -52,8 +52,8 @@ def _sendNMA(self, nma_api=None, nma_priority=None, event=None, message=None, fo
 
         if nma_api is None:
             nma_api = app.NMA_API
-        else:
-            nma_api = nma_api.split(',')
+        elif isinstance(nma_api, text_type):
+            nma_api = [nma_api]
 
         if nma_priority is None:
             nma_priority = app.NMA_PRIORITY
@@ -71,7 +71,7 @@ def _sendNMA(self, nma_api=None, nma_priority=None, event=None, message=None, fo
                   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][u'code'] == u'200':
+        if not response[','.join(nma_api)][u'code'] == u'200':
             log.error(u'Could not send notification to NotifyMyAndroid')
             return False
         else:


Test patch: