• henryaukc

    Got it! Thanks

    posted in Pythonista read more
  • henryaukc

    Hi All,

    I know now how to get the image of an emoji through this line:

    ui.Image.named('emj:Multiplication_X').with_rendering_mode(ui.RENDERING_MODE_ORIGINAL)

    But I search the forum and web but can’t find out how to know the code name of a certain emoji like “Multiplication_X” in the first place?

    Thanks a lot!

    posted in Pythonista read more
  • henryaukc

    @donnieh

    OH, this is what I need! Though I just discovered someone shared about using navigationView to do so. Thanks a lot!

    posted in Pythonista read more
  • henryaukc

    @donnieh Thank a lot! I will consider to try option 1 & 2 when my script becomes useful enough to be put on App store or TestFlight with the annual fee $99. But you just give me a very promising future for me to looking forward. Thanks again for you detailed reply.

    Regarding option 3, can you illustrate more with simple code? Can we set the python files as read-only?

    posted in Pythonista read more
  • henryaukc

    Thanks a lot!

    I have used this to make my script acting a real app by using the “Add to Home Screen” to put my script on the home screen. Without x-button, it looks more like the normal app. However, I have encountered two problems:

    1. When my home screen shortcut was run again, the pythonista ran again my app but not return to the last screen
    2. When I run another Pythonista script on the home screen, it will run on my original script

    Can I detect if my script is now running already and don’t run multiple times to fix problem 1?

    Can I detect that there is another script running and stop Pythonista to load a new one? Or close the old one before loading the new one?

    posted in Pythonista read more
  • henryaukc

    @Phuket2

    It would be great if the non-development mode is implemented. I would like to know if it is possible that when the use tap the “X” in my view window(full screen), it will transfer the user to the home screen so that he/she won’t modify my code accidentally. Is it even possible to take away the “X” so that it would just like a real app?

    posted in Pythonista read more
  • henryaukc

    It works very well. Thanks a lot!

    posted in Pythonista read more
  • henryaukc

    This is my script. It works but slow as hell (maybe 40kb/s). Any suggestions? I would like to show the progress of upload too but can't figure out how to use the callback yet...

    posted in Pythonista read more
  • henryaukc

    # coding: utf-8
    import appex
    import console
    import os
    import ui
    import paramiko
    from io import BytesIO
    
    
    def UploadCallBack(tran_bytes,  total_bytes):
        print("Bytes Transferred:" +tran_bytes + "\nTotal Bytes:" + total_bytes)
    
    def main():     
    
        # Sharing: receive file
        input_file = appex.get_file_path() 
        if input_file == None:
            print('no file passed')
            return 
            
    
        # SFTP Configuration
    
        host = '192.168.1.x'
        port = 22
        password = 'password'
        username = 'Username'
        remoteFilePath = '/media/sda/'
        
        server_file = os.path.basename(input_file)
        filesize = os.path.getsize(input_file)
    #   print("server_file:" + server_file)
        print("Starting to upload the file:" + input_file + "(Size: ", end='')
        print(filesize, end='')
        print(")... ")
        
        try:
            transport = paramiko.Transport((host, port))
    
            transport.connect(username = username, password = password)
                
            sftp = paramiko.SFTPClient.from_transport(transport,max_packet_size=8*1024*1024)
    
            ''' sftp.open() 
                    
            while with open(input_file, 'rb') as ipad_file:
                
                read(ipad_file,  )
            '''
            #sftp.putfo(ipad_file, remoteFilePath + server_file, callback=UploadCallBack(int, int ))
            ipad_file = open(input_file, 'rb')
                
            sftp.putfo(ipad_file, remoteFilePath + server_file)
            
            ipad_file.close()
            sftp.close() 
            
            transport.close()
            print('Upload done!')
                    
        except Exception as e:
            print(str(e))
    
        appex.finish()
    
    if __name__ == '__main__':
        main()```

    posted in Pythonista read more
  • henryaukc

    Thanks a lot @cvp ! I will try to modify using SFTP.

    Hi @scj643, should I use the following method?

    putfo(fl, remotepath, file_size=0, callback=None, confirm=True)
    Copy the contents of an open file object (fl) to the SFTP server as remotepath. Any exception raised by operations will be passed through.

    The SFTP operations use pipelining for speed.

    Parameters:
    fl – opened file or file-like object to copy
    remotepath (str) – the destination path on the SFTP server
    file_size (int) – optional size parameter passed to callback. If none is specified, size defaults to 0
    callback (callable) – optional callback function (form: func(int, int)) that accepts the bytes transferred so far and the total bytes to be transferred (since 1.7.4)
    confirm (bool) – whether to do a stat() on the file afterwards to confirm the file size (since 1.7.7)
    Returns:
    an SFTPAttributes object containing attributes about the given file.

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!