'Execute code instructions.'

def execute_code(self, lines, current_client=True, clear_variables=False):

    sw = self.get_current_shellwidget()
    if (sw is not None):
        if sw._reading:
            pass
        else:
            if (not current_client):
                sw.silent_execute('%clear')
                sw.silent_execute('get_ipython().kernel.close_all_mpl_figures()')
                sw.reset_namespace(force=True)
            elif (current_client and clear_variables):
                sw.reset_namespace(force=True)
            sw.execute(to_text_string(to_text_string(lines)))
        self.activateWindow()
        self.get_current_client().get_control().setFocus()
