Skip to content

Commit

Permalink
Fix strftime() incompatibility with unicode (for Python 2). Fixes #5301
Browse files Browse the repository at this point in the history
… (#5309)
  • Loading branch information
medariox authored and p0psicles committed Sep 26, 2018
1 parent f07b876 commit 65697f1
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 30 deletions.
12 changes: 6 additions & 6 deletions medusa/sbdatetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,11 @@ def sbfdatetime(self, dt=None, show_seconds=False, d_preset=None, t_preset=None)
except Exception:
sbdatetime.has_locale = False
if t_preset is not None:
strd += ', ' + dt.strftime(t_preset)
strd += b', ' + dt.strftime(t_preset)
elif show_seconds:
strd += ', ' + dt.strftime(app.TIME_PRESET_W_SECONDS)
strd += b', ' + dt.strftime(app.TIME_PRESET_W_SECONDS)
else:
strd += ', ' + dt.strftime(app.TIME_PRESET)
strd += b', ' + dt.strftime(app.TIME_PRESET)
else:
if d_preset is not None:
strd = self.strftime(d_preset)
Expand All @@ -266,11 +266,11 @@ def sbfdatetime(self, dt=None, show_seconds=False, d_preset=None, t_preset=None)
except Exception:
sbdatetime.has_locale = False
if t_preset is not None:
strd += ', ' + self.strftime(t_preset)
strd += b', ' + self.strftime(t_preset)
elif show_seconds:
strd += ', ' + self.strftime(app.TIME_PRESET_W_SECONDS)
strd += b', ' + self.strftime(app.TIME_PRESET_W_SECONDS)
else:
strd += ', ' + self.strftime(app.TIME_PRESET)
strd += b', ' + self.strftime(app.TIME_PRESET)
finally:
try:
if sbdatetime.has_locale:
Expand Down
2 changes: 1 addition & 1 deletion themes-default/slim/views/config_general.mako
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ window.app = new Vue({
<select class="form-control input-sm ${'' if not app.FUZZY_DATING else ' metadataDiv'}" id="date_presets${'' if not app.FUZZY_DATING else ' metadataDiv'}" name="date_preset${'' if not app.FUZZY_DATING else '_na'}">
<option value="%x" ${'selected="selected"' if app.DATE_PRESET == '%x' else ''}>Use System Default</option>
% for cur_preset in date_presets:
<option value="${cur_preset}" ${'selected="selected"' if app.DATE_PRESET == cur_preset else ''}>${datetime.datetime(datetime.datetime.now().year, 12, 31, 14, 30, 47).strftime(cur_preset)}</option>
<option value="${cur_preset}" ${'selected="selected"' if app.DATE_PRESET == cur_preset else ''}>${datetime.datetime(datetime.datetime.now().year, 12, 31, 14, 30, 47).strftime(cur_preset).decode(app.SYS_ENCODING)}</option>
% endfor
</select>
</span>
Expand Down
4 changes: 2 additions & 2 deletions themes-default/slim/views/partials/footer.mako
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from medusa.app import (
daily_search_scheduler as daily_search_scheduler,
backlog_search_scheduler as backlog_search_scheduler,
BRANCH, DATE_PRESET, TIME_PRESET
BRANCH, DATE_PRESET, TIME_PRESET, SYS_ENCODING
)
from medusa.helper.common import pretty_file_size
from medusa.show.show import Show
Expand Down Expand Up @@ -54,7 +54,7 @@
% endif
Load time: <span class="footerhighlight">${"%.4f" % (time() - sbStartTime)}s</span> / Mako: <span class="footerhighlight">${"%.4f" % (time() - makoStartTime)}s</span> |
Branch: <span class="footerhighlight">${BRANCH}</span> |
Now: <span class="footerhighlight">${datetime.now().strftime(DATE_PRESET+" "+TIME_PRESET)}</span>
Now: <span class="footerhighlight">${datetime.now().strftime(DATE_PRESET+" "+TIME_PRESET).decode(SYS_ENCODING)}</span>
</div>
</div>
</footer>
Expand Down
4 changes: 2 additions & 2 deletions themes-default/slim/views/snatchSelection.mako
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,10 @@
</td>
<% user_preset = app.DATE_PRESET + ' ' + app.TIME_PRESET %>
<td class="col-date triggerhighlight" data-datetime="${hItem['pubdate'].isoformat('T') if hItem['pubdate'] else datetime.min}">
${hItem['pubdate'].strftime(user_preset) if hItem['pubdate'] else 'N/A'}
${hItem['pubdate'].strftime(user_preset).decode(app.SYS_ENCODING) if hItem['pubdate'] else 'N/A'}
</td>
<td class="col-date triggerhighlight" data-datetime="${hItem['date_added'].isoformat('T') if hItem['date_added'] else datetime.min}">
${hItem['date_added'].strftime(user_preset) if hItem['date_added'] else 'N/A'}
${hItem['date_added'].strftime(user_preset).decode(app.SYS_ENCODING) if hItem['date_added'] else 'N/A'}
</td>
<td class="col-search triggerhighlight"><app-link class="epManualSearch" id="${str(show.indexerid)}x${season}x${episode}" name="${str(show.indexerid)}x${season}x${episode}" href='home/pickManualSearch?provider=${hItem["provider_id"]}&amp;rowid=${hItem["rowid"]}'><img src="images/download.png" width="16" height="16" alt="search" title="Download selected episode" /></app-link></td>
</tr>
Expand Down
6 changes: 3 additions & 3 deletions themes-default/slim/views/status.mako
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
% else:
<td></td>
% endif
<td>${service.lastRun.strftime(dateTimeFormat)}</td>
<td>${service.lastRun.strftime(dateTimeFormat).decode(app.SYS_ENCODING)}</td>
<td>${service.silent}</td>
</tr>
<% del service %>
Expand Down Expand Up @@ -153,7 +153,7 @@
% else:
<td>app.show_queue_scheduler.action.currentItem.priority</td>
% endif
<td>${app.show_queue_scheduler.action.currentItem.added.strftime(dateTimeFormat)}</td>
<td>${app.show_queue_scheduler.action.currentItem.added.strftime(dateTimeFormat).decode(app.SYS_ENCODING)}</td>
<td>${ShowQueueActions.names[app.show_queue_scheduler.action.currentItem.action_id]}</td>
</tr>
% endif
Expand Down Expand Up @@ -185,7 +185,7 @@
% else:
<td>${item.priority}</td>
% endif
<td>${item.added.strftime(dateTimeFormat)}</td>
<td>${item.added.strftime(dateTimeFormat).decode(app.SYS_ENCODING)}</td>
<td>${ShowQueueActions.names[item.action_id]}</td>
</tr>
% endfor
Expand Down
2 changes: 1 addition & 1 deletion themes/dark/templates/config_general.mako

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions themes/dark/templates/partials/footer.mako

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions themes/dark/templates/snatchSelection.mako

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions themes/dark/templates/status.mako

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion themes/light/templates/config_general.mako

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions themes/light/templates/partials/footer.mako

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions themes/light/templates/snatchSelection.mako

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions themes/light/templates/status.mako

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 65697f1

Please sign in to comment.