Exemplo n.º 1
0
 def is_installable(self):
     """Return if the framework can be installed on that arch"""
     if self.only_for_removal:
         return False
     try:
         if len(self.only_on_archs) > 0:
             # we have some restricted archs, check we support it
             current_arch = get_current_arch()
             if current_arch not in self.only_on_archs:
                 logger.debug(
                     "{} only supports {} archs and you are on {}.".format(
                         self.name, self.only_on_archs, current_arch))
                 return False
         if len(self.only_ubuntu_version) > 0:
             current_version = get_current_ubuntu_version()
             if current_version not in self.only_ubuntu_version:
                 logger.debug(
                     "{} only supports {} and you are on {}.".format(
                         self.name, self.only_ubuntu_version,
                         current_version))
                 return False
         if not RequirementsHandler().is_bucket_available(
                 self.packages_requirements):
             return False
     except:
         logger.error(
             "An error occurred when detecting platform, don't register {}".
             format(self.name))
         return False
     return True
Exemplo n.º 2
0
    def get_metadata_and_check_license(self, result):
        """Download files to download + license and check it"""
        logger.debug("Parse download metadata")

        error_msg = result[self.download_page].error
        if error_msg:
            logger.error("An error occurred while downloading {}: {}".format(self.download_page, error_msg))
            UI.return_main_screen(status_code=1)
        in_download = False
        sig_url = None
        for line in result[self.download_page].buffer:
            line_content = line.decode()
            (new_sig_url, in_download) = self.parse_download_link(line_content, in_download)
            if str(new_sig_url) > str(sig_url):
                # Avoid fetching development snapshots
                if 'DEVELOPMENT-SNAPSHOT' not in new_sig_url:
                    tmp_release = re.search("ubuntu(.....).tar", new_sig_url).group(1)
                    if tmp_release <= get_current_ubuntu_version():
                        sig_url = new_sig_url
        if not sig_url:
            logger.error("Download page changed its syntax or is not parsable")
            UI.return_main_screen(status_code=1)

        DownloadCenter(urls=[DownloadItem(sig_url, None), DownloadItem(self.asc_url, None)],
                       on_done=self.check_gpg_and_start_download, download=False)
Exemplo n.º 3
0
 def parse_download_link(self, line, in_download):
     """Parse RStudio download links"""
     url = None
     checksum = None
     if get_current_ubuntu_version().split('.')[0] < "18":
         ubuntu_version = 'trusty'
     else:
         ubuntu_version = 'bionic'
     if '-debian.tar.gz' in line:
         p = re.search(r'href=\"([^<]*{}.*-debian\.tar\.gz)\"'.format(ubuntu_version), line)
         with suppress(AttributeError):
             url = p.group(1)
             in_download = True
     if in_download and '<td><code>' in line:
         p = re.search('<td><code>(.*)</code></td>', line)
         with suppress(AttributeError):
             checksum = p.group(1)
     return ((url, checksum), in_download)
Exemplo n.º 4
0
 def is_installable(self):
     """Return if the framework can be installed on that arch"""
     try:
         if len(self.only_on_archs) > 0:
             # we have some restricted archs, check we support it
             current_arch = get_current_arch()
             if current_arch not in self.only_on_archs:
                 logger.debug("{} only supports {} archs and you are on {}.".format(self.name, self.only_on_archs,
                                                                                    current_arch))
                 return False
         if len(self.only_ubuntu_version) > 0:
             current_version = get_current_ubuntu_version()
             if current_version not in self.only_ubuntu_version:
                 logger.debug("{} only supports {} and you are on {}.".format(self.name, self.only_ubuntu_version,
                                                                              current_version))
                 return False
         if not RequirementsHandler().is_bucket_available(self.packages_requirements):
             return False
     except:
         logger.error("An error occurred when detecting platform, don't register {}".format(self.name))
         return False
     return True
Exemplo n.º 5
0
 def test_get_current_ubuntu_version(self, settings_module):
     """Current ubuntu version is reported from our lsb_release local file"""
     settings_module.LSB_RELEASE_FILE = self.get_lsb_release_filepath(
         "valid")
     self.assertEqual(get_current_ubuntu_version(), '14.04')
Exemplo n.º 6
0
 def test_get_current_ubuntu_version(self, settings_module):
     """Current ubuntu version is reported from our lsb_release local file"""
     settings_module.LSB_RELEASE_FILE = self.get_lsb_release_filepath("valid")
     self.assertEqual(get_current_ubuntu_version(), '14.04')