def on_run(self, event):
        # ask for save before run if script has been modified
        if self.stc.GetModify():
            answer = cjr.confirm_yes_no(
                            self,
                            "Save changes to '%s' ?" % self.filename
                            )
            if answer == wx.ID_YES:
                self.save(True)
            elif answer == wx.ID_CANCEL:
                return

        if self.filename == "":
            cjr.show_information_message(
                "I'm quite stupid, so please you Supreme Intelligence\n" \
                "save the file so I can look at its extension and know\n" \
                "which file type this script is."
                )
        if self.filename.endswith('.lua'):
            servers.get_lua_server().runscript(
                str( format.mangle_path(self.filename) )
                )
        elif self.filename.endswith('.py'):
            servers.get_python_server().runscript(
                str( format.mangle_path(self.filename) )
                )
def get_button(inspector_win):
    # make this object the current
    nebulagui.nebula_object = inspector_win.object

    # Construct the get command        

    cmd_name = inspector_win.cmds.GetValue()
    get_cmd_name = "get" + cmd_name[3:]

    # Execute the get command

    command = "import nebulagui;import savecmdsinspector;"
    command = command + "savecmdsinspector.result = nebulagui.nebula_object.%s" % get_cmd_name + "()"
    servers.get_python_server().run(str(command))

    # The in arguments of set commands are always the out arguments
    # of set commands, then I can use them.

    arg = inspector_win.cmd_proto_name.rsplit('_')
    if arg[2][0] != 'v':
        if len(arg[2]) > 1:
            for i in xrange(len(arg[2])):
                draw_return_values(inspector_win, result[i], arg[2],
                                        inspector_win.in_elements[i])
        else:
            draw_return_values(inspector_win, result, arg[2], inspector_win.in_elements[0])

    inspector_win.cmds_pg.CollapseAll()
    inspector_win.cmds_pg.ExpandAll()
Beispiel #3
0
 def on_python_script(self, event):
     """Show a file browser and run the selected Python script"""
     
     dlg = wx.FileDialog(
         self.get_frame(), message="Choose a python file",
         wildcard="Python files (*.py)|*.py",
         style=wx.OPEN | wx.CHANGE_DIR
         )
     
     if dlg.ShowModal() == wx.ID_OK:
         servers.get_python_server().runscript( str(dlg.GetFilename()) )
     
     dlg.Destroy()
def run_script(index):
    scripts = guisettings.Repository.getsettingvalue(guisettings.ID_ScriptList)
    script_data = scripts[index]
    if index in range(len(scripts)):
        path = script_data['path']
        if path.endswith('.lua'):
            servers.get_lua_server().runscript(str(path))
        elif path.endswith('.py'):
            # Run the script, setting first its custom data
            script.custom_data = script_data['custom data']
            servers.get_python_server().runscript(str(path))

            # Store the new custom data
            script_data['custom data'] = script.custom_data
            scripts[index] = script_data
            guisettings.Repository.setsettingvalue(guisettings.ID_ScriptList,
                                                   scripts)
    def on_send_button(self, evt):
        # Send a enter key event to property for update values

        event =  wx.KeyEvent(wx.wxEVT_CHAR)
        event.m_keyCode = wx.WXK_RETURN
        self.cmds_pg.GetEventHandler().ProcessEvent(event)

        # make this object the current
        nebulagui.nebula_object = self.object

        command = self.__get_signal_command(float(self.ctrl_delay.GetValue()))

        # Run the command

        servers.get_python_server().run(str(command))

        # Look for return values. If it have, extract it from the result
        # and fill the propertygrid fields.

        arg = self.cmd_proto_name.rsplit('_')

        if arg[0][0] != 'v':
            if len(arg[0]) > 1:
                for i in xrange(len(arg[0])):
                    servers.get_python_server().run(
                        "import inspectorsignalstab;"\
                        "inspectorsignalstab.ret = "\
                        "result[" + str(i) +"]"
                        )
                    self.__draw_return_values(ret, arg[0], self.out_elements[i])
            else:
                servers.get_python_server().run(
                    "import inspectorsignalstab;"\
                    "inspectorsignalstab.ret = "\
                        "result"
                    )
                self.__draw_return_values(ret, arg[0], self.out_elements[0])

            # Delete the temp var
            servers.get_python_server().run(str("del inspectorsignalstab.ret"))

        # delete temp variable
        servers.get_python_server().run(str("del result"))

        self.cmds_pg.Refresh()        
        self.executed = True
    def __execute_property (self, property, value, object, undo=False):
        writeshared.set_object(object)
        # Execute each setter with his value        
        if value != []:
            command = self.__get_command(property, value, object)
            if undo == False:                
                # Run the command
                servers.get_python_server().run(str(command))
            else:
                init_value = self.init_values[property["name"]]["value"]
                undo_cmd = self.__get_command(property, init_value[0], object)
                servers.get_command_server().newcommand(str(command), 
                                                    str(undo_cmd))

            self.values[property['name']]['value'] = [readshared.get_result()]
            object.setobjectdirty( True )

        return readshared.get_result()
