Commit 7a6cb045 authored by echel0n's avatar echel0n

Added code to allow specifying pip3 location

parent f9e4e1f1
......@@ -69,7 +69,8 @@ class Config(object):
self.auto_update = True
self.notify_on_update = True
self.notify_on_login = False
self.pip_path = ""
self.pip2_path = ""
self.pip3_path = ""
self.git_reset = True
self.git_username = ""
self.git_password = ""
......@@ -732,7 +733,8 @@ class Config(object):
'display_all_seasons': True,
'usenet_retention': 500,
'download_propers': True,
'pip_path': 'pip2',
'pip2_path': 'pip2',
'pip3_path': 'pip3',
'del_rar_contents': False,
'process_method': 'copy',
'file_timestamp_timezone': 'network',
......@@ -1407,7 +1409,8 @@ class Config(object):
self.log_size = self.check_setting_int('General', 'log_size')
self.socket_timeout = self.check_setting_int('General', 'socket_timeout')
self.default_page = self.check_setting_str('General', 'default_page')
self.pip_path = self.check_setting_str('General', 'pip_path')
self.pip2_path = self.check_setting_str('General', 'pip2_path')
self.pip3_path = self.check_setting_str('General', 'pip3_path')
self.git_path = self.check_setting_str('General', 'git_path')
self.git_autoissues = self.check_setting_bool('General', 'git_autoissues')
self.git_username = self.check_setting_str('General', 'git_username', censor=True)
......@@ -2007,7 +2010,8 @@ class Config(object):
'create_missing_show_dirs': int(self.create_missing_show_dirs),
'add_shows_wo_dir': int(self.add_shows_wo_dir),
'extra_scripts': '|'.join(self.extra_scripts),
'pip_path': self.pip_path,
'pip2_path': self.pip2_path,
'pip3_path': self.pip3_path,
'git_path': self.git_path,
'ignore_words': self.ignore_words,
'require_words': self.require_words,
......
......@@ -256,10 +256,10 @@ class UpdateManager(object):
sickrage.app.alerts.error(_('Updater'), error_message)
@property
def _pip_path(self):
def _pip2_path(self):
test_cmd = '-V'
main_pip = sickrage.app.config.pip_path or 'pip2'
main_pip = sickrage.app.config.pip2_path or 'pip2'
# sickrage.app.log.debug("Checking if we can use pip commands: " + main_pip + ' ' + test_cmd)
__, __, exit_status = self._pip_cmd(main_pip, test_cmd, silent=True)
......@@ -289,7 +289,45 @@ class UpdateManager(object):
return cur_pip
# Still haven't found a working git
error_message = _('Unable to find your pip executable - Set your pip path from Settings->General->Advanced')
error_message = _('Unable to find your pip2 executable - Set your pip2 path from Settings->General->Advanced')
sickrage.app.alerts.error(_('Updater'), error_message)
@property
def _pip3_path(self):
test_cmd = '-V'
main_pip = sickrage.app.config.pip3_path or 'pip3'
# sickrage.app.log.debug("Checking if we can use pip commands: " + main_pip + ' ' + test_cmd)
__, __, exit_status = self._pip_cmd(main_pip, test_cmd, silent=True)
if exit_status == 0:
# sickrage.app.log.debug("Using: " + main_pip)
return main_pip
# trying alternatives
alternative_pip = []
# osx people who start sr from launchd have a broken path, so try a hail-mary attempt for them
if platform.system().lower() == 'darwin':
alternative_pip.append('/usr/local/python3.7/bin/pip3')
if platform.system().lower() == 'windows':
if main_pip != main_pip.lower():
alternative_pip.append(main_pip.lower())
if alternative_pip:
sickrage.app.log.debug("Trying known alternative pip locations")
for cur_pip in alternative_pip:
# sickrage.app.log.debug("Checking if we can use pip commands: " + cur_pip + ' ' + test_cmd)
__, __, exit_status = self._pip_cmd(cur_pip, test_cmd)
if exit_status == 0:
# sickrage.app.log.debug("Using: " + cur_pip)
return cur_pip
# Still haven't found a working git
error_message = _('Unable to find your pip3 executable - Set your pip3 path from Settings->General->Advanced')
sickrage.app.alerts.error(_('Updater'), error_message)
......
......@@ -3779,14 +3779,14 @@ class ConfigGeneral(Config):
api_key=None, indexer_default=None, timezone_display=None, cpu_preset='NORMAL',
version_notify=None, enable_https=None, https_cert=None, https_key=None, handle_reverse_proxy=None,
sort_article=None, auto_update=None, notify_on_update=None, proxy_setting=None, proxy_indexers=None,
anon_redirect=None, git_path=None, pip_path=None, calendar_unprotected=None, calendar_icons=None,
anon_redirect=None, git_path=None, calendar_unprotected=None, calendar_icons=None,
debug=None, ssl_verify=None, no_restart=None, coming_eps_missed_range=None, filter_row=None,
fuzzy_dating=None, trim_zero=None, date_preset=None, date_preset_na=None, time_preset=None,
indexer_timeout=None, download_url=None, rootDir=None, theme_name=None, default_page=None,
git_reset=None, git_username=None, git_password=None, git_autoissues=None, gui_language=None,
display_all_seasons=None, showupdate_stale=None, notify_on_login=None, allowed_video_file_exts=None,
enable_api_providers_cache=None, enable_upnp=None, web_external_port=None,
strip_special_file_bits=None, **kwargs):
strip_special_file_bits=None, pip2_path=None, pip3_path=None, **kwargs):
results = []
......@@ -3830,7 +3830,8 @@ class ConfigGeneral(Config):
sickrage.app.config.git_reset = 1
sickrage.app.config.git_autoissues = checkbox_to_value(git_autoissues)
sickrage.app.config.git_path = git_path
sickrage.app.config.pip_path = pip_path
sickrage.app.config.pip2_path = pip2_path
sickrage.app.config.pip3_path = pip3_path
sickrage.app.config.calendar_unprotected = checkbox_to_value(calendar_unprotected)
sickrage.app.config.calendar_icons = checkbox_to_value(calendar_icons)
sickrage.app.config.no_restart = checkbox_to_value(no_restart)
......
......@@ -1253,7 +1253,7 @@
<fieldset class="col-lg-9 col-md-8 col-sm-8 card-text">
<div class="form-row form-group">
<div class="col-lg-3 col-md-4 col-sm-5">
<label class="component-title">${_('PIP executable path')}</label>
<label class="component-title">${_('PIP2 executable path')}</label>
</div>
<div class="col-lg-9 col-md-8 col-sm-7 component-desc">
<div class="form-row">
......@@ -1264,15 +1264,15 @@
<span class="fas fa-file"></span>
</span>
</div>
<input id="pip_path" name="pip_path"
value="${sickrage.app.config.pip_path}"
placeholder="${_('ex: /path/to/pip')}"
title="only needed if OS is unable to locate pip from env"
<input id="pip2_path" name="pip2_path"
value="${sickrage.app.config.pip2_path}"
placeholder="${_('ex: /path/to/pip2')}"
title="only needed if OS is unable to locate pip2 from env"
class="form-control" autocapitalize="off"/>
<div class="input-group-append">
<span class="input-group-text">
<span class="btn" id="verifyPipPath">
${_('Verify Path')}
<span class="btn" id="verifyPip2Path">
${_('Verify PIP2 Path')}
</span>
</span>
</div>
......@@ -1282,14 +1282,50 @@
<p></p>
<div class="form-row">
<div class="col-md-12">
<div class="testNotification" id="testPIP-result">
${_('Click vefify path to test.')}
<div class="testNotification" id="testPIP2-result">
${_('Click verify path to test.')}
</div>
<input class="btn btn-inline" type="button" id="installRequirements"
value="Install Requirements">
</div>
</div>
</div>
</div>
<div class="form-row form-group">
<div class="col-lg-3 col-md-4 col-sm-5">
<label class="component-title">${_('PIP3 executable path')}</label>
</div>
<div class="col-lg-9 col-md-8 col-sm-7 component-desc">
<div class="form-row">
<div class="col-md-12">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
<span class="fas fa-file"></span>
</span>
</div>
<input id="pip3_path" name="pip3_path"
value="${sickrage.app.config.pip3_path}"
placeholder="${_('ex: /path/to/pip3')}"
title="only needed if OS is unable to locate pip3 from env"
class="form-control" autocapitalize="off"/>
<div class="input-group-append">
<span class="input-group-text">
<span class="btn" id="verifyPip3Path">
${_('Verify PIP3 Path')}
</span>
</span>
</div>
</div>
</div>
</div>
<p></p>
<div class="form-row">
<div class="col-md-12">
<div class="testNotification" id="testPIP3-result">
${_('Click verify path to test.')}
</div>
</div>
</div>
</div>
</div>
......
......@@ -2998,28 +2998,54 @@ $(document).ready(function ($) {
});
});
if ($('#pip_path').length) {
$('#pip_path').fileBrowser({
title: gt('Select path to pip'),
key: 'pip_path',
if ($('#pip2_path').length) {
$('#pip2_path').fileBrowser({
title: gt('Select path to pip2'),
key: 'pip2_path',
includeFiles: 1
});
$('#verifyPipPath').click(function () {
var pip_path = $.trim($('#pip_path').val());
if (!pip_path) {
$('#testPIP-result').html(gt('Please fill out the necessary fields above.'));
$('#pip_path').addClass('warning');
$('#verifyPip2Path').click(function () {
var pip2_path = $.trim($('#pip2_path').val());
if (!pip2_path) {
$('#testPIP2-result').html(gt('Please fill out the necessary fields above.'));
$('#pip2_path').addClass('warning');
return;
}
$('#pip_path').removeClass('warning');
$('#pip2_path').removeClass('warning');
$(this).prop('disabled', true);
$('#testPIP-result').html(SICKRAGE.loadingHTML);
$('#testPIP2-result').html(SICKRAGE.loadingHTML);
$.get(SICKRAGE.srWebRoot + '/home/verifyPath', {
'path': pip_path
'path': pip2_path
}).done(function (data) {
$('#testPIP-result').html(data);
$('#verifyPipPath').prop('disabled', false);
$('#testPIP2-result').html(data);
$('#verifyPip2Path').prop('disabled', false);
});
});
}
if ($('#pip3_path').length) {
$('#pip3_path').fileBrowser({
title: gt('Select path to pip3'),
key: 'pip3_path',
includeFiles: 1
});
$('#verifyPip3Path').click(function () {
var pip3_path = $.trim($('#pip3_path').val());
if (!pip3_path) {
$('#testPIP3-result').html(gt('Please fill out the necessary fields above.'));
$('#pip3_path').addClass('warning');
return;
}
$('#pip3_path').removeClass('warning');
$(this).prop('disabled', true);
$('#testPIP3-result').html(SICKRAGE.loadingHTML);
$.get(SICKRAGE.srWebRoot + '/home/verifyPath', {
'path': pip3_path
}).done(function (data) {
$('#testPIP3-result').html(data);
$('#verifyPip3Path').prop('disabled', false);
});
});
}
......@@ -3050,10 +3076,6 @@ $(document).ready(function ($) {
});
}
$('#installRequirements').on('click', function () {
window.location.href = SICKRAGE.srWebRoot + '/home/installRequirements';
});
$('#branchCheckout').on('click', function () {
window.location.href = SICKRAGE.srWebRoot + '/home/branchCheckout?branch=' + $("#branchVersion").val();
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment