mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-07-14 09:12:54 -07:00
Optimize imports
This commit is contained in:
parent
f61a17b8a0
commit
ad6f0b7bb6
2 changed files with 25 additions and 23 deletions
|
@ -3,24 +3,23 @@
|
||||||
from __future__ import print_function, unicode_literals
|
from __future__ import print_function, unicode_literals
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
from functools import partial
|
||||||
import os
|
import os
|
||||||
import platform
|
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import socket
|
import socket
|
||||||
import stat
|
import stat
|
||||||
import struct
|
import struct
|
||||||
import time
|
import time
|
||||||
from functools import partial
|
|
||||||
|
|
||||||
|
from babelfish import Language
|
||||||
import beets
|
import beets
|
||||||
import guessit
|
import guessit
|
||||||
import linktastic
|
import linktastic
|
||||||
import requests
|
|
||||||
import subliminal
|
|
||||||
from babelfish import Language
|
|
||||||
from qbittorrent import Client as qBittorrentClient
|
from qbittorrent import Client as qBittorrentClient
|
||||||
|
import requests
|
||||||
from six import text_type
|
from six import text_type
|
||||||
|
import subliminal
|
||||||
from synchronousdeluge.client import DelugeClient
|
from synchronousdeluge.client import DelugeClient
|
||||||
from transmissionrpc.client import Client as TransmissionClient
|
from transmissionrpc.client import Client as TransmissionClient
|
||||||
from utorrent.client import UTorrentClient
|
from utorrent.client import UTorrentClient
|
||||||
|
@ -28,6 +27,20 @@ from utorrent.client import UTorrentClient
|
||||||
import core
|
import core
|
||||||
from core import extractor, logger, main_db
|
from core import extractor, logger, main_db
|
||||||
|
|
||||||
|
try:
|
||||||
|
from win32event import CreateMutex
|
||||||
|
from win32api import CloseHandle, GetLastError
|
||||||
|
from winerror import ERROR_ALREADY_EXISTS
|
||||||
|
except ImportError:
|
||||||
|
if os.name == 'nt':
|
||||||
|
raise
|
||||||
|
|
||||||
|
try:
|
||||||
|
import jaraco
|
||||||
|
except ImportError:
|
||||||
|
if os.name == 'nt':
|
||||||
|
raise
|
||||||
|
|
||||||
requests.packages.urllib3.disable_warnings()
|
requests.packages.urllib3.disable_warnings()
|
||||||
|
|
||||||
# Monkey Patch shutil.copyfileobj() to adjust the buffer length to 512KB rather than 4KB
|
# Monkey Patch shutil.copyfileobj() to adjust the buffer length to 512KB rather than 4KB
|
||||||
|
@ -285,7 +298,6 @@ def replace_links(link):
|
||||||
n = 0
|
n = 0
|
||||||
target = link
|
target = link
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
import jaraco
|
|
||||||
if not jaraco.windows.filesystem.islink(link):
|
if not jaraco.windows.filesystem.islink(link):
|
||||||
logger.debug('{0} is not a link'.format(link))
|
logger.debug('{0} is not a link'.format(link))
|
||||||
return
|
return
|
||||||
|
@ -1302,7 +1314,7 @@ class RunningProcess(object):
|
||||||
""" Limits application to single instance """
|
""" Limits application to single instance """
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
if platform.system() == 'Windows':
|
if os.name == 'nt':
|
||||||
self.process = WindowsProcess()
|
self.process = WindowsProcess()
|
||||||
else:
|
else:
|
||||||
self.process = PosixProcess()
|
self.process = PosixProcess()
|
||||||
|
@ -1318,16 +1330,6 @@ class WindowsProcess(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.mutex = None
|
self.mutex = None
|
||||||
self.mutexname = "nzbtomedia_{pid}".format(pid=core.PID_FILE.replace('\\', '/')) # {D0E858DF-985E-4907-B7FB-8D732C3FC3B9}"
|
self.mutexname = "nzbtomedia_{pid}".format(pid=core.PID_FILE.replace('\\', '/')) # {D0E858DF-985E-4907-B7FB-8D732C3FC3B9}"
|
||||||
if platform.system() == 'Windows':
|
|
||||||
try:
|
|
||||||
from win32.win32event import CreateMutex
|
|
||||||
from win32.win32api import CloseHandle, GetLastError
|
|
||||||
from win32.lib.winerror import ERROR_ALREADY_EXISTS
|
|
||||||
except ImportError:
|
|
||||||
from win32event import CreateMutex
|
|
||||||
from win32api import CloseHandle, GetLastError
|
|
||||||
from winerror import ERROR_ALREADY_EXISTS
|
|
||||||
|
|
||||||
self.CreateMutex = CreateMutex
|
self.CreateMutex = CreateMutex
|
||||||
self.CloseHandle = CloseHandle
|
self.CloseHandle = CloseHandle
|
||||||
self.GetLastError = GetLastError
|
self.GetLastError = GetLastError
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
#! /usr/bin/env python2
|
#! /usr/bin/env python2
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
|
from babelfish import Language
|
||||||
import guessit
|
import guessit
|
||||||
import requests
|
import requests
|
||||||
|
import subliminal
|
||||||
|
|
||||||
import core
|
import core
|
||||||
from core import transcoder
|
from core import transcoder
|
||||||
|
@ -38,7 +40,6 @@ if server_responding("http://127.0.0.1:8085"):
|
||||||
if server_responding("http://127.0.0.1:8090"):
|
if server_responding("http://127.0.0.1:8090"):
|
||||||
print("Mylar Running")
|
print("Mylar Running")
|
||||||
|
|
||||||
from babelfish import Language
|
|
||||||
lan = 'pt'
|
lan = 'pt'
|
||||||
lan = Language.fromalpha2(lan)
|
lan = Language.fromalpha2(lan)
|
||||||
print(lan.alpha3)
|
print(lan.alpha3)
|
||||||
|
@ -59,7 +60,6 @@ if guess:
|
||||||
results = r.json()
|
results = r.json()
|
||||||
print(results)
|
print(results)
|
||||||
|
|
||||||
import subliminal
|
|
||||||
subliminal.region.configure('dogpile.cache.dbm', arguments={'filename': 'cachefile.dbm'})
|
subliminal.region.configure('dogpile.cache.dbm', arguments={'filename': 'cachefile.dbm'})
|
||||||
languages = set()
|
languages = set()
|
||||||
languages.add(lan)
|
languages.add(lan)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue