Ejemplo n.º 1
0
    def _display_interaction_info(self, Item):
        """
        Display the currently selected interaction's information. Triggered
        when single-clicking on it in the interactions list view.
        """
        list_widget = Item.listWidget()
        cur_index = list_widget.count() - list_widget.currentRow() - 1
        for k in self.interactions.values():
            if(k.index == cur_index):
                self.cur_selected_interaction = k
                break
        self.interactions_widget.app_info.clear()
        info_text = "<html>"
        info_text += "<p>-------------------------------------------</p>"
        web_interaction = web_interactions.parse(self.cur_selected_interaction.name)
        name = self.cur_selected_interaction.name if web_interaction is None else web_interaction.url
        info_text += "<p><b>name: </b>" + name + "</p>"
        info_text += "<p><b>  ---------------------</b>" + "</p>"
        info_text += "<p><b>compatibility: </b>" + self.cur_selected_interaction.compatibility + "</p>"
        info_text += "<p><b>display name: </b>" + self.cur_selected_interaction.display_name + "</p>"
        info_text += "<p><b>description: </b>" + self.cur_selected_interaction.description + "</p>"
        info_text += "<p><b>namespace: </b>" + self.cur_selected_interaction.namespace + "</p>"
        info_text += "<p><b>max: </b>" + str(self.cur_selected_interaction.max) + "</p>"
        info_text += "<p><b>  ---------------------</b>" + "</p>"
        info_text += "<p><b>remappings: </b>" + str(self.cur_selected_interaction.remappings) + "</p>"
        info_text += "<p><b>parameters: </b>" + str(self.cur_selected_interaction.parameters) + "</p>"
        info_text += "</html>"

        self.interactions_widget.app_info.appendHtml(info_text)
        self._set_stop_interactions_button()
def test_bad_web_interactions():
    print(
        console.bold +
        "\n****************************************************************************************"
        + console.reset)
    print(console.bold + "* Invalid Web Interactions" + console.reset)
    print(
        console.bold +
        "****************************************************************************************"
        + console.reset)
    print("")

    web_interaction = web_interactions.parse(undecorated_web_url)
    assert_is_none(web_interaction)
    web_interaction = web_interactions.parse(not_a_web_interaction)
    assert_is_none(web_interaction)
def test_web_app():
    print(
        console.bold +
        "\n****************************************************************************************"
        + console.reset)
    print(console.bold + "* Valid Web Apps" + console.reset)
    print(
        console.bold +
        "****************************************************************************************"
        + console.reset)
    print("")

    for example_app in [example_web_app, example_web_app_with_quotes]:
        web_interaction = web_interactions.parse(example_app)
        assert_is_not_none(web_interaction)
        assert_false(web_interaction.is_web_url())
        assert_true(web_interaction.is_web_app())
def test_web_urls():
    print(
        console.bold +
        "\n****************************************************************************************"
        + console.reset)
    print(console.bold + "* Valid Web URL's" + console.reset)
    print(
        console.bold +
        "****************************************************************************************"
        + console.reset)
    print("")

    for example_url in [example_web_url, example_web_url_with_quotes]:
        web_interaction = web_interactions.parse(example_url)
        assert_is_not_none(web_interaction)
        assert_true(web_interaction.is_web_url(),
                    "A web url should be a web url")
        assert_false(web_interaction.is_web_app(),
                     "A web url is not a web app")
Ejemplo n.º 5
0
 def _determine_interaction_type(self, interaction):
     '''
       Classifies the interaction based on the name string and some intelligent
       (well, reasonably) parsing of that string.
        - paired dummy (by empty name)
        - ros launcher (by .launch extension)
        - ros runnable (by roslib find_resource success)
        - web app      (by web_interactions.parse)
        - web url      (by web_interactions.parse)
        - global executable (fallback option)
     '''
     # pairing trigger (i.e. dummy interaction)
     if not interaction.name:
         console.logdebug(
             "Interactive Client : start a dummy interaction for triggering a pair"
         )
         return ('', self._start_dummy_interaction)
     # roslaunch
     try:
         launcher_filename = rocon_python_utils.ros.find_resource_from_string(
             interaction.name, extension='launch')
         if interaction.remappings:
             raise rocon_interactions.InvalidInteraction(
                 "remappings are not yet enabled for roslaunchable interactions (workaround: try remapping via interaction parameters and roslaunch args)[%s]"
                 % interaction.name)
         console.logdebug("Interactive Client : roslaunchable [%s]" %
                          interaction.name)
         return (launcher_filename, self._start_roslaunch_interaction)
     except (rospkg.ResourceNotFound, ValueError):
         unused_filename, extension = os.path.splitext(interaction.name)
         if extension == '.launch':
             raise rocon_interactions.InvalidInteraction(
                 "could not find %s on the filesystem" % interaction.name)
         else:
             pass
     # rosrun
     try:
         rosrunnable_filename = rocon_python_utils.ros.find_resource_from_string(
             interaction.name)
         console.logdebug(
             "Interactive Client : start_app_rosrunnable [%s]" %
             interaction.name)
         return (rosrunnable_filename, self._start_rosrunnable_interaction)
     except rospkg.ResourceNotFound:
         pass
     except Exception:
         pass
     # web url/app
     web_interaction = web_interactions.parse(interaction.name)
     if web_interaction is not None:
         if web_interaction.is_web_url():
             console.logdebug(
                 "Interactive Client : _start_weburl_interaction [%s]" %
                 web_interaction.url)
             return (web_interaction.url, self._start_weburl_interaction)
         elif web_interaction.is_web_app():
             console.logdebug(
                 "Interactive Client : _start_webapp_interaction [%s]" %
                 web_interaction.url)
             return (web_interaction.url, self._start_webapp_interaction)
     # executable
     if rocon_python_utils.system.which(interaction.name) is not None:
         console.logdebug(
             "Interactive Client : _start_global_executable_interaction [%s]"
         )
         return (interaction.name,
                 self._start_global_executable_interaction)
     else:
         raise rocon_interactions.InvalidInteraction(
             "could not find a valid rosrunnable or global executable for '%s' (mispelt, not installed?)"
             % interaction.name)