diff --git a/howdy-gtk/src/logo.png b/howdy-gtk/src/logo.png index 78c620b..d8733f2 100644 Binary files a/howdy-gtk/src/logo.png and b/howdy-gtk/src/logo.png differ diff --git a/howdy-gtk/src/tab_models.py b/howdy-gtk/src/tab_models.py index fe61619..01dcf21 100644 --- a/howdy-gtk/src/tab_models.py +++ b/howdy-gtk/src/tab_models.py @@ -68,27 +68,30 @@ def on_model_add(self, button): dialog.destroy() if response == gtk.ResponseType.OK: - dialog = gtk.MessageDialog(parent=self, flags=gtk.DialogFlags.MODAL) + dialog = gtk.MessageDialog(parent=self, flags=gtk.DialogFlags.MODAL, buttons=gtk.ButtonsType.NONE) dialog.set_title(_("Creating Model")) dialog.props.text = _("Please look directly into the camera") + dialog.get_child().connect("map", lambda w: execute_add(self, dialog, entered_name, self.active_user)) dialog.show_all() - time.sleep(1) - status, output = subprocess.getstatusoutput(["howdy add -y -U " + self.active_user + " '" + entered_name + "'"]) +def execute_add(box, dialog, entered_name, user): + time.sleep(1) + + status, output = subprocess.getstatusoutput(["howdy add '" + entered_name + "' -y -U " + box.active_user]) + + dialog.destroy() + + if status != 0: + dialog = gtk.MessageDialog(parent=box, flags=gtk.DialogFlags.MODAL, type=gtk.MessageType.ERROR, buttons=gtk.ButtonsType.CLOSE) + dialog.set_title(_("Howdy Error")) + dialog.props.text = _("Error while adding model, error code {}: \n\n").format(str(status)) + dialog.format_secondary_text(output) + dialog.run() dialog.destroy() - if status != 0: - dialog = gtk.MessageDialog(parent=self, flags=gtk.DialogFlags.MODAL, type=gtk.MessageType.ERROR, buttons=gtk.ButtonsType.CLOSE) - dialog.set_title(_("Howdy Error")) - dialog.props.text = _("Error while adding model, error code {}: \n\n").format(str(status)) - dialog.format_secondary_text(output) - dialog.run() - dialog.destroy() - - self.load_model_list() - + box.load_model_list() def on_model_delete(self, button): selection = self.treeview.get_selection() diff --git a/howdy-gtk/src/window.py b/howdy-gtk/src/window.py index 125f44e..65d95f9 100644 --- a/howdy-gtk/src/window.py +++ b/howdy-gtk/src/window.py @@ -71,10 +71,12 @@ class MainWindow(gtk.Window): def load_model_list(self): """(Re)load the model list""" + # Get username and default to none if there are no models at all yet + user = 'none' + if self.active_user: user = self.active_user + # Execute the list commond to get the models - # status, output = subprocess.getstatusoutput(["howdy list --plain -U " + self.active_user]) - status = 0 - output = "1,2020-12-05 14:10:22,sd\n2,2020-12-05 14:22:41,\n3,2020-12-05 14:57:37,Model #3" + self.active_user + status, output = subprocess.getstatusoutput(["howdy list --plain -U " + user]) # Create a datamodel self.listmodel = gtk.ListStore(str, str, str) @@ -82,12 +84,13 @@ class MainWindow(gtk.Window): # If there was no error if status == 0: # Split the output per line - # lines = output.decode("utf-8").split("\n") lines = output.split("\n") # Add the models to the datamodel for i in range(len(lines)): - self.listmodel.append(lines[i].split(",")) + items = lines[i].split(",") + if len(items) < 3: continue + self.listmodel.append(items) self.treeview.set_model(self.listmodel) diff --git a/howdy/src/cli/list.py b/howdy/src/cli/list.py index b079580..3532e9f 100644 --- a/howdy/src/cli/list.py +++ b/howdy/src/cli/list.py @@ -26,8 +26,9 @@ enc_file = path + "/models/" + user + ".dat" try: encodings = json.load(open(enc_file)) except FileNotFoundError: - print(_("No face model known for the user {}, please run:").format(user)) - print("\n\tsudo howdy -U " + user + " add\n") + if not builtins.howdy_args.plain: + print(_("No face model known for the user {}, please run:").format(user)) + print("\n\tsudo howdy -U " + user + " add\n") sys.exit(1) # Print a header if we're not in plain mode