Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    gpy file system

    Scheduled Pinned Locked Moved GPy
    os.renamegpy
    11 Posts 2 Posters 1.1k Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • robert-hhR Offline
      robert-hh @kjm
      last edited by

      @kjm if you enter the commands:

      import os
      dir(os)
      

      you should see all commands that are supported. Looking at the sources, there is no difference in os or uos between the various Pycom modules. So your difficulties must be cause by something else, like the target file exists, or wrong spelling/coding of os.rename(). Try to retype it.
      What is exactly the error which you get?

      K 1 Reply Last reply Reply Quote 0
      • K Offline
        kjm @robert-hh
        last edited by

        @robert-hh Tnx Rob, my bad, a typo. I'm trying to reuse an OTA directory updater from an Rpi in the gpy. I've been lucky enough to find some code snippet alternatives online for cmds like os.copyfileobject but replacements for the likes of os.rmtree still elude me, mostly because they in turn need path or walk.

        1. Is it possible to customise os to add missing cmds?
        2. Is there something like dir(os) that shows what python cmds are available on the gpy? I can't seem to get tarfile.open() to work
        >>> tar = tarfile.open('/flash/100.tar')
        Traceback (most recent call last):
          File "<stdin>", line 1, in <module>
        NameError: name 'tarfile' is not defined
        
        robert-hhR 2 Replies Last reply Reply Quote 0
        • robert-hhR Offline
          robert-hh @kjm
          last edited by

          @kjm for the builtins set of names and commands, you can use:

          import builtins
          dir(builtins)

          For the set of modules you have to use the documentation. help("modules") is not implemented in the Pycom branch of micropython.

          1 Reply Last reply Reply Quote 0
          • K Offline
            kjm
            last edited by

            @robert-hh Any chance of a link to the modules docs Rob?

            robert-hhR 1 Reply Last reply Reply Quote 0
            • robert-hhR Offline
              robert-hh @kjm
              last edited by robert-hh

              @kjm It's possible & requires a firmware change. At the end, it looks like:

              >>> help("modules")
              MQTTClient        gc                sqnscodec         uio
              MQTTConst         hashlib           sqnscrc           ujson
              MQTTDeviceShadow  json              sqnstp            umachine
              MQTTLib           machine           sqnsupgrade       uos
              MQTTMsgHandler    math              ssl               upysh
              MQTTShadowManager micropython       station           uqueue
              __main__          mount             struct            ure
              _boot             network           sys               uselect
              _main             os                time              uselect
              _thread           pycom             ubinascii         usocket
              array             pye               ubinascii         ussl
              binascii          queue             ucollections      ustruct
              builtins          re                ucrypto           utime
              cmath             reload            uctypes           utimeq
              crypto            select            uerrno            uzlib
              errno             socket            uerrno            websocket
              framebuf          sqnsbrz           uhashlib
              Plus any modules on the filesystem
              

              Edit: I made a PR for that.

              1 Reply Last reply Reply Quote 0
              • robert-hhR Offline
                robert-hh @kjm
                last edited by

                @kjm There is some of a tarfile implementation here: https://github.com/micropython/micropython-lib/tree/master/upip
                Maybe that helps.

                K 1 Reply Last reply Reply Quote 0
                • K Offline
                  kjm @robert-hh
                  last edited by

                  @robert-hh This is never gonna install on the gpy with cmds like mkdir -p ~/.micropython/lib/ in it Rob

                  robert-hhR 1 Reply Last reply Reply Quote 0
                  • robert-hhR Offline
                    robert-hh @kjm
                    last edited by

                    @kjm The files of interest are upip.py and upip.tarfile.py. They run on an ESP32 and ESP8266 with MicroPython from micropython.org and should be mostly compatible to the Pycom branch.

                    K 1 Reply Last reply Reply Quote 0
                    • K Offline
                      kjm @robert-hh
                      last edited by

                      @robert-hh So I'm looking for alternatives to tar=tarfile.open & tar.extractall Rob:

                      upip.tarfile.py is an tar opener maybe? How would anyone know since the author gives no clue on what it does or how to use it?

                      upip.py is looking like an extractor maybe? But it's only for specialist code not just any tar "Note: only MicroPython packages (usually, named micropython-*) are supported for installation, upip does not support arbitrary code in setup.py."

                      robert-hhR 1 Reply Last reply Reply Quote 0
                      • robert-hhR Offline
                        robert-hh @kjm
                        last edited by

                        @kjm upip is meant to install (micro)python packages on a micropython device. So it downloads and extracts micropython packages. You have to tell yourself whether it is useful for you. But at least it is a good example. Paul is an excellent Python specialist and programmer.

                        There is a upip.help() telling how to use it. And upip.tarfile is, as far as I understand it, the tarfile extractor.

                        1 Reply Last reply Reply Quote 0

                        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                        With your input, this post could be even better 💗

                        Register Login
                        • 1 / 1
                        • First post
                          Last post

                        Pycom on Twitter

                        Pycom