Example #1
0
	def start_package_install(self):
		d = Main.WebParser.WebServices.get_packages_data()
		
		for i, component in enumerate(self.components):
			urls, file_hash, install_param = d[component]
			fn = urls[0].split('/')[-1]
			
			log.debug("Downloading Component %s [%d/%d]..." % (component, i+1, len(self.components)))
			self.label1.setText(tr("Downloading %s...") % component)
			self.label2.setText(tr("File: <i>%s</i> [%d/%d]") % (fn, i+1, len(self.components)))
			
			for j in range(self.retries):
				obj = SmartDL(urls, logger=log)
				obj.start(blocking=False)
				
				b = True
				while not obj.isFinished():
					if b:
						self.label1.setText(tr("Downloading %s (%.2f MB)...") % (component, obj.filesize/1024.0**2))
						b = False
					QtGui.QApplication.processEvents()
					self.prg_bar.setValue(int(obj.get_progress()*100))
					time.sleep(0.1)
				if obj._failed:
					QtGui.QMessageBox.critical(self, tr("Error"), tr("The download has failed. It may be a network connection problem. Please try to rerun this application and try again."), QtGui.QMessageBox.Ok)
					self.close()
				self.prg_bar.setValue(100)
					
				computed_hash = utils.calc_sha256(obj.get_dest())
				if file_hash == computed_hash:
					log.debug('Hash for %s is valid.' % component)
					break
				else:
					log.warning('Hash for %s is NOT valid (%s != %s). Retrying (%d/%d)...' % (component, file_hash, computed_hash, j+1, self.retries))	
				
			if file_hash != computed_hash:
				log.error('Hash for %s is NOT valid (%s != %s).' % (component, file_hash, computed_hash))
				QtGui.QMessageBox.warning(self, tr("Warning"), tr("Hash check failed for %s. Please contact with the program's developer.") % component, QtGui.QMessageBox.Ok)
				self.close()
				return
				
			path = obj.get_dest()
			install_params = [path] + install_param
				
			self.label1.setText(tr("Installing %s...") % component)
			subprocess.call(install_params, shell=True)
			QtGui.QApplication.processEvents()
		
		self.close()
Example #2
0
				log.error("Could not check for the newest version (%s)" % unicode(e))
		
		# External Components Check
		hash_failed = []
		not_exists = []
		
		d = WebParser.WebServices.get_components_data()
		for name, t in d.items():
			urls, archive_hash, file_to_extract, file_hash = t
			
			if not os.path.exists(os.path.join(config.ext_bin_path, file_to_extract)):
				log.warning('External component was not found: %s' % name)
				not_exists.append(name)
				continue
			
			computed_hash = utils.calc_sha256(os.path.join(config.ext_bin_path, file_to_extract))
			if file_hash != computed_hash:
				log.warning('External components hash check failed for %s' % name)
				hash_failed.append(name)
				continue
		if hash_failed or not_exists:
			_warnings.append(ComponentsFaultyWarning(hash_failed+not_exists))
		else:
			log.debug('External components hash check passed')
			
		if not _warnings:
			config.last_sanity_check_timestamp = time.time()
	else:
		log.debug('Last successful sanity check was launched %d minutes ago. Skipping...' % math.ceil(timestamp/60))
	
	return _warnings
Example #3
0
    def start_package_install(self):
        d = Main.WebParser.WebServices.get_packages_data()

        for i, component in enumerate(self.components):
            urls, file_hash, install_param = d[component]
            fn = urls[0].split('/')[-1]

            log.debug("Downloading Component %s [%d/%d]..." %
                      (component, i + 1, len(self.components)))
            self.label1.setText(tr("Downloading %s...") % component)
            self.label2.setText(
                tr("File: <i>%s</i> [%d/%d]") %
                (fn, i + 1, len(self.components)))

            for j in range(self.retries):
                obj = Main.SmartDL(urls, logger=log)
                obj.start()

                b = True
                while not obj.isFinished():
                    if b:
                        self.label1.setText(
                            tr("Downloading %s (%.2f MB)...") %
                            (component, obj.filesize / 1024.0**2))
                        b = False
                    QtGui.QApplication.processEvents()
                    self.prg_bar.setValue(int(obj.get_progress() * 100))
                    time.sleep(0.1)
                if obj._failed:
                    QtGui.QMessageBox.critical(
                        self, tr("Error"),
                        tr("The download has failed. It may be a network connection problem. Please try to rerun this application and try again."
                           ), QtGui.QMessageBox.Ok)
                    self.close()
                self.prg_bar.setValue(100)

                computed_hash = utils.calc_sha256(obj.get_dest())
                if file_hash == computed_hash:
                    log.debug('Hash for %s is valid.' % component)
                    break
                else:
                    log.warning(
                        'Hash for %s is NOT valid (%s != %s). Retrying (%d/%d)...'
                        % (component, file_hash, computed_hash, j + 1,
                           self.retries))

            if file_hash != computed_hash:
                log.error('Hash for %s is NOT valid (%s != %s).' %
                          (component, file_hash, computed_hash))
                QtGui.QMessageBox.warning(
                    self, tr("Warning"),
                    tr("Hash check failed for %s. Please contact with the program's developer."
                       ) % component, QtGui.QMessageBox.Ok)
                self.close()

            path = obj.get_dest()
            install_params = [path] + install_param

            self.label1.setText(tr("Installing %s...") % component)
            subprocess.call(install_params, shell=True)
            QtGui.QApplication.processEvents()

        self.close()
Example #4
0
        # External Components Check
        hash_failed = []
        not_exists = []

        d = WebParser.WebServices.get_components_data()
        for name, t in d.items():
            urls, archive_hash, file_to_extract, file_hash = t

            if not os.path.exists(
                    os.path.join(config.ext_bin_path, file_to_extract)):
                log.warning('External component was not found: %s' % name)
                not_exists.append(name)
                continue

            computed_hash = utils.calc_sha256(
                os.path.join(config.ext_bin_path, file_to_extract))
            if file_hash != computed_hash:
                log.warning('External components hash check failed for %s' %
                            name)
                hash_failed.append(name)
                continue
        if hash_failed or not_exists:
            _warnings.append(ComponentsFaultyWarning(hash_failed + not_exists))
        else:
            log.debug('External components hash check passed')

        if not _warnings:
            config.last_sanity_check_timestamp = time.time()
    else:
        log.debug(
            'Last successful sanity check was launched %d minutes ago. Skipping...'