Beispiel #7
0
    def __execute_property(self, property, value, object, undo=False):
        writeshared.set_object(object)
        # Execute each setter with his value
        if value != []:
            command = self.__get_command(property, value, object)
            if undo == False:
                # Run the command
                servers.get_python_server().run(str(command))
            else:
                init_value = self.init_values[property["name"]]["value"]
                undo_cmd = self.__get_command(property, init_value[0], object)
                servers.get_command_server().newcommand(
                    str(command), str(undo_cmd))

            self.values[property['name']]['value'] = [readshared.get_result()]
            object.setobjectdirty(True)

        return readshared.get_result()
def run_script(index):
    scripts = guisettings.Repository.getsettingvalue(
                    guisettings.ID_ScriptList
                    )
    script_data = scripts[index]
    if index in range(len(scripts)):
        path = script_data['path']
        if path.endswith('.lua'):
            servers.get_lua_server().runscript(str(path))
        elif path.endswith('.py'):
            # Run the script, setting first its custom data
            script.custom_data = script_data['custom data']
            servers.get_python_server().runscript(str(path))
            
            # Store the new custom data
            script_data['custom data'] = script.custom_data
            scripts[index] = script_data
            guisettings.Repository.setsettingvalue(
                guisettings.ID_ScriptList, 
                scripts
                )
    def on_run(self, event):
        # ask for save before run if script has been modified
        if self.stc.GetModify():
            answer = cjr.confirm_yes_no(
                self, "Save changes to '%s' ?" % self.filename)
            if answer == wx.ID_YES:
                self.save(True)
            elif answer == wx.ID_CANCEL:
                return

        if self.filename == "":
            cjr.show_information_message(
                "I'm quite stupid, so please you Supreme Intelligence\n" \
                "save the file so I can look at its extension and know\n" \
                "which file type this script is."
                )
        if self.filename.endswith('.lua'):
            servers.get_lua_server().runscript(
                str(format.mangle_path(self.filename)))
        elif self.filename.endswith('.py'):
            servers.get_python_server().runscript(
                str(format.mangle_path(self.filename)))
Beispiel #10
0
 def __execute_cmd(self, cmd_index):
     cmd = "import watcherdlg;"
     cmd = cmd + "watcherdlg.cmd_result = "
     cmd = cmd + self.list_cmds.GetItemText(cmd_index)
     servers.get_python_server().run(str(cmd))
     self.list_cmds.SetStringItem(cmd_index, 1, str(cmd_result))
Beispiel #11
0
 def __execute_cmd(self, cmd_index):
     cmd = "import watcherdlg;"
     cmd = cmd + "watcherdlg.cmd_result = "
     cmd = cmd + self.list_cmds.GetItemText(cmd_index)
     servers.get_python_server().run(str(cmd))
     self.list_cmds.SetStringItem(cmd_index, 1, str(cmd_result))
