Browse Source

Remove tabs and trailing spaces.

These things give needless differences in commits.
Contributors: instruct your editor to use spaces instead of tabs and to remove trailing spaces.
pull/554/merge
shypike 9 years ago
parent
commit
073f7afdf7
  1. 20
      sabnzbd/api.py
  2. 2
      sabnzbd/encoding.py
  3. 24
      sabnzbd/interface.py
  4. 2
      sabnzbd/nzbqueue.py
  5. 4
      sabnzbd/skintext.py
  6. 386
      sabnzbd/utils/configobj.py
  7. 6
      sabnzbd/utils/feedparser.py
  8. 4
      sabnzbd/utils/pybonjour.py
  9. 124
      sabnzbd/utils/rsslib.py
  10. 42
      sabnzbd/utils/ssmtplib.py
  11. 14
      sabnzbd/utils/systrayiconthread.py

20
sabnzbd/api.py

@ -793,7 +793,7 @@ def _api_undefined(name, output, kwargs):
def _api_browse(name, output, kwargs): def _api_browse(name, output, kwargs):
""" Return tree of local path """ """ Return tree of local path """
compact = kwargs.get('compact') compact = kwargs.get('compact')
if compact and compact == '1': if compact and compact == '1':
paths = [] paths = []
name = platform_encode(kwargs.get('term', '')) name = platform_encode(kwargs.get('term', ''))
@ -1253,14 +1253,14 @@ def build_status(web_dir=None, root=None, prim=True, skip_dashboard=False, outpu
# For the templates or for JSON # For the templates or for JSON
if output: if output:
server_info = { 'servername': server.displayname, server_info = { 'servername': server.displayname,
'serveractiveconn': connected, 'serveractiveconn': connected,
'servertotalconn': server.threads, 'servertotalconn': server.threads,
'serverconnections': serverconnections, 'serverconnections': serverconnections,
'serverssl': server.ssl, 'serverssl': server.ssl,
'serveractive': server.active, 'serveractive': server.active,
'servererror': server.errormsg, 'servererror': server.errormsg,
'serverpriority': server.priority, 'serverpriority': server.priority,
'serveroptional': server.optional } 'serveroptional': server.optional }
info['servers'].append(server_info) info['servers'].append(server_info)
else: else:
@ -1302,8 +1302,8 @@ def build_queue(web_dir=None, root=None, prim=True, webdir='', start=0, limit=0,
if info['finish'] > info['noofslots']: if info['finish'] > info['noofslots']:
info['finish'] = info['noofslots'] info['finish'] = info['noofslots']
info['queue_details'] = '0' info['queue_details'] = '0'
if 'queue_details' in cherrypy.request.cookie: if 'queue_details' in cherrypy.request.cookie:
info['queue_details'] = str(int_conv(cherrypy.request.cookie['queue_details'].value)) info['queue_details'] = str(int_conv(cherrypy.request.cookie['queue_details'].value))
n = 0 n = 0
running_bytes = 0 running_bytes = 0

2
sabnzbd/encoding.py

@ -91,7 +91,7 @@ def yenc_name_fixer(p):
return p.decode('utf-8') return p.decode('utf-8')
except: except:
return p.decode('cp1252') return p.decode('cp1252')
def is_utf8(p): def is_utf8(p):
""" Return True when p is UTF-8 or plain ASCII """ """ Return True when p is UTF-8 or plain ASCII """

24
sabnzbd/interface.py

@ -96,7 +96,7 @@ def check_access(access_type=4):
`access_type`: 1=nzb, 2=api, 3=full_api, 4=webui, 5=webui with login for external `access_type`: 1=nzb, 2=api, 3=full_api, 4=webui, 5=webui with login for external
""" """
referrer = cherrypy.request.remote.ip referrer = cherrypy.request.remote.ip
# CherryPy will report ::ffff:192.168.0.10 on dual-stack situation # CherryPy will report ::ffff:192.168.0.10 on dual-stack situation
# It will always contain that ::ffff: prefix # It will always contain that ::ffff: prefix
range_ok = (not cfg.local_ranges()) or bool([1 for r in cfg.local_ranges() if (referrer.startswith(r) or referrer.replace('::ffff:', '').startswith(r))]) range_ok = (not cfg.local_ranges()) or bool([1 for r in cfg.local_ranges() if (referrer.startswith(r) or referrer.replace('::ffff:', '').startswith(r))])
@ -169,9 +169,9 @@ COOKIE_SECRET = str(randint(1000,100000)*os.getpid())
def set_login_cookie(remove=False, remember_me=False): def set_login_cookie(remove=False, remember_me=False):
""" We try to set a cookie as unique as possible """ We try to set a cookie as unique as possible
to the current user. Based on it's IP and the to the current user. Based on it's IP and the
current process ID of the SAB instance and a random current process ID of the SAB instance and a random
number, so cookies cannot be re-used number, so cookies cannot be re-used
""" """
salt = randint(1,1000) salt = randint(1,1000)
cherrypy.response.cookie['login_cookie'] = hashlib.sha1(str(salt) + cherrypy.request.remote.ip + COOKIE_SECRET).hexdigest() cherrypy.response.cookie['login_cookie'] = hashlib.sha1(str(salt) + cherrypy.request.remote.ip + COOKIE_SECRET).hexdigest()
@ -190,7 +190,7 @@ def set_login_cookie(remove=False, remember_me=False):
cherrypy.response.cookie['login_salt']['expires'] = 0 cherrypy.response.cookie['login_salt']['expires'] = 0
else: else:
# Notify about new login # Notify about new login
notifier.send_notification(T('User logged in'), T('User logged in to the web interface'), 'new_login') notifier.send_notification(T('User logged in'), T('User logged in to the web interface'), 'new_login')
def check_login_cookie(): def check_login_cookie():
# Do we have everything? # Do we have everything?
@ -319,7 +319,7 @@ class MainPage(object):
if first == 2: if first == 2:
# Setup addresses with /sabnzbd prefix for primary and secondary skin # Setup addresses with /sabnzbd prefix for primary and secondary skin
self.sabnzbd = MainPage(web_dir, '/sabnzbd/', web_dir2, '/sabnzbd/m/', web_dirc=web_dirc, prim=True, first=1) self.sabnzbd = MainPage(web_dir, '/sabnzbd/', web_dir2, '/sabnzbd/m/', web_dirc=web_dirc, prim=True, first=1)
self.login = LoginPage(web_dirc, root + 'login/', prim) self.login = LoginPage(web_dirc, root + 'login/', prim)
self.queue = QueuePage(web_dir, root + 'queue/', prim) self.queue = QueuePage(web_dir, root + 'queue/', prim)
self.history = HistoryPage(web_dir, root + 'history/', prim) self.history = HistoryPage(web_dir, root + 'history/', prim)
@ -357,7 +357,7 @@ class MainPage(object):
info['cat_list'] = list_cats(True) info['cat_list'] = list_cats(True)
info['have_rss_defined'] = bool(config.get_rss()) info['have_rss_defined'] = bool(config.get_rss())
info['have_watched_dir'] = bool(cfg.dirscan_dir()) info['have_watched_dir'] = bool(cfg.dirscan_dir())
# Have logout only with HTML and if inet=5, only when we are external # Have logout only with HTML and if inet=5, only when we are external
info['have_logout'] = cfg.username() and cfg.password() and (cfg.html_login() and (cfg.inet_exposure() < 5 or (cfg.inet_exposure() == 5 and not check_access(access_type=6)))) info['have_logout'] = cfg.username() and cfg.password() and (cfg.html_login() and (cfg.inet_exposure() < 5 or (cfg.inet_exposure() == 5 and not check_access(access_type=6))))
@ -602,7 +602,7 @@ class LoginPage(object):
raise dcRaiser('../', kwargs) raise dcRaiser('../', kwargs)
elif kwargs.get('username') or kwargs.get('password'): elif kwargs.get('username') or kwargs.get('password'):
info['error'] = T('Authentication failed, check username/password.') info['error'] = T('Authentication failed, check username/password.')
# Show login # Show login
template = Template(file=os.path.join(self.__web_dir, 'login', 'main.tmpl'), template = Template(file=os.path.join(self.__web_dir, 'login', 'main.tmpl'),
filter=FILTER, searchList=[info], compilerSettings=DIRECTIVES) filter=FILTER, searchList=[info], compilerSettings=DIRECTIVES)
@ -1488,16 +1488,16 @@ class ConfigSwitches(object):
SPECIAL_BOOL_LIST = \ SPECIAL_BOOL_LIST = \
('start_paused', 'no_penalties', 'ignore_wrong_unrar', 'create_group_folders', ('start_paused', 'no_penalties', 'ignore_wrong_unrar', 'create_group_folders',
'queue_complete_pers', 'api_warnings', 'allow_64bit_tools', 'queue_complete_pers', 'api_warnings', 'allow_64bit_tools',
'prospective_par_download', 'never_repair', 'allow_streaming', 'ignore_unrar_dates', 'prospective_par_download', 'never_repair', 'allow_streaming', 'ignore_unrar_dates',
'osx_menu', 'osx_speed', 'win_menu', 'use_pickle', 'allow_incomplete_nzb', 'osx_menu', 'osx_speed', 'win_menu', 'use_pickle', 'allow_incomplete_nzb',
'rss_filenames', 'no_ipv6', 'keep_awake', 'empty_postproc', 'html_login', 'rss_filenames', 'no_ipv6', 'keep_awake', 'empty_postproc', 'html_login',
'web_watchdog', 'wait_for_dfolder', 'warn_empty_nzb', 'enable_bonjour', 'web_watchdog', 'wait_for_dfolder', 'warn_empty_nzb', 'enable_bonjour',
'allow_duplicate_files', 'warn_dupl_jobs', 'backup_for_duplicates', 'enable_par_cleanup', 'allow_duplicate_files', 'warn_dupl_jobs', 'backup_for_duplicates', 'enable_par_cleanup',
'enable_https_verification', 'api_logging', 'fixed_ports' 'enable_https_verification', 'api_logging', 'fixed_ports'
) )
SPECIAL_VALUE_LIST = \ SPECIAL_VALUE_LIST = \
('size_limit', 'folder_max_length', 'fsys_type', 'movie_rename_limit', 'nomedia_marker', ('size_limit', 'folder_max_length', 'fsys_type', 'movie_rename_limit', 'nomedia_marker',
'req_completion_rate', 'wait_ext_drive', 'history_limit', 'show_sysload', 'req_completion_rate', 'wait_ext_drive', 'history_limit', 'show_sysload',
'ipv6_servers', 'rating_host', 'selftest_host' 'ipv6_servers', 'rating_host', 'selftest_host'
) )
SPECIAL_LIST_LIST = \ SPECIAL_LIST_LIST = \
@ -2329,7 +2329,7 @@ class ConfigScheduling(object):
actions_lng = {} actions_lng = {}
for action in actions: for action in actions:
actions_lng[action] = Ttemplate("sch-" + action) actions_lng[action] = Ttemplate("sch-" + action)
actions_servers = {} actions_servers = {}
servers = config.get_servers() servers = config.get_servers()
for srv in servers: for srv in servers:
@ -2640,7 +2640,7 @@ class Status(object):
return msg return msg
orphan_delete(kwargs) orphan_delete(kwargs)
raise dcRaiser(self.__root, kwargs) raise dcRaiser(self.__root, kwargs)
@cherrypy.expose @cherrypy.expose
def delete_all(self, **kwargs): def delete_all(self, **kwargs):
msg = check_session(kwargs) msg = check_session(kwargs)

2
sabnzbd/nzbqueue.py

@ -891,7 +891,7 @@ class NzbQueue(TryList):
if (not limit) or (start <= n < start+limit): if (not limit) or (start <= n < start+limit):
pnfo_list.append(nzo.gather_info()) pnfo_list.append(nzo.gather_info())
n += 1 n += 1
if not search: if not search:
n = len(self.__nzo_list) n = len(self.__nzo_list)
return QNFO(bytes_total, bytes_left, pnfo_list, q_size, n) return QNFO(bytes_total, bytes_left, pnfo_list, q_size, n)

4
sabnzbd/skintext.py

@ -564,7 +564,7 @@ SKIN_TEXT = {
'srv-send_group' : TT('Send Group'), 'srv-send_group' : TT('Send Group'),
'srv-explain-send_group' : TT('Send group command before requesting articles.'), 'srv-explain-send_group' : TT('Send group command before requesting articles.'),
'srv-categories' : TT('Categories'), 'srv-categories' : TT('Categories'),
'srv-explain-categories' : TT('Only use this server for these categories.'), 'srv-explain-categories' : TT('Only use this server for these categories.'),
'srv-explain-no-categories' : TT('None of the enabled servers have the \'Default\' category selected. Jobs in the queue that are not assigned to one of the server\'s categories will not be downloaded.'), 'srv-explain-no-categories' : TT('None of the enabled servers have the \'Default\' category selected. Jobs in the queue that are not assigned to one of the server\'s categories will not be downloaded.'),
'srv-notes' : TT('Personal notes'), 'srv-notes' : TT('Personal notes'),
@ -846,7 +846,7 @@ SKIN_TEXT = {
'Glitter-notification-removing1' : TT('Removing job'), # Notification window 'Glitter-notification-removing1' : TT('Removing job'), # Notification window
'Glitter-notification-removing' : TT('Removing jobs'), # Notification window 'Glitter-notification-removing' : TT('Removing jobs'), # Notification window
'Glitter-notification-shutdown' : TT('Shutting down'), # Notification window 'Glitter-notification-shutdown' : TT('Shutting down'), # Notification window
#Plush skin #Plush skin
'Plush-confirmWithoutSavingPrompt' : TT('Changes have not been saved, and will be lost.'), 'Plush-confirmWithoutSavingPrompt' : TT('Changes have not been saved, and will be lost.'),
'Plush-confirm' : TT('Are you sure?'), 'Plush-confirm' : TT('Are you sure?'),

386
sabnzbd/utils/configobj.py

File diff suppressed because it is too large

6
sabnzbd/utils/feedparser.py

@ -3485,7 +3485,7 @@ def _parse_date_group_rfc822(m):
# If the year is 2 digits, assume everything in the 90's is the 1990's # If the year is 2 digits, assume everything in the 90's is the 1990's
if m['year'] < 100: if m['year'] < 100:
m['year'] += (1900, 2000)[m['year'] < 90] m['year'] += (1900, 2000)[m['year'] < 90]
stamp = datetime.datetime(*[m[i] for i in stamp = datetime.datetime(*[m[i] for i in
('year', 'month', 'day', 'hour', 'minute', 'second')]) ('year', 'month', 'day', 'hour', 'minute', 'second')])
# Use the timezone information to calculate the difference between # Use the timezone information to calculate the difference between
@ -3524,7 +3524,7 @@ def _parse_date_rfc822(dt):
registerDateHandler(_parse_date_rfc822) registerDateHandler(_parse_date_rfc822)
def _parse_date_rfc822_grubby(dt): def _parse_date_rfc822_grubby(dt):
"""Parse date format similar to RFC 822, but """Parse date format similar to RFC 822, but
the comma after the dayname is optional and the comma after the dayname is optional and
month/day are inverted""" month/day are inverted"""
_rfc822_date_grubby = "%s %s %s" % (_rfc822_month, _rfc822_day, _rfc822_year) _rfc822_date_grubby = "%s %s %s" % (_rfc822_month, _rfc822_day, _rfc822_year)
@ -3725,7 +3725,7 @@ def convert_to_utf8(http_headers, data):
u'application/xml-external-parsed-entity') u'application/xml-external-parsed-entity')
text_content_types = (u'text/xml', u'text/xml-external-parsed-entity') text_content_types = (u'text/xml', u'text/xml-external-parsed-entity')
if (http_content_type in application_content_types) or \ if (http_content_type in application_content_types) or \
(http_content_type.startswith(u'application/') and (http_content_type.startswith(u'application/') and
http_content_type.endswith(u'+xml')): http_content_type.endswith(u'+xml')):
acceptable_content_type = 1 acceptable_content_type = 1
rfc3023_encoding = http_encoding or xml_encoding or u'utf-8' rfc3023_encoding = http_encoding or xml_encoding or u'utf-8'

4
sabnzbd/utils/pybonjour.py

@ -1813,7 +1813,7 @@ def DNSServiceReconfirmRecord(
flags: flags:
Currently unused, reserved for future use. Currently unused, reserved for future use.
interfaceIndex: interfaceIndex:
If non-zero, specifies the interface of the record in If non-zero, specifies the interface of the record in
question. Passing kDNSServiceInterfaceIndexAny (0) causes all question. Passing kDNSServiceInterfaceIndexAny (0) causes all
instances of this record to be reconfirmed. instances of this record to be reconfirmed.
@ -1855,7 +1855,7 @@ def DNSServiceReconfirmRecord(
def DNSServiceConstructFullName( def DNSServiceConstructFullName(
service = None, service = None,
regtype = _NO_DEFAULT, regtype = _NO_DEFAULT,
domain = _NO_DEFAULT, domain = _NO_DEFAULT,
): ):

124
sabnzbd/utils/rsslib.py

@ -37,15 +37,15 @@ def _xmlcharref_encode(unicode_data, encoding):
class RSS: class RSS:
# """ # """
# RSS # RSS
# #
# This class encapsulates the creation of an RSS 2.0 feed # This class encapsulates the creation of an RSS 2.0 feed
# #
# The RSS2.0 spec can be found here: # The RSS2.0 spec can be found here:
# http://blogs.law.harvard.edu/tech/rss # http://blogs.law.harvard.edu/tech/rss
# #
# #
# RSS validator : http://rss.scripting.com # RSS validator : http://rss.scripting.com
# #
# #
@ -56,26 +56,26 @@ class RSS:
# rss.channel.link = "http://channel.com" # rss.channel.link = "http://channel.com"
# rss.channel.title = "my channel title" # rss.channel.title = "my channel title"
# rss.channel.description = "my channel description" # rss.channel.description = "my channel description"
# #
# ns = Namespace( "foobar", "http://foobar.baz" ) # ns = Namespace( "foobar", "http://foobar.baz" )
# rss.channel.namespaces.append( ns ) # rss.channel.namespaces.append( ns )
# #
# item = Item() # item = Item()
# item.link = "http://link.com" # item.link = "http://link.com"
# item.description = "my link description" # item.description = "my link description"
# item.title ="my item title" # item.title ="my item title"
# item.nsItems[ns.name + ":foo"] = "bar" # item.nsItems[ns.name + ":foo"] = "bar"
# rss.channel.items.append( item ) # rss.channel.items.append( item )
# #
# item = Item() # item = Item()
# item.link = "http://link2.com" # item.link = "http://link2.com"
# item.description = "my link2 description" # item.description = "my link2 description"
# item.title ="my item2 title" # item.title ="my item2 title"
# item.nsItems[ns.name +":foo"] = "foo bar baz" # item.nsItems[ns.name +":foo"] = "foo bar baz"
# rss.channel.items.append( item ) # rss.channel.items.append( item )
# #
# print rss.write() # print rss.write()
# #
# output: # output:
# <?xml version="1.0" encoding="UTF-8"?> # <?xml version="1.0" encoding="UTF-8"?>
# <rss version="2.0" xmlns:foobar=http://foobar.baz > # <rss version="2.0" xmlns:foobar=http://foobar.baz >
@ -83,76 +83,76 @@ class RSS:
# <title>my channel title</title> # <title>my channel title</title>
# <link>http://channel.com</link> # <link>http://channel.com</link>
# <description>my channel description</description> # <description>my channel description</description>
# #
# <item><title>my item title</title> # <item><title>my item title</title>
# <link>http://link.com</link> # <link>http://link.com</link>
# <description>my link description</description> # <description>my link description</description>
# <foobar:foo>bar</foobar:foo> # <foobar:foo>bar</foobar:foo>
# </item> # </item>
# #
# <item><title>my item2 title</title> # <item><title>my item2 title</title>
# <link>http://link2.com</link> # <link>http://link2.com</link>
# <description>my link2 description</description> # <description>my link2 description</description>
# <foobar:foo>foo bar baz</foobar:foo> # <foobar:foo>foo bar baz</foobar:foo>
# </item> # </item>
# #
# </channel> # </channel>
# </rss> # </rss>
# #
# author: cmallory /a t/ berserk /dot/ o r g # author: cmallory /a t/ berserk /dot/ o r g
# """ # """
def __init__(self): def __init__(self):
self.channel = Channel() self.channel = Channel()
self.version = "2.0" self.version = "2.0"
self.contents = None self.contents = None
# if __name__ == "__main__" : # if __name__ == "__main__" :
# from rsslib import RSS, Item, Namespace # from rsslib import RSS, Item, Namespace
# rss = RSS() # rss = RSS()
# rss.channel.link = "http://channel.com" # rss.channel.link = "http://channel.com"
# rss.channel.title = "my channel title" # rss.channel.title = "my channel title"
# rss.channel.description = "my channel description" # rss.channel.description = "my channel description"
# #
# ns = Namespace( "foobar", "http://foobar.baz" ) # ns = Namespace( "foobar", "http://foobar.baz" )
# rss.addNamespace( ns ) # rss.addNamespace( ns )
# #
# item = Item() # item = Item()
# item.link = "http://link.com" # item.link = "http://link.com"
# item.description = "my link description" # item.description = "my link description"
# item.title ="my item title" # item.title ="my item title"
# #
# item.enclosure.url = "http://enclosure.url.com" # item.enclosure.url = "http://enclosure.url.com"
# item.enclosure.length = 12345 # item.enclosure.length = 12345
# item.enclosure.type = "audio/mpeg" # item.enclosure.type = "audio/mpeg"
# #
# item.nsItems[ns.name + ":foo"] = "bar" # item.nsItems[ns.name + ":foo"] = "bar"
# rss.addItem( item ) # rss.addItem( item )
# #
# item = Item() # item = Item()
# item.link = "http://link2.com" # item.link = "http://link2.com"
# item.description = "my link2 description" # item.description = "my link2 description"
# item.title ="my item2 title" # item.title ="my item2 title"
# item.nsItems[ns.name +":foo"] = "foo bar baz" # item.nsItems[ns.name +":foo"] = "foo bar baz"
# rss.addItem( item ) # rss.addItem( item )
# #
# print rss.write() # print rss.write()
#Write out the rss document #Write out the rss document
def write( self ): def write( self ):
self.contents = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" self.contents = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
#contents += "<!--\n Last " + cnt + " urls to be shrunk \n-->\n" #contents += "<!--\n Last " + cnt + " urls to be shrunk \n-->\n"
self.contents += "<rss version=\"" + self.version + "\" " self.contents += "<rss version=\"" + self.version + "\" "
if ( self.channel is not None and self.channel.namespaces is not None ): if ( self.channel is not None and self.channel.namespaces is not None ):
for ns in self.channel.namespaces : for ns in self.channel.namespaces :
self.contents += "xmlns:" + ns.name + "=\"" + ns.url + "\" " self.contents += "xmlns:" + ns.name + "=\"" + ns.url + "\" "
self.contents += ">\n" self.contents += ">\n"
self.contents += self.generateChannel() self.contents += self.generateChannel()
self.contents += "</rss>\n"; self.contents += "</rss>\n";
return self.contents return self.contents
#Generates everything contained in a <channel> element #Generates everything contained in a <channel> element
def generateChannel( self ): def generateChannel( self ):
contents = "" contents = ""
@ -161,7 +161,7 @@ class RSS:
contents += self.optionalWrite("title", self.channel.title ); contents += self.optionalWrite("title", self.channel.title );
contents += self.optionalWrite("link", self.channel.link ); contents += self.optionalWrite("link", self.channel.link );
contents += self.optionalWrite("description", self.channel.description ); contents += self.optionalWrite("description", self.channel.description );
contents += self.optionalWrite("language", self.channel.language ); contents += self.optionalWrite("language", self.channel.language );
contents += self.optionalWrite("copyright", self.channel.copyright ); contents += self.optionalWrite("copyright", self.channel.copyright );
contents += self.optionalWrite("category", self.channel.category ); contents += self.optionalWrite("category", self.channel.category );
@ -172,18 +172,18 @@ class RSS:
contents += self.optionalWrite("docs", self.channel.docs ); contents += self.optionalWrite("docs", self.channel.docs );
contents += self.optionalWrite("cloud", self.channel.cloud ); contents += self.optionalWrite("cloud", self.channel.cloud );
contents += self.optionalWrite("ttl", self.channel.ttl ); contents += self.optionalWrite("ttl", self.channel.ttl );
contents += self.optionalWrite("generator", self.channel.generator ); contents += self.optionalWrite("generator", self.channel.generator );
contents += self.optionalWrite("image", self.channel.image ); contents += self.optionalWrite("image", self.channel.image );
contents += self.optionalWrite("rating", self.channel.rating ); contents += self.optionalWrite("rating", self.channel.rating );
contents += self.optionalWrite("textInput", self.channel.textInput ); contents += self.optionalWrite("textInput", self.channel.textInput );
contents += self.optionalWrite("skipHours", self.channel.skipHours ); contents += self.optionalWrite("skipHours", self.channel.skipHours );
contents += self.optionalWrite("skipDays", self.channel.skipDays ); contents += self.optionalWrite("skipDays", self.channel.skipDays );
contents += "\n" + self.generateItems() + "</channel>\n" contents += "\n" + self.generateItems() + "</channel>\n"
else : else :
contents = "[Channel not properly initialized. " contents = "[Channel not properly initialized. "
contents +="A required field is not set.(title/link/description]" contents +="A required field is not set.(title/link/description]"
return contents return contents
#Generates all items within a channel #Generates all items within a channel
@ -202,17 +202,17 @@ class RSS:
c += self.optionalWrite("comments", i.comments ) c += self.optionalWrite("comments", i.comments )
c += self.optionalWrite("guid", i.guid ) c += self.optionalWrite("guid", i.guid )
c += self.optionalWrite("source", i.source ) c += self.optionalWrite("source", i.source )
if ( i.enclosure.url != "" ): if ( i.enclosure.url != "" ):
c+= "<enclosure url=\"" + i.enclosure.url + "\" " c+= "<enclosure url=\"" + i.enclosure.url + "\" "
c+= "length=\"" + str(i.enclosure.length )+ "\" " c+= "length=\"" + str(i.enclosure.length )+ "\" "
c+= "type=\"" + i.enclosure.type + "\"/>\n" c+= "type=\"" + i.enclosure.type + "\"/>\n"
for k in i.nsItems.keys(): for k in i.nsItems.keys():
c += self.optionalWrite( k , i.nsItems[ k ] ) c += self.optionalWrite( k , i.nsItems[ k ] )
c += "</item>\n\n" c += "</item>\n\n"
return c return c
@ -223,8 +223,8 @@ class RSS:
def addItem( self, item ): def addItem( self, item ):
if ( self.channel is not None): if ( self.channel is not None):
self.channel.items.append( item ) self.channel.items.append( item )
def optionalWrite( self, key, val ): def optionalWrite( self, key, val ):
if ( val is not None and val != "" ): if ( val is not None and val != "" ):
return "<" + key + ">" + encode_for_xml(xml.sax.saxutils.escape(val)) + "</" + key + ">\n" return "<" + key + ">" + encode_for_xml(xml.sax.saxutils.escape(val)) + "</" + key + ">\n"
@ -238,13 +238,13 @@ class Namespace:
self.url = url self.url = url
self.name = name self.name = name
class Channel: class Channel:
# """ # """
# Channel # Channel
# #
# (http://blogs.law.harvard.edu/tech/rss) # (http://blogs.law.harvard.edu/tech/rss)
# #
# This object represents an RSS channel (as of ver2.0) # This object represents an RSS channel (as of ver2.0)
# """ # """
@ -274,26 +274,26 @@ class Channel:
self.textInput = "" self.textInput = ""
self.skipHours = "" self.skipHours = ""
self.skipDays = "" self.skipDays = ""
self.items = [] self.items = []
self.namespaces = [] self.namespaces = []
def initialized( self ): def initialized( self ):
return self.title is not None and self.link is not None and self.description is not None return self.title is not None and self.link is not None and self.description is not None
class Item: class Item:
# """ # """
# Item # Item
# #
# http://blogs.law.harvard.edu/tech/rss#hrelementsOfLtitemgt # http://blogs.law.harvard.edu/tech/rss#hrelementsOfLtitemgt
# #
# A channel may contain any number of &lt;item&gt;s. An item may # A channel may contain any number of &lt;item&gt;s. An item may
# represent a "story" -- much like a story in a newspaper or magazine; # represent a "story" -- much like a story in a newspaper or magazine;
# if so its description is a synopsis of the story, and the link # if so its description is a synopsis of the story, and the link
# points to the full story. An item may also be complete in itself, # points to the full story. An item may also be complete in itself,
# if so, the description contains the text (entity-encoded HTML is # if so, the description contains the text (entity-encoded HTML is
# allowed; see examples), and the link and title may be omitted. # allowed; see examples), and the link and title may be omitted.
# All elements of an item are optional, however at least one of # All elements of an item are optional, however at least one of
# title or description must be present. # title or description must be present.
# """ # """
def __init__( self ): def __init__( self ):
@ -309,32 +309,32 @@ class Item:
self.pubDate = "" self.pubDate = ""
self.source = "" self.source = ""
self.enclosure = Enclosure() self.enclosure = Enclosure()
self.nsItems = {} self.nsItems = {}
class Enclosure: class Enclosure:
# """ # """
# Enclosure # Enclosure
# #
# <enclosure> sub-element of <item> # <enclosure> sub-element of <item>
# #
# <enclosure> is an optional sub-element of <item>. # <enclosure> is an optional sub-element of <item>.
# #
# It has three required attributes: # It has three required attributes:
# #
# url: says where the enclosure is located, # url: says where the enclosure is located,
# length: says how big it is in bytes, and # length: says how big it is in bytes, and
# type: says what its type is, a standard MIME type. # type: says what its type is, a standard MIME type.
# #
# The url must be an http url. # The url must be an http url.
# #
# Example: <enclosure url="http://www.scripting.com/mp3s/weatherReportSuite.mp3" length="12216320" type="audio/mpeg" /> # Example: <enclosure url="http://www.scripting.com/mp3s/weatherReportSuite.mp3" length="12216320" type="audio/mpeg" />
# #
# """ # """
def __init__(self): def __init__(self):
self.url = "" self.url = ""
self.length = 0 self.length = 0
self.type = "" self.type = ""

42
sabnzbd/utils/ssmtplib.py

@ -12,22 +12,22 @@ Public errors: SMTPSSLException
# #
# Copyright (c) 2007 M Butcher # Copyright (c) 2007 M Butcher
# #
# Permission is hereby granted, free of charge, to any person obtaining a copy # Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal # of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights # in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is # copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions: # furnished to do so, subject to the following conditions:
# #
# The above copyright notice and this permission notice shall be included in # The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software. # all copies or substantial portions of the Software.
# #
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE. # SOFTWARE.
## ##
##End License ##End License
@ -43,7 +43,7 @@ SSMTP_PORT = 465
class SMTPSSLException(smtplib.SMTPException): class SMTPSSLException(smtplib.SMTPException):
"""Base class for exceptions resulting from SSL negotiation.""" """Base class for exceptions resulting from SSL negotiation."""
class SMTP_SSL (smtplib.SMTP): class SMTP_SSL (smtplib.SMTP):
"""This class provides SSL access to an SMTP server. """This class provides SSL access to an SMTP server.
SMTP over SSL typical listens on port 465. Unlike StartTLS, SMTP over SSL SMTP over SSL typical listens on port 465. Unlike StartTLS, SMTP over SSL
@ -52,7 +52,7 @@ class SMTP_SSL (smtplib.SMTP):
This class is a simple subclass of the smtplib.SMTP class that comes with This class is a simple subclass of the smtplib.SMTP class that comes with
Python. It overrides the connect() method to use an SSL socket, and it Python. It overrides the connect() method to use an SSL socket, and it
overrides the starttles() function to throw an error (you can't do overrides the starttles() function to throw an error (you can't do
starttls within an SSL session). starttls within an SSL session).
""" """
certfile = None certfile = None
@ -66,7 +66,7 @@ class SMTP_SSL (smtplib.SMTP):
which this object will connect. `local_hostname' is the name of the which this object will connect. `local_hostname' is the name of the
localhost. By default, the value of socket.getfqdn() is used. localhost. By default, the value of socket.getfqdn() is used.
An SMTPConnectError is raised if the SMTP host does not respond An SMTPConnectError is raised if the SMTP host does not respond
correctly. correctly.
An SMTPSSLError is raised if SSL negotiation fails. An SMTPSSLError is raised if SSL negotiation fails.
@ -84,16 +84,16 @@ class SMTP_SSL (smtplib.SMTP):
`host' is localhost by default. Port will be set to 465 (the default `host' is localhost by default. Port will be set to 465 (the default
SSL SMTP port) if no port is specified. SSL SMTP port) if no port is specified.
If the host name ends with a colon (`:') followed by a number, If the host name ends with a colon (`:') followed by a number,
that suffix will be stripped off and the that suffix will be stripped off and the
number interpreted as the port number to use. This will override the number interpreted as the port number to use. This will override the
`port' parameter. `port' parameter.
Note: This method is automatically invoked by __init__, if a host is Note: This method is automatically invoked by __init__, if a host is
specified during instantiation. specified during instantiation.
""" """
# MB: Most of this (Except for the socket connection code) is from # MB: Most of this (Except for the socket connection code) is from
# the SMTP.connect() method. I changed only the bare minimum for the # the SMTP.connect() method. I changed only the bare minimum for the
# sake of compatibility. # sake of compatibility.
if not port and (host.find(':') == host.rfind(':')): if not port and (host.find(':') == host.rfind(':')):
i = host.rfind(':') i = host.rfind(':')
@ -115,7 +115,7 @@ class SMTP_SSL (smtplib.SMTP):
# MB: Make the SSL connection. # MB: Make the SSL connection.
sslobj = socket.ssl(self.sock, self.keyfile, self.certfile) sslobj = socket.ssl(self.sock, self.keyfile, self.certfile)
except socket.error, msg: except socket.error, msg:
if self.debuglevel > 0: if self.debuglevel > 0:
print>>stderr, 'connect fail:', (host, port) print>>stderr, 'connect fail:', (host, port)
if self.sock: if self.sock:
self.sock.close() self.sock.close()
@ -152,7 +152,7 @@ class SMTP_SSL (smtplib.SMTP):
self.certfile = certfile self.certfile = certfile
def starttls(self, keyfile = None, certfile = None): def starttls(self, keyfile = None, certfile = None):
"""Raises an exception. """Raises an exception.
You cannot do StartTLS inside of an ssl session. Calling starttls() will You cannot do StartTLS inside of an ssl session. Calling starttls() will
return an SMTPSSLException""" return an SMTPSSLException"""
raise SMTPSSLException, "Cannot perform StartTLS within SSL session." raise SMTPSSLException, "Cannot perform StartTLS within SSL session."

14
sabnzbd/utils/systrayiconthread.py

@ -94,19 +94,19 @@ class SysTrayIconThread(Thread):
# override this # override this
def doUpdates(self): def doUpdates(self):
pass pass
# Notification # Notification
def sendnotification(self, title, msg): def sendnotification(self, title, msg):
hicon = self.get_icon(self.icon) hicon = self.get_icon(self.icon)
win32gui.Shell_NotifyIcon(win32gui.NIM_MODIFY, win32gui.Shell_NotifyIcon(win32gui.NIM_MODIFY,
(self.hwnd, (self.hwnd,
0, 0,
win32gui.NIF_INFO, win32gui.NIF_INFO,
win32con.WM_USER+20, win32con.WM_USER+20,
hicon, hicon,
"Balloon tooltip", "Balloon tooltip",
msg, msg,
200, 200,
title)) title))
def _add_ids_to_menu_options(self, menu_options): def _add_ids_to_menu_options(self, menu_options):

Loading…
Cancel
Save