Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-11640

Better detect location of My Documents under Windows

    XMLWordPrintable

    Details

    • Backlog priority:
      890
    • Sprint:
      Sprint 1, Sprint 2

      Description

      Under Windows 7, the location of the My Documents folder can be changed, it is actually a standard functionality.
      Though currently Nuxeo Drive considers that My Documents is in the user's home, see controller.py:

      def default_nuxeo_drive_folder():
          """Find a reasonable location for the root Nuxeo Drive folder
      
          This folder is user specific, typically under the home folder.
          """
          if sys.platform == "win32":
              # WARNING: it's important to check `Documents` first as under Windows 7
              # there also exists a `My Documents` folder invisible in the explorer
              # and cmd / powershell but visible from Python
              documents = os.path.expanduser(ur'~\Documents')
              my_documents = os.path.expanduser(ur'~\My Documents')
              if os.path.exists(documents):
                  # Regular location for documents under Windows 7 and up
                  return os.path.join(documents, u'Nuxeo Drive')
              elif os.path.exists(my_documents):
                  # Compat for Windows XP
                  return os.path.join(my_documents, u'Nuxeo Drive')
      
          # Fallback to home folder otherwise
          return os.path.join(os.path.expanduser(u'~'), u'Nuxeo Drive'
      

      This can lead to the following error if the user changes the location of My Documents, for example to D:\Users\joe\My Documents:

      2013-05-30 15:18:11,226 23072 22920 DEBUG    nxdrive.gui.authentication Unable to connect to http://192.168.56.101/nuxeo
      Traceback (most recent call last):
        File "nuxeo-drive-client\nxdrive\gui\authentication.py", line 142, in bind_server
        File "nuxeo-drive-client\nxdrive\controller.py", line 263, in bind_server
        File "C:\Python\32-bit\2.7\lib\os.py", line 157, in makedirs
      WindowsError: [Error 3] The system cannot find the path specified: u'C:\\Users\\joe\\My Documents\\Nuxeo Drive'
      

      (note that the "Unable to connect to http://192.168.56.101/nuxeo") error message is not correct because of a bad exception handling, see NXP-11580

      As suggested in this topic: http://stackoverflow.com/questions/9677692/getting-my-documents-path-in-java the location of the My Documents folder can be pulled from registry which seems to be a more solid solution.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 4 hours
                  4h
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 2 hours Time Not Required
                  2h