def on_change_entry(self): print "onchange" if self.asked_for_master: return plain = self.entry_var.get() if len(plain) == 0: self.label_hash.config(text="") return hashed = hashpasslib.make_password(plain, old=False) self.label_hash.config(text=hashed) self.clipboard_thread.send_to_clipboard_at_some_point(hashed) self.label_clipboard.config(text=("Copied to clipboard. " "Enter to clear."))
def on_change_entry(self): print "onchange" if self.asked_for_master: return plain = self.entry_var.get() if len(plain) == 0: self.label_hash.config(text="") return hashed = hashpasslib.make_password(plain, old=False) self.label_hash.config(text=hashed) self.clipboard_thread.send_to_clipboard_at_some_point(hashed) self.label_clipboard.config(text=( "Copied to clipboard. " "Enter to clear."))
def process_message(self, message): """Process a json message. This does user interaction and could block for a long time. Returns: Response to return to client. """ if not isinstance(message, dict): return None mtype = message.get("type", None) self.maybe_expire_credentials() if mtype == None: return None if mtype == "ping": return {"pong": "pong"} if mtype == "get_password": slug = message.get("slug", None) if slug == None: return None # Try once to get a master. if not hashpasslib.is_ready(): get_master_gui(use_bcrypt=True) if hashpasslib.is_ready(): self.last_auth = time.time() if hashpasslib.is_ready(): password = hashpasslib.make_password(slug, old=False) return {"password": password} else: return {"error": "no master"} if mtype == "shutdown": self.canceled = True return {"ok": "ok"} # Unrecognized message type. return None