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
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import sys
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 getopt
import logging
import logging.handlers
import traceback
import getopt
import platform
import re
import signal
import socket
import platform
import subprocess
import ssl
import subprocess
import sys
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:
import Cheetah
if Cheetah.Version[0] != "3":
raise ValueError
import feedparser
import configobj
import cherrypy
import portend
import cryptography
import chardet
import configobj
import cryptography
import feedparser
import portend
except ValueError:
print("Sorry, requires Python module Cheetah 3 or higher.")
sys.exit(1)
@ -56,10 +56,17 @@ except ImportError as e:
sys.exit(1)
import sabnzbd
import sabnzbd.lang
import sabnzbd.cfg
import sabnzbd.config as config
import sabnzbd.downloader
import sabnzbd.interface
from sabnzbd.constants import *
import sabnzbd.lang
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 (
check_latest_version,
exit_sab,
@ -72,14 +79,7 @@ from sabnzbd.misc import (
get_from_url,
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
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:
import win32api

25
sabnzbd/__init__.py

@ -15,24 +15,25 @@
# along with this program; if not, write to the Free Software
# 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 tempfile
import pickle
import gzip
import subprocess
import time
import socket
import cherrypy
import sys
import logging
import os
import pickle
import re
import socket
import ssl
import subprocess
import sys
import tempfile
import time
from threading import Lock, Thread
import cherrypy
# Imported to be referenced from other files directly
from sabnzbd.version import __version__, __baseline__
##############################################################################
# Determine platform flags
##############################################################################

48
sabnzbd/api.py

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

5
sabnzbd/articlecache.py

@ -19,13 +19,12 @@
sabnzbd.articlecache - Article cache handling
"""
import logging
import threading
import struct
import threading
import sabnzbd
from sabnzbd.decorators import synchronized
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
# the bytes counter we do need a lock

14
sabnzbd/assembler.py

@ -19,24 +19,24 @@
sabnzbd.assembler - threaded assembly/decoding of files
"""
import hashlib
import logging
import os
import queue
import logging
import re
from threading import Thread
from time import sleep
import hashlib
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
from sabnzbd.articlecache import ArticleCache
from sabnzbd.postproc import PostProcessor
import sabnzbd.downloader
import sabnzbd.par2file as par2file
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

4
sabnzbd/bpsmeter.py

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

21
sabnzbd/cfg.py

@ -21,17 +21,6 @@ sabnzbd.cfg - Configuration Parameters
import re
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 (
OptionBool,
OptionNumber,
@ -46,6 +35,16 @@ from sabnzbd.config import (
create_api_key,
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

10
sabnzbd/config.py

@ -19,18 +19,20 @@
sabnzbd.config - Configuration Support
"""
import logging
import os
import re
import logging
import threading
import shutil
import threading
import uuid
from urllib.parse import urlparse
import configobj
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
import configobj
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()
SAVE_CONFIG_LOCK = threading.Lock()

12
sabnzbd/database.py

@ -19,22 +19,22 @@
sabnzbd.database - Database Support
"""
import os
import time
import zlib
import logging
import os
import sqlite3
import sys
import threading
import sqlite3
import time
import zlib
import sabnzbd
import sabnzbd.cfg
from sabnzbd.constants import DB_HISTORY_NAME, STAGES, Status
from sabnzbd.bpsmeter import this_week, this_month
from sabnzbd.constants import DB_HISTORY_NAME, STAGES, Status
from sabnzbd.decorators import synchronized
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.misc import int_conv, caller_name, opts_to_pp
DB_LOCK = threading.RLock()

8
sabnzbd/decoder.py

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

14
sabnzbd/directunpacker.py

@ -19,24 +19,24 @@
sabnzbd.directunpacker
"""
import logging
import os
import re
import time
import threading
import subprocess
import logging
import threading
import time
from subprocess import Popen
import sabnzbd
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.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.postproc import prepare_extraction_path
from sabnzbd.utils.rarfile import RarFile
from sabnzbd.utils.diskspeed import diskspeedmeasure
from sabnzbd.utils.rarfile import RarFile
# Need a lock to make sure start and stop is handled correctly
# Otherwise we could stop while the thread was still starting

10
sabnzbd/dirscanner.py

@ -19,16 +19,16 @@
sabnzbd.dirscanner - Scanner for Watched Folder
"""
import os
import time
import logging
import os
import threading
import time
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.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):

21
sabnzbd/downloader.py

@ -19,27 +19,26 @@
sabnzbd.downloader - download engine
"""
import time
import select
import logging
from threading import Thread, RLock
from nntplib import NNTPPermanentError
import socket
import random
import select
import socket
import sys
import time
from nntplib import NNTPPermanentError
from threading import Thread, RLock
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
from sabnzbd.bpsmeter import BPSMeter
import sabnzbd.config as config
import sabnzbd.notifier as notifier
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.newswrapper import NewsWrapper, request_server_info
from sabnzbd.utils.happyeyeballs import happyeyeballs
# Timeout penalty in minutes for each cause
_PENALTY_UNKNOWN = 3 # Unknown cause
_PENALTY_502 = 5 # Unknown 502

10
sabnzbd/emailer.py

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

2
sabnzbd/encoding.py

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

10
sabnzbd/filesystem.py

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

6
sabnzbd/getipaddress.py

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

79
sabnzbd/interface.py

@ -19,26 +19,54 @@
sabnzbd.interface - webinterface
"""
import os
import time
from datetime import datetime
import cherrypy
import functools
import hashlib
import logging
import urllib.request, urllib.parse, urllib.error
import os
import re
import hashlib
import socket
import ssl
import functools
from threading import Thread
import time
import urllib.error
import urllib.parse
import urllib.request
from datetime import datetime
from random import randint
from threading import Thread
from xml.sax.saxutils import escape
import cherrypy
from Cheetah.Template import Template
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.scheduler as scheduler
from Cheetah.Template import Template
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,
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 (
to_units,
from_units,
@ -50,42 +78,13 @@ from sabnzbd.misc import (
probablyipv6,
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.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.utils.servertests import test_nntp_server_dict
from sabnzbd.decoder import SABYENC_ENABLED
from sabnzbd.utils.diskspeed import diskspeedmeasure
from sabnzbd.utils.getperformance import getpystone
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

4
sabnzbd/lang.py

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

20
sabnzbd/misc.py

@ -18,23 +18,23 @@
"""
sabnzbd.misc - misc classes
"""
import os
import sys
import ctypes
import datetime
import inspect
import logging
import urllib.request
import urllib.parse
import os
import re
import subprocess
import socket
import subprocess
import sys
import time
import datetime
import inspect
import ctypes
import urllib.parse
import urllib.request
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.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
TAB_UNITS = ("", "K", "M", "G", "T", "P")

16
sabnzbd/newsunpack.py

@ -19,21 +19,22 @@
sabnzbd.newsunpack
"""
import functools
import logging
import os
import sys
import re
import shutil
import subprocess
import logging
import sys
import time
import zlib
import shutil
import functools
from subprocess import Popen
import sabnzbd
from sabnzbd.encoding import platform_btou, correct_unknown_encoding, ubtou
import sabnzbd.cfg as cfg
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 (
make_script_path,
real_path,
@ -48,9 +49,8 @@ from sabnzbd.filesystem import (
get_ext,
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
import sabnzbd.cfg as cfg
from sabnzbd.constants import Status
if sabnzbd.WIN32:
try:

10
sabnzbd/newswrapper.py

@ -20,17 +20,17 @@ sabnzbd.newswrapper
"""
import errno
import socket
from threading import Thread
from nntplib import NNTPPermanentError
import time
import logging
import socket
import ssl
import time
from nntplib import NNTPPermanentError
from threading import Thread
import sabnzbd
import sabnzbd.cfg
from sabnzbd.constants import *
from sabnzbd.encoding import utob
import sabnzbd.cfg
from sabnzbd.misc import nntp_to_msg, probablyipv4, probablyipv6
# 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 json
import logging
import os.path
import urllib.error
import urllib.parse
import urllib.request
from threading import Thread
import sabnzbd

6
sabnzbd/nzbparser.py

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

29
sabnzbd/nzbqueue.py

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

46
sabnzbd/nzbstuff.py

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

30
sabnzbd/osxmenu.py

@ -19,33 +19,29 @@
sabnzbd.osxmenu - OSX Top Menu
"""
import objc
from Foundation import *
from AppKit import *
from PyObjCTools import AppHelper
from objc import YES, NO
import logging
import os
import sys
import time
import logging
import cherrypy
from AppKit import *
from Foundation import *
from objc import YES, NO
import sabnzbd
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.scheduler as scheduler
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.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 = {
"idle": "icons/sabnzbd_osx_idle.tiff",

4
sabnzbd/panic.py

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

5
sabnzbd/par2file.py

@ -18,11 +18,12 @@
"""
sabnzbd.par2file - All par2-related functionality
"""
import os
import hashlib
import logging
import os
import re
import hashlib
import struct
from sabnzbd.encoding import correct_unknown_encoding
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
"""
import os
import logging
import sabnzbd
import functools
import time
import re
import logging
import os
import queue
import re
import time
from threading import Thread
from sabnzbd.newsunpack import (
unpack_magic,
par2_repair,
external_processing,
sfv_check,
build_filelists,
rar_sort,
is_sfv_file,
import sabnzbd
import sabnzbd.cfg as cfg
import sabnzbd.config as config
import sabnzbd.database as database
import sabnzbd.downloader
import sabnzbd.emailer as emailer
import sabnzbd.encoding as encoding
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 (
real_path,
get_unique_path,
@ -62,30 +73,19 @@ from sabnzbd.filesystem import (
get_ext,
get_filename,
)
from sabnzbd.sorting import Sorter
from sabnzbd.constants import (
REPAIR_PRIORITY,
TOP_PRIORITY,
POSTPROC_QUEUE_FILE_NAME,
POSTPROC_QUEUE_VERSION,
sample_match,
JOB_ADMIN,
Status,
VERIFIED_FILE,
from sabnzbd.misc import on_cleanup_list
from sabnzbd.newsunpack import (
unpack_magic,
par2_repair,
external_processing,
sfv_check,
build_filelists,
rar_sort,
is_sfv_file,
)
from sabnzbd.nzbparser import process_single_nzb
from sabnzbd.rating import Rating
import sabnzbd.emailer as emailer
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
from sabnzbd.sorting import Sorter
MAX_FAST_JOB_COUNT = 3

3
sabnzbd/powersup.py

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

12
sabnzbd/rating.py

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

16
sabnzbd/rss.py

@ -19,21 +19,21 @@
sabnzbd.rss - rss client functionality
"""
import re
import logging
import time
import datetime
import logging
import re
import threading
import time
import feedparser
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.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
import sabnzbd.emailer as emailer
import feedparser
__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
"""
import os
import logging
import os
from time import sleep
import sabnzbd
from sabnzbd.panic import launch_a_browser
import sabnzbd.api as api
import sabnzbd.cfg as cfg
import sabnzbd.scheduler as scheduler
from sabnzbd.downloader import Downloader
import sabnzbd.cfg as cfg
from sabnzbd.misc import to_units
from sabnzbd.panic import launch_a_browser
# contains the tray icon, which demands its own thread
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
"""
import logging
import gi
from gi.repository import Gtk, GLib
import logging
try:
gi.require_version("XApp", "1.0")

15
sabnzbd/scheduler.py

@ -19,20 +19,19 @@
sabnzbd.scheduler - Event Scheduler
"""
import random
import logging
import random
import time
import sabnzbd.utils.kronos as kronos
import sabnzbd.rss as rss
import sabnzbd.downloader
import sabnzbd.cfg as cfg
import sabnzbd.config as config
import sabnzbd.dirscanner
import sabnzbd.downloader
import sabnzbd.misc
import sabnzbd.config as config
import sabnzbd.cfg as cfg
from sabnzbd.postproc import PostProcessor
import sabnzbd.rss as rss
import sabnzbd.utils.kronos as kronos
from sabnzbd.constants import LOW_PRIORITY, NORMAL_PRIORITY, HIGH_PRIORITY
from sabnzbd.postproc import PostProcessor
__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
"""
import os
import logging
import os
import re
import sabnzbd
import sabnzbd.cfg as cfg
from sabnzbd.constants import series_match, date_match, year_match, sample_match
from sabnzbd.filesystem import (
move_to_path,
cleanup_empty_directories,
@ -37,8 +39,6 @@ from sabnzbd.filesystem import (
sanitize_foldername,
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)
# 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
"""
import base64
import logging
import os
import queue
import sys
import time
import logging
import queue
import urllib.request
import urllib.error
import urllib.parse
import urllib.request
from http.client import IncompleteRead
from threading import Thread
import base64
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.emailer as emailer
import sabnzbd.filesystem
import sabnzbd.misc as misc
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.nzbqueue import NzbQueue
from sabnzbd.postproc import PostProcessor
_RARTING_FIELDS = (
"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
"""
import datetime
import socket
from cryptography import x509
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import serialization, hashes
from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography import x509
from cryptography.x509.oid import NameOID
import datetime
import socket
from sabnzbd.getipaddress import localipv4

2
sabnzbd/utils/checkdir.py

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

2
sabnzbd/utils/diskspeed.py

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

3
sabnzbd/utils/getperformance.py

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

4
sabnzbd/utils/happyeyeballs.py

@ -18,12 +18,12 @@ logger.setLevel(logging.DEBUG)
print happyeyeballs('newszilla.xs4all.nl', port=119)
"""
import logging
import queue
import socket
import ssl
import threading
import time
import logging
import queue
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
"""
import time
import logging
import time
import urllib.request
SizeUrlList = [

1
sabnzbd/utils/pathbrowser.py

@ -19,6 +19,7 @@
# along with Sick Beard. If not, see <http://www.gnu.org/licenses/>.
import os
import sabnzbd
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.
"""
import select
import socket
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.downloader import Server, clues_login, clues_too_many, nntp_to_msg
from sabnzbd.misc import int_conv
from sabnzbd.newswrapper import NewsWrapper
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
import os
import pywintypes
import timer
import win32api
import win32con
import win32gui_struct
import timer
try:
import winxpgui as win32gui

2
sabnzbd/zconfig.py

@ -19,8 +19,8 @@
sabnzbd.zconfig - bonjour/zeroconfig support
"""
import os
import logging
import os
_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!
"""
import shutil
import subprocess
import sys
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 re
import time
import sabyenc3
import argparse
import asyncio
import logging
logging.getLogger().setLevel(logging.INFO)

6
tests/test_filesystem.py

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

1
tests/test_functional_downloads.py

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

2
tests/test_functional_misc.py

@ -19,8 +19,6 @@
tests.test_functional_misc - Functional tests of various functions
"""
import shutil
import subprocess
import sys
import sabnzbd.encoding
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()
"""
import pytest
import shutil
from distutils.dir_util import copy_tree
from unittest import mock
import pytest
from sabnzbd.postproc import *

6
tests/test_urlgrabber.py

@ -18,15 +18,15 @@
"""
tests.test_urlgrabber - Testing functions in urlgrabber.py
"""
import json
import urllib.error
import urllib.parse
import pytest_httpbin
import json
import sabnzbd.urlgrabber as urlgrabber
from sabnzbd.cfg import selftest_host
import sabnzbd.version
from sabnzbd.cfg import selftest_host
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 sabnzbd.utils.happyeyeballs import happyeyeballs

5
tests/test_utils/test_sleepless.py

@ -19,10 +19,11 @@
tests.test_sleepless - Test sleepless for macOS
"""
import subprocess
import sys
import pytest
import time
import subprocess
import pytest
if not sys.platform.startswith("darwin"):
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 pytest
if not sys.platform.startswith("win"):

4
tests/testhelper.py

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

2
tools/extract_pot.py

@ -20,8 +20,8 @@ extract_pot - Extract translatable strings from all PY files
"""
import os
import sys
import re
import sys
# Import version.py without the sabnzbd overhead
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
"""
import gettext
import glob
import os
import re
import sys
import gettext
import subprocess
import sys
PO_DIR = "po/main"
POE_DIR = "po/email"

Loading…
Cancel
Save