diff --git a/lib/CreoMigrateGui.py b/lib/CreoMigrateGui.py index e7a03e2..7f98d63 100644 --- a/lib/CreoMigrateGui.py +++ b/lib/CreoMigrateGui.py @@ -7,69 +7,8 @@ from controller import Controller from manage_configs import Configs import argparse import os -import json -demo_data = """ -{ - "parent_children_mapping": { - "400102130": [ "400102142" ], - "400102167": [ "821116004" ], - "400102168": [ "821116001" ], - "400102195": [ "822066075", "822066216", "822066154", "822066101", - "822064090", "822066196", "400102129", "822066217", "822066160", - "822066215", "913041045", "913011009", "911011057", "822064035", - "925011006", "911091041", "913051040", "911021112", "911021166", - "825006003", "912041005", "911011014", "911011009", "911021144", - "911021001", "913011016", "929055170", "913011010", "911021035", - "829416065", "712000151", "712000100" ], - "400102196": [ "400102125", "400102126", "400102130", "400102161", - "400102163", "400102165", "400102166", "400102167", "400102168", - "400102190", "400102195", "400102198", "400102246", "400102247", - "400102267", "400102272", "400102274", "400102275", "400102277", - "400102278", "400102282", "400102284", "400102417", "720002003", - "721001034", "821114025", "822064091", "822066085", "822996075", - "829416061", "829516004", "911021113", "911021181", "911021259", - "911091054", "911091096", "911091097", "911251013", "912011009", - "919050006", "924031058", "924031081" ], - "400102235": [ "400102236", "400102237", "400102238", "400102239", - "400102268", "911021143", "911021054", "911021055" ], - "400102236": [ "MA0000006" ], - "400102267": [ "400102235", "829416159", "829416077", "829416079", - "911021260", "911021147", "911251014" ], - "400102282": [ "822066026", "822066089", "919010052" ], - "821114025": [ "911081007", "821116053" ], - "821116004": [ "822026004" ], - "822064035": [ "822066065" ], - "822064091": [ "822066212", "822064093", "822066220", "822066200", - "912011010", "911021156", "822066201", "911071027", "913011109", - "911011070", "913011001", "710005021", "919010055", "720000008", "720000007" ], - "822064093": [ "822066204", "822066205", "822066206", "822066207", "822066208" ], - "822066075": [ "822066157", "822066162", "911261023" ], - "822066160": [ "MA0000004" ], - "822066162": [ "822064013" ], - "822066196": [ "MA0000008" ], - "822066220": [ "924031033" ], - "829416159": [ "829416089" ] - }, - "red_ids": [ "400102274", "400102275", "400102190", "400102198", "400102161", - "400102277", "400102163", "400102278", "400102282", "400102284", - "400102195", "MA0000008", "MA0000004", "929055170", "400102267", - "400102235", "400102236", "MA0000006", "400102237", "400102238", - "400102239", "400102268", "829416159", "924031058", "924031081", - "822064091", "822066199", "822066200" ], - "gui_data": { - "asm_id": "400102190", - "teilenummer": "400102195", - "neuaufbau": "False", - "lebenszyklus_status_neu": "Serie", - "aus_halbzeug_neu": "True", - "zusatzinfos_auto_text": "Dies sind neue Zusatzinfos" - }, - "data": {} -} -""" - #"teilenummer": "400102195", assembly class Environment: @@ -80,7 +19,7 @@ class Environment: self.cfg_dir = os.environ.get('CREMIG_CFG') self.ruledesigner_csv_filename = os.environ.get('RD_DATABASE_NAME') -def build_gui(model, configs, env, sivasid, uselocal=True): +def build_gui(model, configs, env, sivasid=None, uselocal=True): root = tk.Tk() #root = ttk.Window() app = App(root) @@ -88,7 +27,8 @@ def build_gui(model, configs, env, sivasid, uselocal=True): controller = Controller(model, app) controller.set_env(env) controller.set_config(configs) - controller.get_csv_files_of_asm(sivasid, uselocal) + if sivasid: + controller.get_csv_files_of_asm(sivasid, uselocal) logic = GuiLogic(model, configs) model.add_logic(logic) @@ -99,7 +39,6 @@ def build_gui(model, configs, env, sivasid, uselocal=True): # Daten des Modells in der Oberfläche darstellen controller.refresh_gui() - app.mainloop() @@ -108,7 +47,6 @@ if __name__ == '__main__': parser.add_argument('-s', '--sivasid', action='store', help='Eingabe der SIVAS-Teilenummer, für die der Migrationsstatus angezeigt werden soll') parser.add_argument('-d', '--demo', action='store_true', help='arbeitet ohne Server. Lädt Testdaten ein um nur eine Oberfläche darzustellen') parser.add_argument('-l', '--uselocal', action='store_true', help='Verbinde dich nicht zur Datenbank. Benutzer alle lokalen Dateien (falls vorhanden) für die gegebene asm-id') - args = parser.parse_args() environment = Environment() @@ -119,11 +57,7 @@ if __name__ == '__main__': model = CadItem() - if args.demo: - model.from_json(json.loads(demo_data)) - build_gui(model, configs, environment, "400102196", True) - - elif args.sivasid: + if args.sivasid: sivasid = args.sivasid.strip() output_dir = environment.out_dir @@ -135,5 +69,6 @@ if __name__ == '__main__': # die Gui aufbauen build_gui(model, configs, environment, sivasid, args.uselocal) else: - parser.print_help() + build_gui(model, configs, environment) + diff --git a/lib/caditem.py b/lib/caditem.py index f056e64..2a98d53 100644 --- a/lib/caditem.py +++ b/lib/caditem.py @@ -1716,10 +1716,10 @@ class GuiLogic(): # Default Vorbelegung default = '' if pdm_kategorie_neu == "Kaufteil": - if calc_art == "Eigenbau" or calc_art == "": + if calc_art == "Eigenbau" or calc_art == "" or calc_art == None: default = "Kaufteil" else: - if calc_art == "Kaufteil" or calc_art == "": + if calc_art == "Kaufteil" or calc_art == "" or calc_art == None: default = "Eigenbau" ret['kalkulationsart_neu'] = default else: diff --git a/lib/controller.py b/lib/controller.py index 7654599..5421136 100644 --- a/lib/controller.py +++ b/lib/controller.py @@ -47,7 +47,7 @@ class Observer: observable.subscribe(self) def notify(self, observable, *args, **kwargs): - print(f"Got {args} {kwargs} from {observable}") + #print(f"Got {args} {kwargs} from {observable}") dependent_cbs = self._model.get_dependent(args[0]) for cb in dependent_cbs: model_values = self._model.callback(cb, None) @@ -269,11 +269,11 @@ class Controller(Observer): self.refresh_gui() def migrieren(self): - # (ok, missing) = self._model.check_pflichtfelder() - # if ok == False: - # labels = ', '.join(missing) - # self.message_error('Fehlende Angaben', 'missing_data', {'Labels':labels}) - # return + (ok, missing) = self._model.check_pflichtfelder() + if ok == False: + labels = ', '.join(missing) + self.message_error('Fehlende Angaben', 'missing_data', {'Labels':labels}) + return invalid_chars = self._config.InvalidChars.get() (ok, wrongchars) = self._model.check_improper_chars(invalid_chars) if ok == False: