Skip to content

Commit

Permalink
Inline Testing from within NZBGet; fixes #21
Browse files Browse the repository at this point in the history
  • Loading branch information
caronc committed Jul 10, 2017
1 parent f5a165d commit 7406945
Show file tree
Hide file tree
Showing 3 changed files with 239 additions and 67 deletions.
54 changes: 52 additions & 2 deletions Notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
#
# Info about this Notify NZB Script:
# Author: Chris Caron (lead2gold@gmail.com).
# Date: Wed, Jul 5th, 2017.
# Date: Wed, Jul 7th, 2017.
# License: GPLv2 (http://www.gnu.org/licenses/gpl.html).
# Script Version: 0.6.0
# Script Version: 0.6.1
#

###########################################################################
Expand Down Expand Up @@ -291,6 +291,9 @@
# if they have this extra bit of detail in your logging output.
#Debug=no

# You can test your server configuration here.
#TestServers@Test Server Configuration

### NZBGET QUEUE/POST-PROCESSING SCRIPT
###########################################################################
import sys
Expand Down Expand Up @@ -1150,6 +1153,53 @@ def hhmmss(seconds):
notify_type=notify_type,
)

def action_testservers(self, *args, **kwargs):
"""
Execute the TestServers Test Action
"""

if not self.validate(keys=(
'Servers',
'IncludeImage',
'IncludeFiles',
'IncludeStats',
'IncludeLogs',
'OnFailure',
'OnSuccess',
)):
return False

servers = self.parse_list(self.get('Servers', ''))
on_failure = self.parse_bool(self.get('OnFailure'))
on_success = self.parse_bool(self.get('OnSuccess'))

include_stats = self.parse_bool(self.get('IncludeStats'))
include_files = self.parse_bool(self.get('IncludeFiles'))
include_logs = self.get('IncludeLogs', 'NO').upper()

# Prepare our Test Response
notify_type = NotifyType.INFO
title='NZBGet-Notify Configuration Test'
body='## NZBGet-Notify Configuration Test ##\r\n'
body += '- **OnFailure**: %s\r\n' % (
'Yes' if on_failure else 'No')
body += '- **OnSuccess**: %s\r\n' % (
'Yes' if on_success else 'No')
body += '- **Include Statistics**: %s\r\n' % (
'Yes' if include_stats else 'No')
body += '- **Include File Listings**: %s\r\n' % (
'Yes' if include_files else 'No')
body += '- **Include Log Details**: %s\r\n' % (
'Yes' if include_logs else 'No')

# Preform Notifications
return self.notify(
servers,
title=title,
body=body,
notify_type=notify_type,
)

def main(self, *args, **kwargs):
"""CLI
"""
Expand Down
Loading

0 comments on commit 7406945

Please sign in to comment.