def check_electron_installed(self, version: str, is_x86_x64_arch: bool) -> Dict[str, bool]: self.logger.info( "Checking if Electron {} is installed".format(version)) res = {'electron': False, 'sha256': False} if not os.path.exists(ELECTRON_PATH): self.logger.info( "The Electron folder {} was not found".format(ELECTRON_PATH)) else: files = os.listdir(ELECTRON_PATH) if files: file_name = self._get_electron_url( version, is_x86_x64_arch).split('/')[-1] res['electron'] = bool([f for f in files if f == file_name]) if not res['electron']: res['sha256'] = True else: file_name = ELECTRON_SHA256_URL.split( '/')[-1] + '-{}'.format(version) res['sha256'] = bool([f for f in files if f == file_name]) else: self.logger.info( 'No Electron file found in {}'.format(ELECTRON_PATH)) for att in ('electron', 'sha256'): if res[att]: self.logger.info('{} ({}) already downloaded'.format( att, version)) return res
def _check_and_fill_electron(self, pkg: WebApplication, env: dict, local_config: dict, x86_x64: bool, output: List[EnvironmentComponent]): electron_version = env['electron']['version'] if pkg.version and pkg.version != electron_version: self.logger.info( 'A preset Electron version is defined for {}: {}'.format( pkg.url, pkg.version)) electron_version = pkg.version if local_config['environment']['electron']['version']: self.logger.warning( "A custom Electron version will be used {} to install {}". format(electron_version, pkg.url)) electron_version = local_config['environment']['electron'][ 'version'] electron_status = self.check_electron_installed( version=electron_version, is_x86_x64_arch=x86_x64) electron_url = self._get_electron_url(version=electron_version, is_x86_x64_arch=x86_x64) output.append( EnvironmentComponent( name=electron_url.split('/')[-1], version=electron_version, url=electron_url, size=self.http_client.get_content_length(electron_url), id='electron', update=not electron_status['electron'])) sha_url = ELECTRON_SHA256_URL.format(version=electron_version) output.append( EnvironmentComponent( name=sha_url.split('/')[-1], version=electron_version, url=sha_url, size=self.http_client.get_content_length(sha_url), id='electron_sha256', update=not electron_status['electron'] or not electron_status['sha256']))
def _get_electron_sha256_url(self, version: str, widevine: bool) -> str: if widevine: return ELECTRON_WIDEVINE_SHA256_URL.format(version=version) else: return ELECTRON_SHA256_URL.format(version=version)