omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Download script into Pythonista

    Pythonista
    18
    39
    36164
    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.
    • JonB
      JonB last edited by

      you might try adding

      import logging
      logging.basicConfig(level=logging.DEBUG)

      before the lines that start the server. Then, check the console in pythonista to see if there are any errors logged server side.

      1 Reply Last reply Reply Quote 0
      • smath
        smath last edited by

        If you have the workflow app, here's another solution for bringing in files that are open in other apps.

        1 Reply Last reply Reply Quote 1
        • Sean
          Sean last edited by

          using third party client on mac will works. Some how using finder ftp will crash pythonista.

          1 Reply Last reply Reply Quote 0
          • zzgus
            zzgus last edited by zzgus

            Is there an "idiot proof guide" ?

            When I follow the GitHub link inside iphone's safari... is supposed that I must try to copy the code (with iphone built in option to copy text) and then paste inside pythonista?

            If I do that, and try to run the code, it starts to show errors, like "()" after print, etc.

            I have also tried another thread with workflow involved without luck.

            Any help will be greatly appreciated.
            Gus

            1 Reply Last reply Reply Quote 0
            • brumm
              brumm last edited by brumm

              An easy way is to open the raw view of the code and then insert the url in this script. All the code is printed to the console and is easy to select.

              import urllib2
              
              url = 'https://raw.githubusercontent.com/humberry/PhoneManager/master/PhoneManager.py'
              print urllib2.urlopen(url).read()
              

              if you use Pythonista3:

              import urllib.request
              
              url = 'https://raw.githubusercontent.com/humberry/PhoneManager/master/PhoneManager.py'
              req = urllib.request.urlopen(url)
              print(req.read().decode('utf-8'))
              
              1 Reply Last reply Reply Quote 0
              • cvp
                cvp last edited by cvp

                @zzgus it's because you download a code for Python 2 and you run it in Python 3.
                Either you convert the code to Python 3 (see tools button at top of script) or you force the code to run in Python 2 by inserting a first line #!python2

                1 Reply Last reply Reply Quote 0
                • ccc
                  ccc last edited by

                  import requests
                  
                  url = 'https://raw.githubusercontent.com/humberry/PhoneManager/master/PhoneManager.py'
                  print(requests.get(url).text)
                  

                  Works in all versions of Pythonista.

                  1 Reply Last reply Reply Quote 1
                  • zzgus
                    zzgus last edited by

                    Finally converted code from v2 to v3, thankyou @cvp for the trick. I see I have a new pyftpd.tar.gz file and a new folder:
                    pyftpdlib-1.4.0
                    -demo
                    -pyftpdlib
                    -pyftpdlib.egg-info
                    -test
                    CREDITS
                    LICENSE
                    make.bat
                    Makefile
                    MANIFEST.in
                    PKG-INFO
                    README.rst
                    setup.cfg
                    setup.oy

                    Where is the ftp server?

                    Thankyou
                    Gus

                    1 Reply Last reply Reply Quote 0
                    • zzgus
                      zzgus last edited by

                      Any help please?
                      I don't know what I'm doing wrong but unable to get the ftp running.

                      Thankyou
                      Gus

                      1 Reply Last reply Reply Quote 0
                      • Webmaster4o
                        Webmaster4o last edited by

                        We'll need some more info to help you.

                        1 Reply Last reply Reply Quote 0
                        • brumm
                          brumm last edited by brumm

                          You just downloaded a module.
                          'Python FTP server library provides a high-level portable interface to easily write very efficient, scalable and asynchronous FTP servers with Python.'
                          Maybe you're looking for an ready-to-run FTP server?

                          zzgus 1 Reply Last reply Reply Quote 0
                          • ccc
                            ccc last edited by ccc

                            @zzgus Try going into the pyftpdlib directory and look for __main__.py and see what running that does. If you want to provide command line arguments then press and hold the run button when you launch the script. There is no guarantee this will work but give it a try.

                            zzgus 1 Reply Last reply Reply Quote 0
                            • zzgus
                              zzgus @brumm last edited by

                              @brumm said:

                              You just downloaded a module.
                              'Python FTP server library provides a high-level portable interface to easily write very efficient, scalable and asynchronous FTP servers with Python.'
                              Maybe you're looking for an ready-to-run FTP server?

                              Yes is what I understood from @omz answer

                              There are various options, my current favorite is the script I've already linked to on Twitter:
                              
                              → PythonistaFTP.py (GitHub)
                              
                              It basically starts an FTP server on your device that you can then connect to from a Mac/PC.
                              
                              1 Reply Last reply Reply Quote 0
                              • zzgus
                                zzgus @ccc last edited by zzgus

                                @ccc Basically when I run it gives this error:
                                ImportError: No module named 'pyftpdlib'.

                                Thankyou
                                Gus

                                1 Reply Last reply Reply Quote 0
                                • brumm
                                  brumm last edited by brumm

                                  Okay, after trying it I understand.
                                  In Pythonista3 the module is downloaded in site-packages and not in site-packages2. After moving the directory you should insert

                                  !#python2
                                  

                                  as first line in the PythonistaFTP code.

                                  zzgus 1 Reply Last reply Reply Quote 0
                                  • zzgus
                                    zzgus last edited by zzgus

                                    Sure I'm doing something wrong as it is my first incursion in programing.
                                    I have made a simple program for my kids to practice the multiplication tables.
                                    I don't want to re-type the code again in my iphone and ipad.

                                    I'm gona try to explain what I do:

                                    For what I understood from @omz there's a script "PythonistaFTP.py" that starts an FTP server (on ipad/iphone) where I can connect from my MAC.

                                    1.- Go to PythonistaFTP.py on https://gist.github.com/omz/1aec8a66a5d5d19a36ab
                                    2.- Press the RAW button to only see the code.
                                    3.- Copy the code
                                    4.- Go to Pythonista and new Empty Script
                                    5.- Paste the code
                                    6.- As @cvp said I force to run under python2 inserting a first line on the code with this #!python2
                                    7.- Run de code and get this error:
                                    Downloading pyftpdlib...
                                    Importerror: No module named pyftpdlib.authorizers

                                    After that tried converting code to 3 with Pythonista build in function "Python 2 to 3" and re-run code:

                                    Downloading pyftpdlib...
                                    [Errno 17] File exists: 'site-packages/pyftpdlib'

                                    After that I end up with a new folder "pyftpdlib-1.4.0"

                                    That's all I have :-)
                                    Any help will be greatly appreciated
                                    Gus

                                    1 Reply Last reply Reply Quote 0
                                    • zzgus
                                      zzgus @brumm last edited by

                                      @brumm said:

                                      Okay, after trying it I understand.
                                      In Pythonista3 the module is downloaded in site-packages and not in site-packages2. After moving the directory you should insert

                                      !#python2
                                      

                                      as first line in the PythonistaFTP code.

                                      Yes I have tried that as @cvp said.
                                      See my last post to exactly what I do.

                                      Thankyou
                                      Gus

                                      1 Reply Last reply Reply Quote 0
                                      • brumm
                                        brumm last edited by brumm

                                        Just try this:

                                        1. Download PythonistFTP.py
                                        2. Insert as first line
                                        #!python2
                                        
                                        1. Change line 21 to
                                        	shutil.copytree('pyftpdlib-1.4.0/pyftpdlib', 'site-packages-2/pyftpdlib')
                                        
                                        1. Restart Pythonista (so the new module can be loaded)
                                        zzgus 1 Reply Last reply Reply Quote 0
                                        • zzgus
                                          zzgus @brumm last edited by

                                          @brumm SOLVED !!!

                                          Thankyou
                                          Gus

                                          1 Reply Last reply Reply Quote 0
                                          • First post
                                            Last post
                                          Powered by NodeBB Forums | Contributors