diff --git a/src/libprs500/__init__.py b/src/libprs500/__init__.py index e91f9804d8..bf09bde47c 100644 --- a/src/libprs500/__init__.py +++ b/src/libprs500/__init__.py @@ -13,7 +13,7 @@ ## with this program; if not, write to the Free Software Foundation, Inc., ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ''' E-book management software''' -__version__ = "0.3.56" +__version__ = "0.3.57" __docformat__ = "epytext" __author__ = "Kovid Goyal " __appname__ = 'libprs500' diff --git a/src/libprs500/devices/prs500/books.py b/src/libprs500/devices/prs500/books.py index 2b5c222b6a..524298cf49 100644 --- a/src/libprs500/devices/prs500/books.py +++ b/src/libprs500/devices/prs500/books.py @@ -57,7 +57,7 @@ class Book(object): size = book_metadata_field("size", formatter=int) # When setting this attribute you must use an epoch datetime = book_metadata_field("date", \ - formatter=lambda x: time.strptime(x, "%a, %d %b %Y %H:%M:%S %Z"), + formatter=lambda x: time.strptime(x.strip(), "%a, %d %b %Y %H:%M:%S %Z"), setter=lambda x: time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime(x))) @apply diff --git a/src/libprs500/ebooks/lrf/html/convert_from.py b/src/libprs500/ebooks/lrf/html/convert_from.py index d202aad0e3..adad211332 100644 --- a/src/libprs500/ebooks/lrf/html/convert_from.py +++ b/src/libprs500/ebooks/lrf/html/convert_from.py @@ -1212,11 +1212,15 @@ def try_opf(path, options): isbn.append((scheme, item.string)) if not options.cover: for item in isbn: - matches = glob.glob(re.sub('-', '', item[1])+'.*') + src = item[1].replace('-', '') + matches = glob.glob(os.path.join(os.path.dirname(path), src+'.*')) for match in matches: - if match.lower().endswith('.jpeg') or match.lower().endswith('.jpg') or \ - match.lower().endswith('.gif') or match.lower().endswith('.png'): + test = os.path.splitext(match)[1].lower() + if test in ['.jpeg', '.jpg', '.gif', '.png']: options.cover = match + break + + if not options.cover: # Search for cover image in opf as created by convertlit ref = soup.package.find('reference', {'type':'other.ms-coverimage-standard'}) diff --git a/src/libprs500/gui2/__init__.py b/src/libprs500/gui2/__init__.py index 52c20e35ed..a64cb24d89 100644 --- a/src/libprs500/gui2/__init__.py +++ b/src/libprs500/gui2/__init__.py @@ -47,7 +47,7 @@ def Error(msg, e): error_dialog.showMessage(msg) error_dialog.show() -def human_readable(cls, size): +def human_readable(size): """ Convert a size in bytes into a human readable form """ if size < 1024: divisor, suffix = 1, "B" diff --git a/src/libprs500/gui2/device.py b/src/libprs500/gui2/device.py index 7e5decc019..0b29580984 100644 --- a/src/libprs500/gui2/device.py +++ b/src/libprs500/gui2/device.py @@ -88,19 +88,18 @@ class DeviceManager(QObject): def get_info_func(self): ''' Return callable that returns device information and free space on device''' def get_device_information(updater): - self.device.set_updater(updater) + self.device.set_progress_reporter(updater) info = self.device.get_device_information(end_session=False) - info = {'name':info[0], 'version':info[1], 'swversion':[2], 'mimetype':info[3]} + info = [i.replace('\x00', '').replace('\x01', '') for i in info] cp = self.device.card_prefix(end_session=False) fs = self.device.free_space() - fs = {'main':fs[0], 'carda':fs[1], 'cardb':fs[2]} return info, cp, fs return get_device_information def books_func(self): '''Return callable that returns the list of books on device as two booklists''' def books(updater): - self.device.set_updater(updater) + self.device.set_progress_reporter(updater) mainlist = self.device.books(oncard=False, end_session=False) cardlist = self.device.books(oncard=True) return mainlist, cardlist diff --git a/src/libprs500/gui2/main.py b/src/libprs500/gui2/main.py index 6074398ec2..c3d6ade3aa 100644 --- a/src/libprs500/gui2/main.py +++ b/src/libprs500/gui2/main.py @@ -39,7 +39,10 @@ class Main(QObject, Ui_MainWindow): self.job_manager = JobManager() self.device_manager = None self.temporary_slots = {} - self.df.setText(self.df.text().arg(VERSION)) + + ####################### Vanity ######################## + self.vanity_template = self.vanity.text().arg(VERSION) + self.vanity.setText(self.vanity_template.arg(' ')) ####################### Status Bar ##################### self.status_bar = StatusBar() @@ -64,18 +67,25 @@ class Main(QObject, Ui_MainWindow): self.detector.start(QThread.InheritPriority) + def job_exception(self, id, exception, formatted_traceback): + raise JobException, str(exception) + '\n\r' + formatted_traceback def device_detected(self, cls, connected): if connected: - def info_read(id, result, exception, formatted_traceback): - if exception: - pass #TODO: Handle error - info, cp, fs = result - print self, id, result, exception, formatted_traceback - self.temporary_slots['device_info_read'] = info_read + + self.device_manager = DeviceManager(cls) func = self.device_manager.get_info_func() - self.job_manager.run_device_job(info_read, func) + + self.job_manager.run_device_job(self.info_read, func) + + def info_read(self, id, result, exception, formatted_traceback): + if exception: + self.job_exception(id, exception, formatted_traceback) + return + info, cp, fs = result + self.location_view.model().update_devices(cp, fs) + self.vanity.setText(self.vanity_template.arg('Connected '+' '.join(info[:-1]))) def read_settings(self): diff --git a/src/libprs500/gui2/main.ui b/src/libprs500/gui2/main.ui index fad4e82626..8382fc0374 100644 --- a/src/libprs500/gui2/main.ui +++ b/src/libprs500/gui2/main.ui @@ -42,7 +42,7 @@ 0 - + 0 @@ -76,7 +76,7 @@ - + 0 @@ -90,7 +90,7 @@ - For help visit <a href="https://libprs500.kovidgoyal.net/wiki/GuiUsage">http://libprs500.kovidgoyal.net</a><br><br><b>libprs500</b>: %1 by <b>Kovid Goyal</b> &copy; 2007<br>%2 %3 %4 + For help visit <a href="https://libprs500.kovidgoyal.net/wiki/GuiUsage">http://libprs500.kovidgoyal.net</a><br><br><b>libprs500</b>: %1 by <b>Kovid Goyal</b> &copy; 2007<br>%2 Qt::RichText diff --git a/src/libprs500/gui2/main_ui.py b/src/libprs500/gui2/main_ui.py index d424edc1bc..784cb071da 100644 --- a/src/libprs500/gui2/main_ui.py +++ b/src/libprs500/gui2/main_ui.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'main.ui' # -# Created: Thu Jun 21 20:31:43 2007 +# Created: Fri Jun 22 16:40:15 2007 # by: PyQt4 UI code generator 4-snapshot-20070606 # # WARNING! All changes made in this file will be lost! @@ -32,35 +32,35 @@ class Ui_MainWindow(object): self.hboxlayout.setMargin(0) self.hboxlayout.setObjectName("hboxlayout") - self.device_tree = LocationView(self.centralwidget) + self.location_view = LocationView(self.centralwidget) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred,QtGui.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.device_tree.sizePolicy().hasHeightForWidth()) - self.device_tree.setSizePolicy(sizePolicy) - self.device_tree.setMaximumSize(QtCore.QSize(10000,90)) - self.device_tree.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) - self.device_tree.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) - self.device_tree.setDragDropMode(QtGui.QAbstractItemView.DragDrop) - self.device_tree.setFlow(QtGui.QListView.TopToBottom) - self.device_tree.setSpacing(20) - self.device_tree.setViewMode(QtGui.QListView.IconMode) - self.device_tree.setObjectName("device_tree") - self.hboxlayout.addWidget(self.device_tree) + sizePolicy.setHeightForWidth(self.location_view.sizePolicy().hasHeightForWidth()) + self.location_view.setSizePolicy(sizePolicy) + self.location_view.setMaximumSize(QtCore.QSize(10000,90)) + self.location_view.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) + self.location_view.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) + self.location_view.setDragDropMode(QtGui.QAbstractItemView.DragDrop) + self.location_view.setFlow(QtGui.QListView.TopToBottom) + self.location_view.setSpacing(20) + self.location_view.setViewMode(QtGui.QListView.IconMode) + self.location_view.setObjectName("location_view") + self.hboxlayout.addWidget(self.location_view) - self.df = QtGui.QLabel(self.centralwidget) + self.vanity = QtGui.QLabel(self.centralwidget) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred,QtGui.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.df.sizePolicy().hasHeightForWidth()) - self.df.setSizePolicy(sizePolicy) - self.df.setMaximumSize(QtCore.QSize(16777215,90)) - self.df.setTextFormat(QtCore.Qt.RichText) - self.df.setOpenExternalLinks(True) - self.df.setObjectName("df") - self.hboxlayout.addWidget(self.df) + sizePolicy.setHeightForWidth(self.vanity.sizePolicy().hasHeightForWidth()) + self.vanity.setSizePolicy(sizePolicy) + self.vanity.setMaximumSize(QtCore.QSize(16777215,90)) + self.vanity.setTextFormat(QtCore.Qt.RichText) + self.vanity.setOpenExternalLinks(True) + self.vanity.setObjectName("vanity") + self.hboxlayout.addWidget(self.vanity) self.gridlayout.addLayout(self.hboxlayout,0,0,1,1) self.hboxlayout1 = QtGui.QHBoxLayout() @@ -184,7 +184,7 @@ class Ui_MainWindow(object): def retranslateUi(self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "libprs500", None, QtGui.QApplication.UnicodeUTF8)) - self.df.setText(QtGui.QApplication.translate("MainWindow", "For help visit http://libprs500.kovidgoyal.net

libprs500: %1 by Kovid Goyal © 2007
%2 %3 %4", None, QtGui.QApplication.UnicodeUTF8)) + self.vanity.setText(QtGui.QApplication.translate("MainWindow", "For help visit http://libprs500.kovidgoyal.net

libprs500: %1 by Kovid Goyal © 2007
%2", None, QtGui.QApplication.UnicodeUTF8)) self.label.setText(QtGui.QApplication.translate("MainWindow", "&Search:", None, QtGui.QApplication.UnicodeUTF8)) self.search.setToolTip(QtGui.QApplication.translate("MainWindow", "Search the list of books by title or author

Words separated by spaces are ANDed", None, QtGui.QApplication.UnicodeUTF8)) self.search.setWhatsThis(QtGui.QApplication.translate("MainWindow", "Search the list of books by title, author, publisher, tags and comments

Words separated by spaces are ANDed", None, QtGui.QApplication.UnicodeUTF8)) diff --git a/src/libprs500/gui2/widgets.py b/src/libprs500/gui2/widgets.py index 0aa4f39b24..5a9b92722c 100644 --- a/src/libprs500/gui2/widgets.py +++ b/src/libprs500/gui2/widgets.py @@ -45,7 +45,7 @@ class LocationModel(QAbstractListModel): data = self.icons[row] elif role == Qt.SizeHintRole: if row == 1: - return QVariant(QSize(150, 70)) + return QVariant(QSize(150, 65)) elif role == Qt.FontRole: font = QFont() font.setBold(True) @@ -55,13 +55,13 @@ class LocationModel(QAbstractListModel): def headerData(self, section, orientation, role): return NONE - def update_devices(self, cp, fs): + def update_devices(self, cp=None, fs=[-1, -1, -1]): self.free[0] = fs[0] self.free[1] = max(fs[1:]) if cp == None: self.free[1] = -1 - self.emit(SIGNAL("dataChanged(QModelIndex, QModelIndex)"), - self.index(1), self.index(2)) + print self.free, self.rowCount(None) + self.reset() class LocationView(QListView): diff --git a/upload.py b/upload.py index ecc2b164d6..665af7d6ff 100644 --- a/upload.py +++ b/upload.py @@ -31,10 +31,9 @@ def build_windows(): vm.loginInGuest('kovid', 'et tu brutus') vm.loginInGuest(VIX_CONSOLE_USER_NAME, '') vm.runProgramInGuest('C:\\Users\kovid\Desktop\libprs500.bat', '') - vm.runProgramInGuest('C:\Windows\system32\shutdown.exe', '/s') - if not glob.glob('dist/*.exe'): raise Exception('Windows build has failed') + vm.runProgramInGuest('C:\Windows\system32\shutdown.exe', '/s') return os.path.basename(glob.glob('dist/*.exe')[-1]) def build_osx(): @@ -53,6 +52,7 @@ def build_osx(): c -= 10 if c%60==0: print c/60, ',', + sys.stdout.flush() print if not os.path.exists('dist/dmgdone'):