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.warning(newest_text) elif self._num_commits_behind > 0: if self._newest_commit_hash: current = self._cur_commit_hash newest = self._newest_commit_hash url = f'https://github.com/{settings.GIT_ORG}/{settings.GIT_REPO}/compare/{current}...{newest}' else: url = f'https://github.com/{settings.GIT_ORG}/{settings.GIT_REPO}/commits/' newest_tag = 'newer_version_available' commits_behind = self._num_commits_behind s = ('', 's')[commits_behind != 1] update_url = self.get_update_url() newest_text = _( 'There is a <a href="{url}" onclick="window.open(this.href); return false;">newer version available</a> (you\'re {commits_behind} commit{s} behind) — <a href="{update_url}">Update Now</a>' .format(commits_behind=commits_behind, update_url=update_url, url=url, s=s)) 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.debug( "Unknown current version number, don't know if we should update or not" ) update_url = self.get_update_url() newest_tag = "unknown_current_version" newest_text = _( f'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>' ) elif self._num_commits_behind > 0: if self._newest_commit_hash: current = self._cur_commit_hash newest = self._newest_commit_hash url = f"https://github.com/{settings.GIT_ORG}/{settings.GIT_REPO}/compare/{current}...{newest}" else: url = f"https://github.com/{settings.GIT_ORG}/{settings.GIT_REPO}/commits/" newest_tag = "newer_version_available" commits_behind = self._num_commits_behind s = ("", "s")[commits_behind != 1] update_url = self.get_update_url() newest_text = _( f'There is a <a href="{url}" onclick="window.open(this.href); return false;">newer version available</a> (you\'re {commits_behind} commit{s} behind) — <a href="{update_url}">Update Now</a>' ) 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.debug( "Unknown current version number, don't know if we should update or not" ) 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 = 'https://github.com/' + settings.GIT_ORG + '/' + settings.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 settings.GIT_PATH: main_git = '"' + settings.GIT_PATH + '"' else: main_git = "git" logger.debug("Checking if we can use git commands: " + main_git + " " + test_cmd) stdout_, stderr_, exit_status = self._run_git(main_git, test_cmd) if exit_status == 0: logger.debug("Using: " + main_git) return main_git else: logger.debug("Not using: " + main_git) # trying alternatives alternative_git = [] # osx people who start sc 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()) alternative_git.append("c:\\SickChill\\Git\\bin\\git.exe") if alternative_git: logger.debug("Trying known alternative git locations") for cur_git in alternative_git: logger.debug("Checking if we can use git commands: " + cur_git + " " + test_cmd) stdout_, stderr_, exit_status = self._run_git( cur_git, test_cmd) if exit_status == 0: logger.debug("Using: " + cur_git) return cur_git else: logger.debug("Not using: " + cur_git) # Still haven't found a working git helpers.add_site_message( _("Unable to find your git executable - Shutdown SickChill 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", ) return None
def set_newest_text(self): if self.need_update(): base_url = 'https://github.com/{}/{}'.format(settings.GIT_ORG, settings.GIT_REPO) if self.get_newest_commit_hash(): url = '{}/compare{}...{}'.format(base_url, self.get_current_commit_hash().base_version, self.get_newest_commit_hash().base_version) else: url = '{}/commits/'.format(base_url) newest_tag = 'newer_version_available' newest_text = _('There is a <a href="{compare_url}" onclick="window.open(this.href); return false;">' 'newer version available</a> — <a href="{update_url}">Update Now</a>').format( compare_url=url, 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.need_update(): if self.get_newest_commit_hash(): current = self.get_clean_version() newest = self.get_clean_version(self.get_newest_commit_hash()) url = f"https://github.com/{settings.GIT_ORG}/{settings.GIT_REPO}/compare/{current}...{newest}" else: url = f"https://github.com/{settings.GIT_ORG}/{settings.GIT_REPO}/commits/" newest_tag = "newer_version_available" update_url = self.get_update_url() newest_text = _( 'There is a <a href="{url}" onclick="window.open(this.href); return false;">newer version available</a> — <a href="{update_url}">Update Now</a>' .format(url=url, update_url=update_url)) else: return helpers.add_site_message(newest_text, tag=newest_tag, level="success")
def set_newest_text(self): if self.need_update(): if self.get_newest_commit_hash(): current = self.get_current_commit_hash().base_version newest = self.get_newest_commit_hash().base_version url = f'https://github.com/{settings.GIT_ORG}/{settings.GIT_REPO}/compare/{current}...{newest}' else: url = f'https://github.com/{settings.GIT_ORG}/{settings.GIT_REPO}/commits/' newest_tag = 'newer_version_available' update_url = self.get_update_url() newest_text = _( f'There is a <a href="{url}" onclick="window.open(this.href); return false;">' f'newer version available</a> — <a href="{update_url}">Update Now</a>' ) else: return helpers.add_site_message(newest_text, tag=newest_tag, level='success')