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.


    How to ask a good question

    Pythonista
    8
    29
    19521
    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.
    • mikael
      mikael @dgelessus last edited by

      @dgelessus, thanks. Still, on the phone, I have so far not found out how to get the actual link to just the picture.

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

        @mikael check this https://gist.github.com/zrzka/b61c74975c777a77232035a3e171337d

        • Follow instructions above line 21 to get an client ID
        • This script can be run from the Pythonista or you can add it to share extensions and run it from Photos for example
        1 Reply Last reply Reply Quote 0
        • Matteo
          Matteo @zrzka last edited by

          Hi @zrzka, I'm trying to follow the steps you have suggested me and I discovered a new feature of Pythonista never tried before (sorry for my ignorance): user can create a script that can executes some operations on a web page or other files through "Share Extension Shortcuts"!

          I have a little problem with the code forum-post-copy-code.py

          Info:

          1. iOS=10.3.3
          2. Pythonista = 3.1 (301016)
          3. I'm following the steps in this link
          4. I obtain an error:
          File "/private......../forum-post-copy-code.py", line 17 
             raise ValueError(f'{url} does not point to the Pythonista Forum)
          SyntaxError: invalid syntax
          

          Can you kindly help me to solve this?
          Thank you
          Regards

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

            @Matteo update to 3.2 & use 3.6 as default interpreter (the error is about f strings).

            Matteo 1 Reply Last reply Reply Quote 0
            • dgelessus
              dgelessus last edited by

              @zrzka If I remember correctly, @Matteo said in another thread that he isn't able to update, because of the Python 2 matplotlib crashes in 3.2.

              If the f-strings are the only issue, you can probably translate them to format calls by hand, which work on any Python version since 2.6 or so. For example, f"{url} does not point to the Pythonista forum" would become "{} does not point to the Pythonista forum".format(url).

              1 Reply Last reply Reply Quote 1
              • Matteo
                Matteo @zrzka last edited by

                @zrzka Hi, ok it is a problem related to version of Pythonista, but @dgelessus is right: for now I'm happy with 3.1 version so no need to upgrade.
                I understand that there is a solution for my problem without upgrade. Can you (@zrzka , @dgelessus or someone else) kindly show me how can I modify the rest of the script in order to not obtain errors related to f-string? In other words can you provide a modified version of the script working with python 2.7.12?

                Thank you for help
                Regards

                1 Reply Last reply Reply Quote 0
                • JonB
                  JonB @Matteo last edited by JonB

                  @Matteo An approach to enable fstrings in 3.1:

                  In stash:
                  pip install tokenize_rt

                  Then, Download future_fstrings.py, and install into site-packages-3.

                  Create usercustomize.py in site-packages-3, which includes

                  import future_fstrings
                  future_fstrings.register()
                  

                  (Iirc, pythonista_startup doesnt get executed by the extension, but usercustomize.py does)

                  Finally, add

                  # -*- coding: future_fstrings -*-
                  

                  to the top of any file where you want fstrings enabled, such as zrzka's script.

                  Matteo 2 Replies Last reply Reply Quote 1
                  • Matteo
                    Matteo @JonB last edited by Matteo

                    Hi @JonB, thank you for suggestion! I will try your procedure.

                    @enceladus thank you for showing me an other way to do what I ask: when I will be able to use @zrzka script with python 2.7.12 by trying to copy the code here (as you suggest) in clipboard, I will try also the @omz script!

                    Regards

                    1 Reply Last reply Reply Quote 0
                    • Matteo
                      Matteo @JonB last edited by

                      Hi @JonB , your procedure works very well! @zrzka script works very well in Pythonista version I use, Thank you guys!
                      Regards

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

                        Guys, below in the snippet is a func 'pythonista_info'. I am pretty sure @JonB wrote this function a long time ago. It still seems to work ok. My wapper to copy it to the clipboard is not so nice(user friendly). But a refined version of what is below could be used as a wrench item to get details about the env when you are posting to the forum. I didn't attempt to make a nice version of it. I think others would do a better job than me.

                        This is quite old, so maybe it does need updating...

                        import clipboard, console
                        import os, platform, plistlib, scene, sys
                        
                        
                        def pythonista_info():
                            plist = plistlib.readPlist(os.path.abspath(os.path.join
                                                      (sys.executable, '..', 'Info.plist')))
                        
                            ios_ver, _, machine_model = platform.mac_ver()
                        
                            return dict(pythonista_ver_str=plist['CFBundleShortVersionString'],
                                        pythonista_ver_num=plist['CFBundleVersion'],
                                        ios_ver_str=ios_ver,
                                        screen_resoultion=scene.get_screen_size(),
                                        screen_scale=scene.get_screen_scale(),
                                        machine_architecture=platform.architecture()[0],
                                        machine_model=machine_model,
                                        )
                        
                        if __name__ == '__main__':
                            info = pythonista_info()
                            str_info = "\n".join(str((k, v)) for k, v in info.items())
                            clipboard.set(str_info)
                            print(str_info)
                            console.hud_alert('Pythonista Env copied to clipboard')
                        
                        cvp 1 Reply Last reply Reply Quote 1
                        • cvp
                          cvp @Phuket2 last edited by cvp

                          @Phuket2 Immediately integrated in my apps/tools

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

                            Regarding the pythonista_info function I posted above. I have since had a few freezes with using it (Pythonista becomes unresponsive) and a hard restart is required.
                            Ok, I found the original post, its over 2 years old. @ccc , @JonB and @dgelessus all helped out on this post. It would be nice if anyone could see why it would be intermittently freezing now. I can imagine quite a few things have changed in 2 years :). Anyway, it would nice to have it stable or an equivalent for easily getting your devices info, to be able to paste into posts if needed. I realise the dict keys could be better if they are to be used as part of the output.
                            @cpv, have you had a freeze using it?

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

                              @Phuket2 No freeze but not used a lot...

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

                                @cvp , ok thanks. There is something wrong though, if I use it multiple times I can get it to freeze. Hopefully someone will spot the problem

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

                                  @Phuket2 I've corrected a serious error 😂

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