Exemplo n.º 1
0
def get_from_db(repo_name):
    #Find the repo_name in pisi db.
    found = False
    try:
        pisiapi.list_repos().index(repo_name)
        #sys.sysout.write("Repo %s found in pisi.\n" % repo_name)
    except:
        #If not found, Exit.
        sys.stderr.write("Repo %s not found.\n" % repo_name)
        sys.exit(1)

    #Delete Cache whether if it has our packages
    print "Deleting Pisi Cache..."
    pisiapi.delete_cache()
    print "Done."

    #Update Repos
    print "Updating Repo: %s..." % repo_name
    pisiapi.update_repos(["%s" % repo_name])
    print "Done."

    #Get package list in repo
    print "Generating package list..."
    package_list = pisiapi.list_available(repo_name)
    print "Done."

    #Install packages
    #TODO: With --reinstall maybe?
    print "Installing %s packages, please wait..." % len(package_list)
    pisiapi.install(package_list)
    print "Done."
def get_from_db(repo_name):
    # Find the repo_name in pisi db.
    found = False
    try:
        pisiapi.list_repos().index(repo_name)
        # sys.sysout.write("Repo %s found in pisi.\n" % repo_name)
    except:
        # If not found, Exit.
        sys.stderr.write("Repo %s not found.\n" % repo_name)
        sys.exit(1)

    # Delete Cache whether if it has our packages
    print "Deleting Pisi Cache..."
    pisiapi.delete_cache()
    print "Done."

    # Update Repos
    print "Updating Repo: %s..." % repo_name
    pisiapi.update_repos(["%s" % repo_name])
    print "Done."

    # Get package list in repo
    print "Generating package list..."
    package_list = pisiapi.list_available(repo_name)
    print "Done."

    # Install packages
    # TODO: With --reinstall maybe?
    print "Installing %s packages, please wait..." % len(package_list)
    pisiapi.install(package_list)
    print "Done."
Exemplo n.º 3
0
    def test_install_main(self):
        """Check the conditions and call the Pisi API to install the packages"""
        # Packages in the testcase file but not installed
        packagestNotInstalled = list(
            set(self.packagelist) - set(self.installedpackages))
        if not packagestNotInstalled:
            self.report.append('All the required packages are installed')
            self.summary.append('Success')
            return

        # Install only packages that are in all the available repositories
        packagesNotInRepo = list(
            set(packagestNotInstalled) - set((self.availablepackages)))
        if packagesNotInRepo:
            self.report.append('The following packages were not found in ' \
                    "the repository: '{0}'".format(', '.join(packagesNotInRepo)))

        # if none of the package to be installed was found in the repository
        # set the failcode to 0 and return. The installation won't continue
        if len(packagesNotInRepo) == len(self.packagelist):
            self.summary.append('Fail')
            self.failcode = 0
            return

        # Modify the package list and remove the packages which are not in the
        # repository. this is done so
        self.packagelist = list(set(self.packagelist) - set(packagesNotInRepo))

        # Only try installing those packages which are in the repository
        finalPackages = list(
            set(packagestNotInstalled) - set(packagesNotInRepo))
        totalPackages = len(finalPackages)
        if totalPackages == 0:
            self.report.append('No packages were installed')
            self.summary.append('Success')
            return

        # Calculate the download size and display it in MiB
        downloadSize = calculate_download_size(finalPackages)[0] / (1024.0 *
                                                                    1024.0)
        self.report.append('Number of packages to be installed: ' \
            "'{0}', total size: '{1:.2f} MiB'".format(totalPackages, downloadSize))
        print 'Installing packages, please wait ... ' \
                'Size:', colorize('{0:.2f} MiB', 'bold').format(downloadSize)
        counter = 0
        while counter < totalPackages:
            # Pisi installs new packages by using a list. However if we pass all the
            # packages as a single list, we don't have much control over the errors.
            # That is why pass a single package as a list here
            package = finalPackages[counter]
            singlePackage = package.split()
            try:
                install(singlePackage)
            except PrivilegeError:  # in case the user doesn't have permission
                self.report.append('Error: To install the packages, ' \
                                        'run the framework with root privileges')
                self.failcode = 0  # for the testcases gui, shell and automated
                print colorize('Failed: Privilege error. Run as root user.',
                               'red')
                self.summary.append('Fail')
                return
            counter += 1
        self.report.append("Finished installing the following " \
                            "packages: '{0}'".format(', '.join(finalPackages)))
        self.summary.append('Success')
Exemplo n.º 4
0
 def test_install_main(self):
     """Check the conditions and call the Pisi API to install the packages"""
     # Packages in the testcase file but not installed
     packagestNotInstalled = list(set(self.packagelist) -
                                  set(self.installedpackages))
     if not packagestNotInstalled:
         self.report.append('All the required packages are installed')
         self.summary.append('Success')
         return
    
     # Install only packages that are in all the available repositories
     packagesNotInRepo = list(set(packagestNotInstalled) -
                              set((self.availablepackages)))
     if packagesNotInRepo:
         self.report.append('The following packages were not found in ' \
                 "the repository: '{0}'".format(', '.join(packagesNotInRepo)))
     
     # if none of the package to be installed was found in the repository
     # set the failcode to 0 and return. The installation won't continue
     if len(packagesNotInRepo) == len(self.packagelist):
         self.summary.append('Fail')
         self.failcode = 0
         return
     
     # Modify the package list and remove the packages which are not in the
     # repository. this is done so 
     self.packagelist = list(set(self.packagelist) - set(packagesNotInRepo))
    
     # Only try installing those packages which are in the repository
     finalPackages = list(set(packagestNotInstalled) - set(packagesNotInRepo))
     totalPackages = len(finalPackages)
     if totalPackages == 0:
         self.report.append('No packages were installed')
         self.summary.append('Success')
         return
     
     # Calculate the download size and display it in MiB        
     downloadSize = calculate_download_size(finalPackages)[0]/(1024.0 * 1024.0)
     self.report.append('Number of packages to be installed: ' \
         "'{0}', total size: '{1:.2f} MiB'".format(totalPackages, downloadSize))
     print 'Installing packages, please wait ... ' \
             'Size:', colorize('{0:.2f} MiB', 'bold').format(downloadSize)
     counter = 0 
     while counter < totalPackages:
         # Pisi installs new packages by using a list. However if we pass all the
         # packages as a single list, we don't have much control over the errors.
         # That is why pass a single package as a list here
         package = finalPackages[counter]
         singlePackage = package.split()
         try:
             install(singlePackage)
         except PrivilegeError:      # in case the user doesn't have permission
             self.report.append('Error: To install the packages, ' \
                                     'run the framework with root privileges')
             self.failcode = 0       # for the testcases gui, shell and automated
             print colorize('Failed: Privilege error. Run as root user.', 'red')
             self.summary.append('Fail')
             return
         counter += 1
     self.report.append("Finished installing the following " \
                         "packages: '{0}'".format(', '.join(finalPackages)))
     self.summary.append('Success')