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.


    Sync to Dropbox

    Pythonista
    13
    31
    29041
    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.
    • ccc
      ccc last edited by

      import dropbox
      print(dropbox.__version__)  # '6.4.0'
      
      1 Reply Last reply Reply Quote 0
      • JonB
        JonB last edited by

        change
        with open(path, 'r') as local_fr:
        to
        with open(path, 'rb') as local_fr:

        in two places. files_upload takes bytes, not str, which you get by reading in binary mode, or else encoding.

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

          Thanks Jon, I have made the change and uploaded it to the GitHub repo.

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

            Works perfectly now, thanks

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

              Hi Mark, everyone.

              I am new to pythonista and came across this, thank you Mark for developing and sharing it!

              I followed your guide / wiki and have installed the latest Dropbox package (8.0.0) via slash.

              Both your scripts setup in the app and when I run it it gives a stack error of ValueError:

              Thanks in advance for any help!

              Joao


              • Dropbox File Syncronization      *
                

              Loading Local State

              Cannot Find State File -- Creating New Local State

              Updating From Dropbox
              Traceback (most recent call last):
              File "/private/var/mobile/Containers/Shared/AppGroup/7C871155-8C31-4773-B218-2D35DDD5C4CC/Pythonista3/Documents/SyncDropbox/Synchronator.py", line 297, in <module>
              check_remote(dbx, state)
              File "/private/var/mobile/Containers/Shared/AppGroup/7C871155-8C31-4773-B218-2D35DDD5C4CC/Pythonista3/Documents/SyncDropbox/Synchronator.py", line 218, in check_remote
              state.execute_delta(dbx)
              File "/private/var/mobile/Containers/Shared/AppGroup/7C871155-8C31-4773-B218-2D35DDD5C4CC/Pythonista3/Documents/SyncDropbox/Synchronator.py", line 104, in execute_delta
              results = dbx.files_list_folder('', True)
              File "/private/var/mobile/Containers/Shared/AppGroup/7C871155-8C31-4773-B218-2D35DDD5C4CC/Pythonista3/Documents/site-packages/dropbox/base.py", line 715, in files_list_folder
              None,
              File "/private/var/mobile/Containers/Shared/AppGroup/7C871155-8C31-4773-B218-2D35DDD5C4CC/Pythonista3/Documents/site-packages/dropbox/dropbox.py", line 234, in request
              timeout=timeout)
              File "/private/var/mobile/Containers/Shared/AppGroup/7C871155-8C31-4773-B218-2D35DDD5C4CC/Pythonista3/Documents/site-packages/dropbox/dropbox.py", line 326, in request_json_string_with_retry
              timeout=timeout)
              File "/private/var/mobile/Containers/Shared/AppGroup/7C871155-8C31-4773-B218-2D35DDD5C4CC/Pythonista3/Documents/site-packages/dropbox/dropbox.py", line 411, in request_json_string
              timeout=timeout)
              File "/var/containers/Bundle/Application/FC4FD503-11FB-4FF7-AFBC-6134FAAE69C8/Pythonista3.app/Frameworks/Py2Kit.framework/pylib/site-packages/requests/sessions.py", line 505, in post
              return self.request('POST', url, data=data, json=json, **kwargs)
              File "/var/containers/Bundle/Application/FC4FD503-11FB-4FF7-AFBC-6134FAAE69C8/Pythonista3.app/Frameworks/Py2Kit.framework/pylib/site-packages/requests/sessions.py", line 462, in request
              resp = self.send(prep, **send_kwargs)
              File "/var/containers/Bundle/Application/FC4FD503-11FB-4FF7-AFBC-6134FAAE69C8/Pythonista3.app/Frameworks/Py2Kit.framework/pylib/site-packages/requests/sessions.py", line 574, in send
              r = adapter.send(request, **kwargs)
              File "/var/containers/Bundle/Application/FC4FD503-11FB-4FF7-AFBC-6134FAAE69C8/Pythonista3.app/Frameworks/Py2Kit.framework/pylib/site-packages/requests/adapters.py", line 371, in send
              timeout=timeout
              File "/var/containers/Bundle/Application/FC4FD503-11FB-4FF7-AFBC-6134FAAE69C8/Pythonista3.app/Frameworks/Py2Kit.framework/pylib/site-packages/urllib3/connectionpool.py", line 566, in urlopen
              timeout_obj = self._get_timeout(timeout)

              File "/var/containers/Bundle/Application/FC4FD503-11FB-4FF7-AFBC-6134FAAE69C8/Pythonista3.app/Frameworks/Py2Kit.framework/pylib/site-packages/urllib3/connectionpool.py", line 309, in _get_timeout
              return Timeout.from_float(timeout)
              File "/var/containers/Bundle/Application/FC4FD503-11FB-4FF7-AFBC-6134FAAE69C8/Pythonista3.app/Frameworks/Py2Kit.framework/pylib/site-packages/urllib3/util/timeout.py", line 155, in from_float
              return Timeout(read=timeout, connect=timeout)
              File "/var/containers/Bundle/Application/FC4FD503-11FB-4FF7-AFBC-6134FAAE69C8/Pythonista3.app/Frameworks/Py2Kit.framework/pylib/site-packages/urllib3/util/timeout.py", line 98, in init
              self._connect = self._validate_timeout(connect, 'connect')
              File "/var/containers/Bundle/Application/FC4FD503-11FB-4FF7-AFBC-6134FAAE69C8/Pythonista3.app/Frameworks/Py2Kit.framework/pylib/site-packages/urllib3/util/timeout.py", line 128, in _validate_timeout
              "int or float." % (name, value))
              ValueError: Timeout value connect was Timeout(connect=30, read=30, total=None), but it must be an int or float.

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

                Thanks for bringing this to my attention!

                So everything I can find online seems to indicate that this was a bug that was exposed in the Requests library when Dropbox updated their library to 8.0. I hate to ever point fingers since I have caused my own share of bugs.

                If you run 'pip install requests' you should get version 2.18.1 or better. They fixed the issue in their 2.17.1 release from what I can find.

                After installing this later version of Requests you will need to quit Pythonista and restart it to have it load the newest versions of the libraries.

                After that Synchronator should run just fine.

                Mark
                Keep Calm and Code Python

                Phuket2 nobregajoao 2 Replies Last reply Reply Quote 0
                • Phuket2
                  Phuket2 @markhamilton1 last edited by

                  @markhamilton1, just want to say thanks. I just used Synchronator to do a backup. Worked very well. On my first run it took a long time to run because of many files, i was worried about it timing out. Maybe using console.set_idle_timer_disabled True/False at the start and end of the sync might be a worthwhile thing.
                  But again thanks, it did work perfectly

                  1 Reply Last reply Reply Quote 0
                  • nobregajoao
                    nobregajoao @markhamilton1 last edited by

                    @markhamilton1
                    Works perfectly now!

                    Thank you! This opens a new whole new world

                    Cheers

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

                      Hi Mark,

                      Synchronator seems great, unfortunately I keep getting this error when I run it on Pythonista 3 using Python 3.5.
                      I used StaSh pip install to install the latest dropbox and requests to no avail, here is the stack trace, it seems to be a timeout problem :(

                      Updating From Dropbox


                      • Dropbox File Syncronization      *
                        

                      Loading Local State

                      Cannot Find State File -- Creating New Local State

                      Updating From Dropbox
                      Traceback (most recent call last):
                      File "/var/containers/Bundle/Application/44E531D9-C860-4F8B-9A15-16BE6F3BE756/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/urllib3/util/timeout.py", line 125, in _validate_timeout
                      float(value)
                      TypeError: float() argument must be a string or a number, not 'Timeout'

                      During handling of the above exception, another exception occurred:

                      Traceback (most recent call last):
                      File "/private/var/mobile/Containers/Shared/AppGroup/895491B4-6F48-4CA2-AF6A-1A663749BD60/Pythonista3/Documents/bin/Utilities/Synchronator/Synchronator.py", line 425, in <module>
                      check_remote(dbx, state)
                      File "/private/var/mobile/Containers/Shared/AppGroup/895491B4-6F48-4CA2-AF6A-1A663749BD60/Pythonista3/Documents/bin/Utilities/Synchronator/Synchronator.py", line 333, in check_remote
                      state.execute_delta(dbx)
                      File "/private/var/mobile/Containers/Shared/AppGroup/895491B4-6F48-4CA2-AF6A-1A663749BD60/Pythonista3/Documents/bin/Utilities/Synchronator/Synchronator.py", line 174, in execute_delta
                      results = dbx.files_list_folder('', True)
                      File "/private/var/mobile/Containers/Shared/AppGroup/895491B4-6F48-4CA2-AF6A-1A663749BD60/Pythonista3/Documents/site-packages/dropbox/base.py", line 1336, in files_list_folder
                      None,
                      File "/private/var/mobile/Containers/Shared/AppGroup/895491B4-6F48-4CA2-AF6A-1A663749BD60/Pythonista3/Documents/site-packages/dropbox/dropbox.py", line 234, in request
                      timeout=timeout)
                      File "/private/var/mobile/Containers/Shared/AppGroup/895491B4-6F48-4CA2-AF6A-1A663749BD60/Pythonista3/Documents/site-packages/dropbox/dropbox.py", line 325, in request_json_string_with_retry
                      timeout=timeout)
                      File "/private/var/mobile/Containers/Shared/AppGroup/895491B4-6F48-4CA2-AF6A-1A663749BD60/Pythonista3/Documents/site-packages/dropbox/dropbox.py", line 409, in request_json_string
                      timeout=timeout,
                      File "/var/containers/Bundle/Application/44E531D9-C860-4F8B-9A15-16BE6F3BE756/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/requests/sessions.py", line 512, in post
                      return self.request('POST', url, data=data, json=json, **kwargs)
                      File "/var/containers/Bundle/Application/44E531D9-C860-4F8B-9A15-16BE6F3BE756/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/requests/sessions.py", line 469, in request
                      resp = self.send(prep, **send_kwargs)
                      File "/var/containers/Bundle/Application/44E531D9-C860-4F8B-9A15-16BE6F3BE756/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/requests/sessions.py", line 577, in send
                      r = adapter.send(request, **kwargs)
                      File "/var/containers/Bundle/Application/44E531D9-C860-4F8B-9A15-16BE6F3BE756/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/requests/adapters.py", line 377, in send
                      timeout=timeout
                      File "/var/containers/Bundle/Application/44E531D9-C860-4F8B-9A15-16BE6F3BE756/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/urllib3/connectionpool.py", line 547, in urlopen
                      timeout_obj = self._get_timeout(timeout)
                      File "/var/containers/Bundle/Application/44E531D9-C860-4F8B-9A15-16BE6F3BE756/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/urllib3/connectionpool.py", line 303, in _get_timeout
                      return Timeout.from_float(timeout)
                      File "/var/containers/Bundle/Application/44E531D9-C860-4F8B-9A15-16BE6F3BE756/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/urllib3/util/timeout.py", line 155, in from_float
                      return Timeout(read=timeout, connect=timeout)
                      File "/var/containers/Bundle/Application/44E531D9-C860-4F8B-9A15-16BE6F3BE756/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/urllib3/util/timeout.py", line 98, in init
                      self._connect = self._validate_timeout(connect, 'connect')
                      File "/var/containers/Bundle/Application/44E531D9-C860-4F8B-9A15-16BE6F3BE756/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/urllib3/util/timeout.py", line 128, in _validate_timeout
                      "int or float." % (name, value))
                      ValueError: Timeout value connect was Timeout(connect=30, read=30, total=None), but it must be an int or float.

                      Thank in advance
                      Cheers
                      Andre

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

                        I've just installed Pythonista, the dropbox and requests packages and Synchronator. When I run DropboxSetup.py I get the following:

                        /private/var/mobile/Containers/Shared/AppGroup/EAEDE395-145A-4A8B-A282-E6D1409E3D51/Pythonista3/Documents/site-packages/requests/init.py:80: RequestsDependencyWarning: urllib3 (1.4) or chardet (3.0.4) doesn't match a supported version!
                        RequestsDependencyWarning)
                        Traceback (most recent call last):
                        File "/private/var/mobile/Containers/Shared/AppGroup/EAEDE395-145A-4A8B-A282-E6D1409E3D51/Pythonista3/Documents/Dropbox/DropboxSetup.py", line 54, in <module>
                        import dropbox
                        File "/private/var/mobile/Containers/Shared/AppGroup/EAEDE395-145A-4A8B-A282-E6D1409E3D51/Pythonista3/Documents/site-packages/dropbox/init.py", line 3, in <module>
                        fronds in my UJ UK m .dropbox import version, Dropbox, DropboxTeam, create_session # noqa: F401
                        File "/private/var/mobile/Containers/Shared/AppGroup/EAEDE395-145A-4A8B-A282-E6D1409E3D51/Pythonista3/Documents/site-packages/dropbox/dropbox.py", line 17, in <module>
                        import requests
                        File "/private/var/mobile/Containers/Shared/AppGroup/EAEDE395-145A-4A8B-A282-E6D1409E3D51/Pythonista3/Documents/site-packages/requests/init.py", line 90, in <module>
                        from urllib3.exceptions import DependencyWarning
                        ImportError: cannot import name 'DependencyWarning'

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

                          1. make sure you are using the latest stash.
                          selfupdate
                          
                          1. Install requests
                          pip install requests
                          
                          1. For me, I had to update chardet and idna. Update failed, but install then fixed it.
                          pip update chardet
                          pip install chardet
                          pip update idna
                          pip install idna
                          pip update dropbox
                          pip install dropbox
                          
                          1. in console:
                          M=[m for m in sys.modules if 'requests' in m]
                          for m in M:
                             del sys.modules[m]
                          import requests
                          
                          Dangthrimble 2 Replies Last reply Reply Quote 0
                          • Dangthrimble
                            Dangthrimble @JonB last edited by Dangthrimble

                            @JonB can you explain the purpose of step 4? And with all the packages that have been installed, why am I only interested in requests? Thanks

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

                              you could just force quit pythonista. The issue is that requests is imported by stash, so to force the new version to import, you have to delete everything related from sys.modules.

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

                                @JonB why don't I have to do the same for the other packages that have been installed? Do you mean StaSh doesn't use the other packages?

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

                                  @JonB I tried the first line at the console and got:

                                  >>> M=[m for m in sys.modules if 'requests' in m]
                                  Traceback (most recent call last):
                                    File "<string>", line 1, in <module>
                                  NameError: name 'sys' is not defined
                                  
                                  1 Reply Last reply Reply Quote 0
                                  • JonB
                                    JonB last edited by

                                    import sys
                                    

                                    Again, the only reason I did this was to check that the import was successful, without a full quit -- it took a few tries, to figure out that I needed to update chardet, then idna.

                                    Since you know what you need to update already, just double tap the home button and swipe to kill pythonista. When you come back, import requests and if it works, you are good to go

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

                                      @JonB I killed and restarted Pythonista and got:

                                      >>> import requests
                                      /private/var/mobile/Containers/Shared/AppGroup/77E4F4DB-EDA3-49C3-8AAD-D4452754B812/Pythonista3/Documents/site-packages/requests/__init__.py:80: RequestsDependencyWarning: urllib3 (1.4) or chardet (3.0.4) doesn't match a supported version!
                                        RequestsDependencyWarning)
                                      Traceback (most recent call last):
                                        File "<string>", line 1, in <module>
                                        File "/private/var/mobile/Containers/Shared/AppGroup/77E4F4DB-EDA3-49C3-8AAD-D4452754B812/Pythonista3/Documents/site-packages/requests/__init__.py", line 90, in <module>
                                          from urllib3.exceptions import DependencyWarning
                                      ImportError: cannot import name 'DependencyWarning'
                                      

                                      Did some more digging and found that StaSh had installed urllib3 version 1.4 whereas the latest version is 1.22. Fortunately I am still at the beginning of my journey with Pythonista so I have deleted and reinstalled it. I will try again.

                                      HerniaChair 1 Reply Last reply Reply Quote 0
                                      • Dangthrimble
                                        Dangthrimble last edited by Dangthrimble

                                        There is a problem with the way StaSh pip handles installing minimum versions. I have raised an issue on GitHub (see Pip installed wrong version of urllib3). To get round the problem, check the latest version of the package you are trying to install using PyPI - the Python Package Index and install that version using:

                                        pip install [-d <directory>] <package>==<version>
                                        

                                        And if a package gets installed as a dependency for another, check its version and if it is wrong perform a pip remove and install the correct version.

                                        I am documenting exactly how I am getting this to work and, once it does, I will post it on this forum.

                                        1 Reply Last reply Reply Quote 0
                                        • HerniaChair
                                          HerniaChair @Dangthrimble last edited by

                                          @Dangthrimble

                                          I have the same issue as you, but when I tried to install/update/ remove requests, I get the same issue:

                                          StaSh v0.6.20
                                          Tip: You can redirect output to Pythonista console, e.g. ls > &3
                                          [~/Documents]$ pip install requests
                                          /private/var/mobile/Containers/Shared/AppGroup/8D798770-A6EB-4040-9568-3BCBFB1CF8E8/Documents/site-packages/requests/__init__.py:80: RequestsDependencyWarning: urllib3 (1.4) or chardet (3.0.4) doesn't match a supported version!
                                            RequestsDependencyWarning)
                                          stash: <type 'exceptions.ImportError'>: cannot import name DependencyWarning
                                          

                                          Is there a way to fix the requests module without deleting Pythonista altogether?

                                          Dangthrimble 1 Reply Last reply Reply Quote 0
                                          • Dangthrimble
                                            Dangthrimble @HerniaChair last edited by Dangthrimble

                                            @HerniaChair I'm not an expert and so I don't know if it will work, but you could try deleting the requests folder in site-packages and close down and restart Pythonista

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