Beispiel #12
0
def execute(inspector):
    # make this object the current
    nebulagui.nebula_object = inspector.object

    # Construct the command string to be called.
    # A variable will be use for storage the return value/s

    command = "import nebulagui;"
    command = command + "result = nebulagui.nebula_object.%s" % inspector.cmds.GetValue(
    ) + "("

    i = 0
    for param in inspector.in_params:
        field = inspector.in_elements[i]
        param_type = inspector.xml.get_param_type(param)
        if param_type == 's':
            if "nroot" == inspector.xml.get_param_subtype(param):
                command = command + "'%s'," % field.GetValueAsString(0)
            elif "nobjectclass" == inspector.xml.get_param_subtype(param):
                string = field.GetValueAsString(0)
                # get the nobjectclass name and use it as parameter
                object_id = re.compile("(\w*)\(").search(string)
                getentity_string = str(object_id.group(1))
                command = command + getentity_string + ","
            else:
                command = command + "'%s'," % field.GetValueAsString(0)

        elif param_type == 'o':
            if "nroot" == inspector.xml.get_param_subtype(param):
                command = command + "lookup('%s')," % field.GetValueAsString(0)
            elif "nobjectclass" == inspector.xml.get_param_subtype(param):
                string = field.GetValueAsString(0)
                # get the nobjectclass id for get the entity object and use it as parameter
                object_id = re.compile("id=(\d*)").search(string)
                getentity_string = "servers.get_entity_object_server().getentityobject(" + str(
                    object_id.group(1)) + ")"
                command = command + getentity_string + ","
            else:
                command = command + "lookup('%s')," % field.GetValueAsString(0)

        else:
            command = command + "%s," % field.GetValueAsString(0)
        i = i + 1

    if i > 0:
        command = command[:-1]

    command = command + ")"

    # Run the command
    servers.get_python_server().run(str(command))

    # Look for return values. If it have, extract it from the result
    # and fill the propertygrid fields.

    if len(inspector.out_params) > 0:
        if len(inspector.out_params) > 1:
            for i in xrange(len(inspector.out_params)):
                servers.get_python_server().\
                    run("import xmlinspector;"\
                            "xmlinspector.ret = "\
                            "result[" + str(i) +"]")
                __draw_return_values(inspector, ret, inspector.out_params[i],
                                     inspector.out_elements[i])
        else:
            servers.get_python_server().\
                run("import xmlinspector;"\
                        "xmlinspector.ret = "\
                        "result")
            __draw_return_values(inspector, ret, inspector.out_params[0],
                                 inspector.out_elements[0])

    # delete temp variable
    servers.get_python_server().run(str("del result"))

    # if is a entity dirt the object.
    # TODO: Ugly hack! Find a better way to do this
    if inspector.object.hascommand("beginnewobjectentityclass"):
        servers.get_entity_class_server().setentityclassdirty(
            inspector.object, True)
    elif inspector.object.hascommand("getid"):
        servers.get_entity_object_server().setentityobjectdirty(
            inspector.object, True)

    # Refresh control
    inspector.cmds_pg.CollapseAll()
    inspector.cmds_pg.ExpandAll()
    inspector.executed = True
 def run_command(self):
     # build a single string with each of the commands 
     # in the list separated by semi-colons
     command = ';'.join(self.statement_list)
     # Run the command
     servers.get_python_server().run(command)
Beispiel #14
0
def execute (inspector):
    # make this object the current
    nebulagui.nebula_object = inspector.object

    # Construct the command string to be called.
    # A variable will be use for storage the return value/s

    command = "import nebulagui;"
    command = command + "result = nebulagui.nebula_object.%s" % inspector.cmds.GetValue()+ "("

    i = 0
    for param in inspector.in_params:            
        field = inspector.in_elements[i]
        param_type = inspector.xml.get_param_type(param)
        if param_type == 's':
            if "nroot" == inspector.xml.get_param_subtype(param):
                command = command + "'%s'," % field.GetValueAsString(0)
            elif "nobjectclass" == inspector.xml.get_param_subtype(param):
                string = field.GetValueAsString(0)
                # get the nobjectclass name and use it as parameter
                object_id = re.compile("(\w*)\(").search(string)
                getentity_string = str( object_id.group(1) )
                command = command + getentity_string + ","
            else:
                command = command + "'%s'," % field.GetValueAsString(0)

        elif param_type == 'o':
            if "nroot" == inspector.xml.get_param_subtype(param):
                command = command + "lookup('%s')," % field.GetValueAsString(0)                
            elif "nobjectclass" == inspector.xml.get_param_subtype(param):
                string = field.GetValueAsString(0)
                # get the nobjectclass id for get the entity object and use it as parameter
                object_id = re.compile("id=(\d*)").search(string)
                getentity_string = "servers.get_entity_object_server().getentityobject("+ str(object_id.group(1)) + ")"
                command = command + getentity_string + ","
            else:
                command = command + "lookup('%s')," % field.GetValueAsString(0)

        else:
            command = command + "%s," % field.GetValueAsString(0)
        i = i + 1

    if i > 0:
        command = command[:-1]

    command = command + ")"

    # Run the command
    servers.get_python_server().run(str(command)) 

    # Look for return values. If it have, extract it from the result
    # and fill the propertygrid fields.

    if len(inspector.out_params) > 0:
        if len(inspector.out_params) > 1:
            for i in xrange(len(inspector.out_params)):                    
                servers.get_python_server().\
                    run("import xmlinspector;"\
                            "xmlinspector.ret = "\
                            "result[" + str(i) +"]")
                __draw_return_values(
                    inspector, 
                    ret, 
                    inspector.out_params[i], 
                    inspector.out_elements[i]
                    )
        else:
            servers.get_python_server().\
                run("import xmlinspector;"\
                        "xmlinspector.ret = "\
                        "result")
            __draw_return_values(
                inspector, 
                ret, 
                inspector.out_params[0], 
                inspector.out_elements[0]
                )

    # delete temp variable
    servers.get_python_server().run( str("del result") )

    # if is a entity dirt the object.
    # TODO: Ugly hack! Find a better way to do this
    if inspector.object.hascommand("beginnewobjectentityclass"):
        servers.get_entity_class_server().setentityclassdirty(
            inspector.object, 
            True
            )
    elif inspector.object.hascommand("getid"):
        servers.get_entity_object_server().setentityobjectdirty(
            inspector.object, 
            True
            )

    # Refresh control
    inspector.cmds_pg.CollapseAll()
    inspector.cmds_pg.ExpandAll()
    inspector.executed = True
