def save_data(self): """ When the user presses save, it saves what has been written to a file on the disk. """ f = open('/sdcard/operator/notes.txt', 'w') f.write(self.text_input.text) toast("Notes saved to disk", True) f.close()
def stop(self): """Stop the recorder.""" if not self.is_recording: return self.recorder.stop() self.recorder.reset() self.is_recording = False self.layout_gen() toast("Recording saved", True)
def do_open_checklist(self, title, event): """ Opens the checklist, depending on the request from the user in the base menu. :param str title: The title of the checklist, according to the title field in the .JSON file. """ toast("Loading...", True) self.clear_widgets() self.title = title json_path = self.get_recent_json(title) if json_path: self.gen_checklist(json_path)
def start(self): """Start the recorder.""" if self.is_recording: self.recorder.stop() self.recorder.reset() self.is_recording = False return self.init_recorder() self.recorder.start() self.is_recording = True self.layout_gen() toast("Recording started", True)
def do_load_true_path(self, path, filename): """ Does a series of a checks to make sure the file that is trying to be loaded is valid. :param str path: The directory of the file. :param list filename: The name of the file. :return: The path to the validated WAV file. If the path is deemed invalid, None is returned. :rtype: str """ if path is None or not os.path.isfile(filename[0]): toast("Not a valid path!", True) return full_path = os.path.join(path, filename[0]) if not os.access(full_path, (os.R_OK | os.W_OK)): toast("No permission, please move file", True) return if not str(filename[0]).endswith('.wav'): toast("Not a WAV file!", True) return with open(full_path) as f: path_list = str(f).split("'") true_path = path_list[1] if not os.path.exists(true_path): toast("Not a valid path!", True) return true_path
def on_muc_receive(self, msg): """ Whenever a group message is received, it is processed according to whatever the user is currently doing. :param Message msg: The XMPP message object. """ sender = str(msg['from']).strip() text = str(msg['body']).strip() if self.chatting == "Operator Group": lab = Label(text=sender.split('/')[1] + ": " + text, size_hint_y=None, markup=True, halign='left') lab.bind(width=lambda s, w: s.setter('text_size')(s, (w, None))) lab.bind(texture_size=lab.setter('size')) lab.color = colorsys.hsv_to_rgb( self.name_to_txt(sender.split('/')[1]), 1, 1) with lab.canvas.before: Color(name_to_bg(sender.split('/')[1]), 1, 1, mode='hsv') lab.bg_rect = Rectangle(pos=self.pos, size=self.size) lab.bind(pos=self.redraw, size=self.redraw) self.sub_layout.add_widget(lab) if self.new: self.sub_layout.remove_widget(self.new_lab) self.new = False else: toast(sender.split('/')[1] + ": " + text, True) vibrator.vibrate(.1) if sender.split('/')[0] in self.messages: self.main_app.xmpp_log('info', 'receiving new message from ' + sender) else: self.main_app.xmpp_log('info', 'receiving first message from ' + sender) m = Message(sender.split('/')[1], text) self.messages[sender.split('/')[0]].append(m)
def muc_online(self, presence): """ Toasts the user whenever another operator comes online. """ if presence['muc']['nick'] != self.nick: toast(presence['muc']['nick'] + " has come online", True)