Ejemplo n.º 1
0
    def _install_pip3_packages(self):
        """Install PIP3 packages.

        Args:
            None

        Returns:
            None

        """
        # Initialize key variables
        username = self.username

        # Don't attempt to install packages if running in the Travis CI
        # environment
        if 'TRAVIS' in os.environ and 'CI' in os.environ:
            return

        # Determine whether PIP3 exists
        shared.print_ok(
            'Installing required pip3 packages from requirements.txt file.')
        pip3 = general.search_file('pip3')
        if pip3 is None:
            log_message = ('Cannot find python "pip3". Please install.')
            log.log2die_safe(1052, log_message)

        # Install required PIP packages
        requirements_file = ('%s/requirements.txt') % (
            general.root_directory())

        if username == 'root':
            script_name = ('pip3 install --upgrade --requirement %s'
                           '') % (requirements_file)
        else:
            script_name = ('pip3 install --user --upgrade --requirement %s'
                           '') % (requirements_file)
        general.run_script(script_name)

        # Status message
        shared.print_ok('pip3 packages installation complete.')
Ejemplo n.º 2
0
 def test_search_file(self):
     """Test function search_file."""
     # Initialize key variables
     result = general.search_file('cat')
     self.assertEqual(result, '/bin/cat')