Refactoring

This commit is contained in:
2024-06-02 19:03:00 +02:00
parent 57b5b4ffab
commit 8c11166397
14 changed files with 401 additions and 322 deletions

23
getMySQL.py Normal file
View File

@ -0,0 +1,23 @@
import getpass
import sys
# noinspection PyPackageRequirements
def get_mysql():
"""
Extrahiert die MySQL-Anmeldedaten aus ~/.my.cnf . \n
Funktioniert wahrscheinlich nur auf Linux, vor allem für den Server gedacht.
:return: [username: str, password: str]:
"""
if sys.platform == "linux":
systemUser = getpass.getuser()
file = open("/home/"+systemUser+"/.my.cnf", "r")
content = file.read()
username = content.find("user=")
password = content.find("password=")
username = content[username+5:password-1]
readOnly = content.find("[clientreadonly]")
password = content[password+9:readOnly-2]
return username, password
else:
return "username-goes-here", "password-goes-here"