Exemplo n.º 1
0
def cmd_persist_config(config,
                       filename,
                       header=None,
                       pretty=False,
                       sort_with_localname=False):
    """writes config to given file in yaml syntax"""
    generate_config_yaml(config, filename, header, pretty, sort_with_localname)
Exemplo n.º 2
0
def cmd_persist_config(config, filename, header=None,
                       pretty=False, sort_with_localname=False,
                       spec=True, exact=False, vcs_only=False):
    """writes config to given file in yaml syntax"""
    generate_config_yaml(config, filename, header,
                         pretty, sort_with_localname,
                         spec, exact, vcs_only)
Exemplo n.º 3
0
 def test_source_setup_sh(self):
     test_folder = os.path.join(self.test_root_path, 'workspacetest')
     os.makedirs(test_folder)
     othersetupfile = os.path.join(test_folder, 'othersetup.sh')
     testsetupfile = os.path.join(test_folder, 'testsetup.sh')
     with open(othersetupfile, 'w') as fhand:
         fhand.write('unset ROS_WORKSPACE')
     config = Config([
         PathSpec(self.ros_path),
         PathSpec(othersetupfile, scmtype=None, tags=['setup-file'])
     ],
                     install_path=test_folder,
                     config_filename=ROSINSTALL_FILENAME)
     result = rosinstall.setupfiles.generate_setup_sh_text(
         config.get_base_path())
     self.assertTrue('export ROS_WORKSPACE=%s' % test_folder in result)
     with open(testsetupfile, 'w') as fhand:
         fhand.write(result)
     # check that sourcing setup.sh raises error when .wstool is missing
     raised = False
     try:
         subprocess.check_call(". %s" % testsetupfile,
                               shell=True,
                               env=self.new_environ)
     except:
         raised = True
     self.assertTrue(raised,
                     'sourcing setup.sh with missing .wstool should fail')
     # test that our otherscript really unsets ROS_WORKSPACE, else nexttest would be invalid
     # using basename to check var is not set
     raised = False
     try:
         cmd = "export ROS_WORKSPACE=foo && . %s && basename $ROS_WORKSPACE" % othersetupfile
         subprocess.check_call(cmd, shell=True, env=self.new_environ)
     except:
         raised = True
     self.assertTrue(raised, 'unsetting-sh-file did not unset var')
     # now test that when sourcing setup.sh that contains a
     # setup-file to other sh file which unsets ROS_WORKSPACE,
     # ROS_WORKSPACE is still set in the end
     generate_config_yaml(config, ROSINSTALL_FILENAME, '')
     self.assertTrue(
         os.path.isfile(os.path.join(test_folder, ROSINSTALL_FILENAME)))
     # using basename to check var is set
     cmd = "export ROS_WORKSPACE=foo && . %s && echo $ROS_WORKSPACE" % testsetupfile
     po = subprocess.Popen(cmd,
                           shell=True,
                           cwd=test_folder,
                           stdout=subprocess.PIPE)
     workspace = po.stdout.read().decode('UTF-8').rstrip('"').lstrip(
         '"').strip()
     po.stdout.close()
     self.assertEqual(test_folder, workspace)
Exemplo n.º 4
0
 def test_source_setup_sh(self):
     test_folder = os.path.join(self.test_root_path, 'workspacetest')
     os.makedirs(test_folder)
     othersetupfile = os.path.join(test_folder, 'othersetup.sh')
     testsetupfile = os.path.join(test_folder, 'testsetup.sh')
     with open(othersetupfile, 'w') as fhand:
         fhand.write('unset ROS_WORKSPACE')
     config = Config([PathSpec(self.ros_path),
                      PathSpec(othersetupfile,
                               scmtype=None,
                               tags=['setup-file'])],
                     install_path=test_folder,
                     config_filename=ROSINSTALL_FILENAME)
     result = rosinstall.setupfiles.generate_setup_sh_text(config.get_base_path())
     self.assertTrue('export ROS_WORKSPACE=%s' % test_folder in result)
     with open(testsetupfile, 'w') as fhand:
         fhand.write(result)
     # check that sourcing setup.sh raises error when .wstool is missing
     raised = False
     try:
         subprocess.check_call(". %s" % testsetupfile , shell=True, env=self.new_environ)
     except:
         raised = True
     self.assertTrue(raised, 'sourcing setup.sh with missing .wstool should fail')
     # test that our otherscript really unsets ROS_WORKSPACE, else nexttest would be invalid
     # using basename to check var is not set
     raised = False
     try:
         cmd = "export ROS_WORKSPACE=foo && . %s && basename $ROS_WORKSPACE" % othersetupfile
         subprocess.check_call(
             cmd,
             shell=True,
             env=self.new_environ)
     except:
         raised = True
     self.assertTrue(raised, 'unsetting-sh-file did not unset var')
     # now test that when sourcing setup.sh that contains a
     # setup-file to other sh file which unsets ROS_WORKSPACE,
     # ROS_WORKSPACE is still set in the end
     generate_config_yaml(config, ROSINSTALL_FILENAME, '')
     self.assertTrue(os.path.isfile(os.path.join(test_folder, ROSINSTALL_FILENAME)))
     # using basename to check var is set
     cmd = "export ROS_WORKSPACE=foo && . %s && echo $ROS_WORKSPACE" % testsetupfile
     po = subprocess.Popen(cmd, shell=True, cwd=test_folder, stdout=subprocess.PIPE)
     workspace = po.stdout.read().decode('UTF-8').rstrip('"').lstrip('"').strip()
     po.stdout.close()
     self.assertEqual(test_folder, workspace)
Exemplo n.º 5
0
def cmd_persist_config(config, filename, header=None):
    """writes config to given file in yaml syntax"""
    generate_config_yaml(config, filename, header)
Exemplo n.º 6
0
 def write(self):
     """Write to .rosinstall in workspace"""
     config_yaml.generate_config_yaml(self.wstool_config,
                                      self.src + ".rosinstall", "")