Bei einigen Dateien kann ich den Montageort nicht bearbeiten, da sie auf einmal Zahlen sind

This commit is contained in:
Sven Riwoldt
2024-10-25 19:35:37 +02:00
parent 56fbc57072
commit a8d5f65438
3 changed files with 203 additions and 147 deletions

View File

@@ -17,13 +17,14 @@
<property name="geometry">
<rect>
<x>450</x>
<y>10</y>
<width>250</width>
<y>0</y>
<width>171</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<family>Arial Unicode MS</family>
<pointsize>18</pointsize>
</font>
</property>
@@ -40,6 +41,11 @@
<height>28</height>
</rect>
</property>
<property name="font">
<font>
<family>Arial Unicode MS</family>
</font>
</property>
<property name="text">
<string>Speichern unter</string>
</property>
@@ -50,9 +56,15 @@
<x>300</x>
<y>60</y>
<width>331</width>
<height>16</height>
<height>21</height>
</rect>
</property>
<property name="font">
<font>
<family>Arial Unicode MS</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
@@ -77,6 +89,7 @@
<widget class="QLabel" name="label_6">
<property name="font">
<font>
<family>Arial Unicode MS</family>
<pointsize>12</pointsize>
</font>
</property>
@@ -90,12 +103,17 @@
<widget class="QPushButton" name="openBtn">
<property name="geometry">
<rect>
<x>160</x>
<x>150</x>
<y>30</y>
<width>85</width>
<width>121</width>
<height>28</height>
</rect>
</property>
<property name="font">
<font>
<family>Arial Unicode MS</family>
</font>
</property>
<property name="text">
<string>Öffnen</string>
</property>
@@ -111,6 +129,7 @@
</property>
<property name="font">
<font>
<family>Arial Unicode MS</family>
<pointsize>13</pointsize>
</font>
</property>

View File

