• Tito

    @cvp done

    I think is the function sftp, the server is a plain FTP...

    Exception: Error reading SSH protocol banner
    Traceback (most recent call last):
    File "/var/containers/Bundle/Application/E5EADB2F-39AA-4401-9C74-050227C872BA/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/paramiko/transport.py", line 1855, in _check_banner
    buf = self.packetizer.readline(timeout)
    File "/var/containers/Bundle/Application/E5EADB2F-39AA-4401-9C74-050227C872BA/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/paramiko/packet.py", line 327, in readline
    buf += self._read_timeout(timeout)
    File "/var/containers/Bundle/Application/E5EADB2F-39AA-4401-9C74-050227C872BA/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/paramiko/packet.py", line 497, in _read_timeout
    raise socket.timeout()

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File "/var/containers/Bundle/Application/E5EADB2F-39AA-4401-9C74-050227C872BA/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/paramiko/transport.py", line 1711, in run
    File "/var/containers/Bundle/Application/E5EADB2F-39AA-4401-9C74-050227C872BA/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/paramiko/transport.py", line 1859, in _check_banner
    raise SSHException('Error reading SSH protocol banner' + str(e))
    paramiko.ssh_exception.SSHException: Error reading SSH protocol banner

    Error reading SSH protocol banner


    posted in Pythonista read more
  • Tito

    @ccc thanks for answer and the link

    I’m starting from here:

    # coding: utf-8
    import appex
    import console
    import os
    import ui
    from ftplib import FTP
    def main():     
    # Sharing: receive file 
        fil = appex.get_file_path() 
        if fil == None:
            print('no file passed')
        server = 'address'
        user = 'account'
        pwd = 'pass'
        server_file = os.path.basename(fil)
            ftp = FTP(server) #connect
            ftp.encoding = 'utf-8'
            ipad_file = open(fil,'rb')
            ftp.storbinary('STOR '+server_file,ipad_file,blocksize=8192)
        except Exception as e:
    if __name__ == '__main__':

    With this code I take a file on OneDrive and upload it to a FTP server, but the code is made for taking files from iOS menu (I think that’s the appex part for the code structure).

    Now here it comes the code that @cvp kindly searched and found it points to a web link route, it points to a file through an extracted link (is really awesome, black magic for me...).

    As you can see, I’m not a coder, I tried to learn python, bought a book (Learn Python the Hard Way) but got jammed soon. And I have this problem with Pythonista when I search for info about python, the code is tailored for a computer environment, and making it work on Pythonista changes the game a lot.

    Sorry I lost focus on this and I’m telling you my sorrows.

    I tried to do it in parts first try to understand the code and make it run alone.

    def create_onedrive_directdownload (onedrive_link):
        data_bytes64 = base64.b64encode(bytes(onedrive_link, 'utf-8'))
        data_bytes64_String = data_bytes64.decode('utf-8').replace('/','_').replace('+','-').rstrip("=")
        resultUrl = f"https://api.onedrive.com/v1.0/shares/u!{data_bytes64_String}/root/content"
        return resultUrl 

    I tried to put the OneDrive link on (onedrive_link) I thought it was the first position working as a shortcut but I got an “invalid syntax” error... I’ve noticed that my OneDrive links are not the same as the ones from the article (1drv vs my works personalised direction https:://xxxxxx-my.share point.com/:x:/g/personal/... maybe could be there the issue.

    My next step would be to get the file and upload to the FTP address and after that try to make it work with two files and upload the together.

    Thanks for your valuable help, I’m a mess with this and I’m trying, for me was a big win to understand the previous code for uploading files from iOS with the script. In the beginning I had to open an ftp app and navigate to the route every time I wanted to upload a file with this script I only have to check that everything worked smoothly, my goal was doing both things on a tap.

    I’m asking myself, if I put a Pythonista script pointing to the files I have to upload in the OneDrive folder, would it found them? I suppose this shouldn’t need any route, only file names, am I right?

    posted in Pythonista read more
  • Tito

    Hi, I’ve been trying but I think this is too complex for my skills.

    You’ve been saying you were old guys, I’m felling useless at my almos brand new forties.

    I don’t really understand how the function resolves the file and in my procedure I have to deal with an FTP server instead of an SFTP, so I don’t know where to touch the code and switching functions.

    Many thanks for your help, and sorry for bothering, I’ll keep trying.

    posted in Pythonista read more
  • Tito

    @cvp wow this is really awesome!!

    Thanks so much, I will study your code and try to use it on my workflow.

    Thanks again.

    posted in Pythonista read more
  • Tito

    @cvp I’ve found a post about the compatibility between OneDrive and Shortcuts but seems to be only for scan documents and related stuff nothing related to file routes.

    posted in Pythonista read more
  • Tito

    @cvp what a pity... in that case I’m have to do it manually forever.

    Thanks for your help. :)

    posted in Pythonista read more
  • Tito

    Now I’m open OneDrive app, go to the folder, I select a file, run Pythonista Script and repeat with the other file.

    I can use iOS to access the route give it to Pythonista and upload a file. It has to be a way for doing this with a fixed route.

    posted in Pythonista read more
  • Tito

    And giving the link obtained trough files?


    posted in Pythonista read more
  • Tito

    @mikael so, would it be possible to make a script that select two files and upload them to the ftp?

    I have would take the data to the folder and then exec the script and upload the files in the same execution?

    Following the logic I only had to say the file name because the script would be in the same folder.

    I think this is it...

    fil = appex.get_file_path()
    if fil == None:
    print('no file passed')

    I have to find the code that says the file names, now it shows the document picker but I want two fixed files.


    posted in Pythonista read more
  • Tito


    I have this repetitive task at work, download data from SAP and upload it to a ftp server.

    I have managed to script the steps making semiautomatic downloads trough a VBA script, the files are stored in a OneDrive folder, after that, I access that folder and run a Pythonista script to upload the files to the ftp server.

    Could somebody give me a hand to do it on a single step?


    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!