def copy(self): """ Copy the file list to the clipboard """ file_list = '\n'.join(self.file_list) cb = QApplication.clipboard() cb.clear(mode=cb.Clipboard ) cb.setText(file_list, mode=cb.Clipboard) info("""The file list has been copied to the clipboard""")
def check_connection(self, quietly=False): """ Check connection by sending token to server and requesting list of permitted rounds. Then update the form. A warning or info message will be shown unless quietly=True. """ print("check_connection: Checking the connection") self.ui.check_connection.setText(self.tr("Checking connection...")) error_handler = self.connection_error if quietly: error_handler = self.connection_error_quiet r = get("get_rounds", getattr(settings, 'email', None), getattr(settings, 'token', None), error_handler=error_handler) if r is not Exception: print("check_connection: connected ok. returned:", r) self.connected = True self.signed_in = True settings.rounds = r['rounds'] if not quietly: if settings.rounds: info(self.tr("You are connected to the server.")) else: warn( self. tr("You are connected to the server, but do not currently have access to a comparison round." )) else: print("check_connection: there was a connection problem") # (A warning message will be generated by the error handler) self.update_form()
def upload(self): self.ui.upload.setText("Uploading...") user_input = { 'file_list': self.file_list, 'description': self.ui.description.toPlainText(), 'file_type': self.get_file_type() } problem = self.validate(user_input) if problem: warn("""Please ensure all fields are filled correctly""") else: print("Uploading", user_input) r = post("add_file_list", user=self.email, token=self.token, json=user_input) if r is not Exception: #self.disable_form() info("""The file list was uploaded successfully""") #self.uploaded = True self.ready_form() else: self.ui.upload.setText("Upload")
def do_next_thing(self, action, detail): if action == 'choose round': self.choose_round(detail) elif action == 'comparison': self.set_choice(detail) self.ui.submit.setEnabled(True) self.ui.play_left.setEnabled(True) self.ui.play_right.setEnabled(True) elif action == 'end': info(self.tr("There are no more comparisons to do in this round.")) self.ui.submit.setEnabled(False) self.ui.play_left.setEnabled(False) self.ui.play_right.setEnabled(False) else: warn( self. tr("The server returned an action that this application was not able to complete. Action: {}; detail: {}" .format(action, detail)))