Repository: pymedusa/Medusa

Issue:
Growl Not Registering Medusa
Medusa Info: | Branch: master   Commit: d6eb72d4e1019e5d1286ae6ac1d7e4b318229ebe                 Version: v0.2.1   Database: 44.9
Python Version: | 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:53:40) [MSC v.1500 64 bit (AMD64)]
SSL Version: | OpenSSL 1.0.2j  26 Sep 2016
OS: | Windows-7-6.1.7601-SP1
Locale: | en_GB.cp1252

**What you did: Input ip:port to register gowl
**What happened: Nothing!
**What you expected: Successful registration.
**Logs:**
```
2018-04-07 08:09:55 ERROR    Thread-298 :: [d6eb72d] Exception generated: 'module' object has no attribute 'GNTPRegister'
Traceback (most recent call last):
  File "C:\Medusa\Medusa\medusa\server\web\core\base.py", line 283, in async_call
    result = function(**kwargs)
  File "C:\Medusa\Medusa\medusa\server\web\home\handler.py", line 354, in testGrowl
    result = notifiers.growl_notifier.test_notify(host, password)
  File "C:\Medusa\Medusa\medusa\notifiers\growl.py", line 20, in test_notify
    self._sendRegistration(host, password)
  File "C:\Medusa\Medusa\medusa\notifiers\growl.py", line 172, in _sendRegistration
    register = gntp.GNTPRegister()
AttributeError: 'module' object has no attribute 'GNTPRegister'
```



Discussion:

Resolving patch:
diff --git a/medusa/notifiers/growl.py b/medusa/notifiers/growl.py
--- a/medusa/notifiers/growl.py
+++ b/medusa/notifiers/growl.py
@@ -25,7 +25,10 @@ def test_notify(self, host, password):
 
     def notify_snatch(self, ep_name, is_proper):
         if app.GROWL_NOTIFY_ONSNATCH:
-            self._sendGrowl(common.notifyStrings[(common.NOTIFY_SNATCH, common.NOTIFY_SNATCH_PROPER)[is_proper]], ep_name)
+            self._sendGrowl(
+                common.notifyStrings[
+                    (common.NOTIFY_SNATCH, common.NOTIFY_SNATCH_PROPER)[is_proper]
+                ], ep_name)
 
     def notify_download(self, ep_name):
         if app.GROWL_NOTIFY_ONDOWNLOAD:
@@ -47,16 +50,13 @@ def notify_login(self, ipaddress=''):
 
     def _send_growl(self, options, message=None):
 
-        # Send Notification
-        notice = gntp.GNTPNotice()
-
-        # Required
-        notice.add_header('Application-Name', options['app'])
-        notice.add_header('Notification-Name', options['name'])
-        notice.add_header('Notification-Title', options['title'])
-
-        if options['password']:
-            notice.set_password(options['password'])
+        # Initialize Notification
+        notice = gntp.core.GNTPNotice(
+            app=options['app'],
+            name=options['name'],
+            title=options['title'],
+            password=options['password'],
+        )
 
         # Optional
         if options['sticky']:
@@ -70,7 +70,7 @@ def _send_growl(self, options, message=None):
             notice.add_header('Notification-Text', message)
 
         response = self._send(options['host'], options['port'], notice.encode(), options['debug'])
-        return True if isinstance(response, gntp.GNTPOK) else False
+        return True if isinstance(response, gntp.core.GNTPOK) else False
 
     @staticmethod
     def _send(host, port, data, debug=False):
@@ -80,7 +80,7 @@ def _send(host, port, data, debug=False):
         s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
         s.connect((host, port))
         s.send(data)
-        response = gntp.parse_gntp(s.recv(1024))
+        response = gntp.core.parse_gntp(s.recv(1024))
         s.close()
 
         if debug:
@@ -171,7 +171,7 @@ def _sendRegistration(self, host=None, password=None):
         opts['debug'] = False
 
         # Send Registration
-        register = gntp.GNTPRegister()
+        register = gntp.core.GNTPRegister()
         register.add_header('Application-Name', opts['app'])
         register.add_header('Application-Icon', app.LOGO_URL)
 


Test patch: