title: relative path parsing in sftp url with python urllib.parse
body: <p>I have a sftp remote server. I want to use a library that uses the pysftp package to upload files to the server. The relevant source code part is:</p>
  
  <pre><code>import pysftp
  import os
  
  
  user = os.getenv("FTP_USER")
  pwd = os.getenv("FTP_PWD")
  path = "dir"
  with pysftp.Connection('192.168.100.120', username=user, password=pwd) as ftp:
     if not ftp.exists(path):
        print("Directory does not exists. Create it")
        ftp.mkdir(path)
     with ftp.cd(path):
        ftp.put('output.txt')
  </code></pre>
  
  <p>It works fine if <code>path</code> is relative to the sftp folder and the user has the right to write into it. The problem comes from the parsing of the URL I gave to the library which extracts the path where to store files:</p>
  
  <pre><code>from six.moves import urllib 
  
  urllib.parse.urlparse("sftp://user:password@server_ip/path").path
  </code></pre>
  
  <p>which return <code>/path</code> instead of <code>path</code>, and of course the user has no right to write to the root of the server.</p>
  
  <p>What am I doing wrong in the URL ? How to construct it so that the path is a relative one and not an absolute one ?</p>