Esempio n. 1
0
    def __init__(self, ros_distro, sudo=False):
        """
        Initializes rosdep database and builds necessary dictionaries

        ros_distro -- string of ROS version
        sudo -- whether commands should be executed with sudo (default False)
        """
        self.r2a = {}
        self.a2r = {}
        self.env = os.environ
        self.env['ROS_DISTRO'] = ros_distro

        print "Initalize rosdep database"
        apt_get_install(['lsb-release', 'python-rosdep'], sudo=sudo)
        try:
            call("rosdep init", self.env)
        except:
            print "Rosdep is already initialized"
        call("rosdep update", self.env)

        print "Building dictionaries from a rosdep's db"
        raw_db = call("rosdep db", self.env, verbose=False).split('\n')

        for entry in raw_db:
            split_entry = entry.split(' -> ')
            if len(split_entry) < 2:
                continue
            ros_entry = split_entry[0]
            apt_entries = split_entry[1].split(' ')
            self.r2a[ros_entry] = apt_entries
            for a_e in apt_entries:
                self.a2r[a_e] = ros_entry
Esempio n. 2
0
    def __init__(self, ros_distro, sudo=False):
        """
        Initializes rosdep database and builds necessary dictionaries

        ros_distro -- string of ROS version
        sudo -- whether commands should be executed with sudo (default False)
        """
        self.r2a = {}
        self.a2r = {}
        self.env = os.environ
        self.env['ROS_DISTRO'] = ros_distro

        print "Initalize rosdep database"
        apt_get_install(['lsb-release', 'python-rosdep'], sudo=sudo)
        try:
            call("rosdep init", self.env)
        except:
            print "Rosdep is already initialized"
        call("rosdep update", self.env)

        print "Building dictionaries from a rosdep's db"
        raw_db = call("rosdep db", self.env, verbose=False).split('\n')

        for entry in raw_db:
            split_entry = entry.split(' -> ')
            if len(split_entry) < 2:
                continue
            ros_entry = split_entry[0]
            apt_entries = split_entry[1].split(' ')
            self.r2a[ros_entry] = apt_entries
            for a_e in apt_entries:
                self.a2r[a_e] = ros_entry
Esempio n. 3
0
 def test__apt_get_install__input_with_rosdep__check_(self, mock_call):
     mock_rosdep = MagicMock()
     common.apt_get_install(['test-package'], rosdep=mock_rosdep)
     mock_rosdep.to_aptlist.assert_called_once_with(['test-package'])
Esempio n. 4
0
 def test__apt_get_install__input_with_sudo__check_correct_call_calling(
         self, mock_call):
     common.apt_get_install(['test-package'], sudo=True)
     mock_call.assert_called_once_with(
         "sudo apt-get install --yes test-package")
Esempio n. 5
0
 def test__apt_get_install__input_empty_list__check_correct_call_calling(
         self, mock_call):
     common.apt_get_install([])
     self.assertEqual(mock_call.call_count, 0)
Esempio n. 6
0
 def test__apt_get_install__input_list__check_correct_call_calling(self):
     with patch('jenkins_setup.common.call') as mock_call:
         common.apt_get_install(['test-package'])
         mock_call.assert_called_once_with(
             "apt-get install --yes test-package")
Esempio n. 7
0
 def test__apt_get_install__input_with_rosdep__check_(self, mock_call):
     mock_rosdep = MagicMock()
     common.apt_get_install(['test-package'], rosdep=mock_rosdep)
     mock_rosdep.to_aptlist.assert_called_once_with(['test-package'])
Esempio n. 8
0
 def test__apt_get_install__input_empty_list__check_correct_call_calling(self, mock_call):
     common.apt_get_install([])
     self.assertEqual(mock_call.call_count, 0)
Esempio n. 9
0
 def test__apt_get_install__input_with_sudo__check_correct_call_calling(self, mock_call):
     common.apt_get_install(['test-package'], sudo=True)
     mock_call.assert_called_once_with("sudo apt-get install --yes test-package")
Esempio n. 10
0
 def test__apt_get_install__input_list__check_correct_call_calling(self):
     with patch('jenkins_setup.common.call') as mock_call:
         common.apt_get_install(['test-package'])
         mock_call.assert_called_once_with("apt-get install --yes test-package")