service-etherpad/parseurl.py

24 lines
578 B
Python
Raw Normal View History

2017-07-07 13:02:43 +00:00
#!/usr/bin/env python
import sys
import os
from urlparse import urlparse
prefix = sys.argv[1]
uri = os.environ['DATABASE_URL']
result = urlparse(uri)
credential, machine = result.netloc.split('@')
username, password = credential.split(':')
host, port = machine.split(':')
path = result.path
print(prefix, 'SCHEME=', result.scheme)
print(prefix, 'USERNAME=', username)
print(prefix, 'PASSWORD=', password)
print(prefix, 'HOST=', host)
print(prefix, 'PORT=', port)
print(prefix, 'PATH=', path)
print(prefix, 'QUERY=', result.query)
print(prefix, 'FRAGMENT=', result.fragment)