Esempio n. 1
0
 def _installGPG(self, phase=0, dt=None):
     if getPlatform() == PLATFORM_MAC:
         # TODO handle errors
         if phase == 0:
             self._ui.setInteractive(False)
             
             self._setStatus("Searching for latest version...")
             dt = DownloadThread(getValidQtParent(), self.logger, "https://gpgtools.org/releases/macgpg2/appcast.xml")
             dt.success.connect(partial(self._install_gpg_finished, 0))
             dt.error.connect(partial(self._install_gpg_failed, 0))
             dt.start()
             
         elif phase == 1:
             xmlContent = dt.getResult()
             dt.close()
             
             e = ElementTree.fromstring(xmlContent)
             dmgURL = e.iter("channel").next().iter("item").next().iter("enclosure").next().attrib["url"]
             
             tmpFile = tempfile.NamedTemporaryFile(suffix=".dmg", prefix="macgpg", delete=False)
             self.logger.debug("Downloading %s to %s", dmgURL, tmpFile.name)
             self._setStatus("Downloading MacGPG...", progress=True)
             self._ui.setProgress(0)
             
             dt = DownloadThread(getValidQtParent(), self.logger, dmgURL, target=tmpFile, progress=True)
             dt.success.connect(partial(self._install_gpg_finished, 1))
             dt.error.connect(partial(self._install_gpg_failed, 1))
             dt.progressChanged.connect(self._downloadProgressChanged)
             dt.start()
             
         elif phase == 2:
             # indeterminate
             self._ui.setProgressIndeterminate(True)
             self._setStatus("Installing MacGPG...", progress=True)
             
             dmgFile = dt.target.name
             dt.close()
             
             st = ShellThread(getValidQtParent(), self.logger, [get_settings().get_resource('bin', 'mac_gpg_installer.sh'), dmgFile], context=dmgFile, quiet=False)
             st.finished.connect(partial(self._install_gpg_finished, 2))
             st.start()
             
         elif phase == 3:
             dmgFile = dt.context
             if os.path.exists(dmgFile):
                 os.remove(dmgFile)
             
             self._ui.setProgressIndeterminate(False)
             if dt.exitCode == 0:
                 self._setStatus("MacGPG installed successfully.")
             else:
                 self._setStatus("Error installing MacGPG.", err=True)
                 if dt.pErr:
                     self.logger.error("Error installing MacGPG.\nConsole output: %s", dt.pErr.strip())
             
             self._updateCheckButtonText()
             self._ui.setInteractive(True)
 def update_reports(self):
     self.refresh_btn.setEnabled(False)
     repoUser = self.mt.options[u"repo_user"]
     repoName = self.mt.options[u"repo_name"]
     if repoUser and repoName:
         log_debug("Fetching issues from repository %s/%s" % (repoUser, repoName))
         thread = DownloadThread(self, "https://api.github.com/repos/%s/%s/issues?state=open" % (repoUser, repoName))
         thread.finished.connect(thread.deleteLater)
         thread.error.connect(self.errorDownloadingIssues)
         thread.success.connect(self.downloadedIssues)
         thread.start()
     else:
         log_warning("No Lunchinator GitHub repository specified.")
 def update(self):
     if not self.isVisible():
         return
      
     if self.pic_url is not None:
         thread = DownloadThread(self, self.logger, self.pic_url, no_proxy = self.no_proxy)
         thread.finished.connect(thread.deleteLater)
         thread.error.connect(self.errorDownloading)
         thread.success.connect(self.downloadFinished)
         thread.start()
     elif self.pic_path is not None:
         super(ResizingWebImageLabel, self).setImage(self.pic_path)
     else:
         self.displayFallbackPic()
     return True
 def _extractPicture(self, url, category, description, sender):
     if not self._hasPicture(category, url):
         ext = os.path.splitext(urlparse(url.encode('utf-8')).path)[1]
         if self._storeLocally:
             target = self._createPictureFile(category, ext=ext)
         else:
             target = tempfile.NamedTemporaryFile(suffix=ext)
         
         downloadThread = DownloadThread(self, self.logger, url, target)
         downloadThread.success.connect(partial(self._downloadedPicture, category, description, sender))
         downloadThread.error.connect(self._errorDownloadingPicture)
         downloadThread.finished.connect(downloadThread.deleteLater)
         downloadThread.start()
     else:
         self.logger.debug("Remote Pics: Downloaded this url before, won't do it again: %s", url)
Esempio n. 5
0
 def checkForUpdate(self):
     if not self._has_gpg():
         # user clicked on "Install GPG"
         return self._installGPG()
     
     self._setStatus("Checking %s for Update..."%self._urlBase)
     
     if self._getCheckURLBase() == None:
         self._setStatus("Auto Update does not work on your OS yet.", True)
         return
     
     url = self._getCheckURLBase() + "/latest_version.asc"
     version_download = DownloadThread(getValidQtParent(), self.logger, url)
     version_download.success.connect(self._versionInfoDownloaded)
     version_download.error.connect(self._errorDownloading)
     version_download.finished.connect(version_download.deleteLater)
     version_download.start()
Esempio n. 6
0
 def _versionInfoDownloaded(self, thread, _url):
     try:
         signedString = thread.getResult()
     except:
         self._setStatus("Version info not available", True)
         return
     
     self.logger.debug("Update: Got version info, checking signature %s", signedString)
     
     ver_result = False
     try:
         ver_result = self._verifySignature(signedString)
     except:
         self.logger.exception("Error verifying signature")
         self._setStatus("Signature could not be verified because of unknown error", True)
         return
     
     if not ver_result:
         self._setStatus("Signature could not be verified", True)
         return
             
     self.logger.debug("Updater: Signature OK, checking version info")
     
     for l in signedString.splitlines():
         info = l.split(":", 1)
         if len(info) > 1:
             self._version_info[info[0]] = info[1].strip()
             
     if not self._version_info.has_key("URL") or not self._version_info.has_key("Commit Count"):
         self._setStatus("Version Info corrupt - URL and/or Commit Count missing", True)
         self.logger.debug(str(self._version_info))
         return
     else:
         try:
             self._version_info["Commit Count"] = int(self._version_info["Commit Count"])
         except:
             self._setStatus("Commit Count has wrong format: " % self._version_info["Commit Count"], True)
             return
             
     self._updateVersionLabel()
     
     self._installer_url = self._getCheckURLBase() + self._version_info["URL"]
     self._local_installer_file = os.path.join(get_settings().get_main_config_dir(), self._installer_url.rsplit('/', 1)[1])
     
     if self._hasNewVersion() and u"Change Log" in self._version_info:
         try:
             changeLog = json.loads(self._version_info[u"Change Log"])
             self._setChangeLog(changeLog)
         except:
             self.logger.exception("Error reading change log.")
             self._setChangeLog(["Error loading change log"])
     
     if self._hasNewVersion():
         # check if we already downloaded this version before
         if not self._checkHash(errorOnBadHash=False):
             self._setStatus("New version %s available, downloading ..." % (self._getDownloadedVersion()), progress=True)
             
             installer_download = DownloadThread(getValidQtParent(), self.logger, self._installer_url, target=open(self._local_installer_file, "wb"), progress=True)
             installer_download.progressChanged.connect(self._downloadProgressChanged)
             installer_download.success.connect(self._installerDownloaded)
             installer_download.error.connect(self._errorDownloading)
             installer_download.finished.connect(installer_download.deleteLater)
             installer_download.start()
     else:
         self._setStatus("No new version available")