def set_newest_text(self): if not self._cur_commit_hash: logger.log("Unknown current version number, don't know if we should update or not", logger.DEBUG) newest_tag = 'unknown_current_version' newest_text = _('Unknown current version number: ' 'If you\'ve never used the SickRage upgrade system before then current version is not set. ' '— <a href="{update_url}">Update Now</a>').format(update_url=self.get_update_url()) elif self._num_commits_behind > 0: base_url = 'http://github.com/' + sickbeard.GIT_ORG + '/' + sickbeard.GIT_REPO if self._newest_commit_hash: url = base_url + '/compare/' + self._cur_commit_hash + '...' + self._newest_commit_hash else: url = base_url + '/commits/' newest_tag = 'newer_version_available' commits_behind = ngettext("(you're {num_commits} commit behind)", "(you're {num_commits} commits behind)", self._num_commits_behind).format(num_commits=self._num_commits_behind) newest_text = _('There is a <a href="{compare_url}" onclick="window.open(this.href); return false;">' 'newer version available</a> {commits_behind} — ' '<a href="{update_url}">Update Now</a>').format( compare_url=url, commits_behind=commits_behind, update_url=self.get_update_url()) else: return helpers.add_site_message(newest_text, tag=newest_tag, level='success')
def set_newest_text(self): if self._num_commits_ahead: logger.log( "Local branch is ahead of " + self.branch + ". Automatic update not possible.", logger.WARNING) newest_text = "Local branch is ahead of " + self.branch + ". Automatic update not possible." elif self._num_commits_behind > 0: base_url = 'http://github.com/' + sickbeard.GIT_ORG + '/' + sickbeard.GIT_REPO if self._newest_commit_hash: url = base_url + '/compare/' + self._cur_commit_hash + '...' + self._newest_commit_hash else: url = base_url + '/commits/' newest_text = 'There is a <a href="' + url + '" onclick="window.open(this.href); return false;">newer version available</a> ' newest_text += " (you're " + str( self._num_commits_behind) + " commit" if self._num_commits_behind > 1: newest_text += 's' newest_text += ' behind)' + "— <a href=\"" + self.get_update_url( ) + "\">Update Now</a>" else: return helpers.add_site_message(newest_text, 'success')
def set_newest_text(self): if self._num_commits_ahead: newest_tag = 'local_branch_ahead' newest_text = 'Local branch is ahead of {branch}. Automatic update not possible.'.format(branch=self.branch) logger.log(newest_text, logger.WARNING) elif self._num_commits_behind > 0: base_url = 'http://github.com/' + sickbeard.GIT_ORG + '/' + sickbeard.GIT_REPO if self._newest_commit_hash: url = base_url + '/compare/' + self._cur_commit_hash + '...' + self._newest_commit_hash else: url = base_url + '/commits/' newest_tag = 'newer_version_available' commits_behind = ngettext("(you're {num_commits} commit behind)", "(you're {num_commits} commits behind)", self._num_commits_behind).format(num_commits=self._num_commits_behind) newest_text = _('There is a <a href="{compare_url}" onclick="window.open(this.href); return false;">' 'newer version available</a> {commits_behind} — ' '<a href="{update_url}">Update Now</a>').format( compare_url=url, commits_behind=commits_behind, update_url=self.get_update_url()) else: return helpers.add_site_message(newest_text, tag=newest_tag, level='success')
def set_newest_text(self): if self._num_commits_ahead: newest_tag = 'local_branch_ahead' newest_text = 'Local branch is ahead of {branch}. Automatic update not possible.'.format( branch=self.branch) logger.log(newest_text, logger.WARNING) elif self._num_commits_behind > 0: base_url = 'http://github.com/' + sickbeard.GIT_ORG + '/' + sickbeard.GIT_REPO if self._newest_commit_hash: url = base_url + '/compare/' + self._cur_commit_hash + '...' + self._newest_commit_hash else: url = base_url + '/commits/' newest_tag = 'newer_version_available' commits_behind = ngettext("(you're {num_commits} commit behind)", "(you're {num_commits} commits behind)", self._num_commits_behind).format( num_commits=self._num_commits_behind) newest_text = _( 'There is a <a href="{compare_url}" onclick="window.open(this.href); return false;">' 'newer version available</a> {commits_behind} — ' '<a href="{update_url}">Update Now</a>').format( compare_url=url, commits_behind=commits_behind, update_url=self.get_update_url()) else: return helpers.add_site_message(newest_text, tag=newest_tag, level='success')
def set_newest_text(self): if not self._cur_commit_hash: logger.log( "Unknown current version number, don't know if we should update or not", logger.DEBUG) newest_text = "Unknown current version number: If you've never used the SickRage upgrade system before then current version is not set." newest_text += "— <a href=\"" + self.get_update_url( ) + "\">Update Now</a>" elif self._num_commits_behind > 0: base_url = 'http://github.com/' + sickbeard.GIT_ORG + '/' + sickbeard.GIT_REPO if self._newest_commit_hash: url = base_url + '/compare/' + self._cur_commit_hash + '...' + self._newest_commit_hash else: url = base_url + '/commits/' newest_text = 'There is a <a href="' + url + '" onclick="window.open(this.href); return false;">newer version available</a>' newest_text += " (you're " + str( self._num_commits_behind) + " commit" if self._num_commits_behind > 1: newest_text += "s" newest_text += " behind)" + "— <a href=\"" + self.get_update_url( ) + "\">Update Now</a>" else: return helpers.add_site_message(newest_text, 'success')
def set_newest_text(self): if not self._cur_commit_hash: logger.log("Unknown current version number, don't know if we should update or not", logger.DEBUG) newest_tag = 'unknown_current_version' newest_text = _('Unknown current version number: ' 'If you\'ve never used the SickChill upgrade system before then current version is not set. ' '— <a href="{update_url}">Update Now</a>').format(update_url=self.get_update_url()) elif self._num_commits_behind > 0: base_url = 'http://github.com/' + sickbeard.GIT_ORG + '/' + sickbeard.GIT_REPO if self._newest_commit_hash: url = base_url + '/compare/' + self._cur_commit_hash + '...' + self._newest_commit_hash else: url = base_url + '/commits/' newest_tag = 'newer_version_available' commits_behind = _("(you're {num_commits} commit behind)").format(num_commits=self._num_commits_behind) newest_text = _('There is a <a href="{compare_url}" onclick="window.open(this.href); return false;">' 'newer version available</a> {commits_behind} — ' '<a href="{update_url}">Update Now</a>').format( compare_url=url, commits_behind=commits_behind, update_url=self.get_update_url()) else: return helpers.add_site_message(newest_text, tag=newest_tag, level='success')
def _find_working_git(self): test_cmd = 'version' if sickbeard.GIT_PATH: main_git = '"' + sickbeard.GIT_PATH + '"' else: main_git = 'git' logger.log( "Checking if we can use git commands: " + main_git + ' ' + test_cmd, logger.DEBUG) stdout_, stderr_, exit_status = self._run_git(main_git, test_cmd) if exit_status == 0: logger.log("Using: " + main_git, logger.DEBUG) return main_git else: logger.log("Not using: " + main_git, logger.DEBUG) # trying alternatives alternative_git = [] # osx people who start sr from launchd have a broken path, so try a hail-mary attempt for them if platform.system() == 'Darwin': alternative_git.append('/usr/local/git/bin/git') if platform.system() == 'Windows': if main_git != main_git.lower(): alternative_git.append(main_git.lower()) if alternative_git: logger.log("Trying known alternative git locations", logger.DEBUG) for cur_git in alternative_git: logger.log( "Checking if we can use git commands: " + cur_git + ' ' + test_cmd, logger.DEBUG) stdout_, stderr_, exit_status = self._run_git( cur_git, test_cmd) if exit_status == 0: logger.log("Using: " + cur_git, logger.DEBUG) return cur_git else: logger.log("Not using: " + cur_git, logger.DEBUG) # Still haven't found a working git helpers.add_site_message(_( 'Unable to find your git executable - Shutdown SickRage and EITHER set git_path in ' 'your config.ini OR delete your .git folder and run from source to enable updates.' ), tag='unable_to_find_git', level='danger') return None
def set_site_message(self, message, tag, level): self.set_header(b'Cache-Control', 'max-age=0,no-cache,no-store') if message: helpers.add_site_message(message, tag=tag, level=level) else: if sickbeard.BRANCH and sickbeard.BRANCH != 'master' and not sickbeard.DEVELOPER and self.get_current_user(): message = _('You\'re using the {branch} branch. ' 'Please use \'master\' unless specifically asked').format(branch=sickbeard.BRANCH) helpers.add_site_message(message, tag='not_using_master_branch', level='danger') return sickbeard.SITE_MESSAGES
def _find_working_git(self): test_cmd = 'version' if sickbeard.GIT_PATH: main_git = '"' + sickbeard.GIT_PATH + '"' else: main_git = 'git' logger.log("Checking if we can use git commands: " + main_git + ' ' + test_cmd, logger.DEBUG) stdout_, stderr_, exit_status = self._run_git(main_git, test_cmd) if exit_status == 0: logger.log("Using: " + main_git, logger.DEBUG) return main_git else: logger.log("Not using: " + main_git, logger.DEBUG) # trying alternatives alternative_git = [] # osx people who start sr from launchd have a broken path, so try a hail-mary attempt for them if platform.system() == 'Darwin': alternative_git.append('/usr/local/git/bin/git') if platform.system() == 'Windows': if main_git != main_git.lower(): alternative_git.append(main_git.lower()) if alternative_git: logger.log("Trying known alternative git locations", logger.DEBUG) for cur_git in alternative_git: logger.log("Checking if we can use git commands: " + cur_git + ' ' + test_cmd, logger.DEBUG) stdout_, stderr_, exit_status = self._run_git(cur_git, test_cmd) if exit_status == 0: logger.log("Using: " + cur_git, logger.DEBUG) return cur_git else: logger.log("Not using: " + cur_git, logger.DEBUG) # Still haven't found a working git helpers.add_site_message( _('Unable to find your git executable - Shutdown SickRage and EITHER set git_path in ' 'your config.ini OR delete your .git folder and run from source to enable updates.'), tag='unable_to_find_git', level='danger') return None
def set_newest_text(self): if not self._cur_commit_hash: logger.log("Unknown current version number, don't know if we should update or not", logger.DEBUG) newest_text = "Unknown current version number: If you've never used the SickRage upgrade system before then current version is not set." newest_text += "— <a href=\"" + self.get_update_url() + "\">Update Now</a>" elif self._num_commits_behind > 0: base_url = 'http://github.com/' + sickbeard.GIT_ORG + '/' + sickbeard.GIT_REPO if self._newest_commit_hash: url = base_url + '/compare/' + self._cur_commit_hash + '...' + self._newest_commit_hash else: url = base_url + '/commits/' newest_text = 'There is a <a href="' + url + '" onclick="window.open(this.href); return false;">newer version available</a>' newest_text += " (you're " + str(self._num_commits_behind) + " commit" if self._num_commits_behind > 1: newest_text += "s" newest_text += " behind)" + "— <a href=\"" + self.get_update_url() + "\">Update Now</a>" else: return helpers.add_site_message(newest_text, 'success')
def set_newest_text(self): if self._num_commits_ahead: logger.log("Local branch is ahead of " + self.branch + ". Automatic update not possible.", logger.WARNING) newest_text = "Local branch is ahead of " + self.branch + ". Automatic update not possible." elif self._num_commits_behind > 0: base_url = 'http://github.com/' + sickbeard.GIT_ORG + '/' + sickbeard.GIT_REPO if self._newest_commit_hash: url = base_url + '/compare/' + self._cur_commit_hash + '...' + self._newest_commit_hash else: url = base_url + '/commits/' newest_text = 'There is a <a href="' + url + '" onclick="window.open(this.href); return false;">newer version available</a> ' newest_text += " (you're " + str(self._num_commits_behind) + " commit" if self._num_commits_behind > 1: newest_text += 's' newest_text += ' behind)' + "— <a href=\"" + self.get_update_url() + "\">Update Now</a>" else: return helpers.add_site_message(newest_text, 'success')
def _git_error(): error_message = 'Unable to find your git executable - Shutdown SickRage and EITHER set git_path in your config.ini OR delete your .git folder and run from source to enable updates.' helpers.add_site_message(error_message, 'danger')
def _git_error(): error_message = 'Unable to find your git executable - Shutdown SickRage and EITHER set git_path in your config.ini OR delete your .git folder and run from source to enable updates.' helpers.add_site_message(error_message, 'danger')