Commit 1da954b4 authored by Jadyn Emma Jäger's avatar Jadyn Emma Jäger 🦄
Browse files

first bits of code

parent b3ebc680
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="SqlDialectMappings">
<file url="file://$PROJECT_DIR$/aumad/__init__.py" dialect="GenericSQL" />
<file url="PROJECT" dialect="MariaDB" />
</component>
</project>
\ No newline at end of file
import database
import host
import installation
def __init__(database_host: str, database_user: str, database_passwd: str, database_name: str, self):
self.database = database(database_host, database_user, database_passwd, database_name)
self.hosts = [host]
self.updateHosts()
self.populateHosts()
def updateHosts(self):
for host_element in database.query("SELECT * from hosts"):
self.hosts.append(host(**host_element))
def populateHosts(self):
for host_element in self.hosts:
for installation_element in database.query("SELECT * from installations WHERE host = %s",
[host_element.host_id]):
host.addInstallation(installation())
import mysql.connector
def __init__(host, user, passwd, database, self):
self.__db = mysql.connector.connect(
host=host,
user=user,
passwd=passwd,
database=database,
buffered=False
)
self.__database.autocommit = True
self.__cursor = self.__db.cursor(buffered=False)
def query(sql_command, self, values=None):
self.__cursor.execute(sql_command, values)
try:
return self.__cursor.fetchall()
except mysql.connector.errors as e:
return None
import installation
import sshConnector
installations = []
ssh = None
def run_once(f):
def wrapper(*args, **kwargs):
if not wrapper.has_run:
wrapper.has_run = True
return f(*args, **kwargs)
wrapper.has_run = False
return wrapper
def __init__(host_id: int, hostname: str, comment: str, enabled: bool, self):
self.host_id = host_id
self.hostname = hostname
self.comment = comment
self.enabled = enabled
def addInstallation(installation_element: installation, self):
self.installations.append(installation_element)
@run_once
def startSSH(self):
self.ssh = sshConnector(self.hostname)
def __init__():
self.
\ No newline at end of file
bcrypt==3.2.0
cffi==1.14.4
cryptography==3.4.4
mysql-connector==2.2.9
paramiko==2.7.2
pycparser==2.20
PyNaCl==1.4.0
six==1.15.0
import paramiko
def __init__(host: str, self, port=22):
self.sshClient = paramiko.SSHClient()
self.sshClient.connect(hostname=host, port=port)
import aumad
aumad = aumad()
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment