Browse Source

Code-formatting: optimize imports

tags/3.0.0Beta3
Safihre 5 years ago
parent
commit
db5ff8c7e1
  1. 50
      SABnzbd.py
  2. 25
      sabnzbd/__init__.py
  3. 48
      sabnzbd/api.py
  4. 5
      sabnzbd/articlecache.py
  5. 14
      sabnzbd/assembler.py
  6. 4
      sabnzbd/bpsmeter.py
  7. 21
      sabnzbd/cfg.py
  8. 10
      sabnzbd/config.py
  9. 12
      sabnzbd/database.py
  10. 8
      sabnzbd/decoder.py
  11. 14
      sabnzbd/directunpacker.py
  12. 10
      sabnzbd/dirscanner.py
  13. 21
      sabnzbd/downloader.py
  14. 10
      sabnzbd/emailer.py
  15. 2
      sabnzbd/encoding.py
  16. 10
      sabnzbd/filesystem.py
  17. 6
      sabnzbd/getipaddress.py
  18. 79
      sabnzbd/interface.py
  19. 4
      sabnzbd/lang.py
  20. 20
      sabnzbd/misc.py
  21. 16
      sabnzbd/newsunpack.py
  22. 10
      sabnzbd/newswrapper.py
  23. 8
      sabnzbd/notifier.py
  24. 6
      sabnzbd/nzbparser.py
  25. 29
      sabnzbd/nzbqueue.py
  26. 46
      sabnzbd/nzbstuff.py
  27. 30
      sabnzbd/osxmenu.py
  28. 4
      sabnzbd/panic.py
  29. 5
      sabnzbd/par2file.py
  30. 72
      sabnzbd/postproc.py
  31. 3
      sabnzbd/powersup.py
  32. 12
      sabnzbd/rating.py
  33. 16
      sabnzbd/rss.py
  34. 6
      sabnzbd/sabtray.py
  35. 3
      sabnzbd/sabtraylinux.py
  36. 15
      sabnzbd/scheduler.py
  37. 6
      sabnzbd/sorting.py
  38. 19
      sabnzbd/urlgrabber.py
  39. 7
      sabnzbd/utils/certgen.py
  40. 2
      sabnzbd/utils/checkdir.py
  41. 2
      sabnzbd/utils/diskspeed.py
  42. 3
      sabnzbd/utils/getperformance.py
  43. 4
      sabnzbd/utils/happyeyeballs.py
  44. 2
      sabnzbd/utils/internetspeed.py
  45. 1
      sabnzbd/utils/pathbrowser.py
  46. 6
      sabnzbd/utils/servertests.py
  47. 3
      sabnzbd/utils/systrayiconthread.py
  48. 2
      sabnzbd/zconfig.py
  49. 2
      tests/conftest.py
  50. 7
      tests/sabnews.py
  51. 6
      tests/test_filesystem.py
  52. 1
      tests/test_functional_downloads.py
  53. 2
      tests/test_functional_misc.py
  54. 3
      tests/test_postproc.py
  55. 6
      tests/test_urlgrabber.py
  56. 1
      tests/test_utils/test_happyeyeballs.py
  57. 5
      tests/test_utils/test_sleepless.py
  58. 1
      tests/test_win_utils.py
  59. 4
      tests/testhelper.py
  60. 2
      tools/extract_pot.py
  61. 4
      tools/make_mo.py

50
SABnzbd.py

@ -15,36 +15,36 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import sys import getopt
if sys.hexversion < 0x03050000:
print("Sorry, requires Python 3.5 or above")
print("You can read more at: https://sabnzbd.org/python3")
sys.exit(1)
import logging import logging
import logging.handlers import logging.handlers
import traceback import platform
import getopt import re
import signal import signal
import socket import socket
import platform
import subprocess
import ssl import ssl
import subprocess
import sys
import time import time
import re import traceback
if sys.hexversion < 0x03050000:
print("Sorry, requires Python 3.5 or above")
print("You can read more at: https://sabnzbd.org/python3")
sys.exit(1)
try: try:
import Cheetah import Cheetah
if Cheetah.Version[0] != "3": if Cheetah.Version[0] != "3":
raise ValueError raise ValueError
import feedparser
import configobj
import cherrypy import cherrypy
import portend
import cryptography
import chardet import chardet
import configobj
import cryptography
import feedparser
import portend
except ValueError: except ValueError:
print("Sorry, requires Python module Cheetah 3 or higher.") print("Sorry, requires Python module Cheetah 3 or higher.")
sys.exit(1) sys.exit(1)
@ -56,10 +56,17 @@ except ImportError as e:
sys.exit(1) sys.exit(1)
import sabnzbd import sabnzbd
import sabnzbd.lang import sabnzbd.cfg
import sabnzbd.config as config
import sabnzbd.downloader
import sabnzbd.interface import sabnzbd.interface
from sabnzbd.constants import * import sabnzbd.lang
import sabnzbd.newsunpack import sabnzbd.newsunpack
import sabnzbd.notifier as notifier
import sabnzbd.scheduler as scheduler
import sabnzbd.zconfig
from sabnzbd.constants import *
from sabnzbd.filesystem import get_ext, real_path, long_path, globber_full, remove_file
from sabnzbd.misc import ( from sabnzbd.misc import (
check_latest_version, check_latest_version,
exit_sab, exit_sab,
@ -72,14 +79,7 @@ from sabnzbd.misc import (
get_from_url, get_from_url,
upload_file_to_sabnzbd, upload_file_to_sabnzbd,
) )
from sabnzbd.filesystem import get_ext, real_path, long_path, globber_full, remove_file
from sabnzbd.panic import panic_tmpl, panic_port, panic_host, panic, launch_a_browser from sabnzbd.panic import panic_tmpl, panic_port, panic_host, panic, launch_a_browser
import sabnzbd.scheduler as scheduler
import sabnzbd.config as config
import sabnzbd.cfg
import sabnzbd.downloader
import sabnzbd.notifier as notifier
import sabnzbd.zconfig
try: try:
import win32api import win32api

25
sabnzbd/__init__.py

@ -15,24 +15,25 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# Imported to be referenced from other files directly
from sabnzbd.version import __version__, __baseline__
import os
import logging
import datetime import datetime
import tempfile
import pickle
import gzip import gzip
import subprocess import logging
import time import os
import socket import pickle
import cherrypy
import sys
import re import re
import socket
import ssl import ssl
import subprocess
import sys
import tempfile
import time
from threading import Lock, Thread from threading import Lock, Thread
import cherrypy
# Imported to be referenced from other files directly
from sabnzbd.version import __version__, __baseline__
############################################################################## ##############################################################################
# Determine platform flags # Determine platform flags
############################################################################## ##############################################################################

48
sabnzbd/api.py

@ -19,15 +19,13 @@
sabnzbd.api - api sabnzbd.api - api
""" """
import os
import logging
import re
import datetime import datetime
import time
import json import json
import cherrypy
import locale import locale
import logging
import os
import re
import time
from threading import Thread from threading import Thread
try: try:
@ -36,7 +34,17 @@ try:
except ImportError: except ImportError:
pass pass
import cherrypy
import sabnzbd import sabnzbd
import sabnzbd.cfg as cfg
import sabnzbd.config as config
import sabnzbd.emailer
import sabnzbd.notifier
import sabnzbd.rss
import sabnzbd.scheduler as scheduler
from sabnzbd.articlecache import ArticleCache
from sabnzbd.bpsmeter import BPSMeter
from sabnzbd.constants import ( from sabnzbd.constants import (
VALID_ARCHIVES, VALID_ARCHIVES,
VALID_NZB_FILES, VALID_NZB_FILES,
@ -50,14 +58,11 @@ from sabnzbd.constants import (
MEBI, MEBI,
GIGI, GIGI,
) )
import sabnzbd.config as config from sabnzbd.database import build_history_info, unpack_history_info, HistoryDB
import sabnzbd.cfg as cfg
from sabnzbd.downloader import Downloader from sabnzbd.downloader import Downloader
from sabnzbd.nzbqueue import NzbQueue from sabnzbd.encoding import xml_name
import sabnzbd.scheduler as scheduler from sabnzbd.filesystem import diskspace, get_ext, globber_full, clip_path, remove_all
from sabnzbd.skintext import SKIN_TEXT from sabnzbd.getipaddress import localipv4, publicipv4, ipv6, addresslookup
from sabnzbd.utils.pathbrowser import folders_at_path
from sabnzbd.utils.getperformance import getcpu
from sabnzbd.misc import ( from sabnzbd.misc import (
loadavg, loadavg,
to_units, to_units,
@ -68,19 +73,14 @@ from sabnzbd.misc import (
calc_age, calc_age,
opts_to_pp, opts_to_pp,
) )
from sabnzbd.filesystem import diskspace, get_ext, globber_full, clip_path, remove_all from sabnzbd.newsunpack import userxbit
from sabnzbd.encoding import xml_name from sabnzbd.nzbqueue import NzbQueue
from sabnzbd.postproc import PostProcessor from sabnzbd.postproc import PostProcessor
from sabnzbd.articlecache import ArticleCache
from sabnzbd.utils.servertests import test_nntp_server_dict
from sabnzbd.bpsmeter import BPSMeter
from sabnzbd.rating import Rating from sabnzbd.rating import Rating
from sabnzbd.getipaddress import localipv4, publicipv4, ipv6, addresslookup from sabnzbd.skintext import SKIN_TEXT
from sabnzbd.newsunpack import userxbit from sabnzbd.utils.getperformance import getcpu
from sabnzbd.database import build_history_info, unpack_history_info, HistoryDB from sabnzbd.utils.pathbrowser import folders_at_path
import sabnzbd.notifier from sabnzbd.utils.servertests import test_nntp_server_dict
import sabnzbd.rss
import sabnzbd.emailer
############################################################################## ##############################################################################
# API error messages # API error messages

5
sabnzbd/articlecache.py

@ -19,13 +19,12 @@
sabnzbd.articlecache - Article cache handling sabnzbd.articlecache - Article cache handling
""" """
import logging
import threading
import struct import struct
import threading
import sabnzbd import sabnzbd
from sabnzbd.decorators import synchronized
from sabnzbd.constants import GIGI, ANFO, MEBI, LIMIT_DECODE_QUEUE, MIN_DECODE_QUEUE from sabnzbd.constants import GIGI, ANFO, MEBI, LIMIT_DECODE_QUEUE, MIN_DECODE_QUEUE
from sabnzbd.decorators import synchronized
# Operations on lists and dicts are atomic, but for # Operations on lists and dicts are atomic, but for
# the bytes counter we do need a lock # the bytes counter we do need a lock

14
sabnzbd/assembler.py

@ -19,24 +19,24 @@
sabnzbd.assembler - threaded assembly/decoding of files sabnzbd.assembler - threaded assembly/decoding of files
""" """
import hashlib
import logging
import os import os
import queue import queue
import logging
import re import re
from threading import Thread from threading import Thread
from time import sleep from time import sleep
import hashlib
import sabnzbd import sabnzbd
from sabnzbd.misc import get_all_passwords
from sabnzbd.filesystem import set_permissions, clip_path, has_win_device, diskspace, get_filename, get_ext
from sabnzbd.constants import Status, GIGI, MAX_ASSEMBLER_QUEUE
import sabnzbd.cfg as cfg import sabnzbd.cfg as cfg
from sabnzbd.articlecache import ArticleCache
from sabnzbd.postproc import PostProcessor
import sabnzbd.downloader import sabnzbd.downloader
import sabnzbd.par2file as par2file import sabnzbd.par2file as par2file
import sabnzbd.utils.rarfile as rarfile import sabnzbd.utils.rarfile as rarfile
from sabnzbd.articlecache import ArticleCache
from sabnzbd.constants import Status, GIGI, MAX_ASSEMBLER_QUEUE
from sabnzbd.filesystem import set_permissions, clip_path, has_win_device, diskspace, get_filename, get_ext
from sabnzbd.misc import get_all_passwords
from sabnzbd.postproc import PostProcessor
from sabnzbd.rating import Rating from sabnzbd.rating import Rating

4
sabnzbd/bpsmeter.py

@ -19,13 +19,13 @@
sabnzbd.bpsmeter - bpsmeter sabnzbd.bpsmeter - bpsmeter
""" """
import time
import logging import logging
import re import re
import time
import sabnzbd import sabnzbd
from sabnzbd.constants import BYTES_FILE_NAME, KIBI
import sabnzbd.cfg as cfg import sabnzbd.cfg as cfg
from sabnzbd.constants import BYTES_FILE_NAME, KIBI
DAY = float(24 * 60 * 60) DAY = float(24 * 60 * 60)
WEEK = DAY * 7 WEEK = DAY * 7

21
sabnzbd/cfg.py

@ -21,17 +21,6 @@ sabnzbd.cfg - Configuration Parameters
import re import re
import sabnzbd import sabnzbd
from sabnzbd.constants import (
DEF_HOST,
DEF_PORT,
DEF_STDINTF,
DEF_ADMIN_DIR,
DEF_DOWNLOAD_DIR,
DEF_NZBBACK_DIR,
DEF_SCANRATE,
DEF_COMPLETE_DIR,
)
from sabnzbd.config import ( from sabnzbd.config import (
OptionBool, OptionBool,
OptionNumber, OptionNumber,
@ -46,6 +35,16 @@ from sabnzbd.config import (
create_api_key, create_api_key,
validate_notempty, validate_notempty,
) )
from sabnzbd.constants import (
DEF_HOST,
DEF_PORT,
DEF_STDINTF,
DEF_ADMIN_DIR,
DEF_DOWNLOAD_DIR,
DEF_NZBBACK_DIR,
DEF_SCANRATE,
DEF_COMPLETE_DIR,
)
############################################################################## ##############################################################################
# Email validation support # Email validation support

10
sabnzbd/config.py

@ -19,18 +19,20 @@
sabnzbd.config - Configuration Support sabnzbd.config - Configuration Support
""" """
import logging
import os import os
import re import re
import logging
import threading
import shutil import shutil
import threading
import uuid import uuid
from urllib.parse import urlparse from urllib.parse import urlparse
import configobj
import sabnzbd.misc import sabnzbd.misc
from sabnzbd.filesystem import clip_path, real_path, create_real_path, renamer, remove_file, is_writable
from sabnzbd.constants import CONFIG_VERSION, NORMAL_PRIORITY, DEFAULT_PRIORITY, MAX_WIN_DFOLDER from sabnzbd.constants import CONFIG_VERSION, NORMAL_PRIORITY, DEFAULT_PRIORITY, MAX_WIN_DFOLDER
import configobj
from sabnzbd.decorators import synchronized from sabnzbd.decorators import synchronized
from sabnzbd.filesystem import clip_path, real_path, create_real_path, renamer, remove_file, is_writable
CONFIG_LOCK = threading.Lock() CONFIG_LOCK = threading.Lock()
SAVE_CONFIG_LOCK = threading.Lock() SAVE_CONFIG_LOCK = threading.Lock()

12
sabnzbd/database.py

@ -19,22 +19,22 @@
sabnzbd.database - Database Support sabnzbd.database - Database Support
""" """
import os
import time
import zlib
import logging import logging
import os
import sqlite3
import sys import sys
import threading import threading
import sqlite3 import time
import zlib
import sabnzbd import sabnzbd
import sabnzbd.cfg import sabnzbd.cfg
from sabnzbd.constants import DB_HISTORY_NAME, STAGES, Status
from sabnzbd.bpsmeter import this_week, this_month from sabnzbd.bpsmeter import this_week, this_month
from sabnzbd.constants import DB_HISTORY_NAME, STAGES, Status
from sabnzbd.decorators import synchronized from sabnzbd.decorators import synchronized
from sabnzbd.encoding import ubtou, utob from sabnzbd.encoding import ubtou, utob
from sabnzbd.misc import int_conv, caller_name, opts_to_pp
from sabnzbd.filesystem import remove_file from sabnzbd.filesystem import remove_file
from sabnzbd.misc import int_conv, caller_name, opts_to_pp
DB_LOCK = threading.RLock() DB_LOCK = threading.RLock()

8
sabnzbd/decoder.py

@ -19,18 +19,18 @@
sabnzbd.decoder - article decoder sabnzbd.decoder - article decoder
""" """
import logging
import hashlib import hashlib
import logging
import queue import queue
from threading import Thread from threading import Thread
import sabnzbd import sabnzbd
from sabnzbd.constants import SABYENC_VERSION_REQUIRED import sabnzbd.cfg as cfg
from sabnzbd.articlecache import ArticleCache from sabnzbd.articlecache import ArticleCache
from sabnzbd.constants import SABYENC_VERSION_REQUIRED
from sabnzbd.downloader import Downloader from sabnzbd.downloader import Downloader
from sabnzbd.nzbqueue import NzbQueue
import sabnzbd.cfg as cfg
from sabnzbd.misc import match_str from sabnzbd.misc import match_str
from sabnzbd.nzbqueue import NzbQueue
# Check for correct SABYenc version # Check for correct SABYenc version
SABYENC_VERSION = None SABYENC_VERSION = None

14
sabnzbd/directunpacker.py

@ -19,24 +19,24 @@
sabnzbd.directunpacker sabnzbd.directunpacker
""" """
import logging
import os import os
import re import re
import time
import threading
import subprocess import subprocess
import logging import threading
import time
from subprocess import Popen from subprocess import Popen
import sabnzbd import sabnzbd
import sabnzbd.cfg as cfg import sabnzbd.cfg as cfg
from sabnzbd.misc import int_conv, format_time_string
from sabnzbd.filesystem import clip_path, long_path, remove_all, real_path, remove_file
from sabnzbd.encoding import platform_btou
from sabnzbd.decorators import synchronized from sabnzbd.decorators import synchronized
from sabnzbd.encoding import platform_btou
from sabnzbd.filesystem import clip_path, long_path, remove_all, real_path, remove_file
from sabnzbd.misc import int_conv, format_time_string
from sabnzbd.newsunpack import build_command, EXTRACTFROM_RE, EXTRACTED_RE, rar_volumelist from sabnzbd.newsunpack import build_command, EXTRACTFROM_RE, EXTRACTED_RE, rar_volumelist
from sabnzbd.postproc import prepare_extraction_path from sabnzbd.postproc import prepare_extraction_path
from sabnzbd.utils.rarfile import RarFile
from sabnzbd.utils.diskspeed import diskspeedmeasure from sabnzbd.utils.diskspeed import diskspeedmeasure
from sabnzbd.utils.rarfile import RarFile
# Need a lock to make sure start and stop is handled correctly # Need a lock to make sure start and stop is handled correctly
# Otherwise we could stop while the thread was still starting # Otherwise we could stop while the thread was still starting

10
sabnzbd/dirscanner.py

@ -19,16 +19,16 @@
sabnzbd.dirscanner - Scanner for Watched Folder sabnzbd.dirscanner - Scanner for Watched Folder
""" """
import os
import time
import logging import logging
import os
import threading import threading
import time
import sabnzbd import sabnzbd
from sabnzbd.constants import SCAN_FILE_NAME, VALID_ARCHIVES, VALID_NZB_FILES
import sabnzbd.filesystem as filesystem
import sabnzbd.config as config
import sabnzbd.cfg as cfg import sabnzbd.cfg as cfg
import sabnzbd.config as config
import sabnzbd.filesystem as filesystem
from sabnzbd.constants import SCAN_FILE_NAME, VALID_ARCHIVES, VALID_NZB_FILES
def compare_stat_tuple(tup1, tup2): def compare_stat_tuple(tup1, tup2):

21
sabnzbd/downloader.py

@ -19,27 +19,26 @@
sabnzbd.downloader - download engine sabnzbd.downloader - download engine
""" """
import time
import select
import logging import logging
from threading import Thread, RLock
from nntplib import NNTPPermanentError
import socket
import random import random
import select
import socket
import sys import sys
import time
from nntplib import NNTPPermanentError
from threading import Thread, RLock
import sabnzbd import sabnzbd
from sabnzbd.decorators import synchronized, NzbQueueLocker, DOWNLOADER_CV
from sabnzbd.newswrapper import NewsWrapper, request_server_info
import sabnzbd.notifier as notifier
import sabnzbd.config as config
import sabnzbd.cfg as cfg import sabnzbd.cfg as cfg
from sabnzbd.bpsmeter import BPSMeter import sabnzbd.config as config
import sabnzbd.notifier as notifier
import sabnzbd.scheduler import sabnzbd.scheduler
from sabnzbd.bpsmeter import BPSMeter
from sabnzbd.decorators import synchronized, NzbQueueLocker, DOWNLOADER_CV
from sabnzbd.misc import from_units, nntp_to_msg, int_conv from sabnzbd.misc import from_units, nntp_to_msg, int_conv
from sabnzbd.newswrapper import NewsWrapper, request_server_info
from sabnzbd.utils.happyeyeballs import happyeyeballs from sabnzbd.utils.happyeyeballs import happyeyeballs
# Timeout penalty in minutes for each cause # Timeout penalty in minutes for each cause
_PENALTY_UNKNOWN = 3 # Unknown cause _PENALTY_UNKNOWN = 3 # Unknown cause
_PENALTY_502 = 5 # Unknown 502 _PENALTY_502 = 5 # Unknown 502

10
sabnzbd/emailer.py

@ -19,20 +19,20 @@
sabnzbd.emailer - Send notification emails sabnzbd.emailer - Send notification emails
""" """
import smtplib import glob
import logging import logging
import re import re
import smtplib
import time import time
import glob from email.message import EmailMessage
from Cheetah.Template import Template from Cheetah.Template import Template
from email.message import EmailMessage
from sabnzbd.constants import *
import sabnzbd import sabnzbd
import sabnzbd.cfg as cfg
from sabnzbd.constants import *
from sabnzbd.misc import to_units, split_host, time_format from sabnzbd.misc import to_units, split_host, time_format
from sabnzbd.notifier import check_cat from sabnzbd.notifier import check_cat
import sabnzbd.cfg as cfg
RE_HEADER = re.compile(r"^([^:]+):(.*)") RE_HEADER = re.compile(r"^([^:]+):(.*)")

2
sabnzbd/encoding.py

@ -20,9 +20,9 @@ sabnzbd.encoding - Unicode/byte translation functions
""" """
import locale import locale
import chardet
from xml.sax.saxutils import escape from xml.sax.saxutils import escape
import chardet
CODEPAGE = locale.getpreferredencoding() CODEPAGE = locale.getpreferredencoding()

10
sabnzbd/filesystem.py

@ -19,20 +19,20 @@
sabnzbd.misc - filesystem operations sabnzbd.misc - filesystem operations
""" """
import os import fnmatch
import sys
import logging import logging
import os
import re import re
import shutil import shutil
import stat
import sys
import threading import threading
import time import time
import fnmatch
import stat
import zipfile import zipfile
import sabnzbd import sabnzbd
from sabnzbd.decorators import synchronized
from sabnzbd.constants import FUTURE_Q_FOLDER, JOB_ADMIN, GIGI from sabnzbd.constants import FUTURE_Q_FOLDER, JOB_ADMIN, GIGI
from sabnzbd.decorators import synchronized
from sabnzbd.encoding import correct_unknown_encoding from sabnzbd.encoding import correct_unknown_encoding
from sabnzbd.utils import rarfile from sabnzbd.utils import rarfile

6
sabnzbd/getipaddress.py

@ -19,11 +19,11 @@
sabnzbd.getipaddress sabnzbd.getipaddress
""" """
import socket
import multiprocessing.pool
import functools import functools
import urllib.request import multiprocessing.pool
import socket
import urllib.error import urllib.error
import urllib.request
import sabnzbd import sabnzbd
import sabnzbd.cfg import sabnzbd.cfg

79
sabnzbd/interface.py

@ -19,26 +19,54 @@
sabnzbd.interface - webinterface sabnzbd.interface - webinterface
""" """
import os import functools
import time import hashlib
from datetime import datetime
import cherrypy
import logging import logging
import urllib.request, urllib.parse, urllib.error import os
import re import re
import hashlib
import socket import socket
import ssl import ssl
import functools import time
from threading import Thread import urllib.error
import urllib.parse
import urllib.request
from datetime import datetime
from random import randint from random import randint
from threading import Thread
from xml.sax.saxutils import escape from xml.sax.saxutils import escape
import cherrypy
from Cheetah.Template import Template
import sabnzbd import sabnzbd
import sabnzbd.cfg as cfg
import sabnzbd.config as config
import sabnzbd.newsunpack
import sabnzbd.notifier as notifier
import sabnzbd.rss import sabnzbd.rss
import sabnzbd.scheduler as scheduler import sabnzbd.scheduler as scheduler
from sabnzbd.api import (
from Cheetah.Template import Template list_scripts,
list_cats,
del_from_section,
api_handler,
build_queue,
build_status,
retry_job,
build_header,
build_history,
format_bytes,
del_hist_job,
Ttemplate,
build_queue_header,
)
from sabnzbd.bpsmeter import BPSMeter
from sabnzbd.constants import MEBI, DEF_SKIN_COLORS, DEF_STDCONFIG, DEF_MAIN_TMPL, DEFAULT_PRIORITY, CHEETAH_DIRECTIVES
from sabnzbd.decoder import SABYENC_ENABLED
from sabnzbd.downloader import Downloader
from sabnzbd.encoding import xml_name, utob
from sabnzbd.filesystem import real_path, long_path, globber, globber_full, remove_all, clip_path, same_file
from sabnzbd.lang import list_languages
from sabnzbd.misc import ( from sabnzbd.misc import (
to_units, to_units,
from_units, from_units,
@ -50,42 +78,13 @@ from sabnzbd.misc import (
probablyipv6, probablyipv6,
opts_to_pp, opts_to_pp,
) )
from sabnzbd.filesystem import real_path, long_path, globber, globber_full, remove_all, clip_path, same_file
from sabnzbd.newswrapper import GetServerParms from sabnzbd.newswrapper import GetServerParms
from sabnzbd.bpsmeter import BPSMeter
from sabnzbd.encoding import xml_name, utob
import sabnzbd.config as config
import sabnzbd.cfg as cfg
import sabnzbd.notifier as notifier
import sabnzbd.newsunpack
from sabnzbd.downloader import Downloader
from sabnzbd.nzbqueue import NzbQueue from sabnzbd.nzbqueue import NzbQueue
from sabnzbd.utils.servertests import test_nntp_server_dict
from sabnzbd.decoder import SABYENC_ENABLED
from sabnzbd.utils.diskspeed import diskspeedmeasure from sabnzbd.utils.diskspeed import diskspeedmeasure
from sabnzbd.utils.getperformance import getpystone from sabnzbd.utils.getperformance import getpystone
from sabnzbd.utils.internetspeed import internetspeed from sabnzbd.utils.internetspeed import internetspeed
from sabnzbd.utils.servertests import test_nntp_server_dict
from sabnzbd.constants import MEBI, DEF_SKIN_COLORS, DEF_STDCONFIG, DEF_MAIN_TMPL, DEFAULT_PRIORITY, CHEETAH_DIRECTIVES
from sabnzbd.lang import list_languages
from sabnzbd.api import (
list_scripts,
list_cats,
del_from_section,
api_handler,
build_queue,
build_status,
retry_job,
build_header,
build_history,
format_bytes,
report,
del_hist_job,
Ttemplate,
build_queue_header,
)
############################################################################## ##############################################################################
# Global constants # Global constants

4
sabnzbd/lang.py

@ -32,11 +32,11 @@ sabnzbd.lang - Language support
# T() Unicode translation # T() Unicode translation
# TT() Dummy translation, use to mark table entries for POT scanning # TT() Dummy translation, use to mark table entries for POT scanning
import gettext
import builtins import builtins
import gettext
import glob import glob
import os
import locale import locale
import os
__all__ = ["set_locale_info", "set_language", "list_languages"] __all__ = ["set_locale_info", "set_language", "list_languages"]

20
sabnzbd/misc.py

@ -18,23 +18,23 @@
""" """
sabnzbd.misc - misc classes sabnzbd.misc - misc classes
""" """
import os import ctypes
import sys import datetime
import inspect
import logging import logging
import urllib.request import os
import urllib.parse
import re import re
import subprocess
import socket import socket
import subprocess
import sys
import time import time
import datetime import urllib.parse
import inspect import urllib.request
import ctypes
import sabnzbd import sabnzbd
from sabnzbd.constants import DEFAULT_PRIORITY, MEBI, DEF_ARTICLE_CACHE_DEFAULT, DEF_ARTICLE_CACHE_MAX
import sabnzbd.config as config
import sabnzbd.cfg as cfg import sabnzbd.cfg as cfg
import sabnzbd.config as config
from sabnzbd.constants import DEFAULT_PRIORITY, MEBI, DEF_ARTICLE_CACHE_DEFAULT, DEF_ARTICLE_CACHE_MAX
from sabnzbd.encoding import ubtou, platform_btou from sabnzbd.encoding import ubtou, platform_btou
TAB_UNITS = ("", "K", "M", "G", "T", "P") TAB_UNITS = ("", "K", "M", "G", "T", "P")

16
sabnzbd/newsunpack.py

@ -19,21 +19,22 @@
sabnzbd.newsunpack sabnzbd.newsunpack
""" """
import functools
import logging
import os import os
import sys
import re import re
import shutil
import subprocess import subprocess
import logging import sys
import time import time
import zlib import zlib
import shutil
import functools
from subprocess import Popen from subprocess import Popen
import sabnzbd import sabnzbd
from sabnzbd.encoding import platform_btou, correct_unknown_encoding, ubtou import sabnzbd.cfg as cfg
import sabnzbd.utils.rarfile as rarfile import sabnzbd.utils.rarfile as rarfile
from sabnzbd.misc import format_time_string, find_on_path, int_conv, get_all_passwords, calc_age, cmp, caller_name from sabnzbd.constants import Status
from sabnzbd.encoding import platform_btou, correct_unknown_encoding, ubtou
from sabnzbd.filesystem import ( from sabnzbd.filesystem import (
make_script_path, make_script_path,
real_path, real_path,
@ -48,9 +49,8 @@ from sabnzbd.filesystem import (
get_ext, get_ext,
get_filename, get_filename,
) )
from sabnzbd.misc import format_time_string, find_on_path, int_conv, get_all_passwords, calc_age, cmp, caller_name
from sabnzbd.sorting import SeriesSorter from sabnzbd.sorting import SeriesSorter
import sabnzbd.cfg as cfg
from sabnzbd.constants import Status
if sabnzbd.WIN32: if sabnzbd.WIN32:
try: try:

10
sabnzbd/newswrapper.py

@ -20,17 +20,17 @@ sabnzbd.newswrapper
""" """
import errno import errno
import socket
from threading import Thread
from nntplib import NNTPPermanentError
import time
import logging import logging
import socket
import ssl import ssl
import time
from nntplib import NNTPPermanentError
from threading import Thread
import sabnzbd import sabnzbd
import sabnzbd.cfg
from sabnzbd.constants import * from sabnzbd.constants import *
from sabnzbd.encoding import utob from sabnzbd.encoding import utob
import sabnzbd.cfg
from sabnzbd.misc import nntp_to_msg, probablyipv4, probablyipv6 from sabnzbd.misc import nntp_to_msg, probablyipv4, probablyipv6
# Set pre-defined socket timeout # Set pre-defined socket timeout

8
sabnzbd/notifier.py

@ -21,11 +21,13 @@ sabnzbd.notifier - Send notifications to any notification services
""" """
import os.path
import logging
import urllib.request, urllib.error, urllib.parse
import http.client import http.client
import json import json
import logging
import os.path
import urllib.error
import urllib.parse
import urllib.request
from threading import Thread from threading import Thread
import sabnzbd import sabnzbd

6
sabnzbd/nzbparser.py

@ -19,12 +19,12 @@
sabnzbd.nzbparser - Parse and import NZB files sabnzbd.nzbparser - Parse and import NZB files
""" """
import bz2 import bz2
import datetime
import gzip import gzip
import time
import logging
import hashlib import hashlib
import logging
import time
import xml.etree.ElementTree import xml.etree.ElementTree
import datetime
import sabnzbd import sabnzbd
from sabnzbd import filesystem, nzbstuff from sabnzbd import filesystem, nzbstuff

29
sabnzbd/nzbqueue.py

@ -19,20 +19,19 @@
sabnzbd.nzbqueue - nzb queue sabnzbd.nzbqueue - nzb queue
""" """
import os
import logging
import time
import datetime import datetime
import functools import functools
import logging
import os
import time
import sabnzbd import sabnzbd
from sabnzbd.nzbstuff import NzbObject import sabnzbd.cfg as cfg
from sabnzbd.misc import exit_sab, cat_to_opts, int_conv, caller_name, cmp, safe_lower
from sabnzbd.filesystem import get_admin_path, remove_all, globber_full, remove_file
from sabnzbd.nzbparser import process_single_nzb
from sabnzbd.panic import panic_queue
import sabnzbd.database as database import sabnzbd.database as database
from sabnzbd.decorators import NzbQueueLocker import sabnzbd.downloader
import sabnzbd.notifier as notifier
from sabnzbd.assembler import Assembler, file_has_articles
from sabnzbd.bpsmeter import BPSMeter
from sabnzbd.constants import ( from sabnzbd.constants import (
QUEUE_FILE_NAME, QUEUE_FILE_NAME,
QUEUE_VERSION, QUEUE_VERSION,
@ -50,12 +49,12 @@ from sabnzbd.constants import (
QNFO, QNFO,
DIRECT_WRITE_TRIGGER, DIRECT_WRITE_TRIGGER,
) )
from sabnzbd.decorators import NzbQueueLocker
import sabnzbd.cfg as cfg from sabnzbd.filesystem import get_admin_path, remove_all, globber_full, remove_file
import sabnzbd.downloader from sabnzbd.misc import exit_sab, cat_to_opts, int_conv, caller_name, cmp, safe_lower
from sabnzbd.assembler import Assembler, file_has_articles from sabnzbd.nzbparser import process_single_nzb
import sabnzbd.notifier as notifier from sabnzbd.nzbstuff import NzbObject
from sabnzbd.bpsmeter import BPSMeter from sabnzbd.panic import panic_queue
class NzbQueue: class NzbQueue:

46
sabnzbd/nzbstuff.py

@ -19,17 +19,21 @@
sabnzbd.nzbstuff - misc sabnzbd.nzbstuff - misc
""" """
import datetime
import difflib
import functools
import logging
import os import os
import time
import re import re
import logging
import datetime
import threading import threading
import functools import time
import difflib
# SABnzbd modules # SABnzbd modules
import sabnzbd import sabnzbd
import sabnzbd.cfg as cfg
import sabnzbd.config as config
import sabnzbd.nzbparser
from sabnzbd.articlecache import ArticleCache
from sabnzbd.constants import ( from sabnzbd.constants import (
GIGI, GIGI,
ATTRIB_FILE, ATTRIB_FILE,
@ -48,18 +52,8 @@ from sabnzbd.constants import (
Status, Status,
PNFO, PNFO,
) )
from sabnzbd.misc import ( from sabnzbd.database import HistoryDB
to_units, from sabnzbd.decorators import synchronized
cat_to_opts,
cat_convert,
int_conv,
format_time_string,
calc_age,
cmp,
caller_name,
opts_to_pp,
pp_to_opts,
)
from sabnzbd.filesystem import ( from sabnzbd.filesystem import (
sanitize_foldername, sanitize_foldername,
get_unique_path, get_unique_path,
@ -79,12 +73,18 @@ from sabnzbd.filesystem import (
get_filepath, get_filepath,
listdir_full, listdir_full,
) )
from sabnzbd.decorators import synchronized from sabnzbd.misc import (
import sabnzbd.config as config to_units,
import sabnzbd.cfg as cfg cat_to_opts,
import sabnzbd.nzbparser cat_convert,
from sabnzbd.database import HistoryDB int_conv,
from sabnzbd.articlecache import ArticleCache format_time_string,
calc_age,
cmp,
caller_name,
opts_to_pp,
pp_to_opts,
)
from sabnzbd.rating import Rating from sabnzbd.rating import Rating
# Name patterns # Name patterns

30
sabnzbd/osxmenu.py

@ -19,33 +19,29 @@
sabnzbd.osxmenu - OSX Top Menu sabnzbd.osxmenu - OSX Top Menu
""" """
import objc import logging
from Foundation import *
from AppKit import *
from PyObjCTools import AppHelper
from objc import YES, NO
import os import os
import sys import sys
import time import time
import logging
import cherrypy import cherrypy
from AppKit import *
from Foundation import *
from objc import YES, NO
import sabnzbd import sabnzbd
import sabnzbd.cfg import sabnzbd.cfg
from sabnzbd.filesystem import diskspace
from sabnzbd.misc import to_units
from sabnzbd.constants import VALID_ARCHIVES, VALID_NZB_FILES, MEBI, Status
from sabnzbd.panic import launch_a_browser
import sabnzbd.notifier as notifier
from sabnzbd.api import fast_queue
from sabnzbd.nzbqueue import NzbQueue
import sabnzbd.config as config import sabnzbd.config as config
import sabnzbd.scheduler as scheduler
import sabnzbd.downloader import sabnzbd.downloader
import sabnzbd.notifier as notifier
import sabnzbd.scheduler as scheduler
from sabnzbd.api import fast_queue
from sabnzbd.bpsmeter import BPSMeter from sabnzbd.bpsmeter import BPSMeter
from sabnzbd.constants import VALID_ARCHIVES, VALID_NZB_FILES, MEBI, Status
from sabnzbd.filesystem import diskspace
from sabnzbd.misc import to_units
from sabnzbd.nzbqueue import NzbQueue
from sabnzbd.panic import launch_a_browser
status_icons = { status_icons = {
"idle": "icons/sabnzbd_osx_idle.tiff", "idle": "icons/sabnzbd_osx_idle.tiff",

4
sabnzbd/panic.py

@ -19,10 +19,10 @@
sabnzbd.panic - Send panic message to the browser sabnzbd.panic - Send panic message to the browser
""" """
import os import ctypes
import logging import logging
import os
import tempfile import tempfile
import ctypes
try: try:
import webbrowser import webbrowser

5
sabnzbd/par2file.py

@ -18,11 +18,12 @@
""" """
sabnzbd.par2file - All par2-related functionality sabnzbd.par2file - All par2-related functionality
""" """
import os import hashlib
import logging import logging
import os
import re import re
import hashlib
import struct import struct
from sabnzbd.encoding import correct_unknown_encoding from sabnzbd.encoding import correct_unknown_encoding
PROBABLY_PAR2_RE = re.compile(r"(.*)\.vol(\d*)[\+\-](\d*)\.par2", re.I) PROBABLY_PAR2_RE = re.compile(r"(.*)\.vol(\d*)[\+\-](\d*)\.par2", re.I)

72
sabnzbd/postproc.py

@ -19,25 +19,36 @@
sabnzbd.postproc - threaded post-processing of jobs sabnzbd.postproc - threaded post-processing of jobs
""" """
import os
import logging
import sabnzbd
import functools import functools
import time import logging
import re import os
import queue import queue
import re
import time
from threading import Thread
from sabnzbd.newsunpack import ( import sabnzbd
unpack_magic, import sabnzbd.cfg as cfg
par2_repair, import sabnzbd.config as config
external_processing, import sabnzbd.database as database
sfv_check, import sabnzbd.downloader
build_filelists, import sabnzbd.emailer as emailer
rar_sort, import sabnzbd.encoding as encoding
is_sfv_file, import sabnzbd.notifier as notifier
import sabnzbd.nzbqueue
import sabnzbd.utils.checkdir
import sabnzbd.utils.rarfile as rarfile
import sabnzbd.utils.rarvolinfo as rarvolinfo
from sabnzbd.constants import (
REPAIR_PRIORITY,
TOP_PRIORITY,
POSTPROC_QUEUE_FILE_NAME,
POSTPROC_QUEUE_VERSION,
sample_match,
JOB_ADMIN,
Status,
VERIFIED_FILE,
) )
from threading import Thread
from sabnzbd.misc import on_cleanup_list
from sabnzbd.filesystem import ( from sabnzbd.filesystem import (
real_path, real_path,
get_unique_path, get_unique_path,
@ -62,30 +73,19 @@ from sabnzbd.filesystem import (
get_ext, get_ext,
get_filename, get_filename,
) )
from sabnzbd.sorting import Sorter from sabnzbd.misc import on_cleanup_list
from sabnzbd.constants import ( from sabnzbd.newsunpack import (
REPAIR_PRIORITY, unpack_magic,
TOP_PRIORITY, par2_repair,
POSTPROC_QUEUE_FILE_NAME, external_processing,
POSTPROC_QUEUE_VERSION, sfv_check,
sample_match, build_filelists,
JOB_ADMIN, rar_sort,
Status, is_sfv_file,
VERIFIED_FILE,
) )
from sabnzbd.nzbparser import process_single_nzb from sabnzbd.nzbparser import process_single_nzb
from sabnzbd.rating import Rating from sabnzbd.rating import Rating
import sabnzbd.emailer as emailer from sabnzbd.sorting import Sorter
import sabnzbd.downloader
import sabnzbd.config as config
import sabnzbd.cfg as cfg
import sabnzbd.encoding as encoding
import sabnzbd.nzbqueue
import sabnzbd.database as database
import sabnzbd.notifier as notifier
import sabnzbd.utils.rarfile as rarfile
import sabnzbd.utils.rarvolinfo as rarvolinfo
import sabnzbd.utils.checkdir
MAX_FAST_JOB_COUNT = 3 MAX_FAST_JOB_COUNT = 3

3
sabnzbd/powersup.py

@ -19,12 +19,11 @@
sabnzbd.powersup - System power management support sabnzbd.powersup - System power management support
""" """
import logging
import os import os
import subprocess import subprocess
import logging
import time import time
############################################################################## ##############################################################################
# Power management for Windows # Power management for Windows
############################################################################## ##############################################################################

12
sabnzbd/rating.py

@ -19,17 +19,19 @@
sabnzbd.rating - Rating support functions sabnzbd.rating - Rating support functions
""" """
import collections
import copy
import http.client import http.client
import urllib.parse
import time
import logging import logging
import copy
import queue import queue
import collections import time
import urllib.parse
from threading import RLock, Thread from threading import RLock, Thread
import sabnzbd import sabnzbd
from sabnzbd.decorators import synchronized
import sabnzbd.cfg as cfg import sabnzbd.cfg as cfg
from sabnzbd.decorators import synchronized
# A queue which ignores duplicates but maintains ordering # A queue which ignores duplicates but maintains ordering
class OrderedSetQueue(queue.Queue): class OrderedSetQueue(queue.Queue):

16
sabnzbd/rss.py

@ -19,21 +19,21 @@
sabnzbd.rss - rss client functionality sabnzbd.rss - rss client functionality
""" """
import re
import logging
import time
import datetime import datetime
import logging
import re
import threading import threading
import time
import feedparser
import sabnzbd import sabnzbd
import sabnzbd.cfg as cfg
import sabnzbd.config as config
import sabnzbd.emailer as emailer
from sabnzbd.constants import RSS_FILE_NAME, DEFAULT_PRIORITY, NORMAL_PRIORITY, DUP_PRIORITY from sabnzbd.constants import RSS_FILE_NAME, DEFAULT_PRIORITY, NORMAL_PRIORITY, DUP_PRIORITY
from sabnzbd.decorators import synchronized from sabnzbd.decorators import synchronized
import sabnzbd.config as config
import sabnzbd.cfg as cfg
from sabnzbd.misc import cat_convert, wildcard_to_re, cat_to_opts, match_str, from_units, int_conv, get_base_url from sabnzbd.misc import cat_convert, wildcard_to_re, cat_to_opts, match_str, from_units, int_conv, get_base_url
import sabnzbd.emailer as emailer
import feedparser
__RSS = None # Global pointer to RSS-scanner instance __RSS = None # Global pointer to RSS-scanner instance

6
sabnzbd/sabtray.py

@ -19,17 +19,17 @@
sabtray.py - Systray icon for SABnzbd on Windows, contributed by Jan Schejbal sabtray.py - Systray icon for SABnzbd on Windows, contributed by Jan Schejbal
""" """
import os
import logging import logging
import os
from time import sleep from time import sleep
import sabnzbd import sabnzbd
from sabnzbd.panic import launch_a_browser
import sabnzbd.api as api import sabnzbd.api as api
import sabnzbd.cfg as cfg
import sabnzbd.scheduler as scheduler import sabnzbd.scheduler as scheduler
from sabnzbd.downloader import Downloader from sabnzbd.downloader import Downloader
import sabnzbd.cfg as cfg
from sabnzbd.misc import to_units from sabnzbd.misc import to_units
from sabnzbd.panic import launch_a_browser
# contains the tray icon, which demands its own thread # contains the tray icon, which demands its own thread
from sabnzbd.utils.systrayiconthread import SysTrayIconThread from sabnzbd.utils.systrayiconthread import SysTrayIconThread

3
sabnzbd/sabtraylinux.py

@ -19,9 +19,10 @@
sabnzbd.sabtraylinux - System tray icon for Linux, inspired from the Windows one sabnzbd.sabtraylinux - System tray icon for Linux, inspired from the Windows one
""" """
import logging
import gi import gi
from gi.repository import Gtk, GLib from gi.repository import Gtk, GLib
import logging
try: try:
gi.require_version("XApp", "1.0") gi.require_version("XApp", "1.0")

15
sabnzbd/scheduler.py

@ -19,20 +19,19 @@
sabnzbd.scheduler - Event Scheduler sabnzbd.scheduler - Event Scheduler
""" """
import random
import logging import logging
import random
import time import time
import sabnzbd.utils.kronos as kronos import sabnzbd.cfg as cfg
import sabnzbd.rss as rss import sabnzbd.config as config
import sabnzbd.downloader
import sabnzbd.dirscanner import sabnzbd.dirscanner
import sabnzbd.downloader
import sabnzbd.misc import sabnzbd.misc
import sabnzbd.config as config import sabnzbd.rss as rss
import sabnzbd.cfg as cfg import sabnzbd.utils.kronos as kronos
from sabnzbd.postproc import PostProcessor
from sabnzbd.constants import LOW_PRIORITY, NORMAL_PRIORITY, HIGH_PRIORITY from sabnzbd.constants import LOW_PRIORITY, NORMAL_PRIORITY, HIGH_PRIORITY
from sabnzbd.postproc import PostProcessor
__SCHED = None # Global pointer to Scheduler instance __SCHED = None # Global pointer to Scheduler instance

6
sabnzbd/sorting.py

@ -22,11 +22,13 @@ Date Sorting - Sorting downloads by a custom date matching
Generic Sorting - Sorting large files by a custom matching Generic Sorting - Sorting large files by a custom matching
""" """
import os
import logging import logging
import os
import re import re
import sabnzbd import sabnzbd
import sabnzbd.cfg as cfg
from sabnzbd.constants import series_match, date_match, year_match, sample_match
from sabnzbd.filesystem import ( from sabnzbd.filesystem import (
move_to_path, move_to_path,
cleanup_empty_directories, cleanup_empty_directories,
@ -37,8 +39,6 @@ from sabnzbd.filesystem import (
sanitize_foldername, sanitize_foldername,
clip_path, clip_path,
) )
from sabnzbd.constants import series_match, date_match, year_match, sample_match
import sabnzbd.cfg as cfg
RE_SAMPLE = re.compile(sample_match, re.I) RE_SAMPLE = re.compile(sample_match, re.I)
# Do not rename .vob files as they are usually DVD's # Do not rename .vob files as they are usually DVD's

19
sabnzbd/urlgrabber.py

@ -19,29 +19,28 @@
sabnzbd.urlgrabber - Queue for grabbing NZB files from websites sabnzbd.urlgrabber - Queue for grabbing NZB files from websites
""" """
import base64
import logging
import os import os
import queue
import sys import sys
import time import time
import logging
import queue
import urllib.request
import urllib.error import urllib.error
import urllib.parse import urllib.parse
import urllib.request
from http.client import IncompleteRead from http.client import IncompleteRead
from threading import Thread from threading import Thread
import base64
import sabnzbd import sabnzbd
from sabnzbd.constants import DEF_TIMEOUT, FUTURE_Q_FOLDER, VALID_NZB_FILES, Status, VALID_ARCHIVES
import sabnzbd.misc as misc
import sabnzbd.filesystem
from sabnzbd.nzbqueue import NzbQueue
from sabnzbd.postproc import PostProcessor
import sabnzbd.cfg as cfg import sabnzbd.cfg as cfg
import sabnzbd.emailer as emailer import sabnzbd.emailer as emailer
import sabnzbd.filesystem
import sabnzbd.misc as misc
import sabnzbd.notifier as notifier import sabnzbd.notifier as notifier
from sabnzbd.constants import DEF_TIMEOUT, FUTURE_Q_FOLDER, VALID_NZB_FILES, Status, VALID_ARCHIVES
from sabnzbd.encoding import ubtou, utob from sabnzbd.encoding import ubtou, utob
from sabnzbd.nzbqueue import NzbQueue
from sabnzbd.postproc import PostProcessor
_RARTING_FIELDS = ( _RARTING_FIELDS = (
"x-rating-id", "x-rating-id",

7
sabnzbd/utils/certgen.py

@ -5,13 +5,14 @@ Adapted from the docs of cryptography
Creates a key and self-signed certificate for local use Creates a key and self-signed certificate for local use
""" """
import datetime
import socket
from cryptography import x509
from cryptography.hazmat.backends import default_backend from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import serialization, hashes from cryptography.hazmat.primitives import serialization, hashes
from cryptography.hazmat.primitives.asymmetric import rsa from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography import x509
from cryptography.x509.oid import NameOID from cryptography.x509.oid import NameOID
import datetime
import socket
from sabnzbd.getipaddress import localipv4 from sabnzbd.getipaddress import localipv4

2
sabnzbd/utils/checkdir.py

@ -4,8 +4,8 @@
Functions to check if the path filesystem uses FAT Functions to check if the path filesystem uses FAT
""" """
import sys
import os import os
import sys
debug = False debug = False

2
sabnzbd/utils/diskspeed.py

@ -1,8 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python
import time
import os import os
import sys import sys
import time
_DUMP_DATA_SIZE = 10 * 1024 * 1024 _DUMP_DATA_SIZE = 10 * 1024 * 1024
_DUMP_DATA = os.urandom(_DUMP_DATA_SIZE) _DUMP_DATA = os.urandom(_DUMP_DATA_SIZE)

3
sabnzbd/utils/getperformance.py

@ -1,6 +1,7 @@
import locale
import platform import platform
import subprocess import subprocess
import locale
from .pystone import pystones from .pystone import pystones

4
sabnzbd/utils/happyeyeballs.py

@ -18,12 +18,12 @@ logger.setLevel(logging.DEBUG)
print happyeyeballs('newszilla.xs4all.nl', port=119) print happyeyeballs('newszilla.xs4all.nl', port=119)
""" """
import logging
import queue
import socket import socket
import ssl import ssl
import threading import threading
import time import time
import logging
import queue
DEBUG = False DEBUG = False

2
sabnzbd/utils/internetspeed.py

@ -6,8 +6,8 @@ Method: get one or more files, and measure how long it takes
Reports in MB/s (so mega BYTES per seconds), not to be confused with Mbps Reports in MB/s (so mega BYTES per seconds), not to be confused with Mbps
""" """
import time
import logging import logging
import time
import urllib.request import urllib.request
SizeUrlList = [ SizeUrlList = [

1
sabnzbd/utils/pathbrowser.py

@ -19,6 +19,7 @@
# along with Sick Beard. If not, see <http://www.gnu.org/licenses/>. # along with Sick Beard. If not, see <http://www.gnu.org/licenses/>.
import os import os
import sabnzbd import sabnzbd
if os.name == "nt": if os.name == "nt":

6
sabnzbd/utils/servertests.py

@ -19,14 +19,14 @@
sabnzbd.utils.servertests - Debugging server connections. Currently only NNTP server tests are done. sabnzbd.utils.servertests - Debugging server connections. Currently only NNTP server tests are done.
""" """
import select
import socket import socket
import sys import sys
import select
from sabnzbd.newswrapper import NewsWrapper
from sabnzbd.downloader import Server, clues_login, clues_too_many, nntp_to_msg
from sabnzbd.config import get_servers from sabnzbd.config import get_servers
from sabnzbd.downloader import Server, clues_login, clues_too_many, nntp_to_msg
from sabnzbd.misc import int_conv from sabnzbd.misc import int_conv
from sabnzbd.newswrapper import NewsWrapper
def test_nntp_server_dict(kwargs): def test_nntp_server_dict(kwargs):

3
sabnzbd/utils/systrayiconthread.py

@ -7,11 +7,12 @@
# override click to perform actions when left-clicking the icon # override click to perform actions when left-clicking the icon
import os import os
import pywintypes import pywintypes
import timer
import win32api import win32api
import win32con import win32con
import win32gui_struct import win32gui_struct
import timer
try: try:
import winxpgui as win32gui import winxpgui as win32gui

2
sabnzbd/zconfig.py

@ -19,8 +19,8 @@
sabnzbd.zconfig - bonjour/zeroconfig support sabnzbd.zconfig - bonjour/zeroconfig support
""" """
import os
import logging import logging
import os
_HOST_PORT = (None, None) _HOST_PORT = (None, None)

2
tests/conftest.py

@ -20,8 +20,6 @@ tests.conftest - Setup pytest fixtures
These have to be separate otherwise SABnzbd is started multiple times! These have to be separate otherwise SABnzbd is started multiple times!
""" """
import shutil import shutil
import subprocess
import sys
from tests.testhelper import * from tests.testhelper import *

7
tests/sabnews.py

@ -22,13 +22,14 @@ Run sabnews.py -h for parameters!
""" """
import argparse
import asyncio
import logging
import os import os
import re import re
import time import time
import sabyenc3 import sabyenc3
import argparse
import asyncio
import logging
logging.getLogger().setLevel(logging.INFO) logging.getLogger().setLevel(logging.INFO)

6
tests/test_filesystem.py

@ -18,16 +18,14 @@
""" """
tests.test_filesystem - Testing functions in filesystem.py tests.test_filesystem - Testing functions in filesystem.py
""" """
import os
import stat import stat
import pyfakefs.fake_filesystem_unittest as ffs import pyfakefs.fake_filesystem_unittest as ffs
import sabnzbd.filesystem as filesystem
import sabnzbd.cfg import sabnzbd.cfg
import sabnzbd.filesystem as filesystem
from tests.testhelper import * from tests.testhelper import *
# Set the global uid for fake filesystems to a non-root user; # Set the global uid for fake filesystems to a non-root user;
# by default this depends on the user running pytest. # by default this depends on the user running pytest.
global_uid = 1000 global_uid = 1000

1
tests/test_functional_downloads.py

@ -19,7 +19,6 @@
tests.test_functional_downloads - Test the downloading flow tests.test_functional_downloads - Test the downloading flow
""" """
import random
from selenium.common.exceptions import NoSuchElementException from selenium.common.exceptions import NoSuchElementException
from tests.testhelper import * from tests.testhelper import *

2
tests/test_functional_misc.py

@ -19,8 +19,6 @@
tests.test_functional_misc - Functional tests of various functions tests.test_functional_misc - Functional tests of various functions
""" """
import shutil import shutil
import subprocess
import sys
import sabnzbd.encoding import sabnzbd.encoding
from tests.testhelper import * from tests.testhelper import *

3
tests/test_postproc.py

@ -8,11 +8,12 @@
tests.test_postproc- Tests of various functions in newspack, among which rar_renamer() tests.test_postproc- Tests of various functions in newspack, among which rar_renamer()
""" """
import pytest
import shutil import shutil
from distutils.dir_util import copy_tree from distutils.dir_util import copy_tree
from unittest import mock from unittest import mock
import pytest
from sabnzbd.postproc import * from sabnzbd.postproc import *

6
tests/test_urlgrabber.py

@ -18,15 +18,15 @@
""" """
tests.test_urlgrabber - Testing functions in urlgrabber.py tests.test_urlgrabber - Testing functions in urlgrabber.py
""" """
import json
import urllib.error import urllib.error
import urllib.parse import urllib.parse
import pytest_httpbin import pytest_httpbin
import json
import sabnzbd.urlgrabber as urlgrabber import sabnzbd.urlgrabber as urlgrabber
from sabnzbd.cfg import selftest_host
import sabnzbd.version import sabnzbd.version
from sabnzbd.cfg import selftest_host
from tests.testhelper import * from tests.testhelper import *

1
tests/test_utils/test_happyeyeballs.py

@ -20,6 +20,7 @@ tests.test_utils.test_happyeyeballs - Testing SABnzbd happyeyeballs
""" """
from flaky import flaky from flaky import flaky
from sabnzbd.utils.happyeyeballs import happyeyeballs from sabnzbd.utils.happyeyeballs import happyeyeballs

5
tests/test_utils/test_sleepless.py

@ -19,10 +19,11 @@
tests.test_sleepless - Test sleepless for macOS tests.test_sleepless - Test sleepless for macOS
""" """
import subprocess
import sys import sys
import pytest
import time import time
import subprocess
import pytest
if not sys.platform.startswith("darwin"): if not sys.platform.startswith("darwin"):
pytest.skip("Skipping macOS-only tests", allow_module_level=True) pytest.skip("Skipping macOS-only tests", allow_module_level=True)

1
tests/test_win_utils.py

@ -20,6 +20,7 @@ tests.test_win_utils - Testing Windows utils
""" """
import sys import sys
import pytest import pytest
if not sys.platform.startswith("win"): if not sys.platform.startswith("win"):

4
tests/testhelper.py

@ -28,16 +28,16 @@ from http.client import RemoteDisconnected
import pytest import pytest
import requests import requests
import tests.sabnews
from selenium import webdriver from selenium import webdriver
from selenium.common.exceptions import WebDriverException
from selenium.webdriver.chrome.options import Options as ChromeOptions from selenium.webdriver.chrome.options import Options as ChromeOptions
from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support.ui import WebDriverWait
from selenium.common.exceptions import WebDriverException
from urllib3.exceptions import ProtocolError from urllib3.exceptions import ProtocolError
import sabnzbd import sabnzbd
import sabnzbd.cfg as cfg import sabnzbd.cfg as cfg
import tests.sabnews
SAB_HOST = "localhost" SAB_HOST = "localhost"
SAB_PORT = 8081 SAB_PORT = 8081

2
tools/extract_pot.py

@ -20,8 +20,8 @@ extract_pot - Extract translatable strings from all PY files
""" """
import os import os
import sys
import re import re
import sys
# Import version.py without the sabnzbd overhead # Import version.py without the sabnzbd overhead
with open("sabnzbd/version.py") as version_file: with open("sabnzbd/version.py") as version_file:

4
tools/make_mo.py

@ -20,12 +20,12 @@
make_mo - Compile PO files to MO files make_mo - Compile PO files to MO files
""" """
import gettext
import glob import glob
import os import os
import re import re
import sys
import gettext
import subprocess import subprocess
import sys
PO_DIR = "po/main" PO_DIR = "po/main"
POE_DIR = "po/email" POE_DIR = "po/email"

Loading…
Cancel
Save