22 lines
563 B
Python
22 lines
563 B
Python
import getpass
|
|
import sys
|
|
|
|
|
|
def get_mysql():
|
|
"""
|
|
Extrahiert die MySQL-Anmeldedaten aus ~/.my.cnf . \n
|
|
Funktioniert wahrscheinlich nur auf Linux, vor allem für den Server gedacht.
|
|
"""
|
|
if sys.platform == "linux":
|
|
u = getpass.getuser()
|
|
f = open("/home/"+u+"/.my.cnf", "r")
|
|
i = f.read()
|
|
u = i.find("user=")
|
|
p = i.find("password=")
|
|
u = i[u+5:p-1]
|
|
ro = i.find("[clientreadonly]")
|
|
p = i[p+9:ro-2]
|
|
return u, p
|
|
else:
|
|
return "username-goes-here", "password-goes-here"
|