Refactor some code

This commit is contained in:
JonnyWong16 2018-02-24 10:09:02 -08:00
parent ab34a74210
commit 754fd24421
9 changed files with 24 additions and 24 deletions

View file

@ -47,7 +47,7 @@
You are running an unknown version of Tautulli.<br /> You are running an unknown version of Tautulli.<br />
<a href="update">Update</a> or <a href="#" id="updateDismiss">Dismiss</a> <a href="update">Update</a> or <a href="#" id="updateDismiss">Dismiss</a>
</div> </div>
% elif plexpy.CONFIG.CHECK_GITHUB and plexpy.COMMITS_BEHIND > 0 and plexpy.common.BRANCH in ('master', 'beta') and plexpy.common.VERSION_NUMBER != plexpy.LATEST_RELEASE: % elif plexpy.CONFIG.CHECK_GITHUB and plexpy.COMMITS_BEHIND > 0 and plexpy.common.BRANCH in ('master', 'beta') and plexpy.common.RELEASE != plexpy.LATEST_RELEASE:
<div id="updatebar" style="display: none;"> <div id="updatebar" style="display: none;">
A <a href="${anon_url('https://github.com/%s/%s/releases/tag/%s' % (plexpy.CONFIG.GIT_USER, plexpy.CONFIG.GIT_REPO, plexpy.LATEST_RELEASE))}" target="_blank"> A <a href="${anon_url('https://github.com/%s/%s/releases/tag/%s' % (plexpy.CONFIG.GIT_USER, plexpy.CONFIG.GIT_REPO, plexpy.LATEST_RELEASE))}" target="_blank">
new release (${plexpy.LATEST_RELEASE})</a> of Tautulli is available!<br /> new release (${plexpy.LATEST_RELEASE})</a> of Tautulli is available!<br />

View file

@ -137,7 +137,7 @@
<%def name="modalIncludes()"> <%def name="modalIncludes()">
% if _session['user_group'] == 'admin' and config['update_show_changelog']: % if _session['user_group'] == 'admin' and config['update_show_changelog']:
<% from plexpy.common import VERSION_NUMBER %> <% from plexpy.common import RELEASE %>
<div id="changelog-modal" class="modal fade wide" tabindex="-1" role="dialog" aria-labelledby="changelog-modal"> <div id="changelog-modal" class="modal fade wide" tabindex="-1" role="dialog" aria-labelledby="changelog-modal">
<div class="modal-dialog" role="document"> <div class="modal-dialog" role="document">
<div class="modal-content"> <div class="modal-content">

View file

@ -60,9 +60,9 @@
<input type="hidden" id="show_advanced_settings" name="show_advanced_settings" value="${config['show_advanced_settings']}" required> <input type="hidden" id="show_advanced_settings" name="show_advanced_settings" value="${config['show_advanced_settings']}" required>
<div class="tab-content"> <div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="tabs-help_info"> <div role="tabpanel" class="tab-pane active" id="tabs-help_info">
% if common.VERSION_NUMBER: % if common.RELEASE:
<div class="padded-header"> <div class="padded-header">
<h3>Version ${common.VERSION_NUMBER} <small><a id="changelog-modal-link" href="#"><i class="fa fa-info-circle"></i> Changelog</a></small></h3> <h3>Version ${common.RELEASE} <small><a id="changelog-modal-link" href="#"><i class="fa fa-info-circle"></i> Changelog</a></small></h3>
</div> </div>
% endif % endif
<div class="padded-header"> <div class="padded-header">

View file

@ -240,7 +240,7 @@ def initialize(config_file):
# Get the previous release from the file # Get the previous release from the file
release_file = os.path.join(DATA_DIR, "release.lock") release_file = os.path.join(DATA_DIR, "release.lock")
PREV_RELEASE = common.VERSION_NUMBER PREV_RELEASE = common.RELEASE
if os.path.isfile(release_file): if os.path.isfile(release_file):
try: try:
with open(release_file, "r") as fp: with open(release_file, "r") as fp:
@ -252,7 +252,7 @@ def initialize(config_file):
PREV_RELEASE = 'v1.4.25' PREV_RELEASE = 'v1.4.25'
# Check if the release was updated # Check if the release was updated
if common.VERSION_NUMBER != PREV_RELEASE: if common.RELEASE != PREV_RELEASE:
CONFIG.UPDATE_SHOW_CHANGELOG = 1 CONFIG.UPDATE_SHOW_CHANGELOG = 1
CONFIG.write() CONFIG.write()
_UPDATE = True _UPDATE = True
@ -260,7 +260,7 @@ def initialize(config_file):
# Write current release version to file for update checking # Write current release version to file for update checking
try: try:
with open(release_file, "w") as fp: with open(release_file, "w") as fp:
fp.write(common.VERSION_NUMBER) fp.write(common.RELEASE)
except IOError as e: except IOError as e:
logger.error(u"Unable to write current release to file '%s': %s" % logger.error(u"Unable to write current release to file '%s': %s" %
(release_file, e)) (release_file, e))
@ -1693,7 +1693,7 @@ def initialize_tracker():
data = { data = {
'dataSource': 'server', 'dataSource': 'server',
'appName': 'Tautulli', 'appName': 'Tautulli',
'appVersion': common.VERSION_NUMBER, 'appVersion': common.RELEASE,
'appId': plexpy.INSTALL_TYPE, 'appId': plexpy.INSTALL_TYPE,
'appInstallerId': plexpy.CONFIG.GIT_BRANCH, 'appInstallerId': plexpy.CONFIG.GIT_BRANCH,
'dimension1': '{} {}'.format(common.PLATFORM, common.PLATFORM_VERSION), # App Platform 'dimension1': '{} {}'.format(common.PLATFORM, common.PLATFORM_VERSION), # App Platform
@ -1702,7 +1702,8 @@ def initialize_tracker():
'noninteractive': True 'noninteractive': True
} }
tracker = Tracker.create('UA-111522699-2', client_id=CONFIG.PMS_UUID, hash_client_id=True) tracker = Tracker.create('UA-111522699-2', client_id=CONFIG.PMS_UUID, hash_client_id=True,
user_agent=common.USER_AGENT)
tracker.set(data) tracker.set(data)
return tracker return tracker

View file

@ -19,13 +19,12 @@ from collections import OrderedDict
import version import version
# Identify Our Application # Identify Our Application
USER_AGENT = 'Tautulli/-' + version.PLEXPY_BRANCH + ' v' + version.PLEXPY_RELEASE_VERSION + ' (' + platform.system() + \
' ' + platform.release() + ')'
PLATFORM = platform.system() PLATFORM = platform.system()
PLATFORM_VERSION = platform.release() PLATFORM_VERSION = platform.release()
BRANCH = version.PLEXPY_BRANCH BRANCH = version.PLEXPY_BRANCH
VERSION_NUMBER = version.PLEXPY_RELEASE_VERSION RELEASE = version.PLEXPY_RELEASE_VERSION
USER_AGENT = 'Tautulli/{} ({} {})'.format(RELEASE, PLATFORM, PLATFORM_VERSION)
DEFAULT_USER_THUMB = "interfaces/default/images/gravatar-default-80x80.png" DEFAULT_USER_THUMB = "interfaces/default/images/gravatar-default-80x80.png"
DEFAULT_POSTER_THUMB = "interfaces/default/images/poster.png" DEFAULT_POSTER_THUMB = "interfaces/default/images/poster.png"

View file

