]> git.phdru.name Git - m_librarian.git/commitdiff
Feat(web): Catch and report errors on downloading
authorOleg Broytman <phd@phdru.name>
Wed, 10 Jan 2024 00:16:24 +0000 (03:16 +0300)
committerOleg Broytman <phd@phdru.name>
Wed, 10 Jan 2024 00:16:24 +0000 (03:16 +0300)
[skip ci]

m_librarian/web/app.py
m_librarian/web/views/download.py
m_librarian/web/views/download.tmpl

index 283ddb715b8b819fb0039c57bf375337eff84a1e..39a1779d38c907ae5cbdc829f44913655eb4fd0e 100644 (file)
@@ -66,15 +66,21 @@ def download_books():
                 books_ids.append(bid)
     if books_ids:
         download_path = get_config().getpath('download', 'path')
-        for bid in books_ids:
-            book = Book.get(int(bid))
-            download(book, download_path)
-        return {
-            'message': u'Книги сохранены.',
-        }
+        try:
+            for bid in books_ids:
+                book = Book.get(int(bid))
+                download(book, download_path)
+        except Exception as e:
+            return {
+                'error': str(e),
+            }
+        else:
+            return {
+                'message': u'Книги сохранены.',
+            }
     else:
         return {
-            'message': u'Не выбрано книг для сохранения.',
+            'error': u'Не выбрано книг для сохранения.',
         }
 
 
index ef05ca465e1bddc7aa0b8017ddf26416271ee6c8..c207ccbc05ea11d3921c64f95d477fdf60b5df52 100644 (file)
@@ -33,12 +33,12 @@ VFFSL=valueFromFrameOrSearchList
 VFSL=valueFromSearchList
 VFN=valueForName
 currentTime=time.time
-__CHEETAH_version__ = '3.1.0'
-__CHEETAH_versionTuple__ = (3, 1, 0, 'final', 1)
-__CHEETAH_genTime__ = 1523146500.915016
-__CHEETAH_genTimestamp__ = 'Sun Apr  8 03:15:00 2018'
+__CHEETAH_version__ = '3.3.1'
+__CHEETAH_versionTuple__ = (3, 3, 1, 'final', 0)
+__CHEETAH_genTime__ = 1704845598.39619
+__CHEETAH_genTimestamp__ = 'Wed Jan 10 03:13:18 2024'
 __CHEETAH_src__ = 'download.tmpl'
-__CHEETAH_srcLastModified__ = 'Sun Apr  8 03:14:43 2018'
+__CHEETAH_srcLastModified__ = 'Wed Jan 10 03:10:53 2024'
 __CHEETAH_docstring__ = 'Autogenerated by Cheetah: The Python-Powered Template Engine'
 
 if __CHEETAH_versionTuple__ < RequiredCheetahVersionTuple:
@@ -91,10 +91,18 @@ class download(layout):
         if _v is not None: write(_filter(_v, rawExpr=u'$title')) # from line 5, col 5.
         write(u'''</h1>
 
-<p>''')
-        _v = VFFSL(SL,"message",True) # u'$message' on line 7, col 4
-        if _v is not None: write(_filter(_v, rawExpr=u'$message')) # from line 7, col 4.
-        write(u'''</p>
+''')
+        if VFFSL(SL,"getVar",False)('error', None): # generated from line 7, col 1
+            write(u'''<p style="color: red">''')
+            _v = VFFSL(SL,"error",True) # u'$error' on line 8, col 23
+            if _v is not None: write(_filter(_v, rawExpr=u'$error')) # from line 8, col 23.
+            write(u'''</p>
+''')
+        else: # generated from line 9, col 1
+            write(u'''<p>''')
+            _v = VFFSL(SL,"message",True) # u'$message' on line 10, col 4
+            if _v is not None: write(_filter(_v, rawExpr=u'$message')) # from line 10, col 4.
+            write(u'''</p>
 ''')
         
         ########################################
@@ -161,7 +169,7 @@ if not hasattr(download, '_initCheetahAttributes'):
 
 # CHEETAH was developed by Tavis Rudd and Mike Orr
 # with code, advice and input from many other volunteers.
-# For more information visit http://cheetahtemplate.org/
+# For more information visit https://cheetahtemplate.org/
 
 ##################################################
 ## if run from command line:
index cf7e5bfae0930e58a7a5df7f37dfca0581268194..f9bf363697e803eb280e6cd65b1998ba05734b68 100644 (file)
@@ -4,5 +4,9 @@
 #def body
 <h1>$title</h1>
 
+#if $getVar('error', None)
+<p style="color: red">$error</p>
+#else
 <p>$message</p>
+#end if
 #end def