@@ -5,13 +5,15 @@ from pathlib import Path
import pandas as pd
from icecream import ic
import numpy as np
class MainUI(QDialog): # erbt von QDialog
class MainUI(QDialog): # erbt von QDialog
def __init__(self):
#super (MainUI, self).__init__() #Aufrufen des Konstruktors von QDialog
# super (MainUI, self).__init__() #Aufrufen des Konstruktors von QDialog
super().__init__()
loadUi ("Aufbaumaster2CSV.ui", self)
loadUi("Aufbaumaster2CSV.ui", self)
self.filename = None
self.path = None
self.path = None
self.df_vte = None
self.df_cmdb = None
self.dfb = None
@@ -21,13 +23,6 @@ class MainUI(QDialog): # erbt von QDialog
self.group = None
self.typ = None
def changegroup(self):
self.group = self.gruppierung.currentText()
# ic("Gruppen: ", self.group)
def changegtyp(self):
self.typ = self.geraetetyp.currentText()
# ic("Typ: ", self.typ)
def open_file_dialog(self):
self.filename, _ = QFileDialog.getOpenFileName(
@@ -42,29 +37,29 @@ class MainUI(QDialog): # erbt von QDialog
if self.filename:
self.path = Path(self.filename)
#self.changetable()
self.collectdata()
self.collect_grundgeraete()
# self.collect_erweiterung()
def onClicked(self):
pass
def collectdata(self):
def collect_grundgeraete(self):
# Einlesen der Sheets
self.df_vte = pd.read_excel(self.filename,header=7,na_filter=False,sheet_name="VTE-Input",engine='pyxlsb',usecols=['Hostname','Gruppierung','CONFIG-ID','CMDB Status'])
#print(self.df_vte.head)
self.df_cmdb = pd.read_excel(self.filename,header=2,sheet_name="CMDB", engine='pyxlsb')
#self.df_sw_asset = pd.read_excel(self.filename,sheet_name="SW-Asset", engine='pyxlsb')
self.df_vte = pd.read_excel(self.filename, header=7, na_filter=False, sheet_name="VTE-Input", engine='pyxlsb',
usecols=['Hostname', 'Gruppierung', 'CONFIG-ID', 'CMDB Status'])
# print(self.df_vte.head)
self.df_cmdb = pd.read_excel(self.filename, header=2, sheet_name="CMDB", engine='pyxlsb')
# self.df_sw_asset = pd.read_excel(self.filename,sheet_name="SW-Asset", engine='pyxlsb')
# Nach relevanten Spalten filtern
self.df_vte = self.df_vte[self.df_vte['Gruppierung']=='Grundgerät']
#self.df_vte = self.df_vte.drop(columns=['RAM','Bestelldatum','Hersteller','Lieferant','SAP-Nr.','Lieferdatum','Lieferschein-Nr.','WV-Start','WV-Ende','Aufgaben Schritt','Verkehrsart','Anz.\nHE '])
self.df_cmdb = self.df_cmdb[self.df_cmdb['Filter'].isin(['Grundgerät','Erweiterung'])]
self.df_cmdb = self.df_cmdb.drop(columns=['WV-Start','WV-Ende','CMDB-Status','Aufgabe Schritt','Filter','Waermeabgabe [BTU/h]','kalk. Strom [A]'])
self.df_vte = self.df_vte[self.df_vte['Gruppierung'] == 'Grundgerät']
# self.df_vte = self.df_vte.drop(columns=['RAM','Bestelldatum','Hersteller','Lieferant','SAP-Nr.','Lieferdatum','Lieferschein-Nr.','WV-Start','WV-Ende','Aufgaben Schritt','Verkehrsart','Anz.\nHE '])
self.df_cmdb = self.df_cmdb[self.df_cmdb['Filter'].isin(['Grundgerät', 'Erweiterung'])]
self.df_cmdb = self.df_cmdb.drop(
columns=['WV-Start', 'WV-Ende', 'CMDB-Status', 'Aufgabe Schritt', 'Filter', 'Waermeabgabe [BTU/h]',
'kalk. Strom [A]'])
# Einfügen von Spalten in die CMDB-Tabelle
self.dfb = self.df_vte.merge(self.df_cmdb, on=['Hostname'], how='left')
@@ -96,7 +91,9 @@ class MainUI(QDialog): # erbt von QDialog
# Führende Leerzeichen in allen Spalten entfernen
self.dfb = self.dfb.apply(lambda x: x.str.lstrip() if x.dtype == "object" else x)
self.dfb = self.dfb.apply(self.suche_Einschub, axis=1)
self.dfb = self.dfb.apply(self.montageort, axis=1)
self.dfb = self.dfb.apply(self.prüfe_und_setze_wert, axis=1)
@@ -105,35 +102,44 @@ class MainUI(QDialog): # erbt von QDialog
self.dfb['belegte\nHE'] = self.dfb['belegte\nHE'].apply(lambda x: x if pd.isnull(x) else str(int(x)))
##############################################################################################
#def collect_erweiterung(self):
def suche_Einschub(self, einschub):
if einschub['Montageort'][-1] in ('v' 'h'):
print (einschub['Montageort'])
einschub['Einschub'] = einschub['Montageort'][-1]
return einschub
def prüfe_und_setze_wert(self, zeile):
ic(zeile)
def montageort(self, montage):
# Fehlerbereinigung
if zeile['ID\nStandort'] not in ("Ber-PS","Bon-BTW"):
if montage['ID\nStandort'] not in ("Ber-PS", "Bon-BTW"):
print("Kein Standort P40 oder BTW")
sys.exit(0)
else:
if len((zeile['Montageort'][8:13])) !=2:
zeile['HE'] = zeile['Montageort'][8:10]
zeile['Montageort'] = zeile['Montageort'][0:7]
if len((montage['Montageort'][8:13])) != 2:
montage['HE'] = montage['Montageort'][8:10]
montage['Montageort'] = montage['Montageort'][0:7]
else:
zeile['HE'] = zeile['Montageort'][8:10]
zeile['Montageort'] = zeile['Montageort'][0:7]
# TODO:
# Einschub vorn/hinten einbauen
montage['HE'] = montage['Montageort'][8:10]
montage['Montageort'] = montage['Montageort'][0:7]
return montage
def korrektur_hersteller(self, hersteller):
if hersteller['Hersteller'].lower() == "cisco":
hersteller['Hersteller'] = "Cisco Systems"
elif hersteller['Hersteller'].lower() == "genua":
hersteller['Hersteller'] = "genua GmbH"
elif hersteller['Hersteller'].lower() == "digi":
hersteller['Hersteller'] = "Digi International Inc."
return hersteller
if zeile['Hersteller'].lower() == "cisco":
zeile['Hersteller'] = "Cisco Systems"
elif zeile['Hersteller'].lower() == "genua":
zeile['Hersteller'] = "genua GmbH"
elif zeile['Hersteller'].lower() == "digi":
zeile['Hersteller'] = "Digi International Inc."
else:
pass
def prüfe_und_setze_wert(self, zeile):
#ic(zeile)
################################################################
if zeile['Hostname'][4:6] == "10":
zeile['ID\nMandanten'] = 'm10 CMP Plattform / iM.0 / iM.4 / PAP sIMCP'
@@ -145,7 +151,7 @@ class MainUI(QDialog): # erbt von QDialog
zeile['Domain'] = 'mgmt.t-cmp.de'
elif zeile['Hostname'][4:6] == "19":
zeile['ID\nMandanten'] = 'm19 Testumgebung'
if zeile['Hostname'][4:8].isin("1920","1921"):
if zeile['Hostname'][4:8].isin("1920", "1921"):
zeile['Domain'] = 'm19.t-cmp.de'
else:
zeile['Domain'] = 'm193.t-cmp.de'
@@ -193,117 +199,117 @@ class MainUI(QDialog): # erbt von QDialog
if zeile['Hostname'][6:8] == "00":
zeile['Segment'] = 'm10 mgmt CMP Core'
elif zeile['Hostname'][6:8] == "01":
zeile['Segment'] = 'm10 mgmt Infrastructure'
zeile['Segment'] = 'm10 mgmt Infrastructure'
elif zeile['Hostname'][6:8] == "02":
zeile['Segment'] = 'm10 mgmt Administration'
zeile['Segment'] = 'm10 mgmt Administration'
elif zeile['Hostname'][6:8] == "03":
zeile['Segment'] = 'm10 mgmt zLightsOut'
zeile['Segment'] = 'm10 mgmt zLightsOut'
elif zeile['Hostname'][6:8] == "04":
zeile['Segment'] = 'm10 CTS'
zeile['Segment'] = 'm10 CTS'
elif zeile['Hostname'][6:8] == "05":
zeile['Segment'] = 'm10-OSS'
zeile['Segment'] = 'm10-OSS'
elif zeile['Hostname'][6:8] == "10":
zeile['Segment'] = 'm10 CMP2sIM'
zeile['Segment'] = 'm10 CMP2sIM'
elif zeile['Hostname'][6:8] == "11":
zeile['Segment'] = 'm10 Intern-CMP iM0'
zeile['Segment'] = 'm10 Intern-CMP iM0'
elif zeile['Hostname'][6:8] == "12":
zeile['Segment'] = 'm20 iM.1 Interner Mandant 1 (SB sehr hoch)'
zeile['Segment'] = 'm20 iM.1 Interner Mandant 1 (SB sehr hoch)'
elif zeile['Hostname'][6:8] == "13":
zeile['Segment'] = 'm21 iM.2 Interner Mandant 2 (SB normal)'
zeile['Segment'] = 'm21 iM.2 Interner Mandant 2 (SB normal)'
elif zeile['Hostname'][6:8] == "14":
zeile['Segment'] = 'm22 iM.3 Interner Mandant 3 (SB hoch)'
zeile['Segment'] = 'm22 iM.3 Interner Mandant 3 (SB hoch)'
elif zeile['Hostname'][6:8] == "15":
zeile['Segment'] = 'm10 iM.4 Interner Mandant 4 (CNMS2CMP)'
zeile['Segment'] = 'm10 iM.4 Interner Mandant 4 (CNMS2CMP)'
elif zeile['Hostname'][6:8] == "20":
zeile['Segment'] = 'VRD-Plattform (PAP-Anbindung)'
zeile['Segment'] = 'VRD-Plattform (PAP-Anbindung)'
elif zeile['Hostname'][6:8] == "21":
zeile['Segment'] = 'VRD-Plattform (LightsOut + Basisinfrastruktur + Cache)'
zeile['Segment'] = 'VRD-Plattform (LightsOut + Basisinfrastruktur + Cache)'
elif zeile['Hostname'][6:8] == "22":
zeile['Segment'] = 'VRD-Plattform (Admin)'
zeile['Segment'] = 'VRD-Plattform (Admin)'
elif zeile['Hostname'][6:8] == "23":
zeile['Segment'] = 'VRD-Plattform (Basisinfrastruktur Mandant zentral)'
zeile['Segment'] = 'VRD-Plattform (Basisinfrastruktur Mandant zentral)'
elif zeile['Hostname'][6:8] == "24":
zeile['Segment'] = 'Spare'
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "25":
zeile['Segment'] = 'Spare'
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "26":
zeile['Segment'] = 'Spare'
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "27":
zeile['Segment'] = 'Spare'
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "28":
zeile['Segment'] = 'Spare'
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "29":
zeile['Segment'] = 'Spare'
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "30":
zeile['Segment'] = 'Spare'
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "31":
zeile['Segment'] = 'VRD-Mandant (Infrastruktur)'
zeile['Segment'] = 'VRD-Mandant (Infrastruktur)'
elif zeile['Hostname'][6:8] == "32":
zeile['Segment'] = 'VRD-Mandant (Admin)'
zeile['Segment'] = 'VRD-Mandant (Admin)'
elif zeile['Hostname'][6:8] == "33":
zeile['Segment'] = 'VRD-Mandant (Anbindung)'
zeile['Segment'] = 'VRD-Mandant (Anbindung)'
elif zeile['Hostname'][6:8] == "34":
zeile['Segment'] = 'Spare'
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "35":
zeile['Segment'] = 'Spare'
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "36":
zeile['Segment'] = 'Spare'
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "37":
zeile['Segment'] = 'Spare'
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "38":
zeile['Segment'] = 'Spare'
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "39":
zeile['Segment'] = 'Spare'
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "40":
zeile['Segment'] = 'Spare'
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "41":
zeile['Segment'] = 'Spare'
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "42":
zeile['Segment'] = 'Spare'
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "43":
zeile['Segment'] = 'Spare'
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "44":
zeile['Segment'] = 'Spare'
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "45":
zeile['Segment'] = 'Spare'
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "46":
zeile['Segment'] = 'Spare'
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "47":
zeile['Segment'] = 'Spare'
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "48":
zeile['Segment'] = 'Spare'
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "49":
zeile['Segment'] = 'Spare'
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "50":
zeile['Segment'] = 'Spare'
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "51":
zeile['Segment'] = 'VRD-Mandant (Kundensegment Infra)'
zeile['Segment'] = 'VRD-Mandant (Kundensegment Infra)'
elif zeile['Hostname'][6:8] == "52":
zeile['Segment'] = 'VRD-Mandant (Kundensegment Admin)'
zeile['Segment'] = 'VRD-Mandant (Kundensegment Admin)'
elif zeile['Hostname'][6:8] == "53":
zeile['Segment'] = 'VRD-Mandant (Kundensegment)'
zeile['Segment'] = 'VRD-Mandant (Kundensegment)'
elif zeile['Hostname'][6:8] == "b0":
zeile['Segment'] = 'mgmt BS Übergang zum CMP Core'
zeile['Segment'] = 'mgmt BS Übergang zum CMP Core'
elif zeile['Hostname'][6:8] == "ba":
zeile['Segment'] = 'mgmt BS Bon BTW'
zeile['Segment'] = 'mgmt BS Bon BTW'
elif zeile['Hostname'][6:8] == "bb":
zeile['Segment'] = 'mgmt BS Bon LRS'
zeile['Segment'] = 'mgmt BS Bon LRS'
elif zeile['Hostname'][6:8] == "bc":
zeile['Segment'] = 'mgmt BS Ber W55'
zeile['Segment'] = 'mgmt BS Ber W55'
elif zeile['Hostname'][6:8] == "bd":
zeile['Segment'] = 'mgmt BS Ber PS'
zeile['Segment'] = 'mgmt BS Ber PS'
elif zeile['Hostname'][6:8] == "be":
zeile['Segment'] = 'mgmt BS Ber NDA'
zeile['Segment'] = 'mgmt BS Ber NDA'
elif zeile['Hostname'][6:8] == "bf":
zeile['Segment'] = 'mgmt BS HanTMX'
zeile['Segment'] = 'mgmt BS HanTMX'
elif zeile['Hostname'][6:8] == "bg":
zeile['Segment'] = 'mgmt BS Ber DS'
zeile['Segment'] = 'mgmt BS Ber DS'
elif zeile['Hostname'][6:8] == "c0":
zeile['Segment'] = 'mgmt CMP Übergang Internet'
zeile['Segment'] = 'mgmt CMP Übergang Internet'
elif zeile['Hostname'][6:8] == "x1":
zeile['Segment'] = 'm10 SecA2sIM'
zeile['Segment'] = 'm10 SecA2sIM'
################################################################
################################################################
# Genucenter -
# HW Appliance -
@@ -318,8 +324,7 @@ class MainUI(QDialog): # erbt von QDialog
# Switch C__OBJTYPE__SWITCH -
# virtuelle Maschine Objekttyp = C__OBJTYPE__VIRTUAL_SERVER
# Terminalserver Objekttyp = C__OBJTYPE__TERMINALSERVER -
# wenn vho dann Objekttyp = C__OBJTYPE__VIRTUAL_HOST -
# wenn vho dann Objekttyp = C__OBJTYPE__VIRTUAL_HOST -
if zeile['Objekttyp (CMDB)'] == 'Genucenter':
zeile['Objekttyp (CMDB)'] = 'C__OBJTYPE__APPLIANCE'
@@ -346,35 +351,25 @@ class MainUI(QDialog): # erbt von QDialog
elif zeile['Objekttyp (CMDB)'] == 'Router':
zeile['Objekttyp (CMDB)'] = 'C__OBJTYPE__ROUTER'
if zeile['Hostname'][1:3] == "vho":
zeile['Objekttyp (CMDB)'] = 'C__OBJTYPE__VIRTUAL_HOST'
################################################################
# Einschub
if zeile['Montageort'][-1].isin('v', 'h'):
zeile['Einschub'] = zeile['Montageort'][-1]
################################################################
return zeile
def save_file_dialog(self):
ic(self.dfb)
options = QFileDialog.Options()
options |= QFileDialog.DontUseNativeDialog
self.savefilename, _ = QFileDialog.getSaveFileName(self,
"Save File", "", "CSV(*.csv);;CSV Files(*.csv)", options = options)
"Save File", "", "CSV(*.csv);;CSV Files(*.csv)",
options=options)
self.dfb.to_csv(self.savefilename, index=None, header=True, encoding='utf-8')
print("Datei wurde gespeichert:", self.savefilename)
if __name__ == "__main__" :
app = QApplication (sys.argv)
if __name__ == "__main__":
app = QApplication(sys.argv)
ui = MainUI()
ui.show()
app.exec_()

42
Fehler.ui Normal file
View File

@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Fehler</class>
<widget class="QDialog" name="Fehler">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>569</width>
<height>294</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>430</x>
<y>230</y>
<width>113</width>
<height>32</height>
</rect>
</property>
<property name="text">
<string>OK</string>
</property>
</widget>
<widget class="QTextEdit" name="textEdit">
<property name="geometry">
<rect>
<x>30</x>
<y>20</y>
<width>511</width>
<height>191</height>
</rect>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>