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.


    Google Drive connection falls in error in Pythonista beta: needs a temporary workaround

    Pythonista
    2
    7
    191
    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 cvp

      To @omz, @JonB or other guru: the Google Drive connection falls in error in Pythonista beta, due to an identified error in Pythonista code.
      Could one of you provide a temporary workaround, like using swizzle, because it is very annoying for my regular processes.
      Thanks a lot in advance

      PS paid by a beer at next meeting 😀

      Traceback (most recent call last):
        File "/private/var/mobile/Containers/Shared/AppGroup/94C45A26-1F47-4486-9539-896F8F44AA91/Pythonista3/Documents/site-packages/GoogleDriveBrowser.py", line 347, in <module>
          main()
        File "/private/var/mobile/Containers/Shared/AppGroup/94C45A26-1F47-4486-9539-896F8F44AA91/Pythonista3/Documents/site-packages/GoogleDriveBrowser.py", line 300, in main
          gauth = GoogleAuth(google_drive_auth_path)
        File "/private/var/mobile/Containers/Shared/AppGroup/94C45A26-1F47-4486-9539-896F8F44AA91/Pythonista3/Documents/site-packages/pydrive/auth.py", line 169, in __init__
          self.settings = LoadSettingsFile(settings_file)
        File "/private/var/mobile/Containers/Shared/AppGroup/94C45A26-1F47-4486-9539-896F8F44AA91/Pythonista3/Documents/site-packages/pydrive/settings.py", line 143, in LoadSettingsFile
          data = load(stream, Loader=Loader)
        File "/var/containers/Bundle/Application/42AA46AA-4145-4FC9-8A31-7063E5F0ADE2/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/yaml/__init__.py", line 73, in load
          return loader.get_single_data()
        File "/var/containers/Bundle/Application/42AA46AA-4145-4FC9-8A31-7063E5F0ADE2/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/yaml/constructor.py", line 38, in get_single_data
          return self.construct_document(node)
        File "/var/containers/Bundle/Application/42AA46AA-4145-4FC9-8A31-7063E5F0ADE2/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/yaml/constructor.py", line 47, in construct_document
          for dummy in generator:
        File "/var/containers/Bundle/Application/42AA46AA-4145-4FC9-8A31-7063E5F0ADE2/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/yaml/constructor.py", line 399, in construct_yaml_map
          value = self.construct_mapping(node)
        File "/var/containers/Bundle/Application/42AA46AA-4145-4FC9-8A31-7063E5F0ADE2/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/yaml/constructor.py", line 205, in construct_mapping
          return super().construct_mapping(node, deep=deep)
        File "/var/containers/Bundle/Application/42AA46AA-4145-4FC9-8A31-7063E5F0ADE2/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/yaml/constructor.py", line 127, in construct_mapping
          if not isinstance(key, collections.Hashable):
      AttributeError: module 'collections' has no attribute 'Hashable'
      
      ccc 1 Reply Last reply Reply Quote 0
      • ccc
        ccc @cvp last edited by

        Yet another thing that was migrated from collections to collections.abc.

        • https://docs.python.org/3/library/collections.abc.html#collections.abc.Hashable
        cvp 1 Reply Last reply Reply Quote 0
        • cvp
          cvp @ccc last edited by

          @ccc I know but I can't change Pythonista code it-self thus I hope a kind of swizzle.

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

            % python3.10

            >>> import collections
            >>> setattr(collections, "Hashable", collections.abc.Hashable)
            >>> collections.Hashable
            <class 'collections.abc.Hashable'>
            

            Try that before importing Google Drive.

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

              @ccc Thanks. It seems to work, my program crashes further, then I've still to search...
              I add you in my guru's list (note that you were already first in the list for Python 😉 but I didn't even know that Python allows such bypass).

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

                @omz same problem with MutableMapping

                Thanks to @ccc, this also works

                setattr(collections, "MutableMapping", collections.abc.MutableMapping)
                
                ccc 1 Reply Last reply Reply Quote 0
                • ccc
                  ccc @cvp last edited by

                  We do not even need setattr()...

                  >>> import collections
                  >>>> collections.Hashable = collections.abc.Hashable
                  >>>> collections.MutableMapping = collections.abc.MutableMapping
                  >>>> collections.Hashable, collections.MutableMapping
                  >(<class 'collections.abc.Hashable'>, <class 'collections.abc.MutableMapping'>)
                  
                  1 Reply Last reply Reply Quote 1
                  • First post
                    Last post
                  Powered by NodeBB Forums | Contributors