@ -41,7 +41,7 @@ class HTTPHandler(object):
self.headers = {'X-Plex-Device-Name': 'Tautulli', self.headers = {'X-Plex-Device-Name': 'Tautulli',
'X-Plex-Product': 'Tautulli', 'X-Plex-Product': 'Tautulli',
'X-Plex-Version': plexpy.common.VERSION_NUMBER, 'X-Plex-Version': plexpy.common.RELEASE,
'X-Plex-Platform': plexpy.common.PLATFORM, 'X-Plex-Platform': plexpy.common.PLATFORM,
'X-Plex-Platform-Version': plexpy.common.PLATFORM_VERSION, 'X-Plex-Platform-Version': plexpy.common.PLATFORM_VERSION,
'X-Plex-Client-Identifier': plexpy.CONFIG.PMS_UUID, 'X-Plex-Client-Identifier': plexpy.CONFIG.PMS_UUID,

View file

@ -677,7 +677,7 @@ def build_media_notify_params(notify_action=None, session=None, timeline=None, m
available_params = { available_params = {
# Global paramaters # Global paramaters
'tautulli_version': common.VERSION_NUMBER, 'tautulli_version': common.RELEASE,
'tautulli_remote': plexpy.CONFIG.GIT_REMOTE, 'tautulli_remote': plexpy.CONFIG.GIT_REMOTE,
'tautulli_branch': plexpy.CONFIG.GIT_BRANCH, 'tautulli_branch': plexpy.CONFIG.GIT_BRANCH,
'tautulli_commit': plexpy.CURRENT_VERSION, 'tautulli_commit': plexpy.CURRENT_VERSION,
@ -877,7 +877,7 @@ def build_server_notify_params(notify_action=None, **kwargs):
available_params = { available_params = {
# Global paramaters # Global paramaters
'tautulli_version': common.VERSION_NUMBER, 'tautulli_version': common.RELEASE,
'tautulli_remote': plexpy.CONFIG.GIT_REMOTE, 'tautulli_remote': plexpy.CONFIG.GIT_REMOTE,
'tautulli_branch': plexpy.CONFIG.GIT_BRANCH, 'tautulli_branch': plexpy.CONFIG.GIT_BRANCH,
'tautulli_commit': plexpy.CURRENT_VERSION, 'tautulli_commit': plexpy.CURRENT_VERSION,

View file

@ -20,9 +20,9 @@ import subprocess
import tarfile import tarfile
import plexpy import plexpy
import common
import logger import logger
import request import request
import version
def runGit(args): def runGit(args):
@ -65,7 +65,7 @@ def runGit(args):
def getVersion(): def getVersion():
if version.PLEXPY_BRANCH.startswith('win32build'): if common.BRANCH.startswith('win32build'):
plexpy.INSTALL_TYPE = 'win' plexpy.INSTALL_TYPE = 'win'
# Don't have a way to update exe yet, but don't want to set VERSION to None # Don't have a way to update exe yet, but don't want to set VERSION to None
@ -120,15 +120,15 @@ def getVersion():
version_file = os.path.join(plexpy.PROG_DIR, 'version.txt') version_file = os.path.join(plexpy.PROG_DIR, 'version.txt')
if not os.path.isfile(version_file): if not os.path.isfile(version_file):
return None, 'origin', 'master' return None, 'origin', common.BRANCH
with open(version_file, 'r') as f: with open(version_file, 'r') as f:
current_version = f.read().strip(' \n\r') current_version = f.read().strip(' \n\r')
if current_version: if current_version:
return current_version, plexpy.CONFIG.GIT_REMOTE, plexpy.CONFIG.GIT_BRANCH return current_version, 'origin', common.BRANCH
else: else:
return None, 'origin', 'master' return None, 'origin', common.BRANCH
def checkGithub(auto_update=False): def checkGithub(auto_update=False):

View file

@ -63,7 +63,7 @@ def serve_template(templatename, **kwargs):
http_root = plexpy.HTTP_ROOT http_root = plexpy.HTTP_ROOT
server_name = plexpy.CONFIG.PMS_NAME server_name = plexpy.CONFIG.PMS_NAME
cache_param = '?' + (plexpy.CURRENT_VERSION or common.VERSION_NUMBER) cache_param = '?' + (plexpy.CURRENT_VERSION or common.RELEASE)
_session = get_session_info() _session = get_session_info()
@ -3581,7 +3581,7 @@ class WebInterface(object):
} }
elif plexpy.COMMITS_BEHIND > 0 and plexpy.common.BRANCH in ('master', 'beta') and \ elif plexpy.COMMITS_BEHIND > 0 and plexpy.common.BRANCH in ('master', 'beta') and \
plexpy.common.VERSION_NUMBER != plexpy.LATEST_RELEASE: plexpy.common.RELEASE != plexpy.LATEST_RELEASE:
return {'result': 'success', return {'result': 'success',
'update': True, 'update': True,
'release': True, 'release': True,
@ -3668,7 +3668,7 @@ class WebInterface(object):
latest_only = (latest_only == 'true') latest_only = (latest_only == 'true')
since_prev_release = (since_prev_release == 'true') since_prev_release = (since_prev_release == 'true')
if since_prev_release and plexpy.PREV_RELEASE == common.VERSION_NUMBER: if since_prev_release and plexpy.PREV_RELEASE == common.RELEASE:
latest_only = True latest_only = True
since_prev_release = False since_prev_release = False