[Microbit-Python] importing modules using uflash

Nicholas H.Tollervey ntoll at ntoll.org
Wed Sep 14 18:13:43 EDT 2016


Here:

http://microfs.readthedocs.io/en/latest/

In general I'm heading towards de-coupling Mu from Qt by building useful
functionality in modules like uflash and microfs that Mu sits on top of.

Hope this helps and see you all at PyCon UK this weekend...

:-)

N.

On 14/09/16 21:11, Radomir Dopieralski wrote:
> As Nicholas already mentioned, this module works also as a standalone
> command line tool.
> 
> On Wed, 14 Sep 2016 22:03:57 +0200
> "M.-A. Lemburg" <mal at egenix.com> wrote:
> 
>> On 14.09.2016 21:55, Radomir Dopieralski wrote:
>>> It just uses normal python commands, such as open(), file.read(),
>>> file.write(), os.listdir() and so on, but executes them over the
>>> REPL console. You can see exactly what it does here:
>>> https://github.com/ntoll/mu/blob/master/mu/contrib/microfs.py
>>
>> Great, thanks.
>>
>> I think this would make an excellent addition to the uflash
>> tool - for those of us who prefer emacs over mu ;-)
>>
>>
>>
>>> On Wed, 14 Sep 2016 21:15:22 +0200
>>> "M.-A. Lemburg" <mal at egenix.com> wrote:
>>>
>>>> On 11.09.2016 14:00, Radomir Dopieralski wrote:
>>>>>
>>>>> Not quite.
>>>>>
>>>>> It doesn't matter how you upload your main script -- you can use
>>>>> uFlash or Mu or the online editor, or even prepare the hex file
>>>>> yourself by hand. The thing is, that the hex file can contain only
>>>>> one python file in it.
>>>>>
>>>>> However, there is also internal filesystem on the micro:bit, where
>>>>> you can put additional files to be imported by your main script.
>>>>> The most convenient way to access that filesystem and upload your
>>>>> files is by using the latest version of the Mu editor. Of course,
>>>>> you could as well just write a program that creates the file and
>>>>> writes its contents, but that is a little roundabout way of doing
>>>>> it.
>>>>>
>>>>> I hope this helps.
>>>>
>>>> Is the functionality needed for uploading modules to the
>>>> MB documented somewhere ? (A pointer to the right place
>>>> in the Mu editor code would already help :-))
>>>>
>>>> Background: I've been looking for something like a few months
>>>> ago and back then, there was no filesystem module import for
>>>> the MB.
>>>>
>>>> Thanks.
>>>>
>>>>> On Sun, 11 Sep 2016 12:47:20 +0100
>>>>> "hot.toast via Microbit" <microbit at python.org> wrote:
>>>>>
>>>>>> So as i understand it,
>>>>>>
>>>>>> 1. uFlash is limited to python scripts that contain all the
>>>>>> local function and class definitions. The only imports that are
>>>>>> allowed are those from the microbit version of micropython.
>>>>>>
>>>>>> 2. If I want to import  "mymodule.py" from a file on my local
>>>>>> hard drive, I will have to use the latest version of the mu
>>>>>> editor...
>>>>>>
>>>>>> On 11/09/16 12:19, David Whale wrote:
>>>>>>> Make sure you use the most up to date version of Mu though to do
>>>>>>> this, as it was a feature that was added reasonably recently.
>>>>>>> The version of Mu in the Raspberry Pi repo's is still out of
>>>>>>> date at the moment, and might not have this feature included
>>>>>>> yet.
>>>>>
>>>>>
>>>>
>>>
>>>
>>>
>>
> 
> 
> 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/microbit/attachments/20160914/b0ee23b1/attachment-0001.sig>


More information about the Microbit mailing list