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.


    Error when trying to get a photo attachment in a mail

    Pythonista
    4
    13
    7400
    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.
    • cvp
      cvp last edited by

      I only try to get a photo attached in a mail and I get an error...
      When I first save the image in the camera roll and I use the same script to get it, no error
      Help needed
      Thanks

      # coding: utf-8
      import appex
      img = appex.get_image(image_type='pil')
      

      UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

      During handling of the above exception, another exception occurred:

      Traceback (most recent call last):
      File "/private/var/mobile/Containers/Shared/AppGroup/BC53E549-355D-4E77-BC46-64C3D3E0BDAF/Pythonista3/Documents/x.py", line 3, in <module>
      img = appex.get_image(image_type='pil')
      File "/var/containers/Bundle/Application/606A7B2D-313E-48DB-BEB5-79336C85A91D/Pythonista3.app/Frameworks/PythonistaKit3.framework/pylib/site-packages/appex.py", line 97, in get_image
      image_attachments = get_attachments('public.image')
      File "/var/containers/Bundle/Application/606A7B2D-313E-48DB-BEB5-79336C85A91D/Pythonista3.app/Frameworks/PythonistaKit3.framework/pylib/site-packages/appex.py", line 38, in get_attachments
      input_items = get_input()
      SystemError: <built-in function get_input> returned a result with an error set

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

        How do you open the Pythonista extension from Mail?

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

          Long press on the photo, run Pythonista script

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

            Try running apex_dump.py in place of your script to see exactly what mail is passing to you. Did you try with jpeg instead of PIL?

            cvp 1 Reply Last reply Reply Quote 0
            • lukaskollmer
              lukaskollmer last edited by

              @ccc @cvp it doesn't work at all. appex.get_input crashes as well.

              Getting the image is not impossible though, since workflow can do it. (Create a new workflow with a single Quick Look action that accepts everything to test)

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

                @ccc
                Same error

                UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

                During handling of the above exception, another exception occurred:

                Traceback (most recent call last):
                File "/private/var/mobile/Containers/Shared/AppGroup/BC53E549-355D-4E77-BC46-64C3D3E0BDAF/Pythonista3/Documents/t2.py", line 15, in <module>
                main()
                File "/private/var/mobile/Containers/Shared/AppGroup/BC53E549-355D-4E77-BC46-64C3D3E0BDAF/Pythonista3/Documents/t2.py", line 12, in main
                print('{:<11} : {}'.format(name.partition('_')[2], func()))
                File "/var/containers/Bundle/Application/606A7B2D-313E-48DB-BEB5-79336C85A91D/Pythonista3.app/Frameworks/PythonistaKit3.framework/pylib/site-packages/appex.py", line 38, in get_attachments
                input_items = get_input()
                SystemError: <built-in function get_input> returned a result with an error set

                1 Reply Last reply Reply Quote 0
                • cvp
                  cvp @lukaskollmer last edited by

                  @lukaskollmer

                  If I use ViewExif, it functions but Pythonista 3 crashes

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

                    Forcing Python 2 functions! bug of Python 3?

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

                      Workaround is to make sure that #! python2 is the first line of your script.

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

                        @ccc

                        That's what I did when I said it's ok in Python 2

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

                          As adviced by @ccc, this is ok even in Python 3

                          #img = appex.get_image()
                          f = appex.get_attachments()
                          img = Image.open(f[0])
                          
                          1 Reply Last reply Reply Quote 0
                          • omz
                            omz last edited by

                            A SystemError exception is nearly always a bug on my part. I'll look into it.

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

                              Thanks
                              Not vital as workaround of @ccc solves it.

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