Skip to content

Instantly share code, notes, and snippets.

@TomasKulhanek
Last active March 20, 2018 10:34
Show Gist options
  • Save TomasKulhanek/67942cc928dba51c29d4235db03008ae to your computer and use it in GitHub Desktop.
Save TomasKulhanek/67942cc928dba51c29d4235db03008ae to your computer and use it in GitHub Desktop.
test connection to virtual folder from python
# 1. obtain URL of VF directory manually using https://portal.west-life.eu/virtualfolder/filepicker.html - using "Open Upload Dir picker ...."
# 2. copy & paste URL of selected dir into the call of: urllib2.urlopen()
# 3. call this code using python2 - e.g. python testvfpy2.py
# it should report something like
# 200
# Server: nginx
# ...
# <!DOCTYPE HTML PUBLIC ....
import urllib2
#paste url from VF upload dir picker here
r = urllib2.urlopen("https://portal.west-life.eu/webdav/eyxxxxx")
print (r.getcode())
print (r.info())
print (r.read())
# 0. need to install certifi and urllib3[secure] see https://urllib3.readthedocs.io/en/latest/user-guide.html#ssl
# 1. obtain URL of VF directory manually using https://portal.west-life.eu/virtualfolder/filepicker.html - using "Open Upload Dir picker ...."
# 2. copy & paste URL of selected dir into the url variable: url = '...';
# 3. call this code using python2 - e.g. python testvfpy2urllib3.py
# it should report something like
# 200
# Server: nginx
# ...
# <!DOCTYPE HTML PUBLIC ....
import certifi
import urllib3
http = urllib3.PoolManager(cert_reqs='CERT_REQUIRED',ca_certs=certifi.where())
url= 'https://portal.west-life.eu/webdav/eyxxxxxxxxxx'
r = http.request('GET',url)
print (r.status)
print (r.info())
print (r.read())
# 1. obtain URL of VF directory manually using https://portal.west-life.eu/virtualfolder/filepicker.html - using "Open Upload Dir picker ...."
# 2. copy & paste URL of selected dir into the call of: urllib2.urlopen()
# 3. call this code using python3 - e.g. python3 testvfpy3.py
# it should report something like
# 200
# Server: nginx
# ...
# <!DOCTYPE HTML PUBLIC ....
import urllib.request
#paste url from VF upload dir picker here
r = urllib.request.urlopen("https://portal.west-life.eu/webdav/eyxxxxxxxxx")
print(r.getcode())
print(r.info())
print(r.read())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment