mirror of
https://github.com/SickGear/SickGear.git
synced 2025-01-05 17:43:37 +00:00
Change py2 file and reload functions to py2/3 compatible open and reload_module functions
This commit is contained in:
parent
16fa92dd80
commit
680491684d
5 changed files with 11 additions and 8 deletions
|
@ -37,6 +37,7 @@
|
|||
* Change py2 octal literals into the new py2/3 syntax
|
||||
* Change py2 iteritems to py2/3 compatible statements using six library
|
||||
* Change py2 queue, httplib, cookielib and xmlrpclib to py2/3 compatible calls using six
|
||||
* Change py2 file and reload functions to py2/3 compatible open and reload_module functions
|
||||
* Change Kodi notifier to use requests as opposed to urllib
|
||||
* Change to consolidate scene exceptions and name cache code
|
||||
* Change check_url function to use requests instead of httplib library
|
||||
|
|
11
SickBeard.py
11
SickBeard.py
|
@ -49,6 +49,7 @@ except:
|
|||
sys.exit(1)
|
||||
|
||||
sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), 'lib')))
|
||||
from six.moves import reload_module
|
||||
|
||||
# We only need this for compiling an EXE and I will just always do that on 2.6+
|
||||
if sys.hexversion >= 0x020600F0:
|
||||
|
@ -140,7 +141,7 @@ class SickGear(object):
|
|||
sickbeard.SYS_ENCODING = 'UTF-8'
|
||||
|
||||
if not hasattr(sys, 'setdefaultencoding'):
|
||||
reload(sys)
|
||||
reload_module(sys)
|
||||
|
||||
try:
|
||||
# pylint: disable=E1101
|
||||
|
@ -412,7 +413,7 @@ class SickGear(object):
|
|||
pid = str(os.getpid())
|
||||
logger.log(u'Writing PID: %s to %s' % (pid, self.PIDFILE))
|
||||
try:
|
||||
file(self.PIDFILE, 'w').write('%s\n' % pid)
|
||||
open(self.PIDFILE, 'w').write('%s\n' % pid)
|
||||
except IOError as e:
|
||||
logger.log_error_and_exit(
|
||||
u'Unable to write PID file: %s Error: %s [%s]' % (self.PIDFILE, e.strerror, e.errno))
|
||||
|
@ -422,9 +423,9 @@ class SickGear(object):
|
|||
sys.stderr.flush()
|
||||
|
||||
devnull = getattr(os, 'devnull', '/dev/null')
|
||||
stdin = file(devnull, 'r')
|
||||
stdout = file(devnull, 'a+')
|
||||
stderr = file(devnull, 'a+')
|
||||
stdin = open(devnull, 'r')
|
||||
stdout = open(devnull, 'a+')
|
||||
stderr = open(devnull, 'a+')
|
||||
os.dup2(stdin.fileno(), sys.stdin.fileno())
|
||||
os.dup2(stdout.fileno(), sys.stdout.fileno())
|
||||
os.dup2(stderr.fileno(), sys.stderr.fileno())
|
||||
|
|
|
@ -1015,7 +1015,7 @@ def mapIndexersToShow(showObj):
|
|||
def touchFile(fname, atime=None):
|
||||
if None != atime:
|
||||
try:
|
||||
with file(fname, 'a'):
|
||||
with open(fname, 'a'):
|
||||
os.utime(fname, (atime, atime))
|
||||
return True
|
||||
except:
|
||||
|
|
|
@ -27,6 +27,7 @@ import os
|
|||
import re
|
||||
import datetime
|
||||
from six import iteritems
|
||||
from six.moves import reload_module
|
||||
|
||||
# regex to parse time (12/24 hour format)
|
||||
time_regex = re.compile(r'(\d{1,2})(([:.](\d{2,2}))? ?([PA][. ]? ?M)|[:.](\d{2,2}))\b', flags=re.IGNORECASE)
|
||||
|
@ -126,7 +127,7 @@ def _update_zoneinfo():
|
|||
# rename downloaded file
|
||||
ek.ek(os.rename, zonefile_tmp, zonefile)
|
||||
# load the new zoneinfo
|
||||
reload(lib.dateutil.zoneinfo)
|
||||
reload_module(lib.dateutil.zoneinfo)
|
||||
sb_timezone = tz.tzlocal()
|
||||
except:
|
||||
_remove_zoneinfo_failed(zonefile_tmp)
|
||||
|
|
|
@ -154,7 +154,7 @@ class BaseHandler(RequestHandler):
|
|||
if api:
|
||||
mime_type, encoding = MimeTypes().guess_type(static_image_path)
|
||||
self.set_header('Content-Type', mime_type)
|
||||
with file(static_image_path, 'rb') as img:
|
||||
with open(static_image_path, 'rb') as img:
|
||||
return img.read()
|
||||
else:
|
||||
static_image_path = os.path.normpath(static_image_path.replace(sickbeard.CACHE_DIR, '/cache'))
|
||||
|
|
Loading…
Reference in a new issue