def _ImportPNGs(self, paths): for path in paths: try: payload = ClientSerialisable.LoadFromPNG(path) except Exception as e: QW.QMessageBox.critical(self, 'Error', str(e)) return try: obj = HydrusSerialisable.CreateFromNetworkBytes(payload) self._ImportObject(obj) except: QW.QMessageBox.critical( self, 'Error', 'I could not understand what was encoded in "{}"!'.format( path)) return
def _ImportPNGs(self, paths): have_shown_load_error = False for path in paths: try: payload = ClientSerialisable.LoadFromPNG(path) except Exception as e: QW.QMessageBox.critical(self, 'Error', str(e)) return try: obj = HydrusSerialisable.CreateFromNetworkBytes( payload, raise_error_on_future_version=True) self._ImportObject(obj) except HydrusExceptions.SerialisationException as e: if not have_shown_load_error: message = str(e) if len(paths) > 1: message += os.linesep * 2 message += 'If there are more objects in this import with similar load problems, they will now be skipped silently.' QW.QMessageBox.critical(self, 'Problem loading', str(e)) have_shown_load_error = True except: QW.QMessageBox.critical( self, 'Error', 'I could not understand what was encoded in "{}"!'.format( path)) return
def _ImportFromPNG( self ): with QP.FileDialog( self, 'select the png with the urls', wildcard = 'PNG (*.png)' ) as dlg: if dlg.exec() == QW.QDialog.Accepted: path = dlg.GetPath() payload = ClientSerialisable.LoadFromPNG( path ) try: urls = self._GetURLsFromURLsString( payload ) self._ImportURLs( urls ) except: QW.QMessageBox.critical( self, 'Error', 'Could not import!' ) raise