Compare commits
9 Commits
a14d7b77fa
...
2f02650bcf
| Author | SHA1 | Date | |
|---|---|---|---|
| 2f02650bcf | |||
| 7cd518c71a | |||
| 09c3b3baa4 | |||
| 550cdb0ac0 | |||
| a1b5b333ff | |||
| a8934a6549 | |||
| 2a2081829f | |||
| 9f36e7db35 | |||
| 1bfc592491 |
@@ -6,7 +6,7 @@ import shelve, os
|
|||||||
class steuer_rechner:
|
class steuer_rechner:
|
||||||
def __init__(self, lohn_eingabe = int) -> None:
|
def __init__(self, lohn_eingabe = int) -> None:
|
||||||
self.lohneingabe = lohn_eingabe
|
self.lohneingabe = lohn_eingabe
|
||||||
self.data_datei = os.path.dirname(os.path.realpath(__file__)) + os.sep + "data"
|
y = os.path.dirname(os.path.realpath(__file__)) + os.sep + "data"
|
||||||
self.month = ['Jan', 'Feb', 'Mae', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez']
|
self.month = ['Jan', 'Feb', 'Mae', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez']
|
||||||
if not os.path.exists(self.data_datei):
|
if not os.path.exists(self.data_datei):
|
||||||
month_dict = dict.fromkeys(self.month, 0)
|
month_dict = dict.fromkeys(self.month, 0)
|
||||||
|
|||||||
@@ -38,6 +38,11 @@ class nfs_server_conf:
|
|||||||
print(mountfile, "wurde gestartet !", sep=" ")
|
print(mountfile, "wurde gestartet !", sep=" ")
|
||||||
else:
|
else:
|
||||||
raise "Service" + mountfile +" konnte nicht gestart werden"
|
raise "Service" + mountfile +" konnte nicht gestart werden"
|
||||||
|
|
||||||
|
if subprocess.run(['systemctl', 'enable', mountfile]).returncode == 0:
|
||||||
|
print(mountfile, "wurde enabled !", sep=" ")
|
||||||
|
else:
|
||||||
|
raise "Service" + mountfile +" konnte nicht enabled werden"
|
||||||
return list_mountfiles
|
return list_mountfiles
|
||||||
|
|
||||||
def nfs_server_conf(self):
|
def nfs_server_conf(self):
|
||||||
@@ -70,10 +75,14 @@ class nfs_server_conf:
|
|||||||
unitname_nfsv4 = "nfsv4-server.service"
|
unitname_nfsv4 = "nfsv4-server.service"
|
||||||
if subprocess.run(['systemctl', 'restart', unitname_nfsv4]).returncode == 0:
|
if subprocess.run(['systemctl', 'restart', unitname_nfsv4]).returncode == 0:
|
||||||
print(unitname_nfsv4, "wurde gestartet !", sep=" ")
|
print(unitname_nfsv4, "wurde gestartet !", sep=" ")
|
||||||
return True
|
|
||||||
else:
|
else:
|
||||||
raise "Service" + unitname_nfsv4 +" konnte nicht gestart werden"
|
raise "Service" + unitname_nfsv4 +" konnte nicht gestart werden"
|
||||||
|
|
||||||
|
if subprocess.run(['systemctl', 'enable', unitname_nfsv4]).returncode == 0:
|
||||||
|
print(unitname_nfsv4, "wurde enabled !", sep=" ")
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
raise "Service" + unitname_nfsv4 +" konnte nicht enabled werden"
|
||||||
|
|
||||||
|
|
||||||
def main_install(self):
|
def main_install(self):
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
def read_sshkeys(target_folder = str, search_string = str):
|
def read_all_sub_Folder(target_folder = str, search_string = str):
|
||||||
key_liste = []
|
key_liste = []
|
||||||
for root, dirs, files in os.walk(target_folder, topdown=False, ):
|
for root, dirs, files in os.walk(target_folder, topdown=False, ):
|
||||||
for name in files:
|
for name in files:
|
||||||
@@ -16,13 +16,19 @@ def read_sshkeys(target_folder = str, search_string = str):
|
|||||||
"Folder": dirs})
|
"Folder": dirs})
|
||||||
return key_liste
|
return key_liste
|
||||||
|
|
||||||
|
#####
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
search_jenkins_folder = "/home/jonnybravo/.jenkins/data/jobs"
|
search_jenkins_folder = "/home/jonnybravo/.jenkins/data/jobs"
|
||||||
for i in read_sshkeys(target_folder=search_jenkins_folder, search_string="config.xml"):
|
search_string = """<command>./test_play.yml</command>"""
|
||||||
print(i["FullPath"])
|
for i in read_all_sub_Folder(target_folder=search_jenkins_folder, search_string="config.xml"):
|
||||||
|
#print(i["FullPath"])
|
||||||
with open(i["FullPath"], 'r') as file:
|
with open(i["FullPath"], 'r') as file:
|
||||||
data = file.read()
|
data = file.read()
|
||||||
data = data.replace('<daysToKeep>-1</daysToKeep>', '')
|
index = data.find(search_string)
|
||||||
with open(i["FullPath"], 'w') as file:
|
print(index)
|
||||||
file.write(data)
|
if not index == -1:
|
||||||
|
print("Ist in file vorhanden", file, sep=" ")
|
||||||
|
|
||||||
|
#data = data.replace('<daysToKeep>-1</daysToKeep>', '')
|
||||||
|
#with open(i["FullPath"], 'w') as file:
|
||||||
|
# file.write(data)
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
CREATE TABLE IF NOT EXISTS eggs(
|
CREATE TABLE IF NOT EXISTS eggs(
|
||||||
cooler_typ TEXT,
|
cooler_typ TEXT PRIMARY KEY,
|
||||||
glückszahl INTEGER
|
glückszahl INTEGER
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -24,14 +24,15 @@ class db_work:
|
|||||||
cursor = con_db.cursor()
|
cursor = con_db.cursor()
|
||||||
fd = open(self.script_folder + os.sep + "add_value.sql", "r")
|
fd = open(self.script_folder + os.sep + "add_value.sql", "r")
|
||||||
sql_code = fd.read().format(coolertype=cooler_typ,eine_zahl=glueckszahl)
|
sql_code = fd.read().format(coolertype=cooler_typ,eine_zahl=glueckszahl)
|
||||||
#sql_code = '''
|
|
||||||
# INSERT INTO eggs (cooler_typ, glückszahl)
|
try:
|
||||||
# VALUES('{coolertype}', {eine_zahl});
|
cursor.execute(sql_code)
|
||||||
# '''.format(coolertype=cooler_typ,eine_zahl=glueckszahl)
|
except sqlite3.IntegrityError:
|
||||||
|
return False
|
||||||
cursor.execute(sql_code)
|
|
||||||
con_db.commit()
|
con_db.commit()
|
||||||
|
return True
|
||||||
|
|
||||||
def show_value(self):
|
def show_value(self):
|
||||||
with sqlite3.connect(self.db_file) as con_db:
|
with sqlite3.connect(self.db_file) as con_db:
|
||||||
cursor = con_db.cursor()
|
cursor = con_db.cursor()
|
||||||
@@ -48,5 +49,6 @@ if __name__ == "__main__":
|
|||||||
db_file_full = script_folder + os.sep + "spam.db"
|
db_file_full = script_folder + os.sep + "spam.db"
|
||||||
my_db = db_work(db_file=db_file_full)
|
my_db = db_work(db_file=db_file_full)
|
||||||
my_db.create_db()
|
my_db.create_db()
|
||||||
my_db.add_value_db(cooler_typ="daniel-3", glueckszahl=42)
|
add_value_to_db = my_db.add_value_db(cooler_typ="daniel-5", glueckszahl=42)
|
||||||
|
print (add_value_to_db)
|
||||||
print(my_db.show_value())
|
print(my_db.show_value())
|
||||||
Binary file not shown.
1
netstat_mon/DoTo.md
Normal file
1
netstat_mon/DoTo.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
---
|
||||||
80
play_with_sqllite/main.py
Normal file
80
play_with_sqllite/main.py
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
#! /usr/bin/env python.3.11
|
||||||
|
|
||||||
|
import sqlite3, os
|
||||||
|
|
||||||
|
script_folder = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
|
||||||
|
def erzeuge_tabellen():
|
||||||
|
with sqlite3.connect(script_folder + "/startegie.db") as verbindung:
|
||||||
|
cursor = verbindung.cursor()
|
||||||
|
|
||||||
|
cursor.execute("DROP TABLE IF EXISTS viren;")
|
||||||
|
cursor.execute("DROP TABLE IF EXISTS viren_typ;")
|
||||||
|
cursor.execute("DROP TABLE IF EXISTS vorfall;")
|
||||||
|
|
||||||
|
sql = '''
|
||||||
|
CREATE TABLE viren(
|
||||||
|
name TEXT PRIMARY KEY,
|
||||||
|
typ INTEGER,
|
||||||
|
status TEXT)
|
||||||
|
'''
|
||||||
|
cursor.execute(sql)
|
||||||
|
|
||||||
|
sql = '''
|
||||||
|
CREATE TABLE viren_typ(
|
||||||
|
typ INTEGER PRIMARY KEY,
|
||||||
|
groesse INT,
|
||||||
|
signatur TEXT)
|
||||||
|
'''
|
||||||
|
cursor.execute(sql)
|
||||||
|
|
||||||
|
sql = '''
|
||||||
|
CREATE TABLE vorfall(
|
||||||
|
name TEXT,
|
||||||
|
ort TEXT,
|
||||||
|
vorfall TEXT)
|
||||||
|
'''
|
||||||
|
cursor.execute(sql)
|
||||||
|
|
||||||
|
verbindung.commit()
|
||||||
|
|
||||||
|
def schreibe_tabellen():
|
||||||
|
with sqlite3.connect(script_folder + "/startegie.db") as verbindung:
|
||||||
|
cursor = verbindung.cursor()
|
||||||
|
sql = '''
|
||||||
|
INSERT INTO viren_typ(typ, groesse, signatur)
|
||||||
|
VALUES(1,128,'ABAABA'),(2,256,'ABAABA'),(3,256,'BCCBCB')
|
||||||
|
'''
|
||||||
|
cursor.execute(sql)
|
||||||
|
|
||||||
|
sql = '''
|
||||||
|
INSERT INTO viren(name, typ, status)
|
||||||
|
VALUES ('T800', 1, 'aktiv'),
|
||||||
|
('T803', 2, 'aktiv'),
|
||||||
|
('Bit13', 3, 'aktiv'),
|
||||||
|
('Gorf3', 1, 'aktiv'),
|
||||||
|
('Gorf7', 2, 'aktiv')
|
||||||
|
'''
|
||||||
|
|
||||||
|
cursor.execute(sql)
|
||||||
|
verbindung.commit()
|
||||||
|
|
||||||
|
|
||||||
|
def lese_tabellen():
|
||||||
|
with sqlite3.connect(script_folder + "/startegie.db") as verbindung:
|
||||||
|
cursor = verbindung.cursor()
|
||||||
|
sql = '''SELECT * FROM viren_typ;'''
|
||||||
|
cursor.execute(sql)
|
||||||
|
#for ergebnis in cursor:
|
||||||
|
# print(ergebnis)
|
||||||
|
|
||||||
|
return cursor.fetchall()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
erzeuge_tabellen()
|
||||||
|
schreibe_tabellen()
|
||||||
|
for i in lese_tabellen():
|
||||||
|
print(i)
|
||||||
BIN
play_with_sqllite/startegie.db
Normal file
BIN
play_with_sqllite/startegie.db
Normal file
Binary file not shown.
Reference in New Issue
Block a user