Skip to content

Commit

Permalink
Migrated % string formating
Browse files Browse the repository at this point in the history
  • Loading branch information
fernandog committed Mar 26, 2016
1 parent 9bdf9bc commit 610cae5
Show file tree
Hide file tree
Showing 103 changed files with 573 additions and 612 deletions.
24 changes: 12 additions & 12 deletions SickBeard.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def start(self): # pylint: disable=too-many-branches,too-many-statements
try:
self.forced_port = int(value)
except ValueError:
sys.exit('Port: %s is not a number. Exiting.' % value)
sys.exit('Port: {0} is not a number. Exiting.'.format(value))

# Run as a double forked daemon
if option in ('-d', '--daemon'):
Expand All @@ -243,7 +243,7 @@ def start(self): # pylint: disable=too-many-branches,too-many-statements

# If the pid file already exists, Medusa may still be running, so exit
if ek(os.path.exists, self.pid_file):
sys.exit('PID file: %s already exists. Exiting.' % self.pid_file)
sys.exit('PID file: {0} already exists. Exiting.'.format(self.pid_file))

# Specify folder to load the config file from
if option in ('--config',):
Expand All @@ -262,9 +262,9 @@ def start(self): # pylint: disable=too-many-branches,too-many-statements
if self.run_as_daemon:
pid_dir = ek(os.path.dirname, self.pid_file)
if not ek(os.access, pid_dir, os.F_OK):
sys.exit('PID dir: %s doesn\'t exist. Exiting.' % pid_dir)
sys.exit('PID dir: {0} doesn\'t exist. Exiting.'.format(pid_dir))
if not ek(os.access, pid_dir, os.W_OK):
sys.exit('PID dir: %s must be writable (write permissions). Exiting.' % pid_dir)
sys.exit('PID dir: {0} must be writable (write permissions). Exiting.'.format(pid_dir))

else:
if self.console_logging:
Expand All @@ -281,18 +281,18 @@ def start(self): # pylint: disable=too-many-branches,too-many-statements
try:
ek(os.makedirs, sickbeard.DATA_DIR, 0o744)
except os.error:
raise SystemExit('Unable to create data directory: %s' % sickbeard.DATA_DIR)
raise SystemExit('Unable to create data directory: {0}'.format(sickbeard.DATA_DIR))

# Make sure we can write to the data dir
if not ek(os.access, sickbeard.DATA_DIR, os.W_OK):
raise SystemExit('Data directory must be writeable: %s' % sickbeard.DATA_DIR)
raise SystemExit('Data directory must be writeable: {0}'.format(sickbeard.DATA_DIR))

# Make sure we can write to the config file
if not ek(os.access, sickbeard.CONFIG_FILE, os.W_OK):
if ek(os.path.isfile, sickbeard.CONFIG_FILE):
raise SystemExit('Config file must be writeable: %s' % sickbeard.CONFIG_FILE)
raise SystemExit('Config file must be writeable: {0}'.format(sickbeard.CONFIG_FILE))
elif not ek(os.access, ek(os.path.dirname, sickbeard.CONFIG_FILE), os.W_OK):
raise SystemExit('Config file root dir must be writeable: %s' % ek(os.path.dirname, sickbeard.CONFIG_FILE))
raise SystemExit('Config file root dir must be writeable: {0}'.format(ek(os.path.dirname, sickbeard.CONFIG_FILE)))

ek(os.chdir, sickbeard.DATA_DIR)

Expand All @@ -301,11 +301,11 @@ def start(self): # pylint: disable=too-many-branches,too-many-statements
if ek(os.path.exists, restore_dir):
success = self.restore_db(restore_dir, sickbeard.DATA_DIR)
if self.console_logging:
sys.stdout.write('Restore: restoring DB and config.ini %s!\n' % ('FAILED', 'SUCCESSFUL')[success])
sys.stdout.write('Restore: restoring DB and config.ini {0}!\n'.format(('FAILED', 'SUCCESSFUL')[success]))

# Load the config and publish it to the sickbeard package
if self.console_logging and not ek(os.path.isfile, sickbeard.CONFIG_FILE):
sys.stdout.write('Unable to find %s, all settings will be default!\n' % sickbeard.CONFIG_FILE)
sys.stdout.write('Unable to find {0}, all settings will be default!\n'.format(sickbeard.CONFIG_FILE))

sickbeard.CFG = ConfigObj(sickbeard.CONFIG_FILE)

Expand Down Expand Up @@ -430,7 +430,7 @@ def daemonize(self):

try:
with io.open(self.pid_file, 'w') as f_pid:
f_pid.write('%s\n' % pid)
f_pid.write('{0}\n'.format(pid))
except EnvironmentError as error:
logger.log_error_and_exit('Unable to write PID file: {filename} Error {error_num}: {error_message}'.format
(filename=self.pid_file, error_num=error.errno, error_message=error.strerror))
Expand Down Expand Up @@ -500,7 +500,7 @@ def restore_db(src_dir, dst_dir):
for filename in files_list:
src_file = ek(os.path.join, src_dir, filename)
dst_file = ek(os.path.join, dst_dir, filename)
bak_file = ek(os.path.join, dst_dir, '%s.bak-%s' % (filename, datetime.datetime.now().strftime('%Y%m%d_%H%M%S')))
bak_file = ek(os.path.join, dst_dir, '{0}.bak-{1}'.format(filename, datetime.datetime.now().strftime('%Y%m%d_%H%M%S')))
if ek(os.path.isfile, dst_file):
shutil.move(dst_file, bak_file)
shutil.move(src_file, dst_file)
Expand Down
8 changes: 4 additions & 4 deletions sickbeard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ def initialize(consoleLogging=True): # pylint: disable=too-many-locals, too-man
# git_remote
GIT_REMOTE = check_setting_str(CFG, 'General', 'git_remote', 'origin')
GIT_REMOTE_URL = check_setting_str(CFG, 'General', 'git_remote_url',
'https://github.com/%s/%s.git' % (GIT_ORG, GIT_REPO))
'https://github.com/{0}/{1}.git'.format(GIT_ORG, GIT_REPO))

if 'com/sickrage' in GIT_REMOTE_URL.lower():
GIT_REMOTE_URL = 'https://github.com/PyMedusa/SickRage.git'
Expand Down Expand Up @@ -1607,7 +1607,7 @@ def halt():
t.stop.set()

for t in threads:
logger.log(u"Waiting for the %s thread to exit" % t.name)
logger.log(u"Waiting for the {0} thread to exit".format(t.name))
try:
t.join(10)
except Exception:
Expand All @@ -1628,7 +1628,7 @@ def halt():
def sig_handler(signum=None, frame=None):
_ = frame
if not isinstance(signum, type(None)):
logger.log(u"Signal %i caught, saving and exiting..." % int(signum))
logger.log(u"Signal {0:d} caught, saving and exiting...".format(int(signum)))
Shutdown.stop(PID)


Expand Down Expand Up @@ -2204,7 +2204,7 @@ def launchBrowser(protocol='http', startPort=None, web_root='/'):
if not startPort:
startPort = WEB_PORT

browserURL = '%s://localhost:%d%s/home/' % (protocol, startPort, web_root)
browserURL = '{0}://localhost:{1:d}{2}/home/'.format(protocol, startPort, web_root)

try:
webbrowser.open(browserURL, 2, 1)
Expand Down
4 changes: 2 additions & 2 deletions sickbeard/auto_postprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def run(self, force=False):
self.amActive = True

if not ek(os.path.isdir, sickbeard.TV_DOWNLOAD_DIR):
logger.log(u"Automatic post-processing attempted but directory doesn't exist: %s" %
sickbeard.TV_DOWNLOAD_DIR, logger.ERROR)
logger.log(u"Automatic post-processing attempted but directory doesn't exist: {0}".format(
sickbeard.TV_DOWNLOAD_DIR), logger.ERROR)
self.amActive = False
return

Expand Down
2 changes: 1 addition & 1 deletion sickbeard/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def foldersAtPath(path, includeParent=False, includeFiles=False):
try:
file_list = getFileList(path, includeFiles)
except OSError as e:
logger.log('Unable to open %s: %s / %s' % (path, repr(e), str(e)), logger.WARNING)
logger.log('Unable to open {0}: {1} / {2}'.format(path, repr(e), str(e)), logger.WARNING)
file_list = getFileList(parent_path, includeFiles)

file_list = sorted(file_list,
Expand Down
2 changes: 1 addition & 1 deletion sickbeard/clients/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def _get_torrent_hash(result):
torrent_bdecode = bdecode(result.content)
except BTFailure:
logger.log(u'Unable to bdecode torrent', logger.ERROR)
logger.log(u'Torrent bencoded data: %r' % result.content, logger.DEBUG)
logger.log(u'Torrent bencoded data: {0!r}'.format(result.content), logger.DEBUG)
raise
try:
info = torrent_bdecode["info"]
Expand Down
2 changes: 1 addition & 1 deletion sickbeard/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def _getStatusStrings(status):
stat = Quality.statusPrefixes[status]
qual = Quality.qualityStrings[quality]
comp = Quality.compositeStatus(status, quality)
to_return[comp] = '%s (%s)' % (stat, qual)
to_return[comp] = '{0} ({1})'.format(stat, qual)
return to_return

@staticmethod
Expand Down
5 changes: 2 additions & 3 deletions sickbeard/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,9 +632,8 @@ def migrate_config(self):

if self.config_version > self.expected_config_version:
logger.log_error_and_exit(
u"""Your config version (%i) has been incremented past what this version of SickRage supports (%i).
If you have used other forks or a newer version of SickRage, your config file may be unusable due to their modifications.""" %
(self.config_version, self.expected_config_version)
u"""Your config version ({0:d}) has been incremented past what this version of SickRage supports ({1:d}).
If you have used other forks or a newer version of SickRage, your config file may be unusable due to their modifications.""".format(self.config_version, self.expected_config_version)
)

sickbeard.CONFIG_VERSION = self.config_version
Expand Down
2 changes: 1 addition & 1 deletion sickbeard/dailysearcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def run(self, force=False): # pylint:disable=too-many-branches
logger.log(u"New episode " + ep.prettyName() + " airs today, setting status to SKIPPED because is a special season")
ep.status = common.SKIPPED
else:
logger.log(u"New episode %s airs today, setting to default episode status for this show: %s" % (ep.prettyName(), common.statusStrings[ep.show.default_ep_status]))
logger.log(u"New episode {0} airs today, setting to default episode status for this show: {1}".format(ep.prettyName(), common.statusStrings[ep.show.default_ep_status]))
ep.status = ep.show.default_ep_status

sql_l.append(ep.get_sql())
Expand Down
Loading

0 comments on commit 610cae5

Please sign in to comment.