Compare commits
81 Commits
v2.1.23-be
...
v2.1.29
Author | SHA1 | Date | |
---|---|---|---|
![]() |
2635569e76 | ||
![]() |
7d11e1de2d | ||
![]() |
36aa4a6be3 | ||
![]() |
24ed63e07c | ||
![]() |
f41ed9953a | ||
![]() |
6970231687 | ||
![]() |
ea036aa354 | ||
![]() |
d0a7c2f92c | ||
![]() |
f07acd839b | ||
![]() |
c1fd798fe9 | ||
![]() |
2f8d2f23fe | ||
![]() |
b65a30263e | ||
![]() |
766e33df0e | ||
![]() |
68df0f07c8 | ||
![]() |
819829554b | ||
![]() |
18a38b16b1 | ||
![]() |
a9169d2b53 | ||
![]() |
76b9b3e474 | ||
![]() |
00405f0b18 | ||
![]() |
9dfeccdaed | ||
![]() |
b6d044fe8f | ||
![]() |
e949b1486e | ||
![]() |
8e1b6efc51 | ||
![]() |
00012ffe09 | ||
![]() |
bcf6b4de77 | ||
![]() |
b1516e9963 | ||
![]() |
231de3a7a5 | ||
![]() |
b611ea659e | ||
![]() |
6e9f299c19 | ||
![]() |
61fac10079 | ||
![]() |
536e8add17 | ||
![]() |
cb81bcac57 | ||
![]() |
5dd7806c0e | ||
![]() |
2a707fc512 | ||
![]() |
469e54a22c | ||
![]() |
f6f5df3d1e | ||
![]() |
ae0960d2e2 | ||
![]() |
a646cc36a1 | ||
![]() |
b243ac5f5c | ||
![]() |
bca7744bc5 | ||
![]() |
2fc826c88f | ||
![]() |
6397b1e5a7 | ||
![]() |
85b9a47a0d | ||
![]() |
5749ab7c92 | ||
![]() |
dcb56cfd20 | ||
![]() |
90849f9196 | ||
![]() |
5b77cab575 | ||
![]() |
6a21d7690a | ||
![]() |
037e983350 | ||
![]() |
aa023f0166 | ||
![]() |
571b5461c0 | ||
![]() |
a749b71f7f | ||
![]() |
ac259214f7 | ||
![]() |
e11803685c | ||
![]() |
e4c3601312 | ||
![]() |
56a91de2c4 | ||
![]() |
e2d217a981 | ||
![]() |
b484f27724 | ||
![]() |
eb04a2e579 | ||
![]() |
c66d8ecd5f | ||
![]() |
79b5f3c36f | ||
![]() |
4a78424b75 | ||
![]() |
4f78d0c98a | ||
![]() |
91b84b4437 | ||
![]() |
8a9b3dc782 | ||
![]() |
944df6cec1 | ||
![]() |
354d46e940 | ||
![]() |
71cb2d9c4c | ||
![]() |
c08cec40cb | ||
![]() |
dee544c951 | ||
![]() |
f42581a5a6 | ||
![]() |
fdc9f165a4 | ||
![]() |
8fff796700 | ||
![]() |
c64a115d29 | ||
![]() |
d731ad851c | ||
![]() |
c098175ba9 | ||
![]() |
d728f7a11e | ||
![]() |
7271e66ab8 | ||
![]() |
5c54283df7 | ||
![]() |
86b1d0f51d | ||
![]() |
f2fedb182c |
1
API.md
1
API.md
@@ -893,6 +893,7 @@ Returns:
|
|||||||
json:
|
json:
|
||||||
{"child_count": null,
|
{"child_count": null,
|
||||||
"count": 887,
|
"count": 887,
|
||||||
|
"deleted_section": 0,
|
||||||
"do_notify": 1,
|
"do_notify": 1,
|
||||||
"do_notify_created": 1,
|
"do_notify_created": 1,
|
||||||
"keep_history": 1,
|
"keep_history": 1,
|
||||||
|
89
CHANGELOG.md
89
CHANGELOG.md
@@ -1,5 +1,92 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## v2.1.29 (2019-05-11)
|
||||||
|
* No additional changes from v2.1.29-beta.
|
||||||
|
|
||||||
|
|
||||||
|
## v2.1.29-beta (2019-04-14)
|
||||||
|
|
||||||
|
* Monitoring:
|
||||||
|
* Change: "Required Bandwidth" changed to "Reserved Bandwidth" in order to match the Plex dashboard.
|
||||||
|
* Notifications:
|
||||||
|
* New: Added prefix and suffix notification text modifiers. See the "Notification Text Modifiers" help modal for details.
|
||||||
|
* UI:
|
||||||
|
* New: Added "Undelete" button to the edit library and edit user modals.
|
||||||
|
* Fix: User IP address history table showing incorrect "Last Seen" values.
|
||||||
|
* API:
|
||||||
|
* Fix: Search API only returning 3 results.
|
||||||
|
* Fix: Terminate stream API failing when both session_key and session_id were provided.
|
||||||
|
* Change: Improved API response HTTP status codes and error messages.
|
||||||
|
|
||||||
|
|
||||||
|
## v2.1.28 (2019-03-10)
|
||||||
|
|
||||||
|
* Monitoring:
|
||||||
|
* New: Added secure/insecure connection icon on the activity cards. Requires Plex Media Server v1.15+.
|
||||||
|
* Other:
|
||||||
|
* Change: Improved mass deleting of all images from Cloudinary. Requires all previous images on Cloudinary to be manually tagged with "tautulli". New uploads are automatically tagged.
|
||||||
|
|
||||||
|
|
||||||
|
## v2.1.27-beta (2019-03-03)
|
||||||
|
|
||||||
|
* Monitoring:
|
||||||
|
* Fix: Error when playing synced optimized versions.
|
||||||
|
* Change: Show message to complete the setup wizard instead of error communicating with server message.
|
||||||
|
* Change: URL changed on Plex.tv for Plex Media Server beta updates.
|
||||||
|
* Notifications:
|
||||||
|
* New: Show the media type exclusion tags in the text preview modal.
|
||||||
|
* Fix: Unicode error in the Email notification failed response message.
|
||||||
|
* Fix: Error when a notification agent response is missing the "Content-Type" header.
|
||||||
|
* UI:
|
||||||
|
* Fix: Usernames were not being sanitized in dropdown selectors.
|
||||||
|
* Change: Different display of "All" recently added items on the homepage due to change in the Plex Media Server v1.15+ API.
|
||||||
|
* API:
|
||||||
|
* New: Added current Tautulli version to update_check API response.
|
||||||
|
* Change: API no longer returns sanitized HTML response data.
|
||||||
|
* Other:
|
||||||
|
* New: Added auto-restart to systemd init script.
|
||||||
|
* Fix: Patreon donation URL.
|
||||||
|
* Remove: Crypto donation options.
|
||||||
|
|
||||||
|
|
||||||
|
## v2.1.26 (2018-12-01)
|
||||||
|
|
||||||
|
* Monitoring:
|
||||||
|
* Fix: Resume event not being triggered after buffering.
|
||||||
|
* Notifications:
|
||||||
|
* New: Added user email as a notification parameter.
|
||||||
|
* Graphs:
|
||||||
|
* Fix: History model showing no results for stream info graph.
|
||||||
|
* API:
|
||||||
|
* Fix: API returning error when missing a cmd.
|
||||||
|
|
||||||
|
|
||||||
|
## v2.1.25 (2018-11-03)
|
||||||
|
|
||||||
|
* Monitoring:
|
||||||
|
* Fix: Audio and video codec showing up as * on the activity cards.
|
||||||
|
* New: Poster and background image on the activity cards for live TV.
|
||||||
|
* UI:
|
||||||
|
* Fix: Alert message for invalid Tautulli Public Domain setting.
|
||||||
|
|
||||||
|
|
||||||
|
## v2.1.24-beta (2018-10-29)
|
||||||
|
|
||||||
|
* Monitoring:
|
||||||
|
* Fix: Transcode change events creating invalid sessions in the database.
|
||||||
|
* Notifications:
|
||||||
|
* Change: Update Telegram character limit to 1024.
|
||||||
|
* History:
|
||||||
|
* Fix: Save history table states separately for multiple Tautulli instances.
|
||||||
|
* Graphs:
|
||||||
|
* Fix: Save graphs states separately for multiple Tautulli instances.
|
||||||
|
* Change: Version graphs to bypass browser cache.
|
||||||
|
* UI:
|
||||||
|
* New: Added queued tasks modals to the scheduled tasks table for debugging.
|
||||||
|
* Other:
|
||||||
|
* Change: Updated timezone info and display in configuration table.
|
||||||
|
|
||||||
|
|
||||||
## v2.1.23-beta (2018-10-14)
|
## v2.1.23-beta (2018-10-14)
|
||||||
|
|
||||||
* Monitoring:
|
* Monitoring:
|
||||||
@@ -58,7 +145,7 @@
|
|||||||
|
|
||||||
|
|
||||||
## v2.1.20 (2018-09-05)
|
## v2.1.20 (2018-09-05)
|
||||||
* No changes.
|
* No additional changes from v2.1.20-beta.
|
||||||
|
|
||||||
|
|
||||||
## v2.1.20-beta (2018-09-02)
|
## v2.1.20-beta (2018-09-02)
|
||||||
|
11
Tautulli.py
11
Tautulli.py
@@ -28,9 +28,12 @@ import sys
|
|||||||
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), 'lib'))
|
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), 'lib'))
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
import datetime
|
||||||
import locale
|
import locale
|
||||||
|
import pytz
|
||||||
import signal
|
import signal
|
||||||
import time
|
import time
|
||||||
|
import tzlocal
|
||||||
|
|
||||||
import plexpy
|
import plexpy
|
||||||
from plexpy import config, database, logger, webstart
|
from plexpy import config, database, logger, webstart
|
||||||
@@ -106,6 +109,14 @@ def main():
|
|||||||
logger.initLogger(console=not plexpy.QUIET, log_dir=False,
|
logger.initLogger(console=not plexpy.QUIET, log_dir=False,
|
||||||
verbose=plexpy.VERBOSE)
|
verbose=plexpy.VERBOSE)
|
||||||
|
|
||||||
|
try:
|
||||||
|
plexpy.SYS_TIMEZONE = str(tzlocal.get_localzone())
|
||||||
|
plexpy.SYS_UTC_OFFSET = datetime.datetime.now(pytz.timezone(plexpy.SYS_TIMEZONE)).strftime('%z')
|
||||||
|
except (pytz.UnknownTimeZoneError, LookupError, ValueError) as e:
|
||||||
|
logger.error("Could not determine system timezone: %s" % e)
|
||||||
|
plexpy.SYS_TIMEZONE = 'Unknown'
|
||||||
|
plexpy.SYS_UTC_OFFSET = '+0000'
|
||||||
|
|
||||||
if os.getenv('TAUTULLI_DOCKER', False) == 'True':
|
if os.getenv('TAUTULLI_DOCKER', False) == 'True':
|
||||||
plexpy.DOCKER = True
|
plexpy.DOCKER = True
|
||||||
|
|
||||||
|
@@ -209,7 +209,7 @@ ${next.modalIncludes()}
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
% else:
|
% else:
|
||||||
<div id="donate-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="crypto-donate-modal">
|
<div id="donate-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="donate-modal">
|
||||||
<div class="modal-dialog" role="document">
|
<div class="modal-dialog" role="document">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
@@ -230,17 +230,13 @@ ${next.modalIncludes()}
|
|||||||
<ul id="donation_type" class="nav nav-pills" role="tablist" style="display: flex; justify-content: center; margin: 10px 0;">
|
<ul id="donation_type" class="nav nav-pills" role="tablist" style="display: flex; justify-content: center; margin: 10px 0;">
|
||||||
<li class="active"><a href="#patreon-donation" role="tab" data-toggle="tab">Patreon</a></li>
|
<li class="active"><a href="#patreon-donation" role="tab" data-toggle="tab">Patreon</a></li>
|
||||||
<li><a href="#paypal-donation" role="tab" data-toggle="tab">PayPal</a></li>
|
<li><a href="#paypal-donation" role="tab" data-toggle="tab">PayPal</a></li>
|
||||||
<li><a href="#crypto-donation" role="tab" data-toggle="tab" class="crypto-donation" data-coin="bitcoin" data-name="Bitcoin" data-address="3FdfJAyNWU15Sf11U9FTgPHuP1hPz32eEN">Bitcoin</a></li>
|
|
||||||
<li><a href="#crypto-donation" role="tab" data-toggle="tab" class="crypto-donation" data-coin="bitcoincash" data-name="Bitcoin Cash" data-address="1H2atabxAQGaFAWYQEiLkXKSnK9CZZvt2n">Bitcoin Cash</a></li>
|
|
||||||
<li><a href="#crypto-donation" role="tab" data-toggle="tab" class="crypto-donation" data-coin="ethereum" data-name="Ethereum" data-address="0x77ae4c2b8de1a1ccfa93553db39971da58c873d3">Ethereum</a></li>
|
|
||||||
<li><a href="#crypto-donation" role="tab" data-toggle="tab" class="crypto-donation" data-coin="litecoin" data-name="Litecoin" data-address="LWpPmUqQYHBhMV83XSCsHzPmKLhJt6r57J">Litecoin</a></li>
|
|
||||||
</ul>
|
</ul>
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
<div role="tabpanel" class="tab-pane active" id="patreon-donation" style="text-align: center">
|
<div role="tabpanel" class="tab-pane active" id="patreon-donation" style="text-align: center">
|
||||||
<p>
|
<p>
|
||||||
Click the button below to continue to Patreon.
|
Click the button below to continue to Patreon.
|
||||||
</p>
|
</p>
|
||||||
<a href="${anon_url('https://www.patreon.com/bePatron?u=10078609')}" target="_blank">
|
<a href="${anon_url('https://www.patreon.com/join/tautulli')}" target="_blank">
|
||||||
<img src="images/become_a_patron_button.png" alt="Become a Patron" height="40">
|
<img src="images/become_a_patron_button.png" alt="Become a Patron" height="40">
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
@@ -252,12 +248,6 @@ ${next.modalIncludes()}
|
|||||||
<img src="images/gold-rect-paypal-34px.png" alt="PayPal">
|
<img src="images/gold-rect-paypal-34px.png" alt="PayPal">
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div role="tabpanel" class="tab-pane" id="crypto-donation">
|
|
||||||
<label>QR Code</label>
|
|
||||||
<pre id="crypto_qr_code" style="text-align: center"></pre>
|
|
||||||
<label><span id="crypto_type_label"></span> Address</label>
|
|
||||||
<pre id="crypto_address" style="text-align: center"></pre>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
@@ -293,7 +283,6 @@ ${next.modalIncludes()}
|
|||||||
<script src="${http_root}js/pnotify.custom.min.js"></script>
|
<script src="${http_root}js/pnotify.custom.min.js"></script>
|
||||||
<script src="${http_root}js/platform.min.js"></script>
|
<script src="${http_root}js/platform.min.js"></script>
|
||||||
<script src="${http_root}js/script.js${cache_param}"></script>
|
<script src="${http_root}js/script.js${cache_param}"></script>
|
||||||
<script src="${http_root}js/jquery.qrcode.min.js"></script>
|
|
||||||
<script src="${http_root}js/jquery.tripleclick.min.js"></script>
|
<script src="${http_root}js/jquery.tripleclick.min.js"></script>
|
||||||
% if _session['user_group'] == 'admin' and BROWSER_NOTIFIERS:
|
% if _session['user_group'] == 'admin' and BROWSER_NOTIFIERS:
|
||||||
<script src="${http_root}js/ajaxNotifications.js"></script>
|
<script src="${http_root}js/ajaxNotifications.js"></script>
|
||||||
@@ -365,16 +354,6 @@ ${next.modalIncludes()}
|
|||||||
checkUpdate(function () { $('#nav-update').html('<i class="fa fa-fw fa-arrow-alt-circle-up"></i> Check for Updates'); });
|
checkUpdate(function () { $('#nav-update').html('<i class="fa fa-fw fa-arrow-alt-circle-up"></i> Check for Updates'); });
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#donation_type a.crypto-donation').on('shown.bs.tab', function () {
|
|
||||||
var crypto_coin = $(this).data('coin');
|
|
||||||
var crypto_name = $(this).data('name');
|
|
||||||
var crypto_address = $(this).data('address')
|
|
||||||
$('#crypto_qr_code').empty().qrcode({
|
|
||||||
text: crypto_coin + ":" + crypto_address
|
|
||||||
});
|
|
||||||
$('#crypto_type_label').html(crypto_name);
|
|
||||||
$('#crypto_address').html(crypto_address);
|
|
||||||
});
|
|
||||||
% endif
|
% endif
|
||||||
|
|
||||||
$('.dropdown-toggle').click(function (e) {
|
$('.dropdown-toggle').click(function (e) {
|
||||||
|
@@ -71,6 +71,10 @@ DOCUMENTATION :: END
|
|||||||
<td>Platform:</td>
|
<td>Platform:</td>
|
||||||
<td>${common.PLATFORM} ${common.PLATFORM_RELEASE} (${common.PLATFORM_VERSION + (' - {}'.format(common.PLATFORM_LINUX_DISTRO) if common.PLATFORM_LINUX_DISTRO else '')})</td>
|
<td>${common.PLATFORM} ${common.PLATFORM_RELEASE} (${common.PLATFORM_VERSION + (' - {}'.format(common.PLATFORM_LINUX_DISTRO) if common.PLATFORM_LINUX_DISTRO else '')})</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>System Timezone:</td>
|
||||||
|
<td>${plexpy.SYS_TIMEZONE} (${'UTC{}'.format(plexpy.SYS_UTC_OFFSET)})
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Python Version:</td>
|
<td>Python Version:</td>
|
||||||
<td>${sys.version}</td>
|
<td>${sys.version}</td>
|
||||||
|
@@ -3367,6 +3367,34 @@ pre::-webkit-scrollbar-thumb {
|
|||||||
.notification-params tr:nth-child(even) td {
|
.notification-params tr:nth-child(even) td {
|
||||||
background-color: rgba(255,255,255,0.010);
|
background-color: rgba(255,255,255,0.010);
|
||||||
}
|
}
|
||||||
|
.activity-queue {
|
||||||
|
width: 100%;
|
||||||
|
margin-top: 10px;
|
||||||
|
background-color: #282828;
|
||||||
|
}
|
||||||
|
.activity-queue th {
|
||||||
|
padding-left: 10px;
|
||||||
|
height: 30px;
|
||||||
|
}
|
||||||
|
.activity-queue th:first-child {
|
||||||
|
width: 268px;
|
||||||
|
}
|
||||||
|
.activity-queue th:nth-child(2) {
|
||||||
|
width: 125px;
|
||||||
|
}
|
||||||
|
.activity-queue th:nth-child(3) {
|
||||||
|
width: 175px;
|
||||||
|
}
|
||||||
|
.activity-queue td {
|
||||||
|
height: 25px;
|
||||||
|
padding: 5px 10px;
|
||||||
|
}
|
||||||
|
.activity-queue tr:nth-child(odd) td {
|
||||||
|
background-color: rgba(255,255,255,0.035);
|
||||||
|
}
|
||||||
|
.activity-queue tr:nth-child(even) td {
|
||||||
|
background-color: rgba(255,255,255,0.010);
|
||||||
|
}
|
||||||
#days-selection label,
|
#days-selection label,
|
||||||
#months-selection label {
|
#months-selection label {
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
@@ -4176,8 +4204,13 @@ a[data-tab-destination] {
|
|||||||
background: #cc7b19;
|
background: #cc7b19;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
padding-top: 2px;
|
padding: 2px 10px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
z-index: 9999;
|
z-index: 9999;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.help-block li {
|
||||||
|
margin-top: 0;
|
||||||
|
color: #737373;
|
||||||
|
}
|
@@ -80,7 +80,9 @@ DOCUMENTATION :: END
|
|||||||
data-rating_key="${data['rating_key']}" data-parent_rating_key="${data['parent_rating_key']}" data-grandparent_rating_key="${data['grandparent_rating_key']}">
|
data-rating_key="${data['rating_key']}" data-parent_rating_key="${data['parent_rating_key']}" data-grandparent_rating_key="${data['grandparent_rating_key']}">
|
||||||
<div class="dashboard-activity-container">
|
<div class="dashboard-activity-container">
|
||||||
<%
|
<%
|
||||||
if data['channel_stream'] == 0:
|
if data['live'] == 1:
|
||||||
|
background_url = 'images/art-live.png'
|
||||||
|
elif data['channel_stream'] == 0:
|
||||||
background_url = 'pms_image_proxy?img=' + data['art'] + '&width=500&height=280&opacity=40&background=282828&blur=3&fallback=art&refresh=true'
|
background_url = 'pms_image_proxy?img=' + data['art'] + '&width=500&height=280&opacity=40&background=282828&blur=3&fallback=art&refresh=true'
|
||||||
else:
|
else:
|
||||||
if (data['art'] and data['art'].startswith('http')) or (data['thumb'] and data['thumb'].startswith('http')):
|
if (data['art'] and data['art'].startswith('http')) or (data['thumb'] and data['thumb'].startswith('http')):
|
||||||
@@ -93,7 +95,9 @@ DOCUMENTATION :: END
|
|||||||
% if data['media_type'] == 'track':
|
% if data['media_type'] == 'track':
|
||||||
<div id="poster-${sk}-bg" class="dashboard-activity-poster" style="background-image: url(pms_image_proxy?img=${data['parent_thumb']}&width=300&height=300&opacity=60&background=282828&blur=3&fallback=cover&refresh=true);"></div>
|
<div id="poster-${sk}-bg" class="dashboard-activity-poster" style="background-image: url(pms_image_proxy?img=${data['parent_thumb']}&width=300&height=300&opacity=60&background=282828&blur=3&fallback=cover&refresh=true);"></div>
|
||||||
% endif
|
% endif
|
||||||
% if data['channel_stream'] == 0:
|
% if data['live'] == 1:
|
||||||
|
<div id="poster-${sk}" class="dashboard-activity-poster" style="background-image: url(images/poster-live.png);"></div>
|
||||||
|
% elif data['channel_stream'] == 0:
|
||||||
% if data['media_type'] == 'movie':
|
% if data['media_type'] == 'movie':
|
||||||
<a id="poster-url-${sk}" href="${href}" title="${data['title']}">
|
<a id="poster-url-${sk}" href="${href}" title="${data['title']}">
|
||||||
<div id="poster-${sk}" class="dashboard-activity-poster" style="background-image: url(pms_image_proxy?img=${data['thumb']}&width=300&height=450&fallback=poster&refresh=true);"></div>
|
<div id="poster-${sk}" class="dashboard-activity-poster" style="background-image: url(pms_image_proxy?img=${data['thumb']}&width=300&height=450&fallback=poster&refresh=true);"></div>
|
||||||
@@ -113,7 +117,7 @@ DOCUMENTATION :: END
|
|||||||
<div id="poster-${sk}" class="dashboard-activity-poster" style="background-image: url(pms_image_proxy?img=${data['parent_thumb'] or data['thumb']}&width=300&height=450&fallback=poster&refresh=true);"></div>
|
<div id="poster-${sk}" class="dashboard-activity-poster" style="background-image: url(pms_image_proxy?img=${data['parent_thumb'] or data['thumb']}&width=300&height=450&fallback=poster&refresh=true);"></div>
|
||||||
% endif
|
% endif
|
||||||
% else:
|
% else:
|
||||||
<div id="poster-${sk}" class="dashboard-activity-poster" style="background-image: url(images/art.png);"></div>
|
<div id="poster-${sk}" class="dashboard-activity-poster" style="background-image: url(images/poster.png);"></div>
|
||||||
% endif
|
% endif
|
||||||
% else:
|
% else:
|
||||||
% if data['channel_icon'].startswith('http'):
|
% if data['channel_icon'].startswith('http'):
|
||||||
@@ -279,10 +283,17 @@ DOCUMENTATION :: END
|
|||||||
<li class="dashboard-activity-info-item">
|
<li class="dashboard-activity-info-item">
|
||||||
<div class="sub-heading">Location</div>
|
<div class="sub-heading">Location</div>
|
||||||
<div class="sub-value time-right">
|
<div class="sub-value time-right">
|
||||||
|
% if data['secure'] is not None:
|
||||||
|
% if data['secure']:
|
||||||
|
<span data-toggle="tooltip" title="Secure Connection"><i class="fa fa-lock"></i></span>
|
||||||
|
% else:
|
||||||
|
<span data-toggle="tooltip" title="Insecure Connection"><i class="fa fa-unlock"></i></span>
|
||||||
|
% endif
|
||||||
|
% endif
|
||||||
<span id="location-${sk}">${data['location'].upper()}</span>:
|
<span id="location-${sk}">${data['location'].upper()}</span>:
|
||||||
% if data['ip_address'] != 'N/A':
|
% if data['ip_address'] != 'N/A':
|
||||||
<span class="ip-container"><span class="ip-address">${data['ip_address']}</span></span>
|
<span class="ip-container"><span class="ip-address">${data['ip_address']}</span></span>
|
||||||
% if data['relay']:
|
% if data['relayed']:
|
||||||
<span data-toggle="tooltip" title="Plex Relay"><i class="fa fa-exclamation-circle"></i></span>
|
<span data-toggle="tooltip" title="Plex Relay"><i class="fa fa-exclamation-circle"></i></span>
|
||||||
% else:
|
% else:
|
||||||
<a href="#" class="external_ip-modal" data-toggle="modal" data-target="#ip-info-modal" data-ip="${data['ip_address']}">
|
<a href="#" class="external_ip-modal" data-toggle="modal" data-target="#ip-info-modal" data-ip="${data['ip_address']}">
|
||||||
@@ -313,7 +324,7 @@ DOCUMENTATION :: END
|
|||||||
bw = str(bw) + ' kbps'
|
bw = str(bw) + ' kbps'
|
||||||
%>
|
%>
|
||||||
<span id="stream-bandwidth-${sk}">${bw}</span>
|
<span id="stream-bandwidth-${sk}">${bw}</span>
|
||||||
<span id="streaming-brain-${sk}" data-toggle="tooltip" title="Streaming Brain Estimate (Required Bandwidth)"><i class="fa fa-info-circle"></i></span>
|
<span id="streaming-brain-${sk}" data-toggle="tooltip" title="Streaming Brain Estimate (Reserved Bandwidth)"><i class="fa fa-info-circle"></i></span>
|
||||||
% elif data['synced_version'] == 1 or data['channel_stream'] == 1:
|
% elif data['synced_version'] == 1 or data['channel_stream'] == 1:
|
||||||
<span id="stream-bandwidth-${sk}">None</span>
|
<span id="stream-bandwidth-${sk}">None</span>
|
||||||
% else:
|
% else:
|
||||||
|
@@ -21,6 +21,7 @@ parent_count Returns the parent item count for the library.
|
|||||||
child_count Returns the child item count for the library.
|
child_count Returns the child item count for the library.
|
||||||
do_notify Returns bool value for whether to send notifications for the library.
|
do_notify Returns bool value for whether to send notifications for the library.
|
||||||
keep_history Returns bool value for whether to keep history for the library.
|
keep_history Returns bool value for whether to keep history for the library.
|
||||||
|
deleted_section Returns bool value for whether the library is marked as deleted.
|
||||||
|
|
||||||
DOCUMENTATION :: END
|
DOCUMENTATION :: END
|
||||||
</%doc>
|
</%doc>
|
||||||
@@ -59,6 +60,12 @@ DOCUMENTATION :: END
|
|||||||
<p class="help-block">DANGER ZONE! Click the purge button to remove all history logged for this library. This is permanent!</p>
|
<p class="help-block">DANGER ZONE! Click the purge button to remove all history logged for this library. This is permanent!</p>
|
||||||
</div>
|
</div>
|
||||||
% endif
|
% endif
|
||||||
|
% if data['deleted_section']:
|
||||||
|
<div class="form-group">
|
||||||
|
<button class="btn btn-bright" id="undelete-library">Undelete</button>
|
||||||
|
<p class="help-block">Click to re-add the library to the Tautulli libraries list.</p>
|
||||||
|
</div>
|
||||||
|
% endif
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
@@ -100,6 +107,12 @@ DOCUMENTATION :: END
|
|||||||
confirmAjaxCall(url, msg, { section_id: '${data["section_id"]}' }, null, function () { location.reload(); });
|
confirmAjaxCall(url, msg, { section_id: '${data["section_id"]}' }, null, function () { location.reload(); });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#undelete-library').click(function () {
|
||||||
|
var msg = 'Are you sure you want to undelete this user?';
|
||||||
|
var url = 'undelete_library';
|
||||||
|
confirmAjaxCall(url, msg, { section_id: '${data["section_id"]}' }, null, function () { location.reload(); });
|
||||||
|
});
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
// Move #confirm-modal to parent container
|
// Move #confirm-modal to parent container
|
||||||
if (!($('#edit-library-modal').next().is('#confirm-modal-purge'))) {
|
if (!($('#edit-library-modal').next().is('#confirm-modal-purge'))) {
|
||||||
|
@@ -21,6 +21,7 @@ is_restricted Returns bool value for whether the user account is restricte
|
|||||||
do_notify Returns bool value for whether to send notifications for the user.
|
do_notify Returns bool value for whether to send notifications for the user.
|
||||||
keep_history Returns bool value for whether to keep history for the user.
|
keep_history Returns bool value for whether to keep history for the user.
|
||||||
allow_guest Returns bool value for whether to allow guest access for the user.
|
allow_guest Returns bool value for whether to allow guest access for the user.
|
||||||
|
deleted_user Returns bool value for whether the user is marked as deleted.
|
||||||
|
|
||||||
DOCUMENTATION :: END
|
DOCUMENTATION :: END
|
||||||
</%doc>
|
</%doc>
|
||||||
@@ -74,6 +75,12 @@ DOCUMENTATION :: END
|
|||||||
<p class="help-block">DANGER ZONE! Click the purge button to remove all history logged for this user. This is permanent!</p>
|
<p class="help-block">DANGER ZONE! Click the purge button to remove all history logged for this user. This is permanent!</p>
|
||||||
</div>
|
</div>
|
||||||
% endif
|
% endif
|
||||||
|
% if data['deleted_user']:
|
||||||
|
<div class="form-group">
|
||||||
|
<button class="btn btn-bright" id="undelete-user">Undelete</button>
|
||||||
|
<p class="help-block">Click to re-add the user to the Tautulli users list.</p>
|
||||||
|
</div>
|
||||||
|
% endif
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
@@ -122,6 +129,12 @@ DOCUMENTATION :: END
|
|||||||
confirmAjaxCall(url, msg, { user_id: '${data["user_id"]}' }, null, function () { location.reload(); });
|
confirmAjaxCall(url, msg, { user_id: '${data["user_id"]}' }, null, function () { location.reload(); });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#undelete-user').click(function () {
|
||||||
|
var msg = 'Are you sure you want to undelete this user?';
|
||||||
|
var url = 'undelete_user';
|
||||||
|
confirmAjaxCall(url, msg, { user_id: '${data["user_id"]}' }, null, function () { location.reload(); });
|
||||||
|
});
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
// Move #confirm-modal-purge to parent container
|
// Move #confirm-modal-purge to parent container
|
||||||
if (!($('#edit-user-modal').next().is('#confirm-modal-purge'))) {
|
if (!($('#edit-user-modal').next().is('#confirm-modal-purge'))) {
|
||||||
|
@@ -305,17 +305,17 @@
|
|||||||
setLocalStorage(chart_key, JSON.stringify(chart_visibility));
|
setLocalStorage(chart_key, JSON.stringify(chart_visibility));
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<script src="${http_root}js/graphs/plays_by_day.js"></script>
|
<script src="${http_root}js/graphs/plays_by_day.js${cache_param}"></script>
|
||||||
<script src="${http_root}js/graphs/plays_by_dayofweek.js"></script>
|
<script src="${http_root}js/graphs/plays_by_dayofweek.js${cache_param}"></script>
|
||||||
<script src="${http_root}js/graphs/plays_by_hourofday.js"></script>
|
<script src="${http_root}js/graphs/plays_by_hourofday.js${cache_param}"></script>
|
||||||
<script src="${http_root}js/graphs/plays_by_platform.js"></script>
|
<script src="${http_root}js/graphs/plays_by_platform.js${cache_param}"></script>
|
||||||
<script src="${http_root}js/graphs/plays_by_user.js"></script>
|
<script src="${http_root}js/graphs/plays_by_user.js${cache_param}"></script>
|
||||||
<script src="${http_root}js/graphs/plays_by_stream_type.js"></script>
|
<script src="${http_root}js/graphs/plays_by_stream_type.js${cache_param}"></script>
|
||||||
<script src="${http_root}js/graphs/plays_by_source_resolution.js"></script>
|
<script src="${http_root}js/graphs/plays_by_source_resolution.js${cache_param}"></script>
|
||||||
<script src="${http_root}js/graphs/plays_by_stream_resolution.js"></script>
|
<script src="${http_root}js/graphs/plays_by_stream_resolution.js${cache_param}"></script>
|
||||||
<script src="${http_root}js/graphs/plays_by_platform_by_stream_type.js"></script>
|
<script src="${http_root}js/graphs/plays_by_platform_by_stream_type.js${cache_param}"></script>
|
||||||
<script src="${http_root}js/graphs/plays_by_user_by_stream_type.js"></script>
|
<script src="${http_root}js/graphs/plays_by_user_by_stream_type.js${cache_param}"></script>
|
||||||
<script src="${http_root}js/graphs/plays_by_month.js"></script>
|
<script src="${http_root}js/graphs/plays_by_month.js${cache_param}"></script>
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
|
|
||||||
|
@@ -54,7 +54,7 @@
|
|||||||
json_data: JSON.stringify(d),
|
json_data: JSON.stringify(d),
|
||||||
user_id: "${data['user_id']}",
|
user_id: "${data['user_id']}",
|
||||||
start_date: "${data['start_date']}",
|
start_date: "${data['start_date']}",
|
||||||
media_type: "${data.get('media_type')}",
|
media_type: "${data.get('media_type') or 'all'}",
|
||||||
transcode_decision: "${data.get('transcode_decision')}"
|
transcode_decision: "${data.get('transcode_decision')}"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
BIN
data/interfaces/default/images/art-live.png
Normal file
BIN
data/interfaces/default/images/art-live.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 34 KiB |
BIN
data/interfaces/default/images/poster-live.png
Normal file
BIN
data/interfaces/default/images/poster-live.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 37 KiB |
@@ -15,9 +15,9 @@
|
|||||||
<h3><span id="sessions-xml">Activity</span>
|
<h3><span id="sessions-xml">Activity</span>
|
||||||
<small>
|
<small>
|
||||||
<span id="currentActivityHeader" style="display: none;">
|
<span id="currentActivityHeader" style="display: none;">
|
||||||
Streams: <span id="currentActivityHeader-streams"></span> |
|
Sessions: <span id="currentActivityHeader-streams"></span> |
|
||||||
Bandwidth: <span id="currentActivityHeader-bandwidth"></span>
|
Bandwidth: <span id="currentActivityHeader-bandwidth"></span>
|
||||||
<span id="currentActivityHeader-bandwidth-tooltip" data-toggle="tooltip" title="Streaming Brain Estimate (Required Bandwidth)"><i class="fa fa-info-circle"></i></span>
|
<span id="currentActivityHeader-bandwidth-tooltip" data-toggle="tooltip" title="Streaming Brain Estimate (Reserved Bandwidth)"><i class="fa fa-info-circle"></i></span>
|
||||||
</span>
|
</span>
|
||||||
</small>
|
</small>
|
||||||
</h3>
|
</h3>
|
||||||
@@ -27,6 +27,8 @@
|
|||||||
<div class="text-muted" id="dashboard-checking-activity"><i class="fa fa-refresh fa-spin"></i> Checking for activity...</div>
|
<div class="text-muted" id="dashboard-checking-activity"><i class="fa fa-refresh fa-spin"></i> Checking for activity...</div>
|
||||||
% elif config['pms_is_cloud']:
|
% elif config['pms_is_cloud']:
|
||||||
<div id="dashboard-no-activity" class="text-muted">Plex Cloud server is sleeping.</div>
|
<div id="dashboard-no-activity" class="text-muted">Plex Cloud server is sleeping.</div>
|
||||||
|
% elif not config['first_run_complete']:
|
||||||
|
<div id="dashboard-no-activity" class="text-muted">The Tautulli setup wizard has not been completed. Please click <a href="welcome">here</a> to go to the setup wizard.</div>
|
||||||
% else:
|
% else:
|
||||||
<div id="dashboard-no-activity" class="text-muted">There was an error communicating with your Plex Server.
|
<div id="dashboard-no-activity" class="text-muted">There was an error communicating with your Plex Server.
|
||||||
% if _session['user_group'] == 'admin':
|
% if _session['user_group'] == 'admin':
|
||||||
|
@@ -10,17 +10,33 @@ if (typeof platform !== 'undefined') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (['IE', 'Microsoft Edge', 'IE Mobile'].indexOf(p.name) > -1) {
|
if (['IE', 'Microsoft Edge', 'IE Mobile'].indexOf(p.name) > -1) {
|
||||||
$('body').prepend('<div id="browser-warning"><i class="fa fa-exclamation-circle"></i> ' +
|
if (!getCookie('browserDismiss')) {
|
||||||
'Tautulli does not support Internet Explorer or Microsoft Edge! ' +
|
var $browser_warning = $('<div id="browser-warning">' +
|
||||||
'Please use a different browser such as Chrome or Firefox.</div>');
|
'<i class="fa fa-exclamation-circle"></i> ' +
|
||||||
var offset = $('#browser-warning').height();
|
'Tautulli does not support Internet Explorer or Microsoft Edge! ' +
|
||||||
var navbar = $('.navbar-fixed-top');
|
'Please use a different browser such as Chrome or Firefox.' +
|
||||||
if (navbar.length) {
|
'<button type="button" class="close"><i class="fa fa-remove"></i></button>' +
|
||||||
navbar.offset({top: navbar.offset().top + offset});
|
'</div>');
|
||||||
}
|
$('body').prepend($browser_warning);
|
||||||
var container = $('.body-container');
|
var offset = $browser_warning.height();
|
||||||
if (container.length) {
|
warningOffset(offset);
|
||||||
container.offset({top: container.offset().top + offset});
|
|
||||||
|
$browser_warning.one('click', 'button.close', function () {
|
||||||
|
$browser_warning.remove();
|
||||||
|
warningOffset(-offset);
|
||||||
|
setCookie('browserDismiss', 'true', 7);
|
||||||
|
});
|
||||||
|
|
||||||
|
function warningOffset(offset) {
|
||||||
|
var navbar = $('.navbar-fixed-top');
|
||||||
|
if (navbar.length) {
|
||||||
|
navbar.offset({top: navbar.offset().top + offset});
|
||||||
|
}
|
||||||
|
var container = $('.body-container');
|
||||||
|
if (container.length) {
|
||||||
|
container.offset({top: container.offset().top + offset});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -517,23 +533,26 @@ function PopupCenter(url, title, w, h) {
|
|||||||
return newWindow;
|
return newWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setLocalStorage(key, value) {
|
|
||||||
|
function setLocalStorage(key, value, path) {
|
||||||
|
if (path !== false) {
|
||||||
|
key = key + '_' + window.location.pathname;
|
||||||
|
}
|
||||||
localStorage.setItem(key, value);
|
localStorage.setItem(key, value);
|
||||||
}
|
}
|
||||||
function getLocalStorage(key, default_value) {
|
function getLocalStorage(key, default_value, path) {
|
||||||
|
if (path !== false) {
|
||||||
|
key = key + '_' + window.location.pathname;
|
||||||
|
}
|
||||||
var value = localStorage.getItem(key);
|
var value = localStorage.getItem(key);
|
||||||
if (value !== null) {
|
if (value !== null) {
|
||||||
return value
|
return value
|
||||||
} else if (default_value !== undefined) {
|
} else if (default_value !== undefined) {
|
||||||
setLocalStorage(key, default_value);
|
setLocalStorage(key, default_value, path);
|
||||||
return default_value
|
return default_value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!getLocalStorage('Tautulli_ClientId')) {
|
|
||||||
setLocalStorage('Tautulli_ClientId', uuidv4());
|
|
||||||
}
|
|
||||||
|
|
||||||
function uuidv4() {
|
function uuidv4() {
|
||||||
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, function(c) {
|
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, function(c) {
|
||||||
var cryptoObj = window.crypto || window.msCrypto; // for IE 11
|
var cryptoObj = window.crypto || window.msCrypto; // for IE 11
|
||||||
@@ -541,16 +560,18 @@ function uuidv4() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var x_plex_headers = {
|
function getPlexHeaders() {
|
||||||
'Accept': 'application/json',
|
return {
|
||||||
'X-Plex-Product': 'Tautulli',
|
'Accept': 'application/json',
|
||||||
'X-Plex-Version': 'Plex OAuth',
|
'X-Plex-Product': 'Tautulli',
|
||||||
'X-Plex-Client-Identifier': localStorage.getItem('Tautulli_ClientId'),
|
'X-Plex-Version': 'Plex OAuth',
|
||||||
'X-Plex-Platform': p.name,
|
'X-Plex-Client-Identifier': getLocalStorage('Tautulli_ClientID', uuidv4(), false),
|
||||||
'X-Plex-Platform-Version': p.version,
|
'X-Plex-Platform': p.name,
|
||||||
'X-Plex-Device': p.os,
|
'X-Plex-Platform-Version': p.version,
|
||||||
'X-Plex-Device-Name': p.name
|
'X-Plex-Device': p.os,
|
||||||
};
|
'X-Plex-Device-Name': p.name
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
var plex_oauth_window = null;
|
var plex_oauth_window = null;
|
||||||
const plex_oauth_loader = '<style>' +
|
const plex_oauth_loader = '<style>' +
|
||||||
@@ -601,6 +622,7 @@ function closePlexOAuthWindow() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getPlexOAuthPin = function () {
|
getPlexOAuthPin = function () {
|
||||||
|
var x_plex_headers = getPlexHeaders();
|
||||||
var deferred = $.Deferred();
|
var deferred = $.Deferred();
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@@ -629,6 +651,7 @@ function PlexOAuth(success, error, pre) {
|
|||||||
$(plex_oauth_window.document.body).html(plex_oauth_loader);
|
$(plex_oauth_window.document.body).html(plex_oauth_loader);
|
||||||
|
|
||||||
getPlexOAuthPin().then(function (data) {
|
getPlexOAuthPin().then(function (data) {
|
||||||
|
var x_plex_headers = getPlexHeaders();
|
||||||
const pin = data.pin;
|
const pin = data.pin;
|
||||||
const code = data.code;
|
const code = data.code;
|
||||||
|
|
||||||
|
@@ -150,6 +150,7 @@
|
|||||||
token: token,
|
token: token,
|
||||||
remember_me: remember_me
|
remember_me: remember_me
|
||||||
};
|
};
|
||||||
|
var x_plex_headers = getPlexHeaders();
|
||||||
data = $.extend(data, x_plex_headers);
|
data = $.extend(data, x_plex_headers);
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
@@ -148,7 +148,7 @@
|
|||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<label>Notification Triggers</label>
|
<label>Notification Triggers</label>
|
||||||
<p class="help-block">
|
<p class="help-block">
|
||||||
Select items that will trigger a notification for this ${notifier['agent_label']} notifiation agent.
|
Select items that will trigger a notification for this ${notifier['agent_label']} notification agent.
|
||||||
</p>
|
</p>
|
||||||
% for action in available_notification_actions:
|
% for action in available_notification_actions:
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
|
@@ -8,7 +8,12 @@
|
|||||||
% if text:
|
% if text:
|
||||||
% for item in text:
|
% for item in text:
|
||||||
<div style="padding-bottom: 10px;">
|
<div style="padding-bottom: 10px;">
|
||||||
<h4>${item['media_type'].capitalize()}</h4>
|
<h4>
|
||||||
|
${item['media_type'].capitalize()}
|
||||||
|
% if item['media_type'] != 'server':
|
||||||
|
<span class="inline-pre"><${item['media_type']}></${item['media_type']}></span> tags
|
||||||
|
% endif
|
||||||
|
</h4>
|
||||||
% if agent != 'webhook':
|
% if agent != 'webhook':
|
||||||
<pre>${item['subject']}</pre>
|
<pre>${item['subject']}</pre>
|
||||||
% endif
|
% endif
|
||||||
|
66
data/interfaces/default/queue_modal.html
Normal file
66
data/interfaces/default/queue_modal.html
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
<%
|
||||||
|
import arrow
|
||||||
|
from plexpy.activity_handler import ACTIVITY_SCHED, schedule_callback
|
||||||
|
|
||||||
|
if queue == 'active sessions':
|
||||||
|
filter_key = 'session_key-'
|
||||||
|
title_format = '{2} / {1} ({0})'
|
||||||
|
title_key = title_format.format('Session Key', 'Title', 'User')
|
||||||
|
description = 'Queue to flush stuck active sessions to the database.'
|
||||||
|
else:
|
||||||
|
filter_key = 'rating_key-'
|
||||||
|
title_format = '{1} ({0})'
|
||||||
|
title_key = title_format.format('Rating Key', 'Title')
|
||||||
|
description = 'Queue to flush recently added items to the database and send notifications if enabled.'
|
||||||
|
|
||||||
|
scheduled_jobs = [j.id for j in ACTIVITY_SCHED.get_jobs() if j.id.startswith(filter_key)]
|
||||||
|
%>
|
||||||
|
<div class="modal-dialog" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="fa fa-remove"></i></button>
|
||||||
|
<h4 class="modal-title">${queue.title()} Queue</h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<p class="help-block">
|
||||||
|
${description}
|
||||||
|
</p>
|
||||||
|
<table class="activity-queue">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
${title_key}
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Next Flush In
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Next Flush Time
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
% if scheduled_jobs:
|
||||||
|
% for job in scheduled_jobs:
|
||||||
|
<%
|
||||||
|
sched_job = ACTIVITY_SCHED.get_job(job)
|
||||||
|
next_run_in = arrow.get(sched_job.next_run_time).timestamp - arrow.now().timestamp
|
||||||
|
%>
|
||||||
|
<tr>
|
||||||
|
<td><strong>${title_format.format(*sched_job.args)}</strong></td>
|
||||||
|
<td>${arrow.get(next_run_in).format('HH:mm:ss')}</td>
|
||||||
|
<td>${arrow.get(sched_job.next_run_time).format('YYYY-MM-DD HH:mm:ss')}</td>
|
||||||
|
</tr>
|
||||||
|
% endfor
|
||||||
|
% else:
|
||||||
|
<tr>
|
||||||
|
<td colspan="3" style="text-align: center;"><i class="fa fa-check"></i> Nothing in the ${queue} queue</td>
|
||||||
|
</tr>
|
||||||
|
% endif
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
@@ -44,7 +44,13 @@ DOCUMENTATION :: END
|
|||||||
</tr>
|
</tr>
|
||||||
% elif job in ('Check for server response', 'Check for active sessions', 'Check for recently added items') and plexpy.WS_CONNECTED:
|
% elif job in ('Check for server response', 'Check for active sessions', 'Check for recently added items') and plexpy.WS_CONNECTED:
|
||||||
<tr>
|
<tr>
|
||||||
|
% if job == 'Check for active sessions':
|
||||||
|
<td><a class="queue-modal-link" href="#" data-queue="active sessions">${job}</a></td>
|
||||||
|
% elif job == 'Check for recently added items':
|
||||||
|
<td><a class="queue-modal-link" href="#" data-queue="recently added">${job}</a></td>
|
||||||
|
% else:
|
||||||
<td>${job}</td>
|
<td>${job}</td>
|
||||||
|
% endif
|
||||||
<td><i class="fa fa-sm fa-fw fa-check"></i> Websocket</td>
|
<td><i class="fa fa-sm fa-fw fa-check"></i> Websocket</td>
|
||||||
<td>N/A</td>
|
<td>N/A</td>
|
||||||
<td>N/A</td>
|
<td>N/A</td>
|
||||||
@@ -62,3 +68,20 @@ DOCUMENTATION :: END
|
|||||||
% endfor
|
% endfor
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
<script>
|
||||||
|
$('.queue-modal-link').on('click', function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
$.ajax({
|
||||||
|
url: 'get_queue_modal',
|
||||||
|
data: {
|
||||||
|
queue: $(this).data('queue')
|
||||||
|
},
|
||||||
|
cache: false,
|
||||||
|
async: true,
|
||||||
|
complete: function(xhr, status) {
|
||||||
|
$("#queue-modal").html(xhr.responseText);
|
||||||
|
$('#queue-modal').modal();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@@ -472,7 +472,7 @@
|
|||||||
<div class="col-md-8">
|
<div class="col-md-8">
|
||||||
<input type="text" class="form-control" id="http_base_url" name="http_base_url" value="${config['http_base_url']}" placeholder="http://mydomain.com" data-parsley-trigger="change" data-parsley-pattern="^https?:\/\/\S+$" data-parsley-errors-container="#http_base_url_error" data-parsley-error-message="Invalid URL">
|
<input type="text" class="form-control" id="http_base_url" name="http_base_url" value="${config['http_base_url']}" placeholder="http://mydomain.com" data-parsley-trigger="change" data-parsley-pattern="^https?:\/\/\S+$" data-parsley-errors-container="#http_base_url_error" data-parsley-error-message="Invalid URL">
|
||||||
</div>
|
</div>
|
||||||
<div id=http_base_url_error" class="alert alert-danger settings-alert" role="alert"></div>
|
<div id="http_base_url_error" class="alert alert-danger settings-alert" role="alert"></div>
|
||||||
</div>
|
</div>
|
||||||
<p class="help-block">
|
<p class="help-block">
|
||||||
Set your public Tautulli domain for self-hosted notification images and newsletters. (e.g. http://mydomain.com)
|
Set your public Tautulli domain for self-hosted notification images and newsletters. (e.g. http://mydomain.com)
|
||||||
@@ -1316,6 +1316,7 @@
|
|||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
<%def name="modalIncludes()">
|
<%def name="modalIncludes()">
|
||||||
|
<div id="queue-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="queue-modal"></div>
|
||||||
<div id="guidelines-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="guidelines-modal">
|
<div id="guidelines-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="guidelines-modal">
|
||||||
<div class="modal-dialog" role="document">
|
<div class="modal-dialog" role="document">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
@@ -1531,7 +1532,7 @@
|
|||||||
<div style="padding-bottom: 10px;">
|
<div style="padding-bottom: 10px;">
|
||||||
<p class="help-block">
|
<p class="help-block">
|
||||||
All text inside <span class="inline-pre"><show></show></span>/<span class="inline-pre"><season></season></span>/<span class="inline-pre"><episode></episode></span>
|
All text inside <span class="inline-pre"><show></show></span>/<span class="inline-pre"><season></season></span>/<span class="inline-pre"><episode></episode></span>
|
||||||
tags will only be sent when the media type is show/season/episode.
|
tags will only be sent when the media type is show, season, or episode, respectively.
|
||||||
</p>
|
</p>
|
||||||
<p><strong style="color: #fff;">Example:</strong></p>
|
<p><strong style="color: #fff;">Example:</strong></p>
|
||||||
<pre>{show_name}<season> - Season {season_num}</season><episode> - S{season_num}E{episode_num} - {episode_name}</episode> was recently added to Plex.</pre>
|
<pre>{show_name}<season> - Season {season_num}</season><episode> - S{season_num}E{episode_num} - {episode_name}</episode> was recently added to Plex.</pre>
|
||||||
@@ -1542,7 +1543,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<p class="help-block">
|
<p class="help-block">
|
||||||
All text inside <span class="inline-pre"><artist></artist></span>/<span class="inline-pre"><album></album></span>/<span class="inline-pre"><track></track></span>
|
All text inside <span class="inline-pre"><artist></artist></span>/<span class="inline-pre"><album></album></span>/<span class="inline-pre"><track></track></span>
|
||||||
tags will only be sent when the media type is artist/album/track.
|
tags will only be sent when the media type is artist, album, or track, respectively.
|
||||||
</p>
|
</p>
|
||||||
<p><strong style="color: #fff;">Example:</strong></p>
|
<p><strong style="color: #fff;">Example:</strong></p>
|
||||||
<pre>{artist_name}<album> - {album_name}</album><track> - {album_name} - {track_name}</track> was recently added to Plex.</pre>
|
<pre>{artist_name}<album> - {album_name}</album><track> - {album_name} - {track_name}</track> was recently added to Plex.</pre>
|
||||||
@@ -1587,7 +1588,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<h4>List Slicing</h4>
|
<h4>List Slicing</h4>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div style="padding-bottom: 10px;">
|
||||||
<p class="help-block">
|
<p class="help-block">
|
||||||
Notification parameters which have a list of items can be sliced with a slice formatter <span class="inline-pre">:[X:Y]</span> to limit the number of items.
|
Notification parameters which have a list of items can be sliced with a slice formatter <span class="inline-pre">:[X:Y]</span> to limit the number of items.
|
||||||
Note: the first item in the list is numbered <span class="inline-pre">0</span>.
|
Note: the first item in the list is numbered <span class="inline-pre">0</span>.
|
||||||
@@ -1598,6 +1599,41 @@
|
|||||||
{actors:[2:]} --> Only the 3rd to last actors (Actors: 2, 3, 4, ...)
|
{actors:[2:]} --> Only the 3rd to last actors (Actors: 2, 3, 4, ...)
|
||||||
{actors:[1:5]} --> Only the 2nd to 5th actors (Actors: 1, 2, 3, 4)</pre>
|
{actors:[1:5]} --> Only the 2nd to 5th actors (Actors: 1, 2, 3, 4)</pre>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<h4>Prefix and Suffix</h4>
|
||||||
|
</div>
|
||||||
|
<div style="padding-bottom: 10px;">
|
||||||
|
<p class="help-block">
|
||||||
|
A prefix or a suffix can be added to the notification parameters using <span class="inline-pre">Prefix<</span> and <span class="inline-pre">>Suffix</span>.
|
||||||
|
If the notification parameter is unavailable, the prefix or suffix will not be displayed.
|
||||||
|
</p>
|
||||||
|
<p><strong style="color: #fff;">Example:</strong></p>
|
||||||
|
<pre>{rating} --> 8.9
|
||||||
|
{Rating: <rating} --> Rating: 8.9
|
||||||
|
{rating>/10} --> 8.9/10
|
||||||
|
{Rating: <rating>/10} --> Rating: 8.9/10</pre>
|
||||||
|
<p><strong style="color: #fff;">Example with unavailable parameter:</strong></p>
|
||||||
|
<pre>{rating} -->
|
||||||
|
Rating: {rating}/10 --> Rating: /10
|
||||||
|
{Rating: <rating>/10} --> </pre>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h4>Combined</h4>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p class="help-block">
|
||||||
|
If combining multiple notification text modifiers, the order of the modifiers must be:
|
||||||
|
</p>
|
||||||
|
<ol class="help-block">
|
||||||
|
<li>Prefix</li>
|
||||||
|
<li>Parameter</li>
|
||||||
|
<li>Case Modifier</li>
|
||||||
|
<li>List Slicing</li>
|
||||||
|
<li>Suffix</li>
|
||||||
|
</ol>
|
||||||
|
<p><strong style="color: #fff;">Example:</strong></p>
|
||||||
|
<pre>{Starring <actors!c:[0]> as the main character.} --> Starring Arnold Schwarzenegger as the main character.</pre>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
@@ -1619,7 +1655,7 @@
|
|||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<div>
|
<div>
|
||||||
<p class="help-block">
|
<p class="help-block">
|
||||||
If the value for a selected parameter cannot be provided, it will display as blank.
|
If the value for a selected parameter is unavailable, it will display as blank.
|
||||||
</p>
|
</p>
|
||||||
% for category in common.NEWSLETTER_PARAMETERS:
|
% for category in common.NEWSLETTER_PARAMETERS:
|
||||||
<table class="notification-params">
|
<table class="notification-params">
|
||||||
@@ -2300,6 +2336,7 @@ $(document).ready(function() {
|
|||||||
$("#token_verify").html('<i class="fa fa-refresh fa-spin"></i>').fadeIn('fast');
|
$("#token_verify").html('<i class="fa fa-refresh fa-spin"></i>').fadeIn('fast');
|
||||||
}
|
}
|
||||||
function OAuthSuccessCallback(authToken) {
|
function OAuthSuccessCallback(authToken) {
|
||||||
|
var x_plex_headers = getPlexHeaders();
|
||||||
$("#pms_token").val(authToken);
|
$("#pms_token").val(authToken);
|
||||||
$("#pms_uuid").val(x_plex_headers['X-Plex-Client-Identifier']);
|
$("#pms_uuid").val(x_plex_headers['X-Plex-Client-Identifier']);
|
||||||
$("#token_verify").html('<i class="fa fa-check"></i>').fadeIn('fast');
|
$("#token_verify").html('<i class="fa fa-check"></i>').fadeIn('fast');
|
||||||
@@ -2529,8 +2566,10 @@ $(document).ready(function() {
|
|||||||
.prop('selected', selected));
|
.prop('selected', selected));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var download_url = 'https://plex.tv/api/downloads/' + (plex_update_channel === 'plexpass' ? '5' : '1') + '.json?channel=' + plex_update_channel;
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: 'https://plex.tv/api/downloads/1.json?channel=' + plex_update_channel,
|
url: download_url,
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
beforeSend: function (xhr) {
|
beforeSend: function (xhr) {
|
||||||
|
@@ -230,7 +230,7 @@ DOCUMENTATION :: END
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Codec</td>
|
<td>Codec</td>
|
||||||
<td>${data['stream_subtitle_codec'].upper()}</td>
|
<td>${data['stream_subtitle_codec'].upper() or '-'}</td>
|
||||||
<td>${data['subtitle_codec'].upper()}</td>
|
<td>${data['subtitle_codec'].upper()}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@@ -183,6 +183,7 @@ DOCUMENTATION :: END
|
|||||||
async: true,
|
async: true,
|
||||||
data: {
|
data: {
|
||||||
query: query_string,
|
query: query_string,
|
||||||
|
limit: 30,
|
||||||
media_type: '${query["media_type"]}',
|
media_type: '${query["media_type"]}',
|
||||||
season_index: '${query["parent_media_index"]}'
|
season_index: '${query["parent_media_index"]}'
|
||||||
},
|
},
|
||||||
|
@@ -274,12 +274,12 @@ DOCUMENTATION :: END
|
|||||||
<table class="display user_ip_table" id="user_ip_table-UID-${data['user_id']}" width="100%">
|
<table class="display user_ip_table" id="user_ip_table-UID-${data['user_id']}" width="100%">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th align="left">Last Seen</th>
|
<th align="left" id="last_seen">Last Seen</th>
|
||||||
<th align="left">IP Address</th>
|
<th align="left" id="ip_address">IP Address</th>
|
||||||
<th align="left">Last Platform</th>
|
<th align="left" id="platform">Last Platform</th>
|
||||||
<th align="left">Last Player</th>
|
<th align="left" id="player">Last Player</th>
|
||||||
<th align="left">Last Played</th>
|
<th align="left" id="last_played">Last Played</th>
|
||||||
<th align="left">Play Count</th>
|
<th align="left" id="play_count">Play Count</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
</table>
|
</table>
|
||||||
|
12
init-scripts/init.systemd
Executable file → Normal file
12
init-scripts/init.systemd
Executable file → Normal file
@@ -24,9 +24,11 @@
|
|||||||
# - The example settings in this file assume that Tautulli is installed to: /opt/Tautulli
|
# - The example settings in this file assume that Tautulli is installed to: /opt/Tautulli
|
||||||
#
|
#
|
||||||
# - To create this user and give it ownership of the Tautulli directory:
|
# - To create this user and give it ownership of the Tautulli directory:
|
||||||
# Ubuntu/Debian: sudo addgroup tautulli && sudo adduser --system --no-create-home tautulli --ingroup tautulli
|
# 1. Create the user:
|
||||||
# CentOS/Fedora: sudo adduser --system --no-create-home tautulli
|
# Ubuntu/Debian: sudo addgroup tautulli && sudo adduser --system --no-create-home tautulli --ingroup tautulli
|
||||||
# sudo chown tautulli:tautulli -R /opt/Tautulli
|
# CentOS/Fedora: sudo adduser --system --no-create-home tautulli
|
||||||
|
# 2. Give the user ownership of the Tautulli directory:
|
||||||
|
# sudo chown tautulli:tautulli -R /opt/Tautulli
|
||||||
#
|
#
|
||||||
# - Adjust ExecStart= to point to:
|
# - Adjust ExecStart= to point to:
|
||||||
# 1. Your Tautulli executable
|
# 1. Your Tautulli executable
|
||||||
@@ -53,6 +55,10 @@ GuessMainPID=no
|
|||||||
Type=forking
|
Type=forking
|
||||||
User=tautulli
|
User=tautulli
|
||||||
Group=tautulli
|
Group=tautulli
|
||||||
|
Restart=on-abnormal
|
||||||
|
RestartSec=5
|
||||||
|
StartLimitInterval=90
|
||||||
|
StartLimitBurst=3
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
Copyright (c) 2003-2009 Stuart Bishop <stuart@stuartbishop.net>
|
Copyright (c) 2003-2018 Stuart Bishop <stuart@stuartbishop.net>
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a
|
Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
copy of this software and associated documentation files (the "Software"),
|
copy of this software and associated documentation files (the "Software"),
|
||||||
|
@@ -87,13 +87,13 @@ localized time using the standard ``astimezone()`` method:
|
|||||||
Unfortunately using the tzinfo argument of the standard datetime
|
Unfortunately using the tzinfo argument of the standard datetime
|
||||||
constructors ''does not work'' with pytz for many timezones.
|
constructors ''does not work'' with pytz for many timezones.
|
||||||
|
|
||||||
>>> datetime(2002, 10, 27, 12, 0, 0, tzinfo=amsterdam).strftime(fmt)
|
>>> datetime(2002, 10, 27, 12, 0, 0, tzinfo=amsterdam).strftime(fmt) # /!\ Does not work this way!
|
||||||
'2002-10-27 12:00:00 LMT+0020'
|
'2002-10-27 12:00:00 LMT+0020'
|
||||||
|
|
||||||
It is safe for timezones without daylight saving transitions though, such
|
It is safe for timezones without daylight saving transitions though, such
|
||||||
as UTC:
|
as UTC:
|
||||||
|
|
||||||
>>> datetime(2002, 10, 27, 12, 0, 0, tzinfo=pytz.utc).strftime(fmt)
|
>>> datetime(2002, 10, 27, 12, 0, 0, tzinfo=pytz.utc).strftime(fmt) # /!\ Not recommended except for UTC
|
||||||
'2002-10-27 12:00:00 UTC+0000'
|
'2002-10-27 12:00:00 UTC+0000'
|
||||||
|
|
||||||
The preferred way of dealing with times is to always work in UTC,
|
The preferred way of dealing with times is to always work in UTC,
|
||||||
@@ -134,19 +134,21 @@ section for more details)
|
|||||||
>>> dt2.strftime(fmt)
|
>>> dt2.strftime(fmt)
|
||||||
'2002-10-27 01:30:00 EST-0500'
|
'2002-10-27 01:30:00 EST-0500'
|
||||||
|
|
||||||
Converting between timezones also needs special attention. We also need
|
Converting between timezones is more easily done, using the
|
||||||
to use the ``normalize()`` method to ensure the conversion is correct.
|
standard astimezone method.
|
||||||
|
|
||||||
>>> utc_dt = utc.localize(datetime.utcfromtimestamp(1143408899))
|
>>> utc_dt = utc.localize(datetime.utcfromtimestamp(1143408899))
|
||||||
>>> utc_dt.strftime(fmt)
|
>>> utc_dt.strftime(fmt)
|
||||||
'2006-03-26 21:34:59 UTC+0000'
|
'2006-03-26 21:34:59 UTC+0000'
|
||||||
>>> au_tz = timezone('Australia/Sydney')
|
>>> au_tz = timezone('Australia/Sydney')
|
||||||
>>> au_dt = au_tz.normalize(utc_dt.astimezone(au_tz))
|
>>> au_dt = utc_dt.astimezone(au_tz)
|
||||||
>>> au_dt.strftime(fmt)
|
>>> au_dt.strftime(fmt)
|
||||||
'2006-03-27 08:34:59 AEDT+1100'
|
'2006-03-27 08:34:59 AEDT+1100'
|
||||||
>>> utc_dt2 = utc.normalize(au_dt.astimezone(utc))
|
>>> utc_dt2 = au_dt.astimezone(utc)
|
||||||
>>> utc_dt2.strftime(fmt)
|
>>> utc_dt2.strftime(fmt)
|
||||||
'2006-03-26 21:34:59 UTC+0000'
|
'2006-03-26 21:34:59 UTC+0000'
|
||||||
|
>>> utc_dt == utc_dt2
|
||||||
|
True
|
||||||
|
|
||||||
You can take shortcuts when dealing with the UTC side of timezone
|
You can take shortcuts when dealing with the UTC side of timezone
|
||||||
conversions. ``normalize()`` and ``localize()`` are not really
|
conversions. ``normalize()`` and ``localize()`` are not really
|
||||||
@@ -178,7 +180,7 @@ parameter to the ``utcoffset()``, ``dst()`` && ``tzname()`` methods.
|
|||||||
>>> ambiguous = datetime(2009, 10, 31, 23, 30)
|
>>> ambiguous = datetime(2009, 10, 31, 23, 30)
|
||||||
|
|
||||||
The ``is_dst`` parameter is ignored for most timestamps. It is only used
|
The ``is_dst`` parameter is ignored for most timestamps. It is only used
|
||||||
during DST transition ambiguous periods to resulve that ambiguity.
|
during DST transition ambiguous periods to resolve that ambiguity.
|
||||||
|
|
||||||
>>> tz.utcoffset(normal, is_dst=True)
|
>>> tz.utcoffset(normal, is_dst=True)
|
||||||
datetime.timedelta(-1, 77400)
|
datetime.timedelta(-1, 77400)
|
||||||
@@ -472,9 +474,9 @@ True
|
|||||||
True
|
True
|
||||||
>>> 'Canada/Eastern' in common_timezones
|
>>> 'Canada/Eastern' in common_timezones
|
||||||
True
|
True
|
||||||
>>> 'US/Pacific-New' in all_timezones
|
>>> 'Australia/Yancowinna' in all_timezones
|
||||||
True
|
True
|
||||||
>>> 'US/Pacific-New' in common_timezones
|
>>> 'Australia/Yancowinna' in common_timezones
|
||||||
False
|
False
|
||||||
|
|
||||||
Both ``common_timezones`` and ``all_timezones`` are alphabetically
|
Both ``common_timezones`` and ``all_timezones`` are alphabetically
|
||||||
@@ -510,6 +512,15 @@ Europe/Zurich
|
|||||||
Europe/Zurich
|
Europe/Zurich
|
||||||
|
|
||||||
|
|
||||||
|
Internationalization - i18n/l10n
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Pytz is an interface to the IANA database, which uses ASCII names. The `Unicode Consortium's Unicode Locales (CLDR) <http://cldr.unicode.org>`_
|
||||||
|
project provides translations. Thomas Khyn's
|
||||||
|
`l18n <https://pypi.org/project/l18n/>`_ package can be used to access
|
||||||
|
these translations from Python.
|
||||||
|
|
||||||
|
|
||||||
License
|
License
|
||||||
~~~~~~~
|
~~~~~~~
|
||||||
|
|
||||||
@@ -527,12 +538,13 @@ Latest Versions
|
|||||||
|
|
||||||
This package will be updated after releases of the Olson timezone
|
This package will be updated after releases of the Olson timezone
|
||||||
database. The latest version can be downloaded from the `Python Package
|
database. The latest version can be downloaded from the `Python Package
|
||||||
Index <http://pypi.python.org/pypi/pytz/>`_. The code that is used
|
Index <https://pypi.org/project/pytz/>`_. The code that is used
|
||||||
to generate this distribution is hosted on launchpad.net and available
|
to generate this distribution is hosted on launchpad.net and available
|
||||||
using the `Bazaar version control system <http://bazaar-vcs.org>`_
|
using git::
|
||||||
using::
|
|
||||||
|
|
||||||
bzr branch lp:pytz
|
git clone https://git.launchpad.net/pytz
|
||||||
|
|
||||||
|
A mirror on github is also available at https://github.com/stub42/pytz
|
||||||
|
|
||||||
Announcements of new releases are made on
|
Announcements of new releases are made on
|
||||||
`Launchpad <https://launchpad.net/pytz>`_, and the
|
`Launchpad <https://launchpad.net/pytz>`_, and the
|
||||||
@@ -543,7 +555,7 @@ hosted there.
|
|||||||
Bugs, Feature Requests & Patches
|
Bugs, Feature Requests & Patches
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Bugs can be reported using `Launchpad <https://bugs.launchpad.net/pytz>`_.
|
Bugs can be reported using `Launchpad <https://bugs.launchpad.net/pytz>`__.
|
||||||
|
|
||||||
|
|
||||||
Issues & Limitations
|
Issues & Limitations
|
||||||
|
@@ -8,12 +8,25 @@ See the datetime section of the Python Library Reference for information
|
|||||||
on how to use these modules.
|
on how to use these modules.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import datetime
|
||||||
|
import os.path
|
||||||
|
|
||||||
|
from pytz.exceptions import AmbiguousTimeError
|
||||||
|
from pytz.exceptions import InvalidTimeError
|
||||||
|
from pytz.exceptions import NonExistentTimeError
|
||||||
|
from pytz.exceptions import UnknownTimeZoneError
|
||||||
|
from pytz.lazy import LazyDict, LazyList, LazySet
|
||||||
|
from pytz.tzinfo import unpickler, BaseTzInfo
|
||||||
|
from pytz.tzfile import build_tzinfo
|
||||||
|
|
||||||
|
|
||||||
# The IANA (nee Olson) database is updated several times a year.
|
# The IANA (nee Olson) database is updated several times a year.
|
||||||
OLSON_VERSION = '2016f'
|
OLSON_VERSION = '2018f'
|
||||||
VERSION = '2016.6.1' # Switching to pip compatible version numbering.
|
VERSION = '2018.6' # pip compatible version number.
|
||||||
__version__ = VERSION
|
__version__ = VERSION
|
||||||
|
|
||||||
OLSEN_VERSION = OLSON_VERSION # Old releases had this misspelling
|
OLSEN_VERSION = OLSON_VERSION # Old releases had this misspelling
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'timezone', 'utc', 'country_timezones', 'country_names',
|
'timezone', 'utc', 'country_timezones', 'country_names',
|
||||||
@@ -21,23 +34,11 @@ __all__ = [
|
|||||||
'NonExistentTimeError', 'UnknownTimeZoneError',
|
'NonExistentTimeError', 'UnknownTimeZoneError',
|
||||||
'all_timezones', 'all_timezones_set',
|
'all_timezones', 'all_timezones_set',
|
||||||
'common_timezones', 'common_timezones_set',
|
'common_timezones', 'common_timezones_set',
|
||||||
]
|
'BaseTzInfo',
|
||||||
|
]
|
||||||
import sys, datetime, os.path, gettext
|
|
||||||
|
|
||||||
from pytz.exceptions import AmbiguousTimeError
|
|
||||||
from pytz.exceptions import InvalidTimeError
|
|
||||||
from pytz.exceptions import NonExistentTimeError
|
|
||||||
from pytz.exceptions import UnknownTimeZoneError
|
|
||||||
from pytz.lazy import LazyDict, LazyList, LazySet
|
|
||||||
from pytz.tzinfo import unpickler
|
|
||||||
from pytz.tzfile import build_tzinfo, _byte_string
|
|
||||||
|
|
||||||
|
|
||||||
try:
|
if sys.version_info[0] > 2: # Python 3.x
|
||||||
unicode
|
|
||||||
|
|
||||||
except NameError: # Python 3.x
|
|
||||||
|
|
||||||
# Python 3.x doesn't have unicode(), making writing code
|
# Python 3.x doesn't have unicode(), making writing code
|
||||||
# for Python 2.3 and Python 3.x a pain.
|
# for Python 2.3 and Python 3.x a pain.
|
||||||
@@ -52,10 +53,13 @@ except NameError: # Python 3.x
|
|||||||
...
|
...
|
||||||
UnicodeEncodeError: ...
|
UnicodeEncodeError: ...
|
||||||
"""
|
"""
|
||||||
s.encode('ASCII') # Raise an exception if not ASCII
|
if type(s) == bytes:
|
||||||
return s # But return the original string - not a byte string.
|
s = s.decode('ASCII')
|
||||||
|
else:
|
||||||
|
s.encode('ASCII') # Raise an exception if not ASCII
|
||||||
|
return s # But the string - not a byte string.
|
||||||
|
|
||||||
else: # Python 2.x
|
else: # Python 2.x
|
||||||
|
|
||||||
def ascii(s):
|
def ascii(s):
|
||||||
r"""
|
r"""
|
||||||
@@ -76,24 +80,31 @@ def open_resource(name):
|
|||||||
|
|
||||||
Uses the pkg_resources module if available and no standard file
|
Uses the pkg_resources module if available and no standard file
|
||||||
found at the calculated location.
|
found at the calculated location.
|
||||||
|
|
||||||
|
It is possible to specify different location for zoneinfo
|
||||||
|
subdir by using the PYTZ_TZDATADIR environment variable.
|
||||||
"""
|
"""
|
||||||
name_parts = name.lstrip('/').split('/')
|
name_parts = name.lstrip('/').split('/')
|
||||||
for part in name_parts:
|
for part in name_parts:
|
||||||
if part == os.path.pardir or os.path.sep in part:
|
if part == os.path.pardir or os.path.sep in part:
|
||||||
raise ValueError('Bad path segment: %r' % part)
|
raise ValueError('Bad path segment: %r' % part)
|
||||||
filename = os.path.join(os.path.dirname(__file__),
|
zoneinfo_dir = os.environ.get('PYTZ_TZDATADIR', None)
|
||||||
'zoneinfo', *name_parts)
|
if zoneinfo_dir is not None:
|
||||||
if not os.path.exists(filename):
|
filename = os.path.join(zoneinfo_dir, *name_parts)
|
||||||
# http://bugs.launchpad.net/bugs/383171 - we avoid using this
|
else:
|
||||||
# unless absolutely necessary to help when a broken version of
|
filename = os.path.join(os.path.dirname(__file__),
|
||||||
# pkg_resources is installed.
|
'zoneinfo', *name_parts)
|
||||||
try:
|
if not os.path.exists(filename):
|
||||||
from pkg_resources import resource_stream
|
# http://bugs.launchpad.net/bugs/383171 - we avoid using this
|
||||||
except ImportError:
|
# unless absolutely necessary to help when a broken version of
|
||||||
resource_stream = None
|
# pkg_resources is installed.
|
||||||
|
try:
|
||||||
|
from pkg_resources import resource_stream
|
||||||
|
except ImportError:
|
||||||
|
resource_stream = None
|
||||||
|
|
||||||
if resource_stream is not None:
|
if resource_stream is not None:
|
||||||
return resource_stream(__name__, 'zoneinfo/' + name)
|
return resource_stream(__name__, 'zoneinfo/' + name)
|
||||||
return open(filename, 'rb')
|
return open(filename, 'rb')
|
||||||
|
|
||||||
|
|
||||||
@@ -106,23 +117,9 @@ def resource_exists(name):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
# Enable this when we get some translations?
|
|
||||||
# We want an i18n API that is useful to programs using Python's gettext
|
|
||||||
# module, as well as the Zope3 i18n package. Perhaps we should just provide
|
|
||||||
# the POT file and translations, and leave it up to callers to make use
|
|
||||||
# of them.
|
|
||||||
#
|
|
||||||
# t = gettext.translation(
|
|
||||||
# 'pytz', os.path.join(os.path.dirname(__file__), 'locales'),
|
|
||||||
# fallback=True
|
|
||||||
# )
|
|
||||||
# def _(timezone_name):
|
|
||||||
# """Translate a timezone name using the current locale, returning Unicode"""
|
|
||||||
# return t.ugettext(timezone_name)
|
|
||||||
|
|
||||||
|
|
||||||
_tzinfo_cache = {}
|
_tzinfo_cache = {}
|
||||||
|
|
||||||
|
|
||||||
def timezone(zone):
|
def timezone(zone):
|
||||||
r''' Return a datetime.tzinfo implementation for the given timezone
|
r''' Return a datetime.tzinfo implementation for the given timezone
|
||||||
|
|
||||||
@@ -192,7 +189,7 @@ ZERO = datetime.timedelta(0)
|
|||||||
HOUR = datetime.timedelta(hours=1)
|
HOUR = datetime.timedelta(hours=1)
|
||||||
|
|
||||||
|
|
||||||
class UTC(datetime.tzinfo):
|
class UTC(BaseTzInfo):
|
||||||
"""UTC
|
"""UTC
|
||||||
|
|
||||||
Optimized UTC implementation. It unpickles using the single module global
|
Optimized UTC implementation. It unpickles using the single module global
|
||||||
@@ -288,7 +285,6 @@ def _p(*args):
|
|||||||
_p.__safe_for_unpickling__ = True
|
_p.__safe_for_unpickling__ = True
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class _CountryTimezoneDict(LazyDict):
|
class _CountryTimezoneDict(LazyDict):
|
||||||
"""Map ISO 3166 country code to a list of timezone names commonly used
|
"""Map ISO 3166 country code to a list of timezone names commonly used
|
||||||
in that country.
|
in that country.
|
||||||
@@ -374,7 +370,7 @@ country_names = _CountryNameDict()
|
|||||||
|
|
||||||
class _FixedOffset(datetime.tzinfo):
|
class _FixedOffset(datetime.tzinfo):
|
||||||
|
|
||||||
zone = None # to match the standard pytz API
|
zone = None # to match the standard pytz API
|
||||||
|
|
||||||
def __init__(self, minutes):
|
def __init__(self, minutes):
|
||||||
if abs(minutes) >= 1440:
|
if abs(minutes) >= 1440:
|
||||||
@@ -412,24 +408,24 @@ class _FixedOffset(datetime.tzinfo):
|
|||||||
return dt.astimezone(self)
|
return dt.astimezone(self)
|
||||||
|
|
||||||
|
|
||||||
def FixedOffset(offset, _tzinfos = {}):
|
def FixedOffset(offset, _tzinfos={}):
|
||||||
"""return a fixed-offset timezone based off a number of minutes.
|
"""return a fixed-offset timezone based off a number of minutes.
|
||||||
|
|
||||||
>>> one = FixedOffset(-330)
|
>>> one = FixedOffset(-330)
|
||||||
>>> one
|
>>> one
|
||||||
pytz.FixedOffset(-330)
|
pytz.FixedOffset(-330)
|
||||||
>>> one.utcoffset(datetime.datetime.now())
|
>>> str(one.utcoffset(datetime.datetime.now()))
|
||||||
datetime.timedelta(-1, 66600)
|
'-1 day, 18:30:00'
|
||||||
>>> one.dst(datetime.datetime.now())
|
>>> str(one.dst(datetime.datetime.now()))
|
||||||
datetime.timedelta(0)
|
'0:00:00'
|
||||||
|
|
||||||
>>> two = FixedOffset(1380)
|
>>> two = FixedOffset(1380)
|
||||||
>>> two
|
>>> two
|
||||||
pytz.FixedOffset(1380)
|
pytz.FixedOffset(1380)
|
||||||
>>> two.utcoffset(datetime.datetime.now())
|
>>> str(two.utcoffset(datetime.datetime.now()))
|
||||||
datetime.timedelta(0, 82800)
|
'23:00:00'
|
||||||
>>> two.dst(datetime.datetime.now())
|
>>> str(two.dst(datetime.datetime.now()))
|
||||||
datetime.timedelta(0)
|
'0:00:00'
|
||||||
|
|
||||||
The datetime.timedelta must be between the range of -1 and 1 day,
|
The datetime.timedelta must be between the range of -1 and 1 day,
|
||||||
non-inclusive.
|
non-inclusive.
|
||||||
@@ -482,14 +478,13 @@ FixedOffset.__safe_for_unpickling__ = True
|
|||||||
|
|
||||||
|
|
||||||
def _test():
|
def _test():
|
||||||
import doctest, os, sys
|
import doctest
|
||||||
sys.path.insert(0, os.pardir)
|
sys.path.insert(0, os.pardir)
|
||||||
import pytz
|
import pytz
|
||||||
return doctest.testmod(pytz)
|
return doctest.testmod(pytz)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
_test()
|
_test()
|
||||||
|
|
||||||
all_timezones = \
|
all_timezones = \
|
||||||
['Africa/Abidjan',
|
['Africa/Abidjan',
|
||||||
'Africa/Accra',
|
'Africa/Accra',
|
||||||
@@ -676,6 +671,7 @@ all_timezones = \
|
|||||||
'America/Porto_Acre',
|
'America/Porto_Acre',
|
||||||
'America/Porto_Velho',
|
'America/Porto_Velho',
|
||||||
'America/Puerto_Rico',
|
'America/Puerto_Rico',
|
||||||
|
'America/Punta_Arenas',
|
||||||
'America/Rainy_River',
|
'America/Rainy_River',
|
||||||
'America/Rankin_Inlet',
|
'America/Rankin_Inlet',
|
||||||
'America/Recife',
|
'America/Recife',
|
||||||
@@ -731,6 +727,7 @@ all_timezones = \
|
|||||||
'Asia/Aqtobe',
|
'Asia/Aqtobe',
|
||||||
'Asia/Ashgabat',
|
'Asia/Ashgabat',
|
||||||
'Asia/Ashkhabad',
|
'Asia/Ashkhabad',
|
||||||
|
'Asia/Atyrau',
|
||||||
'Asia/Baghdad',
|
'Asia/Baghdad',
|
||||||
'Asia/Bahrain',
|
'Asia/Bahrain',
|
||||||
'Asia/Baku',
|
'Asia/Baku',
|
||||||
@@ -751,6 +748,7 @@ all_timezones = \
|
|||||||
'Asia/Dili',
|
'Asia/Dili',
|
||||||
'Asia/Dubai',
|
'Asia/Dubai',
|
||||||
'Asia/Dushanbe',
|
'Asia/Dushanbe',
|
||||||
|
'Asia/Famagusta',
|
||||||
'Asia/Gaza',
|
'Asia/Gaza',
|
||||||
'Asia/Harbin',
|
'Asia/Harbin',
|
||||||
'Asia/Hebron',
|
'Asia/Hebron',
|
||||||
@@ -816,6 +814,7 @@ all_timezones = \
|
|||||||
'Asia/Vientiane',
|
'Asia/Vientiane',
|
||||||
'Asia/Vladivostok',
|
'Asia/Vladivostok',
|
||||||
'Asia/Yakutsk',
|
'Asia/Yakutsk',
|
||||||
|
'Asia/Yangon',
|
||||||
'Asia/Yekaterinburg',
|
'Asia/Yekaterinburg',
|
||||||
'Asia/Yerevan',
|
'Asia/Yerevan',
|
||||||
'Atlantic/Azores',
|
'Atlantic/Azores',
|
||||||
@@ -861,7 +860,6 @@ all_timezones = \
|
|||||||
'CST6CDT',
|
'CST6CDT',
|
||||||
'Canada/Atlantic',
|
'Canada/Atlantic',
|
||||||
'Canada/Central',
|
'Canada/Central',
|
||||||
'Canada/East-Saskatchewan',
|
|
||||||
'Canada/Eastern',
|
'Canada/Eastern',
|
||||||
'Canada/Mountain',
|
'Canada/Mountain',
|
||||||
'Canada/Newfoundland',
|
'Canada/Newfoundland',
|
||||||
@@ -955,6 +953,7 @@ all_timezones = \
|
|||||||
'Europe/Samara',
|
'Europe/Samara',
|
||||||
'Europe/San_Marino',
|
'Europe/San_Marino',
|
||||||
'Europe/Sarajevo',
|
'Europe/Sarajevo',
|
||||||
|
'Europe/Saratov',
|
||||||
'Europe/Simferopol',
|
'Europe/Simferopol',
|
||||||
'Europe/Skopje',
|
'Europe/Skopje',
|
||||||
'Europe/Sofia',
|
'Europe/Sofia',
|
||||||
@@ -1072,7 +1071,6 @@ all_timezones = \
|
|||||||
'US/Michigan',
|
'US/Michigan',
|
||||||
'US/Mountain',
|
'US/Mountain',
|
||||||
'US/Pacific',
|
'US/Pacific',
|
||||||
'US/Pacific-New',
|
|
||||||
'US/Samoa',
|
'US/Samoa',
|
||||||
'UTC',
|
'UTC',
|
||||||
'Universal',
|
'Universal',
|
||||||
@@ -1252,6 +1250,7 @@ common_timezones = \
|
|||||||
'America/Port_of_Spain',
|
'America/Port_of_Spain',
|
||||||
'America/Porto_Velho',
|
'America/Porto_Velho',
|
||||||
'America/Puerto_Rico',
|
'America/Puerto_Rico',
|
||||||
|
'America/Punta_Arenas',
|
||||||
'America/Rainy_River',
|
'America/Rainy_River',
|
||||||
'America/Rankin_Inlet',
|
'America/Rankin_Inlet',
|
||||||
'America/Recife',
|
'America/Recife',
|
||||||
@@ -1301,6 +1300,7 @@ common_timezones = \
|
|||||||
'Asia/Aqtau',
|
'Asia/Aqtau',
|
||||||
'Asia/Aqtobe',
|
'Asia/Aqtobe',
|
||||||
'Asia/Ashgabat',
|
'Asia/Ashgabat',
|
||||||
|
'Asia/Atyrau',
|
||||||
'Asia/Baghdad',
|
'Asia/Baghdad',
|
||||||
'Asia/Bahrain',
|
'Asia/Bahrain',
|
||||||
'Asia/Baku',
|
'Asia/Baku',
|
||||||
@@ -1317,6 +1317,7 @@ common_timezones = \
|
|||||||
'Asia/Dili',
|
'Asia/Dili',
|
||||||
'Asia/Dubai',
|
'Asia/Dubai',
|
||||||
'Asia/Dushanbe',
|
'Asia/Dushanbe',
|
||||||
|
'Asia/Famagusta',
|
||||||
'Asia/Gaza',
|
'Asia/Gaza',
|
||||||
'Asia/Hebron',
|
'Asia/Hebron',
|
||||||
'Asia/Ho_Chi_Minh',
|
'Asia/Ho_Chi_Minh',
|
||||||
@@ -1351,7 +1352,6 @@ common_timezones = \
|
|||||||
'Asia/Pyongyang',
|
'Asia/Pyongyang',
|
||||||
'Asia/Qatar',
|
'Asia/Qatar',
|
||||||
'Asia/Qyzylorda',
|
'Asia/Qyzylorda',
|
||||||
'Asia/Rangoon',
|
|
||||||
'Asia/Riyadh',
|
'Asia/Riyadh',
|
||||||
'Asia/Sakhalin',
|
'Asia/Sakhalin',
|
||||||
'Asia/Samarkand',
|
'Asia/Samarkand',
|
||||||
@@ -1372,6 +1372,7 @@ common_timezones = \
|
|||||||
'Asia/Vientiane',
|
'Asia/Vientiane',
|
||||||
'Asia/Vladivostok',
|
'Asia/Vladivostok',
|
||||||
'Asia/Yakutsk',
|
'Asia/Yakutsk',
|
||||||
|
'Asia/Yangon',
|
||||||
'Asia/Yekaterinburg',
|
'Asia/Yekaterinburg',
|
||||||
'Asia/Yerevan',
|
'Asia/Yerevan',
|
||||||
'Atlantic/Azores',
|
'Atlantic/Azores',
|
||||||
@@ -1444,6 +1445,7 @@ common_timezones = \
|
|||||||
'Europe/Samara',
|
'Europe/Samara',
|
||||||
'Europe/San_Marino',
|
'Europe/San_Marino',
|
||||||
'Europe/Sarajevo',
|
'Europe/Sarajevo',
|
||||||
|
'Europe/Saratov',
|
||||||
'Europe/Simferopol',
|
'Europe/Simferopol',
|
||||||
'Europe/Skopje',
|
'Europe/Skopje',
|
||||||
'Europe/Sofia',
|
'Europe/Sofia',
|
||||||
@@ -1489,7 +1491,6 @@ common_timezones = \
|
|||||||
'Pacific/Guadalcanal',
|
'Pacific/Guadalcanal',
|
||||||
'Pacific/Guam',
|
'Pacific/Guam',
|
||||||
'Pacific/Honolulu',
|
'Pacific/Honolulu',
|
||||||
'Pacific/Johnston',
|
|
||||||
'Pacific/Kiritimati',
|
'Pacific/Kiritimati',
|
||||||
'Pacific/Kosrae',
|
'Pacific/Kosrae',
|
||||||
'Pacific/Kwajalein',
|
'Pacific/Kwajalein',
|
||||||
|
@@ -5,7 +5,7 @@ Custom exceptions raised by pytz.
|
|||||||
__all__ = [
|
__all__ = [
|
||||||
'UnknownTimeZoneError', 'InvalidTimeError', 'AmbiguousTimeError',
|
'UnknownTimeZoneError', 'InvalidTimeError', 'AmbiguousTimeError',
|
||||||
'NonExistentTimeError',
|
'NonExistentTimeError',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class UnknownTimeZoneError(KeyError):
|
class UnknownTimeZoneError(KeyError):
|
||||||
|
@@ -1,8 +1,11 @@
|
|||||||
from threading import RLock
|
from threading import RLock
|
||||||
try:
|
try:
|
||||||
from UserDict import DictMixin
|
from collections.abc import Mapping as DictMixin
|
||||||
except ImportError:
|
except ImportError: # Python < 3.3
|
||||||
from collections import Mapping as DictMixin
|
try:
|
||||||
|
from UserDict import DictMixin # Python 2
|
||||||
|
except ImportError: # Python 3.0-3.3
|
||||||
|
from collections import Mapping as DictMixin
|
||||||
|
|
||||||
|
|
||||||
# With lazy loading, we might end up with multiple threads triggering
|
# With lazy loading, we might end up with multiple threads triggering
|
||||||
@@ -13,6 +16,7 @@ _fill_lock = RLock()
|
|||||||
class LazyDict(DictMixin):
|
class LazyDict(DictMixin):
|
||||||
"""Dictionary populated on first use."""
|
"""Dictionary populated on first use."""
|
||||||
data = None
|
data = None
|
||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
if self.data is None:
|
if self.data is None:
|
||||||
_fill_lock.acquire()
|
_fill_lock.acquire()
|
||||||
|
@@ -5,17 +5,28 @@ Used for testing against as they are only correct for the years
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
from datetime import tzinfo, timedelta, datetime
|
from datetime import tzinfo, timedelta, datetime
|
||||||
from pytz import utc, UTC, HOUR, ZERO
|
from pytz import HOUR, ZERO, UTC
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
'FixedOffset',
|
||||||
|
'LocalTimezone',
|
||||||
|
'USTimeZone',
|
||||||
|
'Eastern',
|
||||||
|
'Central',
|
||||||
|
'Mountain',
|
||||||
|
'Pacific',
|
||||||
|
'UTC'
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
# A class building tzinfo objects for fixed-offset time zones.
|
# A class building tzinfo objects for fixed-offset time zones.
|
||||||
# Note that FixedOffset(0, "UTC") is a different way to build a
|
# Note that FixedOffset(0, "UTC") is a different way to build a
|
||||||
# UTC tzinfo object.
|
# UTC tzinfo object.
|
||||||
|
|
||||||
class FixedOffset(tzinfo):
|
class FixedOffset(tzinfo):
|
||||||
"""Fixed offset in minutes east from UTC."""
|
"""Fixed offset in minutes east from UTC."""
|
||||||
|
|
||||||
def __init__(self, offset, name):
|
def __init__(self, offset, name):
|
||||||
self.__offset = timedelta(minutes = offset)
|
self.__offset = timedelta(minutes=offset)
|
||||||
self.__name = name
|
self.__name = name
|
||||||
|
|
||||||
def utcoffset(self, dt):
|
def utcoffset(self, dt):
|
||||||
@@ -27,18 +38,19 @@ class FixedOffset(tzinfo):
|
|||||||
def dst(self, dt):
|
def dst(self, dt):
|
||||||
return ZERO
|
return ZERO
|
||||||
|
|
||||||
# A class capturing the platform's idea of local time.
|
|
||||||
|
|
||||||
import time as _time
|
import time as _time
|
||||||
|
|
||||||
STDOFFSET = timedelta(seconds = -_time.timezone)
|
STDOFFSET = timedelta(seconds=-_time.timezone)
|
||||||
if _time.daylight:
|
if _time.daylight:
|
||||||
DSTOFFSET = timedelta(seconds = -_time.altzone)
|
DSTOFFSET = timedelta(seconds=-_time.altzone)
|
||||||
else:
|
else:
|
||||||
DSTOFFSET = STDOFFSET
|
DSTOFFSET = STDOFFSET
|
||||||
|
|
||||||
DSTDIFF = DSTOFFSET - STDOFFSET
|
DSTDIFF = DSTOFFSET - STDOFFSET
|
||||||
|
|
||||||
|
|
||||||
|
# A class capturing the platform's idea of local time.
|
||||||
class LocalTimezone(tzinfo):
|
class LocalTimezone(tzinfo):
|
||||||
|
|
||||||
def utcoffset(self, dt):
|
def utcoffset(self, dt):
|
||||||
@@ -66,7 +78,6 @@ class LocalTimezone(tzinfo):
|
|||||||
|
|
||||||
Local = LocalTimezone()
|
Local = LocalTimezone()
|
||||||
|
|
||||||
# A complete implementation of current DST rules for major US time zones.
|
|
||||||
|
|
||||||
def first_sunday_on_or_after(dt):
|
def first_sunday_on_or_after(dt):
|
||||||
days_to_go = 6 - dt.weekday()
|
days_to_go = 6 - dt.weekday()
|
||||||
@@ -74,12 +85,15 @@ def first_sunday_on_or_after(dt):
|
|||||||
dt += timedelta(days_to_go)
|
dt += timedelta(days_to_go)
|
||||||
return dt
|
return dt
|
||||||
|
|
||||||
|
|
||||||
# In the US, DST starts at 2am (standard time) on the first Sunday in April.
|
# In the US, DST starts at 2am (standard time) on the first Sunday in April.
|
||||||
DSTSTART = datetime(1, 4, 1, 2)
|
DSTSTART = datetime(1, 4, 1, 2)
|
||||||
# and ends at 2am (DST time; 1am standard time) on the last Sunday of Oct.
|
# and ends at 2am (DST time; 1am standard time) on the last Sunday of Oct.
|
||||||
# which is the first Sunday on or after Oct 25.
|
# which is the first Sunday on or after Oct 25.
|
||||||
DSTEND = datetime(1, 10, 25, 1)
|
DSTEND = datetime(1, 10, 25, 1)
|
||||||
|
|
||||||
|
|
||||||
|
# A complete implementation of current DST rules for major US time zones.
|
||||||
class USTimeZone(tzinfo):
|
class USTimeZone(tzinfo):
|
||||||
|
|
||||||
def __init__(self, hours, reprname, stdname, dstname):
|
def __init__(self, hours, reprname, stdname, dstname):
|
||||||
@@ -120,8 +134,7 @@ class USTimeZone(tzinfo):
|
|||||||
else:
|
else:
|
||||||
return ZERO
|
return ZERO
|
||||||
|
|
||||||
Eastern = USTimeZone(-5, "Eastern", "EST", "EDT")
|
Eastern = USTimeZone(-5, "Eastern", "EST", "EDT")
|
||||||
Central = USTimeZone(-6, "Central", "CST", "CDT")
|
Central = USTimeZone(-6, "Central", "CST", "CDT")
|
||||||
Mountain = USTimeZone(-7, "Mountain", "MST", "MDT")
|
Mountain = USTimeZone(-7, "Mountain", "MST", "MDT")
|
||||||
Pacific = USTimeZone(-8, "Pacific", "PST", "PDT")
|
Pacific = USTimeZone(-8, "Pacific", "PST", "PDT")
|
||||||
|
|
||||||
|
@@ -3,38 +3,37 @@
|
|||||||
$Id: tzfile.py,v 1.8 2004/06/03 00:15:24 zenzen Exp $
|
$Id: tzfile.py,v 1.8 2004/06/03 00:15:24 zenzen Exp $
|
||||||
'''
|
'''
|
||||||
|
|
||||||
try:
|
from datetime import datetime
|
||||||
from cStringIO import StringIO
|
|
||||||
except ImportError:
|
|
||||||
from io import StringIO
|
|
||||||
from datetime import datetime, timedelta
|
|
||||||
from struct import unpack, calcsize
|
from struct import unpack, calcsize
|
||||||
|
|
||||||
from pytz.tzinfo import StaticTzInfo, DstTzInfo, memorized_ttinfo
|
from pytz.tzinfo import StaticTzInfo, DstTzInfo, memorized_ttinfo
|
||||||
from pytz.tzinfo import memorized_datetime, memorized_timedelta
|
from pytz.tzinfo import memorized_datetime, memorized_timedelta
|
||||||
|
|
||||||
|
|
||||||
def _byte_string(s):
|
def _byte_string(s):
|
||||||
"""Cast a string or byte string to an ASCII byte string."""
|
"""Cast a string or byte string to an ASCII byte string."""
|
||||||
return s.encode('ASCII')
|
return s.encode('ASCII')
|
||||||
|
|
||||||
_NULL = _byte_string('\0')
|
_NULL = _byte_string('\0')
|
||||||
|
|
||||||
|
|
||||||
def _std_string(s):
|
def _std_string(s):
|
||||||
"""Cast a string or byte string to an ASCII string."""
|
"""Cast a string or byte string to an ASCII string."""
|
||||||
return str(s.decode('ASCII'))
|
return str(s.decode('ASCII'))
|
||||||
|
|
||||||
|
|
||||||
def build_tzinfo(zone, fp):
|
def build_tzinfo(zone, fp):
|
||||||
head_fmt = '>4s c 15x 6l'
|
head_fmt = '>4s c 15x 6l'
|
||||||
head_size = calcsize(head_fmt)
|
head_size = calcsize(head_fmt)
|
||||||
(magic, format, ttisgmtcnt, ttisstdcnt,leapcnt, timecnt,
|
(magic, format, ttisgmtcnt, ttisstdcnt, leapcnt, timecnt,
|
||||||
typecnt, charcnt) = unpack(head_fmt, fp.read(head_size))
|
typecnt, charcnt) = unpack(head_fmt, fp.read(head_size))
|
||||||
|
|
||||||
# Make sure it is a tzfile(5) file
|
# Make sure it is a tzfile(5) file
|
||||||
assert magic == _byte_string('TZif'), 'Got magic %s' % repr(magic)
|
assert magic == _byte_string('TZif'), 'Got magic %s' % repr(magic)
|
||||||
|
|
||||||
# Read out the transition times, localtime indices and ttinfo structures.
|
# Read out the transition times, localtime indices and ttinfo structures.
|
||||||
data_fmt = '>%(timecnt)dl %(timecnt)dB %(ttinfo)s %(charcnt)ds' % dict(
|
data_fmt = '>%(timecnt)dl %(timecnt)dB %(ttinfo)s %(charcnt)ds' % dict(
|
||||||
timecnt=timecnt, ttinfo='lBB'*typecnt, charcnt=charcnt)
|
timecnt=timecnt, ttinfo='lBB' * typecnt, charcnt=charcnt)
|
||||||
data_size = calcsize(data_fmt)
|
data_size = calcsize(data_fmt)
|
||||||
data = unpack(data_fmt, fp.read(data_size))
|
data = unpack(data_fmt, fp.read(data_size))
|
||||||
|
|
||||||
@@ -53,7 +52,7 @@ def build_tzinfo(zone, fp):
|
|||||||
i = 0
|
i = 0
|
||||||
while i < len(ttinfo_raw):
|
while i < len(ttinfo_raw):
|
||||||
# have we looked up this timezone name yet?
|
# have we looked up this timezone name yet?
|
||||||
tzname_offset = ttinfo_raw[i+2]
|
tzname_offset = ttinfo_raw[i + 2]
|
||||||
if tzname_offset not in tznames:
|
if tzname_offset not in tznames:
|
||||||
nul = tznames_raw.find(_NULL, tzname_offset)
|
nul = tznames_raw.find(_NULL, tzname_offset)
|
||||||
if nul < 0:
|
if nul < 0:
|
||||||
@@ -61,12 +60,12 @@ def build_tzinfo(zone, fp):
|
|||||||
tznames[tzname_offset] = _std_string(
|
tznames[tzname_offset] = _std_string(
|
||||||
tznames_raw[tzname_offset:nul])
|
tznames_raw[tzname_offset:nul])
|
||||||
ttinfo.append((ttinfo_raw[i],
|
ttinfo.append((ttinfo_raw[i],
|
||||||
bool(ttinfo_raw[i+1]),
|
bool(ttinfo_raw[i + 1]),
|
||||||
tznames[tzname_offset]))
|
tznames[tzname_offset]))
|
||||||
i += 3
|
i += 3
|
||||||
|
|
||||||
# Now build the timezone object
|
# Now build the timezone object
|
||||||
if len(ttinfo) ==1 or len(transitions) == 0:
|
if len(ttinfo) == 1 or len(transitions) == 0:
|
||||||
ttinfo[0][0], ttinfo[0][2]
|
ttinfo[0][0], ttinfo[0][2]
|
||||||
cls = type(zone, (StaticTzInfo,), dict(
|
cls = type(zone, (StaticTzInfo,), dict(
|
||||||
zone=zone,
|
zone=zone,
|
||||||
@@ -91,21 +90,21 @@ def build_tzinfo(zone, fp):
|
|||||||
if not inf[1]:
|
if not inf[1]:
|
||||||
dst = 0
|
dst = 0
|
||||||
else:
|
else:
|
||||||
for j in range(i-1, -1, -1):
|
for j in range(i - 1, -1, -1):
|
||||||
prev_inf = ttinfo[lindexes[j]]
|
prev_inf = ttinfo[lindexes[j]]
|
||||||
if not prev_inf[1]:
|
if not prev_inf[1]:
|
||||||
break
|
break
|
||||||
dst = inf[0] - prev_inf[0] # dst offset
|
dst = inf[0] - prev_inf[0] # dst offset
|
||||||
|
|
||||||
# Bad dst? Look further. DST > 24 hours happens when
|
# Bad dst? Look further. DST > 24 hours happens when
|
||||||
# a timzone has moved across the international dateline.
|
# a timzone has moved across the international dateline.
|
||||||
if dst <= 0 or dst > 3600*3:
|
if dst <= 0 or dst > 3600 * 3:
|
||||||
for j in range(i+1, len(transitions)):
|
for j in range(i + 1, len(transitions)):
|
||||||
stdinf = ttinfo[lindexes[j]]
|
stdinf = ttinfo[lindexes[j]]
|
||||||
if not stdinf[1]:
|
if not stdinf[1]:
|
||||||
dst = inf[0] - stdinf[0]
|
dst = inf[0] - stdinf[0]
|
||||||
if dst > 0:
|
if dst > 0:
|
||||||
break # Found a useful std time.
|
break # Found a useful std time.
|
||||||
|
|
||||||
tzname = inf[2]
|
tzname = inf[2]
|
||||||
|
|
||||||
@@ -129,9 +128,7 @@ if __name__ == '__main__':
|
|||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
base = os.path.join(os.path.dirname(__file__), 'zoneinfo')
|
base = os.path.join(os.path.dirname(__file__), 'zoneinfo')
|
||||||
tz = build_tzinfo('Australia/Melbourne',
|
tz = build_tzinfo('Australia/Melbourne',
|
||||||
open(os.path.join(base,'Australia','Melbourne'), 'rb'))
|
open(os.path.join(base, 'Australia', 'Melbourne'), 'rb'))
|
||||||
tz = build_tzinfo('US/Eastern',
|
tz = build_tzinfo('US/Eastern',
|
||||||
open(os.path.join(base,'US','Eastern'), 'rb'))
|
open(os.path.join(base, 'US', 'Eastern'), 'rb'))
|
||||||
pprint(tz._utc_transition_times)
|
pprint(tz._utc_transition_times)
|
||||||
#print tz.asPython(4)
|
|
||||||
#print tz.transitions_mapping
|
|
||||||
|
@@ -13,6 +13,8 @@ from pytz.exceptions import AmbiguousTimeError, NonExistentTimeError
|
|||||||
__all__ = []
|
__all__ = []
|
||||||
|
|
||||||
_timedelta_cache = {}
|
_timedelta_cache = {}
|
||||||
|
|
||||||
|
|
||||||
def memorized_timedelta(seconds):
|
def memorized_timedelta(seconds):
|
||||||
'''Create only one instance of each distinct timedelta'''
|
'''Create only one instance of each distinct timedelta'''
|
||||||
try:
|
try:
|
||||||
@@ -24,6 +26,8 @@ def memorized_timedelta(seconds):
|
|||||||
|
|
||||||
_epoch = datetime.utcfromtimestamp(0)
|
_epoch = datetime.utcfromtimestamp(0)
|
||||||
_datetime_cache = {0: _epoch}
|
_datetime_cache = {0: _epoch}
|
||||||
|
|
||||||
|
|
||||||
def memorized_datetime(seconds):
|
def memorized_datetime(seconds):
|
||||||
'''Create only one instance of each distinct datetime'''
|
'''Create only one instance of each distinct datetime'''
|
||||||
try:
|
try:
|
||||||
@@ -36,21 +40,24 @@ def memorized_datetime(seconds):
|
|||||||
return dt
|
return dt
|
||||||
|
|
||||||
_ttinfo_cache = {}
|
_ttinfo_cache = {}
|
||||||
|
|
||||||
|
|
||||||
def memorized_ttinfo(*args):
|
def memorized_ttinfo(*args):
|
||||||
'''Create only one instance of each distinct tuple'''
|
'''Create only one instance of each distinct tuple'''
|
||||||
try:
|
try:
|
||||||
return _ttinfo_cache[args]
|
return _ttinfo_cache[args]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
ttinfo = (
|
ttinfo = (
|
||||||
memorized_timedelta(args[0]),
|
memorized_timedelta(args[0]),
|
||||||
memorized_timedelta(args[1]),
|
memorized_timedelta(args[1]),
|
||||||
args[2]
|
args[2]
|
||||||
)
|
)
|
||||||
_ttinfo_cache[args] = ttinfo
|
_ttinfo_cache[args] = ttinfo
|
||||||
return ttinfo
|
return ttinfo
|
||||||
|
|
||||||
_notime = memorized_timedelta(0)
|
_notime = memorized_timedelta(0)
|
||||||
|
|
||||||
|
|
||||||
def _to_seconds(td):
|
def _to_seconds(td):
|
||||||
'''Convert a timedelta to seconds'''
|
'''Convert a timedelta to seconds'''
|
||||||
return td.seconds + td.days * 24 * 60 * 60
|
return td.seconds + td.days * 24 * 60 * 60
|
||||||
@@ -154,14 +161,20 @@ class DstTzInfo(BaseTzInfo):
|
|||||||
timezone definition.
|
timezone definition.
|
||||||
'''
|
'''
|
||||||
# Overridden in subclass
|
# Overridden in subclass
|
||||||
_utc_transition_times = None # Sorted list of DST transition times in UTC
|
|
||||||
_transition_info = None # [(utcoffset, dstoffset, tzname)] corresponding
|
# Sorted list of DST transition times, UTC
|
||||||
# to _utc_transition_times entries
|
_utc_transition_times = None
|
||||||
|
|
||||||
|
# [(utcoffset, dstoffset, tzname)] corresponding to
|
||||||
|
# _utc_transition_times entries
|
||||||
|
_transition_info = None
|
||||||
|
|
||||||
zone = None
|
zone = None
|
||||||
|
|
||||||
# Set in __init__
|
# Set in __init__
|
||||||
|
|
||||||
_tzinfos = None
|
_tzinfos = None
|
||||||
_dst = None # DST offset
|
_dst = None # DST offset
|
||||||
|
|
||||||
def __init__(self, _inf=None, _tzinfos=None):
|
def __init__(self, _inf=None, _tzinfos=None):
|
||||||
if _inf:
|
if _inf:
|
||||||
@@ -170,7 +183,8 @@ class DstTzInfo(BaseTzInfo):
|
|||||||
else:
|
else:
|
||||||
_tzinfos = {}
|
_tzinfos = {}
|
||||||
self._tzinfos = _tzinfos
|
self._tzinfos = _tzinfos
|
||||||
self._utcoffset, self._dst, self._tzname = self._transition_info[0]
|
self._utcoffset, self._dst, self._tzname = (
|
||||||
|
self._transition_info[0])
|
||||||
_tzinfos[self._transition_info[0]] = self
|
_tzinfos[self._transition_info[0]] = self
|
||||||
for inf in self._transition_info[1:]:
|
for inf in self._transition_info[1:]:
|
||||||
if inf not in _tzinfos:
|
if inf not in _tzinfos:
|
||||||
@@ -178,8 +192,8 @@ class DstTzInfo(BaseTzInfo):
|
|||||||
|
|
||||||
def fromutc(self, dt):
|
def fromutc(self, dt):
|
||||||
'''See datetime.tzinfo.fromutc'''
|
'''See datetime.tzinfo.fromutc'''
|
||||||
if (dt.tzinfo is not None
|
if (dt.tzinfo is not None and
|
||||||
and getattr(dt.tzinfo, '_tzinfos', None) is not self._tzinfos):
|
getattr(dt.tzinfo, '_tzinfos', None) is not self._tzinfos):
|
||||||
raise ValueError('fromutc: dt.tzinfo is not self')
|
raise ValueError('fromutc: dt.tzinfo is not self')
|
||||||
dt = dt.replace(tzinfo=None)
|
dt = dt.replace(tzinfo=None)
|
||||||
idx = max(0, bisect_right(self._utc_transition_times, dt) - 1)
|
idx = max(0, bisect_right(self._utc_transition_times, dt) - 1)
|
||||||
@@ -337,8 +351,8 @@ class DstTzInfo(BaseTzInfo):
|
|||||||
# obtain the correct timezone by winding the clock back.
|
# obtain the correct timezone by winding the clock back.
|
||||||
else:
|
else:
|
||||||
return self.localize(
|
return self.localize(
|
||||||
dt - timedelta(hours=6), is_dst=False) + timedelta(hours=6)
|
dt - timedelta(hours=6),
|
||||||
|
is_dst=False) + timedelta(hours=6)
|
||||||
|
|
||||||
# If we get this far, we have multiple possible timezones - this
|
# If we get this far, we have multiple possible timezones - this
|
||||||
# is an ambiguous case occuring during the end-of-DST transition.
|
# is an ambiguous case occuring during the end-of-DST transition.
|
||||||
@@ -351,9 +365,8 @@ class DstTzInfo(BaseTzInfo):
|
|||||||
# Filter out the possiblilities that don't match the requested
|
# Filter out the possiblilities that don't match the requested
|
||||||
# is_dst
|
# is_dst
|
||||||
filtered_possible_loc_dt = [
|
filtered_possible_loc_dt = [
|
||||||
p for p in possible_loc_dt
|
p for p in possible_loc_dt if bool(p.tzinfo._dst) == is_dst
|
||||||
if bool(p.tzinfo._dst) == is_dst
|
]
|
||||||
]
|
|
||||||
|
|
||||||
# Hopefully we only have one possibility left. Return it.
|
# Hopefully we only have one possibility left. Return it.
|
||||||
if len(filtered_possible_loc_dt) == 1:
|
if len(filtered_possible_loc_dt) == 1:
|
||||||
@@ -372,9 +385,10 @@ class DstTzInfo(BaseTzInfo):
|
|||||||
# Choose the earliest (by UTC) applicable timezone if is_dst=True
|
# Choose the earliest (by UTC) applicable timezone if is_dst=True
|
||||||
# Choose the latest (by UTC) applicable timezone if is_dst=False
|
# Choose the latest (by UTC) applicable timezone if is_dst=False
|
||||||
# i.e., behave like end-of-DST transition
|
# i.e., behave like end-of-DST transition
|
||||||
dates = {} # utc -> local
|
dates = {} # utc -> local
|
||||||
for local_dt in filtered_possible_loc_dt:
|
for local_dt in filtered_possible_loc_dt:
|
||||||
utc_time = local_dt.replace(tzinfo=None) - local_dt.tzinfo._utcoffset
|
utc_time = (
|
||||||
|
local_dt.replace(tzinfo=None) - local_dt.tzinfo._utcoffset)
|
||||||
assert utc_time not in dates
|
assert utc_time not in dates
|
||||||
dates[utc_time] = local_dt
|
dates[utc_time] = local_dt
|
||||||
return dates[[min, max][not is_dst](dates)]
|
return dates[[min, max][not is_dst](dates)]
|
||||||
@@ -389,11 +403,11 @@ class DstTzInfo(BaseTzInfo):
|
|||||||
>>> tz = timezone('America/St_Johns')
|
>>> tz = timezone('America/St_Johns')
|
||||||
>>> ambiguous = datetime(2009, 10, 31, 23, 30)
|
>>> ambiguous = datetime(2009, 10, 31, 23, 30)
|
||||||
|
|
||||||
>>> tz.utcoffset(ambiguous, is_dst=False)
|
>>> str(tz.utcoffset(ambiguous, is_dst=False))
|
||||||
datetime.timedelta(-1, 73800)
|
'-1 day, 20:30:00'
|
||||||
|
|
||||||
>>> tz.utcoffset(ambiguous, is_dst=True)
|
>>> str(tz.utcoffset(ambiguous, is_dst=True))
|
||||||
datetime.timedelta(-1, 77400)
|
'-1 day, 21:30:00'
|
||||||
|
|
||||||
>>> try:
|
>>> try:
|
||||||
... tz.utcoffset(ambiguous)
|
... tz.utcoffset(ambiguous)
|
||||||
@@ -421,19 +435,19 @@ class DstTzInfo(BaseTzInfo):
|
|||||||
|
|
||||||
>>> normal = datetime(2009, 9, 1)
|
>>> normal = datetime(2009, 9, 1)
|
||||||
|
|
||||||
>>> tz.dst(normal)
|
>>> str(tz.dst(normal))
|
||||||
datetime.timedelta(0, 3600)
|
'1:00:00'
|
||||||
>>> tz.dst(normal, is_dst=False)
|
>>> str(tz.dst(normal, is_dst=False))
|
||||||
datetime.timedelta(0, 3600)
|
'1:00:00'
|
||||||
>>> tz.dst(normal, is_dst=True)
|
>>> str(tz.dst(normal, is_dst=True))
|
||||||
datetime.timedelta(0, 3600)
|
'1:00:00'
|
||||||
|
|
||||||
>>> ambiguous = datetime(2009, 10, 31, 23, 30)
|
>>> ambiguous = datetime(2009, 10, 31, 23, 30)
|
||||||
|
|
||||||
>>> tz.dst(ambiguous, is_dst=False)
|
>>> str(tz.dst(ambiguous, is_dst=False))
|
||||||
datetime.timedelta(0)
|
'0:00:00'
|
||||||
>>> tz.dst(ambiguous, is_dst=True)
|
>>> str(tz.dst(ambiguous, is_dst=True))
|
||||||
datetime.timedelta(0, 3600)
|
'1:00:00'
|
||||||
>>> try:
|
>>> try:
|
||||||
... tz.dst(ambiguous)
|
... tz.dst(ambiguous)
|
||||||
... except AmbiguousTimeError:
|
... except AmbiguousTimeError:
|
||||||
@@ -494,23 +508,22 @@ class DstTzInfo(BaseTzInfo):
|
|||||||
dst = 'STD'
|
dst = 'STD'
|
||||||
if self._utcoffset > _notime:
|
if self._utcoffset > _notime:
|
||||||
return '<DstTzInfo %r %s+%s %s>' % (
|
return '<DstTzInfo %r %s+%s %s>' % (
|
||||||
self.zone, self._tzname, self._utcoffset, dst
|
self.zone, self._tzname, self._utcoffset, dst
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
return '<DstTzInfo %r %s%s %s>' % (
|
return '<DstTzInfo %r %s%s %s>' % (
|
||||||
self.zone, self._tzname, self._utcoffset, dst
|
self.zone, self._tzname, self._utcoffset, dst
|
||||||
)
|
)
|
||||||
|
|
||||||
def __reduce__(self):
|
def __reduce__(self):
|
||||||
# Special pickle to zone remains a singleton and to cope with
|
# Special pickle to zone remains a singleton and to cope with
|
||||||
# database changes.
|
# database changes.
|
||||||
return pytz._p, (
|
return pytz._p, (
|
||||||
self.zone,
|
self.zone,
|
||||||
_to_seconds(self._utcoffset),
|
_to_seconds(self._utcoffset),
|
||||||
_to_seconds(self._dst),
|
_to_seconds(self._dst),
|
||||||
self._tzname
|
self._tzname
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def unpickler(zone, utcoffset=None, dstoffset=None, tzname=None):
|
def unpickler(zone, utcoffset=None, dstoffset=None, tzname=None):
|
||||||
@@ -549,8 +562,8 @@ def unpickler(zone, utcoffset=None, dstoffset=None, tzname=None):
|
|||||||
# get changed from the initial guess by the database maintainers to
|
# get changed from the initial guess by the database maintainers to
|
||||||
# match reality when this information is discovered.
|
# match reality when this information is discovered.
|
||||||
for localized_tz in tz._tzinfos.values():
|
for localized_tz in tz._tzinfos.values():
|
||||||
if (localized_tz._utcoffset == utcoffset
|
if (localized_tz._utcoffset == utcoffset and
|
||||||
and localized_tz._dst == dstoffset):
|
localized_tz._dst == dstoffset):
|
||||||
return localized_tz
|
return localized_tz
|
||||||
|
|
||||||
# This (utcoffset, dstoffset) information has been removed from the
|
# This (utcoffset, dstoffset) information has been removed from the
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user