Beispiel #15
0
 def run_command(self):
     # build a single string with each of the commands
     # in the list separated by semi-colons
     command = ';'.join(self.statement_list)
     # Run the command
     servers.get_python_server().run(command)
def execute(inspector_win):
    # Send a enter key event to property for update values

    event =  wx.KeyEvent(wx.wxEVT_CHAR)
    event.m_keyCode = wx.WXK_RETURN  
    inspector_win.cmds_pg.GetEventHandler().ProcessEvent(event)

    # make this object the current
    nebulagui.nebula_object = inspector_win.object

    # Construct the command string to be called.
    # A variable will be use for storage the return value/s

    arg = inspector_win.cmd_proto_name.rsplit('_')
    command = "import nebulagui;"
    command = command + "result = nebulagui.nebula_object.%s" % inspector_win.cmds.GetValue()+ "("

    i = 0
    for field in inspector_win.in_elements:            
        if arg[2][i] == 's':
            command = command + "'%s'," % field.GetValueAsString(0)
        elif arg[2][i] == 'o':
            command = command + "lookup('%s')," % field.GetValueAsString(0)                
        else:
            command = command + "%s," % field.GetValueAsString(0)                
        i = i + 1

    if i > 0:
        command = command[:-1]

    command = command + ")"
    
    # Make undo command if possible
    normal_execute = True

    if re.compile("set.*").match(inspector_win.cmds.GetValue()):
        name = inspector_win.cmds.GetValue()[3:]
        num_getcmd = inspector_win.cmds.FindString(str("get"+name))

        if num_getcmd != wx.NOT_FOUND:
            proto_cmd = inspector_win.get_dict[str("get"+name)]
            get_arg = proto_cmd.rsplit('_')

            if get_arg[2] == 'v':

                # Execute the get for get undo values

                get_cmd = "import nebulagui;import savecmdsinspector;"
                get_cmd = get_cmd + "savecmdsinspector.ret = nebulagui.nebula_object.%s" \
                                                      % str("get"+name) + "()"
                pynebula.lookup('/sys/servers/persist/npythonserver').\
                                    run(str(get_cmd))
            
                # Create undo command

                i = 0
                undo_cmd = "import nebulagui;"
                undo_cmd = undo_cmd + "nebulagui.nebula_object.%s" % str("set"+name) + "("
                for i in xrange(len(get_arg[0])):       
                    if len(get_arg[0]) > 1:
                        element = ret[i]
                    else:
                        element = ret
                    if get_arg[0][i] == 's':
                        undo_cmd = undo_cmd + "'%s'," % str(element)
                    elif get_arg[0][i] == 'o':
                        undo_cmd = undo_cmd + "lookup('%s')," % str(element)                
                    else:
                        undo_cmd = undo_cmd + "%s," % str(element)                
                    i = i + 1

                undo_cmd = undo_cmd[:-1] + ")"

                # New command
                servers.get_command_server().newcommand(str(command), 
                                                        str(undo_cmd))
                normal_execute = False

    if normal_execute:   
        # Run the command
        servers.get_python_server().run(str(command))       
    
    # Look for return values. If it have, extract it from the result
    # and fill the propertygrid fields.

    if arg[0][0] != 'v':
        if len(arg[0]) > 1:
            for i in xrange(len(arg[0])):                    
                value = servers.get_python_server().\
                         run("import savecmdsinspector;"\
                             "savecmdsinspector.ret = "\
                             "result[" + str(i) +"]")
                draw_return_values(inspector_win, ret, arg[0], inspector_win.out_elements[i]) 
        else:
            value = servers.get_python_server().\
                         run("import savecmdsinspector;"\
                             "savecmdsinspector.ret = "\
                             "result")
            draw_return_values(inspector_win, ret, arg[0], inspector_win.out_elements[0])
            
                
    # delete temp variable
    servers.get_python_server().run(str("del result"))

    # if is a entity dirt the object.
    # TODO: Ugly hack! Find a better way to do this

    if inspector_win.object.hascommand("beginnewobjectentityclass"):
        servers.get_entity_class_server().setentityclassdirty(inspector_win.object, True)
    elif inspector_win.object.hascommand("getid"):
        servers.get_entity_object_server().setentityobjectdirty(inspector_win.object, True)

    # Refresh control
    inspector_win.cmds_pg.CollapseAll()
    inspector_win.cmds_pg.ExpandAll()
    inspector_win.executed = True