Private GIT

Skip to content
Snippets Groups Projects
Commit 12f1a5dd authored by labrys's avatar labrys
Browse files

Revert codecs.open to io.open

parent d46fda0f
Branches
Tags
No related merge requests found
...@@ -52,6 +52,7 @@ from __future__ import print_function ...@@ -52,6 +52,7 @@ from __future__ import print_function
import codecs import codecs
import datetime import datetime
import getopt import getopt
import io
import locale import locale
import os import os
import shutil import shutil
...@@ -419,7 +420,7 @@ class SickRage(object): ...@@ -419,7 +420,7 @@ class SickRage(object):
logger.log('Writing PID: %s to %s' % (pid, self.pid_file)) logger.log('Writing PID: %s to %s' % (pid, self.pid_file))
try: try:
with codecs.open(self.pid_file, 'w') as f_pid: with io.open(self.pid_file, 'w') as f_pid:
f_pid.write('%s\n' % pid) f_pid.write('%s\n' % pid)
except EnvironmentError as error_message: except EnvironmentError as error_message:
logger.log_error_and_exit('Unable to write PID file: %s Error: %s [%s]' % (self.pid_file, error_message.strerror, error_message.errno)) logger.log_error_and_exit('Unable to write PID file: %s Error: %s [%s]' % (self.pid_file, error_message.strerror, error_message.errno))
......
...@@ -24,7 +24,7 @@ Custom Logger for SickRage ...@@ -24,7 +24,7 @@ Custom Logger for SickRage
from __future__ import unicode_literals from __future__ import unicode_literals
import codecs import io
import os import os
import re import re
import sys import sys
...@@ -250,13 +250,13 @@ class Logger(object): # pylint: disable=too-many-instance-attributes ...@@ -250,13 +250,13 @@ class Logger(object): # pylint: disable=too-many-instance-attributes
log_data = None log_data = None
if ek(os.path.isfile, self.log_file): if ek(os.path.isfile, self.log_file):
with codecs.open(self.log_file, encoding='utf-8') as log_f: with io.open(self.log_file, encoding='utf-8') as log_f:
log_data = log_f.readlines() log_data = log_f.readlines()
for i in range(1, int(sickbeard.LOG_NR)): for i in range(1, int(sickbeard.LOG_NR)):
f_name = '%s.%i' % (self.log_file, i) f_name = '%s.%i' % (self.log_file, i)
if ek(os.path.isfile, f_name) and (len(log_data) <= 500): if ek(os.path.isfile, f_name) and (len(log_data) <= 500):
with codecs.open(f_name, encoding='utf-8') as log_f: with io.open(f_name, encoding='utf-8') as log_f:
log_data += log_f.readlines() log_data += log_f.readlines()
log_data = [line for line in reversed(log_data)] log_data = [line for line in reversed(log_data)]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment