Page 1 of 1

REPL improvement

Posted: Mon Sep 08, 2014 12:23 pm
by pythoncoder
It would be handy if there were a way to make the REPL command history survive a soft reboot. Either automagically or with a control key. Is this feasible?

Regards, Pete

Re: REPL improvement

Posted: Mon Sep 08, 2014 3:20 pm
by pfalcon
It's on my todo to enable this (optionally) for unix version.

Re: REPL improvement

Posted: Mon Sep 08, 2014 3:31 pm
by pythoncoder
A thought occurred to me after I posted this. Can the same effect can be achieved at the terminal emulator level? IOW one which retains a list of its own history and enables you to re-send previous lines. I don't think screen has this facility but maybe one of the numerous alternatives does? It would save a lot of time testing code on the Micropython board.

I'm after a Linux solution but others used closed source OS's. Or so I'm told ;)

Regards, Pete

Re: REPL improvement

Posted: Mon Sep 08, 2014 6:20 pm
by dhylands
I put together a python script I called

Under linux, it has the advantage that it detects when USB connected devices go away and it auto-reconnects when it comes back.

It could definitely be modified to provide infinite history (and perhaps even record it to a file). It already records the entire session in the form of a log file.

I think that adding support for readline (probably as an option) would give you what you're looking for. I guess I need to think about adding support for some type of .rc file to support customizable options is in order here as well.

I've also been investigating what's available in the form of remote-editors, and it looks like gedit supports writing plugins in python, and supports remote editing. So I was thinking it would be cool to write a plug which allowed files to be edited from the python flash (but through the serial/USB interface, not the mass storage interface), and you could also create a terminal style plugin as well. gedit is also cross-plaform, so it may be possible to get something that works on linux/windows/mac.

Re: REPL improvement

Posted: Mon Sep 08, 2014 6:54 pm
by Turbinenreiter
I'm using the External Tools plugin to copy scripts to the pyboard. That way I can work on them on the computers filesystem (and use git) and send them to the pyboard wit ctrl-alt-d. Uses the mass storage interface tough and is not cross-platform.

Code: Select all

echo deployed $GEDIT_CURRENT_DOCUMENT_NAME to '/media/plam/4421-0000/'$GEDIT_CURRENT_DOCUMENT_NAME
Having a cross platform 'IDE' would be a pretty big deal and make it way easier to help people with their problems. It would also make it easier for people to start.
I'd imagine something that:
[*] provides a REPL on the bottom (in the picture it's the *nix interpreter instead of the REPL)
[*] provides sort of an upload button to copy the script to the board, but you are actually working in a local dir
[*] provides a view of the pyboards filesystem and the local one

All this would be possible to do with gedit.

Re: REPL improvement

Posted: Tue Sep 09, 2014 7:35 am
by stijn
re: REPL: Just having the history is useful, but often history is flooded with me trying to figure out the correct syntax and other statements which have no real use for a history. So ideally it would be editable (just a file as backend) and have bash-like Ctrl-R functionality to make it somewhat easier to work with history. Anyway, personally I still find a bunch of seperate files with all things I ever tried much more useful and organized than REPL history.

re: IDE: SublimeText can do all that as well, plugins are also in Python. Closed source though so gedit seems a better choice.. Pretty much all plugins are open source. The only thing to do from you whishlist would be to write the plugin for the upload, but that's probably just a couple of lines. The seperate filesys views is covered already and the REPL plugin works pretty well with uPy, I've been using it since I started with uPy. And it has history as well. And syntax highlighting.

Re: REPL improvement

Posted: Tue Sep 09, 2014 10:33 am
by Turbinenreiter
Sublime Text costs two pyboards.
However, having plugins for that would also be nice and we could probably share code.

Another feature:
[*] flash a new micropython version to the board. maybe even compiled from source, with an easy way to enable options by just ticking boxes.

I'll dive into gedit plugins this evening and see what I can come up with.

Re: REPL improvement

Posted: Sun Sep 21, 2014 8:34 am
by stijn
Any news on this? Does the REPL/file view/... work in GEdit?

Re: REPL improvement

Posted: Sun Sep 21, 2014 9:18 am
by Turbinenreiter
Yes. Terminal and file view already exist and can be used.

I also tried to build a little toolbox, but I got stuck quickly, because I couldn't figure out how to get the current files name.

This is what I got so far:

Code: Select all

from gi.repository import GObject, GLib, Gio, Gtk, Gedit

class MicropythonToolbox(Gtk.Box):

    def __init__(self):

        grid = Gtk.Grid()

        button1 = Gtk.Button(label='Deploy')
        button1.connect('clicked', self.on_button1_clicked)

        button2 = Gtk.Button(label='Flash new Firmware')
        #button1.connect('clicked', self.on_button1_clicked)


    def on_button1_clicked(self, widget):

class MicropythonDeveloperTools(GObject.Object, Gedit.WindowActivatable):
    __gtype_name__ = 'MicropythonDeveloperTools'

    window =

    def __init__(self):

    def do_activate(self):

        self._panel = MicropythonToolbox()

        bottom = self.window.get_bottom_panel()
        bottom.add_titled(self._panel, 'MicropythonToolbox', _('MicropythonToolbox'))

    def do_deactivate(self):
        bottom = self.window.get_bottom_panel()

Code: Select all

Name=Micropython Developer Tools
Description=A set of tools to work with micropython and the pyboard
Authors=Sebastian Plamauer
Copyright=Copyright 2014 Sebastian Plamauer