after_merge
stringlengths
28
79.6k
before_merge
stringlengths
20
79.6k
url
stringlengths
38
71
full_traceback
stringlengths
43
922k
traceback_type
stringclasses
555 values
def extractCover(tmp_file_name, original_file_extension): cover_data = None if original_file_extension.upper() == ".CBZ": cf = zipfile.ZipFile(tmp_file_name) for name in cf.namelist(): ext = os.path.splitext(name) if len(ext) > 1: extension = ext[1].lower() if extension == ".jpg": cover_data = cf.read(name) break elif original_file_extension.upper() == ".CBT": cf = tarfile.TarFile(tmp_file_name) for name in cf.getnames(): ext = os.path.splitext(name) if len(ext) > 1: extension = ext[1].lower() if extension == ".jpg": cover_data = cf.extractfile(name).read() break prefix = os.path.dirname(tmp_file_name) if cover_data: tmp_cover_name = prefix + "/cover" + extension image = open(tmp_cover_name, "wb") image.write(cover_data) image.close() else: tmp_cover_name = None return tmp_cover_name
def extractCover(tmp_file_name, original_file_extension): if original_file_extension.upper() == ".CBZ": cf = zipfile.ZipFile(tmp_file_name) compressed_name = cf.namelist()[0] cover_data = cf.read(compressed_name) elif original_file_extension.upper() == ".CBT": cf = tarfile.TarFile(tmp_file_name) compressed_name = cf.getnames()[0] cover_data = cf.extractfile(compressed_name).read() prefix = os.path.dirname(tmp_file_name) tmp_cover_name = prefix + "/cover" + os.path.splitext(compressed_name)[1] image = open(tmp_cover_name, "wb") image.write(cover_data) image.close() return tmp_cover_name
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def get_display_dict(self): display_dict = ast.literal_eval(self.display) if sys.version_info < (3, 0): display_dict["enum_values"] = [ x.decode("unicode_escape") for x in display_dict["enum_values"] ] return display_dict
def get_display_dict(self): display_dict = ast.literal_eval(self.display) return display_dict
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def migrate(): if not engine.dialect.has_table(engine.connect(), "permissions_added"): PermissionAdded.__table__.create(bind=engine) for sql in session.execute("select sql from sqlite_master where type='table'"): if "CREATE TABLE gdrive_ids" in sql[0]: currUniqueConstraint = "UNIQUE (gdrive_id)" if currUniqueConstraint in sql[0]: sql = sql[0].replace(currUniqueConstraint, "UNIQUE (gdrive_id, path)") sql = sql.replace(GdriveId.__tablename__, GdriveId.__tablename__ + "2") session.execute(sql) session.execute( "INSERT INTO gdrive_ids2 (id, gdrive_id, path) SELECT id, " "gdrive_id, path FROM gdrive_ids;" ) session.commit() session.execute("DROP TABLE %s" % "gdrive_ids") session.execute("ALTER TABLE gdrive_ids2 RENAME to gdrive_ids") break
def migrate(): if not engine.dialect.has_table(engine.connect(), "permissions_added"): PermissionAdded.__table__.create(bind=engine) for sql in session.execute("select sql from sqlite_master where type='table'"): if "CREATE TABLE gdrive_ids" in sql[0]: currUniqueConstraint = "UNIQUE (gdrive_id)" if currUniqueConstraint in sql[0]: sql = sql[0].replace(currUniqueConstraint, "UNIQUE (gdrive_id, path)") sql = sql.replace(GdriveId.__tablename__, GdriveId.__tablename__ + "2") session.execute(sql) session.execute( "INSERT INTO gdrive_ids2 (id, gdrive_id, path) SELECT id, gdrive_id, path FROM gdrive_ids;" ) session.commit() session.execute("DROP TABLE %s" % "gdrive_ids") session.execute("ALTER TABLE gdrive_ids2 RENAME to gdrive_ids") break
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def getDrive(drive=None, gauth=None): if not drive: if not gauth: gauth = GoogleAuth( settings_file=os.path.join(config.get_main_dir, "settings.yaml") ) # Try to load saved client credentials gauth.LoadCredentialsFile( os.path.join(config.get_main_dir, "gdrive_credentials") ) if gauth.access_token_expired: # Refresh them if expired try: gauth.Refresh() except RefreshError as e: web.app.logger.error("Google Drive error: " + e.message) except Exception as e: web.app.logger.exception(e) else: # Initialize the saved creds gauth.Authorize() # Save the current credentials to a file return GoogleDrive(gauth) if drive.auth.access_token_expired: try: drive.auth.Refresh() except RefreshError as e: web.app.logger.error("Google Drive error: " + e.message) return drive
def getDrive(drive=None, gauth=None): if not drive: if not gauth: gauth = GoogleAuth( settings_file=os.path.join(config.get_main_dir, "settings.yaml") ) # Try to load saved client credentials gauth.LoadCredentialsFile( os.path.join(config.get_main_dir, "gdrive_credentials") ) if gauth.access_token_expired: # Refresh them if expired try: gauth.Refresh() except RefreshError as e: web.app.logger.error("Google Drive error: " + e.message) except Exception as e: web.app.logger.exception(e) else: # Initialize the saved creds gauth.Authorize() # Save the current credentials to a file return GoogleDrive(gauth) if drive.auth.access_token_expired: drive.auth.Refresh() return drive
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def getFolderInFolder(parentId, folderName, drive): # drive = getDrive(drive) query = "" if folderName: query = "title = '%s' and " % folderName.replace("'", r"\'") folder = ( query + "'%s' in parents and mimeType = 'application/vnd.google-apps.folder'" " and trashed = false" % parentId ) fileList = drive.ListFile({"q": folder}).GetList() if fileList.__len__() == 0: return None else: return fileList[0]
def getFolderInFolder(parentId, folderName, drive): # drive = getDrive(drive) query = "" if folderName: query = "title = '%s' and " % folderName.replace("'", "\\'") folder = ( query + "'%s' in parents and mimeType = 'application/vnd.google-apps.folder' and trashed = false" % parentId ) fileList = drive.ListFile({"q": folder}).GetList() if fileList.__len__() == 0: return None else: return fileList[0]
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def getFile(pathId, fileName, drive): metaDataFile = "'%s' in parents and trashed = false and title = '%s'" % ( pathId, fileName.replace("'", r"\'"), ) fileList = drive.ListFile({"q": metaDataFile}).GetList() if fileList.__len__() == 0: return None else: return fileList[0]
def getFile(pathId, fileName, drive): metaDataFile = "'%s' in parents and trashed = false and title = '%s'" % ( pathId, fileName.replace("'", "\\'"), ) fileList = drive.ListFile({"q": metaDataFile}).GetList() if fileList.__len__() == 0: return None else: return fileList[0]
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def moveGdriveFolderRemote(origin_file, target_folder): drive = getDrive(Gdrive.Instance().drive) previous_parents = ",".join([parent["id"] for parent in origin_file.get("parents")]) children = drive.auth.service.children().list(folderId=previous_parents).execute() gFileTargetDir = getFileFromEbooksFolder(None, target_folder) if not gFileTargetDir: # Folder is not existing, create, and move folder gFileTargetDir = drive.CreateFile( { "title": target_folder, "parents": [{"kind": "drive#fileLink", "id": getEbooksFolderId()}], "mimeType": "application/vnd.google-apps.folder", } ) gFileTargetDir.Upload() # Move the file to the new folder drive.auth.service.files().update( fileId=origin_file["id"], addParents=gFileTargetDir["id"], removeParents=previous_parents, fields="id, parents", ).execute() # if previous_parents has no childs anymore, delete original fileparent if len(children["items"]) == 1: deleteDatabaseEntry(previous_parents) drive.auth.service.files().delete(fileId=previous_parents).execute()
def moveGdriveFolderRemote(origin_file, target_folder): drive = getDrive(Gdrive.Instance().drive) previous_parents = ",".join([parent["id"] for parent in origin_file.get("parents")]) gFileTargetDir = getFileFromEbooksFolder(None, target_folder) if not gFileTargetDir: # Folder is not exisiting, create, and move folder gFileTargetDir = drive.CreateFile( { "title": target_folder, "parents": [{"kind": "drive#fileLink", "id": getEbooksFolderId()}], "mimeType": "application/vnd.google-apps.folder", } ) gFileTargetDir.Upload() # Move the file to the new folder drive.auth.service.files().update( fileId=origin_file["id"], addParents=gFileTargetDir["id"], removeParents=previous_parents, fields="id, parents", ).execute()
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def copyToDrive( drive, uploadFile, createRoot, replaceFiles, ignoreFiles=None, parent=None, prevDir="", ): ignoreFiles = ignoreFiles or [] drive = getDrive(drive) isInitial = not bool(parent) if not parent: parent = getEbooksFolder(drive) if os.path.isdir(os.path.join(prevDir, uploadFile)): existingFolder = drive.ListFile( { "q": "title = '%s' and '%s' in parents and trashed = false" % (os.path.basename(uploadFile).replace("'", r"\'"), parent["id"]) } ).GetList() if len(existingFolder) == 0 and (not isInitial or createRoot): parent = drive.CreateFile( { "title": os.path.basename(uploadFile), "parents": [{"kind": "drive#fileLink", "id": parent["id"]}], "mimeType": "application/vnd.google-apps.folder", } ) parent.Upload() else: if (not isInitial or createRoot) and len(existingFolder) > 0: parent = existingFolder[0] for f in os.listdir(os.path.join(prevDir, uploadFile)): if f not in ignoreFiles: copyToDrive( drive, f, True, replaceFiles, ignoreFiles, parent, os.path.join(prevDir, uploadFile), ) else: if os.path.basename(uploadFile) not in ignoreFiles: existingFiles = drive.ListFile( { "q": "title = '%s' and '%s' in parents and trashed = false" % (os.path.basename(uploadFile).replace("'", r"\'"), parent["id"]) } ).GetList() if len(existingFiles) > 0: driveFile = existingFiles[0] else: driveFile = drive.CreateFile( { "title": os.path.basename(uploadFile).replace("'", r"\'"), "parents": [{"kind": "drive#fileLink", "id": parent["id"]}], } ) driveFile.SetContentFile(os.path.join(prevDir, uploadFile)) driveFile.Upload()
def copyToDrive( drive, uploadFile, createRoot, replaceFiles, ignoreFiles=None, parent=None, prevDir="", ): ignoreFiles = ignoreFiles or [] drive = getDrive(drive) isInitial = not bool(parent) if not parent: parent = getEbooksFolder(drive) if os.path.isdir(os.path.join(prevDir, uploadFile)): existingFolder = drive.ListFile( { "q": "title = '%s' and '%s' in parents and trashed = false" % (os.path.basename(uploadFile), parent["id"]) } ).GetList() if len(existingFolder) == 0 and (not isInitial or createRoot): parent = drive.CreateFile( { "title": os.path.basename(uploadFile), "parents": [{"kind": "drive#fileLink", "id": parent["id"]}], "mimeType": "application/vnd.google-apps.folder", } ) parent.Upload() else: if (not isInitial or createRoot) and len(existingFolder) > 0: parent = existingFolder[0] for f in os.listdir(os.path.join(prevDir, uploadFile)): if f not in ignoreFiles: copyToDrive( drive, f, True, replaceFiles, ignoreFiles, parent, os.path.join(prevDir, uploadFile), ) else: if os.path.basename(uploadFile) not in ignoreFiles: existingFiles = drive.ListFile( { "q": "title = '%s' and '%s' in parents and trashed = false" % (os.path.basename(uploadFile), parent["id"]) } ).GetList() if len(existingFiles) > 0: driveFile = existingFiles[0] else: driveFile = drive.CreateFile( { "title": os.path.basename(uploadFile), "parents": [{"kind": "drive#fileLink", "id": parent["id"]}], } ) driveFile.SetContentFile(os.path.join(prevDir, uploadFile)) driveFile.Upload()
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def uploadFileToEbooksFolder(destFile, f): drive = getDrive(Gdrive.Instance().drive) parent = getEbooksFolder(drive) splitDir = destFile.split("/") for i, x in enumerate(splitDir): if i == len(splitDir) - 1: existingFiles = drive.ListFile( { "q": "title = '%s' and '%s' in parents and trashed = false" % (x.replace("'", r"\'"), parent["id"]) } ).GetList() if len(existingFiles) > 0: driveFile = existingFiles[0] else: driveFile = drive.CreateFile( { "title": x, "parents": [{"kind": "drive#fileLink", "id": parent["id"]}], } ) driveFile.SetContentFile(f) driveFile.Upload() else: existingFolder = drive.ListFile( { "q": "title = '%s' and '%s' in parents and trashed = false" % (x.replace("'", r"\'"), parent["id"]) } ).GetList() if len(existingFolder) == 0: parent = drive.CreateFile( { "title": x, "parents": [{"kind": "drive#fileLink", "id": parent["id"]}], "mimeType": "application/vnd.google-apps.folder", } ) parent.Upload() else: parent = existingFolder[0]
def uploadFileToEbooksFolder(destFile, f): drive = getDrive(Gdrive.Instance().drive) parent = getEbooksFolder(drive) splitDir = destFile.split("/") for i, x in enumerate(splitDir): if i == len(splitDir) - 1: existingFiles = drive.ListFile( { "q": "title = '%s' and '%s' in parents and trashed = false" % (x, parent["id"]) } ).GetList() if len(existingFiles) > 0: driveFile = existingFiles[0] else: driveFile = drive.CreateFile( { "title": x, "parents": [{"kind": "drive#fileLink", "id": parent["id"]}], } ) driveFile.SetContentFile(f) driveFile.Upload() else: existingFolder = drive.ListFile( { "q": "title = '%s' and '%s' in parents and trashed = false" % (x, parent["id"]) } ).GetList() if len(existingFolder) == 0: parent = drive.CreateFile( { "title": x, "parents": [{"kind": "drive#fileLink", "id": parent["id"]}], "mimeType": "application/vnd.google-apps.folder", } ) parent.Upload() else: parent = existingFolder[0]
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def getChangeById(drive, change_id): # Print a single Change resource information. # # Args: # service: Drive API service instance. # change_id: ID of the Change resource to retrieve. try: change = drive.auth.service.changes().get(changeId=change_id).execute() return change except errors.HttpError as error: web.app.logger.info(error.message) return None except Exception as e: web.app.logger.info(e) return None
def getChangeById(drive, change_id): # Print a single Change resource information. # # Args: # service: Drive API service instance. # change_id: ID of the Change resource to retrieve. try: change = drive.auth.service.changes().get(changeId=change_id).execute() return change except errors.HttpError as error: web.app.logger.info(error.message) return None
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def updateDatabaseOnEdit(ID, newPath): sqlCheckPath = newPath if newPath[-1] == "/" else newPath + "/" storedPathName = session.query(GdriveId).filter(GdriveId.gdrive_id == ID).first() if storedPathName: storedPathName.path = sqlCheckPath session.commit()
def updateDatabaseOnEdit(ID, newPath): storedPathName = session.query(GdriveId).filter(GdriveId.gdrive_id == ID).first() if storedPathName: storedPathName.path = newPath session.commit()
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def send_mail(book_id, book_format, convert, kindle_mail, calibrepath, user_id): """Send email with attachments""" book = db.session.query(db.Books).filter(db.Books.id == book_id).first() if convert: # returns None if success, otherwise errormessage return convert_book_format( book_id, calibrepath, "epub", book_format.lower(), user_id, kindle_mail ) else: for entry in iter(book.data): if entry.format.upper() == book_format.upper(): result = entry.name + "." + book_format.lower() global_WorkerThread.add_email( _("Send to Kindle"), book.path, result, ub.get_mail_settings(), kindle_mail, user_id, _("E-mail: %(book)s", book=book.title), _("This e-mail has been sent via Calibre-Web."), ) return return _("The requested file could not be read. Maybe wrong permissions?")
def send_mail(book_id, kindle_mail, calibrepath, user_id): """Send email with attachments""" book = db.session.query(db.Books).filter(db.Books.id == book_id).first() data = db.session.query(db.Data).filter(db.Data.book == book.id).all() formats = {} for entry in data: if entry.format == "MOBI": formats["mobi"] = entry.name + ".mobi" if entry.format == "EPUB": formats["epub"] = entry.name + ".epub" if entry.format == "PDF": formats["pdf"] = entry.name + ".pdf" if len(formats) == 0: return _("Could not find any formats suitable for sending by e-mail") if "mobi" in formats: result = formats["mobi"] elif "epub" in formats: # returns None if success, otherwise errormessage return convert_book_format( book_id, calibrepath, "epub", "mobi", user_id, kindle_mail ) elif "pdf" in formats: result = formats["pdf"] # worker.get_attachment() else: return _("Could not find any formats suitable for sending by e-mail") if result: global_WorkerThread.add_email( _("Send to Kindle"), book.path, result, ub.get_mail_settings(), kindle_mail, user_id, _("E-mail: %(book)s", book=book.title), _("This e-mail has been sent via Calibre-Web."), ) else: return _("The requested file could not be read. Maybe wrong permissions?")
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def get_valid_filename(value, replace_whitespace=True): """ Returns the given string converted to a string that can be used for a clean filename. Limits num characters to 128 max. """ if value[-1:] == ".": value = value[:-1] + "_" value = value.replace("/", "_").replace(":", "_").strip("\0") if use_unidecode: value = (unidecode.unidecode(value)).strip() else: value = value.replace("§", "SS") value = value.replace("ß", "ss") value = unicodedata.normalize("NFKD", value) re_slugify = re.compile("[\W\s-]", re.UNICODE) if isinstance(value, str): # Python3 str, Python2 unicode value = re_slugify.sub("", value).strip() else: value = unicode(re_slugify.sub("", value).strip()) if replace_whitespace: # *+:\"/<>? are replaced by _ value = re.sub(r"[\*\+:\\\"/<>\?]+", "_", value, flags=re.U) # pipe has to be replaced with comma value = re.sub(r"[\|]+", ",", value, flags=re.U) value = value[:128] if not value: raise ValueError("Filename cannot be empty") if sys.version_info.major == 3: return value else: return value.decode("utf-8")
def get_valid_filename(value, replace_whitespace=True): """ Returns the given string converted to a string that can be used for a clean filename. Limits num characters to 128 max. """ if value[-1:] == ".": value = value[:-1] + "_" value = value.replace("/", "_").replace(":", "_").strip("\0") if use_unidecode: value = (unidecode.unidecode(value)).strip() else: value = value.replace("§", "SS") value = value.replace("ß", "ss") value = unicodedata.normalize("NFKD", value) re_slugify = re.compile("[\W\s-]", re.UNICODE) if isinstance(value, str): # Python3 str, Python2 unicode value = re_slugify.sub("", value).strip() else: value = unicode(re_slugify.sub("", value).strip()) if replace_whitespace: # *+:\"/<>? are replaced by _ value = re.sub(r"[\*\+:\\\"/<>\?]+", "_", value, flags=re.U) # pipe has to be replaced with comma value = re.sub(r"[\|]+", ",", value, flags=re.U) value = value[:128] if not value: raise ValueError("Filename cannot be empty") return value
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def update_dir_structure_file(book_id, calibrepath, first_author): localbook = db.session.query(db.Books).filter(db.Books.id == book_id).first() path = os.path.join(calibrepath, localbook.path) authordir = localbook.path.split("/")[0] if first_author: new_authordir = get_valid_filename(first_author) else: new_authordir = get_valid_filename(localbook.authors[0].name) titledir = localbook.path.split("/")[1] new_titledir = get_valid_filename(localbook.title) + " (" + str(book_id) + ")" if titledir != new_titledir: try: new_title_path = os.path.join(os.path.dirname(path), new_titledir) if not os.path.exists(new_title_path): os.renames(path, new_title_path) else: web.app.logger.info( "Copying title: " + path + " into existing: " + new_title_path ) for dir_name, subdir_list, file_list in os.walk(path): for file in file_list: os.renames( os.path.join(dir_name, file), os.path.join(new_title_path + dir_name[len(path) :], file), ) path = new_title_path localbook.path = localbook.path.split("/")[0] + "/" + new_titledir except OSError as ex: web.app.logger.error( "Rename title from: " + path + " to " + new_title_path + ": " + str(ex) ) web.app.logger.debug(ex, exc_info=True) return _( "Rename title from: '%(src)s' to '%(dest)s' failed with error: %(error)s", src=path, dest=new_title_path, error=str(ex), ) if authordir != new_authordir: try: new_author_path = os.path.join( calibrepath, new_authordir, os.path.basename(path) ) os.renames(path, new_author_path) localbook.path = new_authordir + "/" + localbook.path.split("/")[1] except OSError as ex: web.app.logger.error( "Rename author from: " + path + " to " + new_author_path + ": " + str(ex) ) web.app.logger.debug(ex, exc_info=True) return _( "Rename author from: '%(src)s' to '%(dest)s' failed with error: %(error)s", src=path, dest=new_author_path, error=str(ex), ) # Rename all files from old names to new names if authordir != new_authordir or titledir != new_titledir: try: new_name = ( get_valid_filename(localbook.title) + " - " + get_valid_filename(new_authordir) ) path_name = os.path.join(calibrepath, new_authordir, os.path.basename(path)) for file_format in localbook.data: os.renames( os.path.join( path_name, file_format.name + "." + file_format.format.lower() ), os.path.join( path_name, new_name + "." + file_format.format.lower() ), ) file_format.name = new_name except OSError as ex: web.app.logger.error( "Rename file in path " + path + " to " + new_name + ": " + str(ex) ) web.app.logger.debug(ex, exc_info=True) return _( "Rename file in path '%(src)s' to '%(dest)s' failed with error: %(error)s", src=path, dest=new_name, error=str(ex), ) return False
def update_dir_structure_file(book_id, calibrepath): localbook = db.session.query(db.Books).filter(db.Books.id == book_id).first() path = os.path.join(calibrepath, localbook.path) authordir = localbook.path.split("/")[0] new_authordir = get_valid_filename(localbook.authors[0].name) titledir = localbook.path.split("/")[1] new_titledir = get_valid_filename(localbook.title) + " (" + str(book_id) + ")" if titledir != new_titledir: try: new_title_path = os.path.join(os.path.dirname(path), new_titledir) if not os.path.exists(new_title_path): os.renames(path, new_title_path) else: web.app.logger.info( "Copying title: " + path + " into existing: " + new_title_path ) for dir_name, subdir_list, file_list in os.walk(path): for file in file_list: os.renames( os.path.join(dir_name, file), os.path.join(new_title_path + dir_name[len(path) :], file), ) path = new_title_path localbook.path = localbook.path.split("/")[0] + "/" + new_titledir except OSError as ex: web.app.logger.error( "Rename title from: " + path + " to " + new_title_path + ": " + str(ex) ) web.app.logger.debug(ex, exc_info=True) return _( "Rename title from: '%(src)s' to '%(dest)s' failed with error: %(error)s", src=path, dest=new_title_path, error=str(ex), ) if authordir != new_authordir: try: new_author_path = os.path.join( os.path.join(calibrepath, new_authordir), os.path.basename(path) ) os.renames(path, new_author_path) localbook.path = new_authordir + "/" + localbook.path.split("/")[1] except OSError as ex: web.app.logger.error( "Rename author from: " + path + " to " + new_author_path + ": " + str(ex) ) web.app.logger.debug(ex, exc_info=True) return _( "Rename author from: '%(src)s' to '%(dest)s' failed with error: %(error)s", src=path, dest=new_author_path, error=str(ex), ) return False
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def update_dir_structure_gdrive(book_id, first_author): error = False book = db.session.query(db.Books).filter(db.Books.id == book_id).first() path = book.path authordir = book.path.split("/")[0] if first_author: new_authordir = get_valid_filename(first_author) else: new_authordir = get_valid_filename(book.authors[0].name) titledir = book.path.split("/")[1] new_titledir = get_valid_filename(book.title) + " (" + str(book_id) + ")" if titledir != new_titledir: gFile = gd.getFileFromEbooksFolder(os.path.dirname(book.path), titledir) if gFile: gFile["title"] = new_titledir gFile.Upload() book.path = book.path.split("/")[0] + "/" + new_titledir path = book.path gd.updateDatabaseOnEdit( gFile["id"], book.path ) # only child folder affected else: error = _( "File %(file)s not found on Google Drive", file=book.path ) # file not found if authordir != new_authordir: gFile = gd.getFileFromEbooksFolder(os.path.dirname(book.path), new_titledir) if gFile: gd.moveGdriveFolderRemote(gFile, new_authordir) book.path = new_authordir + "/" + book.path.split("/")[1] path = book.path gd.updateDatabaseOnEdit(gFile["id"], book.path) else: error = _( "File %(file)s not found on Google Drive", file=authordir ) # file not found # Rename all files from old names to new names if authordir != new_authordir or titledir != new_titledir: new_name = ( get_valid_filename(book.title) + " - " + get_valid_filename(new_authordir) ) for file_format in book.data: gFile = gd.getFileFromEbooksFolder( path, file_format.name + "." + file_format.format.lower() ) if not gFile: error = _( "File %(file)s not found on Google Drive", file=file_format.name ) # file not found break gd.moveGdriveFileRemote(gFile, new_name + "." + file_format.format.lower()) file_format.name = new_name return error
def update_dir_structure_gdrive(book_id): error = False book = db.session.query(db.Books).filter(db.Books.id == book_id).first() authordir = book.path.split("/")[0] new_authordir = get_valid_filename(book.authors[0].name) titledir = book.path.split("/")[1] new_titledir = get_valid_filename(book.title) + " (" + str(book_id) + ")" if titledir != new_titledir: gFile = gd.getFileFromEbooksFolder(os.path.dirname(book.path), titledir) if gFile: gFile["title"] = new_titledir gFile.Upload() book.path = book.path.split("/")[0] + "/" + new_titledir gd.updateDatabaseOnEdit( gFile["id"], book.path ) # only child folder affected else: error = _( "File %(file)s not found on Google Drive", file=book.path ) # file not found if authordir != new_authordir: gFile = gd.getFileFromEbooksFolder(os.path.dirname(book.path), titledir) if gFile: gd.moveGdriveFolderRemote(gFile, new_authordir) book.path = new_authordir + "/" + book.path.split("/")[1] gd.updateDatabaseOnEdit(gFile["id"], book.path) else: error = _( "File %(file)s not found on Google Drive", file=authordir ) # file not found return error
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def update_dir_stucture(book_id, calibrepath, first_author=None): if ub.config.config_use_google_drive: return update_dir_structure_gdrive(book_id, first_author) else: return update_dir_structure_file(book_id, calibrepath, first_author)
def update_dir_stucture(book_id, calibrepath): if ub.config.config_use_google_drive: return update_dir_structure_gdrive(book_id) else: return update_dir_structure_file(book_id, calibrepath)
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def get_book_cover(cover_path): if ub.config.config_use_google_drive: try: if not web.is_gdrive_ready(): return send_from_directory( os.path.join(os.path.dirname(__file__), "static"), "generic_cover.jpg", ) path = gd.get_cover_via_gdrive(cover_path) if path: return redirect(path) else: web.app.logger.error( cover_path + "/cover.jpg not found on Google Drive" ) return send_from_directory( os.path.join(os.path.dirname(__file__), "static"), "generic_cover.jpg", ) except Exception as e: web.app.logger.error("Error Message: " + e.message) web.app.logger.exception(e) # traceback.print_exc() return send_from_directory( os.path.join(os.path.dirname(__file__), "static"), "generic_cover.jpg" ) else: return send_from_directory( os.path.join(ub.config.config_calibre_dir, cover_path), "cover.jpg" )
def get_book_cover(cover_path): if ub.config.config_use_google_drive: try: path = gd.get_cover_via_gdrive(cover_path) if path: return redirect(path) else: web.app.logger.error( cover_path + "/cover.jpg not found on Google Drive" ) return send_from_directory( os.path.join(os.path.dirname(__file__), "static"), "generic_cover.jpg", ) except Exception as e: web.app.logger.error("Error Message: " + e.message) web.app.logger.exception(e) # traceback.print_exc() return send_from_directory( os.path.join(os.path.dirname(__file__), "static"), "generic_cover.jpg" ) else: return send_from_directory( os.path.join(ub.config.config_calibre_dir, cover_path), "cover.jpg" )
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def save_cover(url, book_path): img = requests.get(url) if img.headers.get("content-type") != "image/jpeg": web.app.logger.error("Cover is no jpg file, can't save") return False if ub.config.config_use_google_drive: tmpDir = gettempdir() f = open(os.path.join(tmpDir, "uploaded_cover.jpg"), "wb") f.write(img.content) f.close() gd.uploadFileToEbooksFolder( os.path.join(book_path, "cover.jpg"), os.path.join(tmpDir, f.name) ) web.app.logger.info("Cover is saved on Google Drive") return True f = open(os.path.join(ub.config.config_calibre_dir, book_path, "cover.jpg"), "wb") f.write(img.content) f.close() web.app.logger.info("Cover is saved") return True
def save_cover(url, book_path): img = requests.get(url) if img.headers.get("content-type") != "image/jpeg": web.app.logger.error("Cover is no jpg file, can't save") return False if ub.config.config_use_google_drive: tmpDir = gettempdir() f = open(os.path.join(tmpDir, "uploaded_cover.jpg"), "wb") f.write(img.content) f.close() uploadFileToEbooksFolder( os.path.join(book_path, "cover.jpg"), os.path.join(tmpDir, f.name) ) web.app.logger.info("Cover is saved on Google Drive") return True f = open(os.path.join(ub.config.config_calibre_dir, book_path, "cover.jpg"), "wb") f.write(img.content) f.close() web.app.logger.info("Cover is saved") return True
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def render_task_status(tasklist): # helper function to apply localize status information in tasklist entries renderedtasklist = list() # task2 = task for task in tasklist: if task["user"] == current_user.nickname or current_user.role_admin(): # task2 = copy.deepcopy(task) # = task if task["formStarttime"]: task["starttime"] = format_datetime( task["formStarttime"], format="short", locale=web.get_locale() ) # task2['formStarttime'] = "" else: if "starttime" not in task: task["starttime"] = "" # localize the task status if isinstance(task["stat"], int): if task["stat"] == worker.STAT_WAITING: task["status"] = _("Waiting") elif task["stat"] == worker.STAT_FAIL: task["status"] = _("Failed") elif task["stat"] == worker.STAT_STARTED: task["status"] = _("Started") elif task["stat"] == worker.STAT_FINISH_SUCCESS: task["status"] = _("Finished") else: task["status"] = _("Unknown Status") # localize the task type if isinstance(task["taskType"], int): if task["taskType"] == worker.TASK_EMAIL: task["taskMessage"] = _("E-mail: ") + task["taskMess"] elif task["taskType"] == worker.TASK_CONVERT: task["taskMessage"] = _("Convert: ") + task["taskMess"] elif task["taskType"] == worker.TASK_UPLOAD: task["taskMessage"] = _("Upload: ") + task["taskMess"] elif task["taskType"] == worker.TASK_CONVERT_ANY: task["taskMessage"] = _("Convert: ") + task["taskMess"] else: task["taskMessage"] = _("Unknown Task: ") + task["taskMess"] renderedtasklist.append(task) return renderedtasklist
def render_task_status(tasklist): # helper function to apply localize status information in tasklist entries renderedtasklist = list() for task in tasklist: if task["user"] == current_user.nickname or current_user.role_admin(): if task["formStarttime"]: task["starttime"] = format_datetime( task["formStarttime"], format="short", locale=web.get_locale() ) task["formStarttime"] = "" else: if "starttime" not in task: task["starttime"] = "" # localize the task status if isinstance(task["stat"], int): if task["stat"] == worker.STAT_WAITING: task["status"] = _("Waiting") elif task["stat"] == worker.STAT_FAIL: task["status"] = _("Failed") elif task["stat"] == worker.STAT_STARTED: task["status"] = _("Started") elif task["stat"] == worker.STAT_FINISH_SUCCESS: task["status"] = _("Finished") else: task["status"] = _("Unknown Status") # localize the task type if isinstance(task["taskType"], int): if task["taskType"] == worker.TASK_EMAIL: task["taskMessage"] = _("E-mail: ") + task["taskMess"] elif task["taskType"] == worker.TASK_CONVERT: task["taskMessage"] = _("Convert: ") + task["taskMess"] elif task["taskType"] == worker.TASK_UPLOAD: task["taskMessage"] = _("Upload: ") + task["taskMess"] elif task["taskType"] == worker.TASK_CONVERT_ANY: task["taskMessage"] = _("Convert: ") + task["taskMess"] else: task["taskMessage"] = _("Unknown Task: ") + task["taskMess"] renderedtasklist.append(task) return renderedtasklist
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def start_gevent(self): try: ssl_args = dict() certfile_path = web.ub.config.get_config_certfile() keyfile_path = web.ub.config.get_config_keyfile() if certfile_path and keyfile_path: if os.path.isfile(certfile_path) and os.path.isfile(keyfile_path): ssl_args = {"certfile": certfile_path, "keyfile": keyfile_path} else: web.app.logger.info( "The specified paths for the ssl certificate file and/or key file seem to be broken. Ignoring ssl. Cert path: %s | Key path: %s" % (certfile_path, keyfile_path) ) if os.name == "nt": self.wsgiserver = WSGIServer( ("0.0.0.0", web.ub.config.config_port), web.app, spawn=Pool(), **ssl_args, ) else: self.wsgiserver = WSGIServer( ("", web.ub.config.config_port), web.app, spawn=Pool(), **ssl_args ) web.py3_gevent_link = self.wsgiserver self.wsgiserver.serve_forever() except SocketError: try: web.app.logger.info("Unable to listen on '', trying on IPv4 only...") self.wsgiserver = WSGIServer( ("0.0.0.0", web.ub.config.config_port), web.app, spawn=Pool(), **ssl_args, ) web.py3_gevent_link = self.wsgiserver self.wsgiserver.serve_forever() except (OSError, SocketError) as e: web.app.logger.info("Error starting server: %s" % e.strerror) print("Error starting server: %s" % e.strerror) web.helper.global_WorkerThread.stop() sys.exit(1) except Exception: web.app.logger.info("Unknown error while starting gevent")
def start_gevent(self): try: ssl_args = dict() if web.ub.config.get_config_certfile() and web.ub.config.get_config_keyfile(): ssl_args = { "certfile": web.ub.config.get_config_certfile(), "keyfile": web.ub.config.get_config_keyfile(), } if os.name == "nt": self.wsgiserver = WSGIServer( ("0.0.0.0", web.ub.config.config_port), web.app, spawn=Pool(), **ssl_args, ) else: self.wsgiserver = WSGIServer( ("", web.ub.config.config_port), web.app, spawn=Pool(), **ssl_args ) self.wsgiserver.serve_forever() except SocketError: try: web.app.logger.info("Unable to listen on '', trying on IPv4 only...") self.wsgiserver = WSGIServer( ("0.0.0.0", web.ub.config.config_port), web.app, spawn=Pool(), **ssl_args, ) self.wsgiserver.serve_forever() except (OSError, SocketError) as e: web.app.logger.info("Error starting server: %s" % e.strerror) print("Error starting server: %s" % e.strerror) web.helper.global_WorkerThread.stop() sys.exit(1) except Exception: web.app.logger.info("Unknown error while starting gevent")
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def startServer(self): if gevent_present: web.app.logger.info("Starting Gevent server") # leave subprocess out to allow forking for fetchers and processors self.start_gevent() else: try: ssl = None web.app.logger.info("Starting Tornado server") certfile_path = web.ub.config.get_config_certfile() keyfile_path = web.ub.config.get_config_keyfile() if certfile_path and keyfile_path: if os.path.isfile(certfile_path) and os.path.isfile(keyfile_path): ssl = {"certfile": certfile_path, "keyfile": keyfile_path} else: web.app.logger.info( "The specified paths for the ssl certificate file and/or key file seem to be broken. Ignoring ssl. Cert path: %s | Key path: %s" % (certfile_path, keyfile_path) ) # Max Buffersize set to 200MB http_server = HTTPServer( WSGIContainer(web.app), max_buffer_size=209700000, ssl_options=ssl ) http_server.listen(web.ub.config.config_port) self.wsgiserver = IOLoop.instance() self.wsgiserver.start() # wait for stop signal self.wsgiserver.close(True) except SocketError as e: web.app.logger.info("Error starting server: %s" % e.strerror) print("Error starting server: %s" % e.strerror) web.helper.global_WorkerThread.stop() sys.exit(1) # ToDo: Somehow caused by circular import under python3 refactor if sys.version_info > (3, 0): self.restart = web.py3_restart_Typ if self.restart == True: web.app.logger.info("Performing restart of Calibre-Web") web.helper.global_WorkerThread.stop() if os.name == "nt": arguments = ['"' + sys.executable + '"'] for e in sys.argv: arguments.append('"' + e + '"') os.execv(sys.executable, arguments) else: os.execl(sys.executable, sys.executable, *sys.argv) else: web.app.logger.info("Performing shutdown of Calibre-Web") web.helper.global_WorkerThread.stop() sys.exit(0)
def startServer(self): if gevent_present: web.app.logger.info("Starting Gevent server") # leave subprocess out to allow forking for fetchers and processors self.start_gevent() else: try: web.app.logger.info("Starting Tornado server") if ( web.ub.config.get_config_certfile() and web.ub.config.get_config_keyfile() ): ssl = { "certfile": web.ub.config.get_config_certfile(), "keyfile": web.ub.config.get_config_keyfile(), } else: ssl = None # Max Buffersize set to 200MB http_server = HTTPServer( WSGIContainer(web.app), max_buffer_size=209700000, ssl_options=ssl ) http_server.listen(web.ub.config.config_port) self.wsgiserver = IOLoop.instance() self.wsgiserver.start() # wait for stop signal self.wsgiserver.close(True) except SocketError as e: web.app.logger.info("Error starting server: %s" % e.strerror) print("Error starting server: %s" % e.strerror) web.helper.global_WorkerThread.stop() sys.exit(1) if self.restart == True: web.app.logger.info("Performing restart of Calibre-Web") web.helper.global_WorkerThread.stop() if os.name == "nt": arguments = ['"' + sys.executable + '"'] for e in sys.argv: arguments.append('"' + e + '"') os.execv(sys.executable, arguments) else: os.execl(sys.executable, sys.executable, *sys.argv) else: web.app.logger.info("Performing shutdown of Calibre-Web") web.helper.global_WorkerThread.stop() sys.exit(0)
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def setRestartTyp(self, starttyp): self.restart = starttyp # ToDo: Somehow caused by circular import under python3 refactor web.py3_restart_Typ = starttyp
def setRestartTyp(self, starttyp): self.restart = starttyp
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def stopServer(self): # ToDo: Somehow caused by circular import under python3 refactor if sys.version_info > (3, 0): if not self.wsgiserver: if gevent_present: self.wsgiserver = web.py3_gevent_link else: self.wsgiserver = IOLoop.instance() if self.wsgiserver: if gevent_present: self.wsgiserver.close() else: self.wsgiserver.add_callback(self.wsgiserver.stop)
def stopServer(self): if gevent_present: self.wsgiserver.close() else: self.wsgiserver.add_callback(self.wsgiserver.stop)
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def loadSettings(self): data = session.query(Settings).first() # type: Settings self.config_calibre_dir = data.config_calibre_dir self.config_port = data.config_port self.config_certfile = data.config_certfile self.config_keyfile = data.config_keyfile self.config_calibre_web_title = data.config_calibre_web_title self.config_books_per_page = data.config_books_per_page self.config_random_books = data.config_random_books self.config_authors_max = data.config_authors_max self.config_title_regex = data.config_title_regex self.config_read_column = data.config_read_column self.config_log_level = data.config_log_level self.config_uploading = data.config_uploading self.config_anonbrowse = data.config_anonbrowse self.config_public_reg = data.config_public_reg self.config_default_role = data.config_default_role self.config_default_show = data.config_default_show self.config_columns_to_ignore = data.config_columns_to_ignore self.config_use_google_drive = data.config_use_google_drive self.config_google_drive_folder = data.config_google_drive_folder self.config_ebookconverter = data.config_ebookconverter self.config_converterpath = data.config_converterpath self.config_calibre = data.config_calibre if data.config_google_drive_watch_changes_response: self.config_google_drive_watch_changes_response = json.loads( data.config_google_drive_watch_changes_response ) else: self.config_google_drive_watch_changes_response = None self.config_columns_to_ignore = data.config_columns_to_ignore self.db_configured = bool( self.config_calibre_dir is not None and ( not self.config_use_google_drive or os.path.exists(self.config_calibre_dir + "/metadata.db") ) ) self.config_remote_login = data.config_remote_login self.config_use_goodreads = data.config_use_goodreads self.config_goodreads_api_key = data.config_goodreads_api_key self.config_goodreads_api_secret = data.config_goodreads_api_secret if data.config_mature_content_tags: self.config_mature_content_tags = data.config_mature_content_tags else: self.config_mature_content_tags = "" if data.config_logfile: self.config_logfile = data.config_logfile self.config_rarfile_location = data.config_rarfile_location self.config_theme = data.config_theme self.config_updatechannel = data.config_updatechannel
def loadSettings(self): data = session.query(Settings).first() # type: Settings self.config_calibre_dir = data.config_calibre_dir self.config_port = data.config_port self.config_certfile = data.config_certfile self.config_keyfile = data.config_keyfile self.config_calibre_web_title = data.config_calibre_web_title self.config_books_per_page = data.config_books_per_page self.config_random_books = data.config_random_books self.config_title_regex = data.config_title_regex self.config_read_column = data.config_read_column self.config_log_level = data.config_log_level self.config_uploading = data.config_uploading self.config_anonbrowse = data.config_anonbrowse self.config_public_reg = data.config_public_reg self.config_default_role = data.config_default_role self.config_default_show = data.config_default_show self.config_columns_to_ignore = data.config_columns_to_ignore self.config_use_google_drive = data.config_use_google_drive self.config_google_drive_folder = data.config_google_drive_folder self.config_ebookconverter = data.config_ebookconverter self.config_converterpath = data.config_converterpath self.config_calibre = data.config_calibre if data.config_google_drive_watch_changes_response: self.config_google_drive_watch_changes_response = json.loads( data.config_google_drive_watch_changes_response ) else: self.config_google_drive_watch_changes_response = None self.config_columns_to_ignore = data.config_columns_to_ignore self.db_configured = bool( self.config_calibre_dir is not None and ( not self.config_use_google_drive or os.path.exists(self.config_calibre_dir + "/metadata.db") ) ) self.config_remote_login = data.config_remote_login self.config_use_goodreads = data.config_use_goodreads self.config_goodreads_api_key = data.config_goodreads_api_key self.config_goodreads_api_secret = data.config_goodreads_api_secret if data.config_mature_content_tags: self.config_mature_content_tags = data.config_mature_content_tags else: self.config_mature_content_tags = "" if data.config_logfile: self.config_logfile = data.config_logfile self.config_rarfile_location = data.config_rarfile_location
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def migrate_Database(): if not engine.dialect.has_table(engine.connect(), "book_read_link"): ReadBook.__table__.create(bind=engine) if not engine.dialect.has_table(engine.connect(), "bookmark"): Bookmark.__table__.create(bind=engine) if not engine.dialect.has_table(engine.connect(), "registration"): ReadBook.__table__.create(bind=engine) conn = engine.connect() conn.execute("insert into registration (domain) values('%.%')") session.commit() # Handle table exists, but no content cnt = session.query(Registration).count() if not cnt: conn = engine.connect() conn.execute("insert into registration (domain) values('%.%')") session.commit() try: session.query(exists().where(Settings.config_use_google_drive)).scalar() except exc.OperationalError: conn = engine.connect() conn.execute( "ALTER TABLE Settings ADD column `config_use_google_drive` INTEGER DEFAULT 0" ) conn.execute( "ALTER TABLE Settings ADD column `config_google_drive_folder` String DEFAULT ''" ) conn.execute( "ALTER TABLE Settings ADD column `config_google_drive_watch_changes_response` String DEFAULT ''" ) session.commit() try: session.query(exists().where(Settings.config_columns_to_ignore)).scalar() except exc.OperationalError: conn = engine.connect() conn.execute( "ALTER TABLE Settings ADD column `config_columns_to_ignore` String DEFAULT ''" ) session.commit() try: session.query(exists().where(Settings.config_default_role)).scalar() except exc.OperationalError: # Database is not compatible, some rows are missing conn = engine.connect() conn.execute( "ALTER TABLE Settings ADD column `config_default_role` SmallInteger DEFAULT 0" ) session.commit() try: session.query(exists().where(Settings.config_authors_max)).scalar() except exc.OperationalError: # Database is not compatible, some rows are missing conn = engine.connect() conn.execute( "ALTER TABLE Settings ADD column `config_authors_max` INTEGER DEFAULT 0" ) session.commit() try: session.query(exists().where(BookShelf.order)).scalar() except exc.OperationalError: # Database is not compatible, some rows are missing conn = engine.connect() conn.execute("ALTER TABLE book_shelf_link ADD column 'order' INTEGER DEFAULT 1") session.commit() try: session.query(exists().where(Settings.config_rarfile_location)).scalar() session.commit() except exc.OperationalError: # Database is not compatible, some rows are missing conn = engine.connect() conn.execute( "ALTER TABLE Settings ADD column `config_rarfile_location` String DEFAULT ''" ) session.commit() try: create = False session.query(exists().where(User.sidebar_view)).scalar() except exc.OperationalError: # Database is not compatible, some rows are missing conn = engine.connect() conn.execute("ALTER TABLE user ADD column `sidebar_view` Integer DEFAULT 1") session.commit() create = True try: if create: conn = engine.connect() conn.execute("SELECT language_books FROM user") session.commit() except exc.OperationalError: conn = engine.connect() conn.execute( "UPDATE user SET 'sidebar_view' = (random_books* :side_random + language_books * :side_lang " "+ series_books * :side_series + category_books * :side_category + hot_books * " ":side_hot + :side_autor + :detail_random)", { "side_random": SIDEBAR_RANDOM, "side_lang": SIDEBAR_LANGUAGE, "side_series": SIDEBAR_SERIES, "side_category": SIDEBAR_CATEGORY, "side_hot": SIDEBAR_HOT, "side_autor": SIDEBAR_AUTHOR, "detail_random": DETAIL_RANDOM, }, ) session.commit() try: session.query(exists().where(User.mature_content)).scalar() except exc.OperationalError: conn = engine.connect() conn.execute("ALTER TABLE user ADD column `mature_content` INTEGER DEFAULT 1") if ( session.query(User) .filter(User.role.op("&")(ROLE_ANONYMOUS) == ROLE_ANONYMOUS) .first() is None ): create_anonymous_user() try: session.query(exists().where(Settings.config_remote_login)).scalar() except exc.OperationalError: conn = engine.connect() conn.execute( "ALTER TABLE Settings ADD column `config_remote_login` INTEGER DEFAULT 0" ) try: session.query(exists().where(Settings.config_use_goodreads)).scalar() except exc.OperationalError: conn = engine.connect() conn.execute( "ALTER TABLE Settings ADD column `config_use_goodreads` INTEGER DEFAULT 0" ) conn.execute( "ALTER TABLE Settings ADD column `config_goodreads_api_key` String DEFAULT ''" ) conn.execute( "ALTER TABLE Settings ADD column `config_goodreads_api_secret` String DEFAULT ''" ) try: session.query(exists().where(Settings.config_mature_content_tags)).scalar() except exc.OperationalError: conn = engine.connect() conn.execute( "ALTER TABLE Settings ADD column `config_mature_content_tags` String DEFAULT ''" ) try: session.query(exists().where(Settings.config_default_show)).scalar() except exc.OperationalError: # Database is not compatible, some rows are missing conn = engine.connect() conn.execute( "ALTER TABLE Settings ADD column `config_default_show` SmallInteger DEFAULT 2047" ) session.commit() try: session.query(exists().where(Settings.config_logfile)).scalar() except exc.OperationalError: # Database is not compatible, some rows are missing conn = engine.connect() conn.execute( "ALTER TABLE Settings ADD column `config_logfile` String DEFAULT ''" ) session.commit() try: session.query(exists().where(Settings.config_certfile)).scalar() except exc.OperationalError: # Database is not compatible, some rows are missing conn = engine.connect() conn.execute( "ALTER TABLE Settings ADD column `config_certfile` String DEFAULT ''" ) conn.execute( "ALTER TABLE Settings ADD column `config_keyfile` String DEFAULT ''" ) session.commit() try: session.query(exists().where(Settings.config_read_column)).scalar() except exc.OperationalError: # Database is not compatible, some rows are missing conn = engine.connect() conn.execute( "ALTER TABLE Settings ADD column `config_read_column` INTEGER DEFAULT 0" ) session.commit() try: session.query(exists().where(Settings.config_ebookconverter)).scalar() except exc.OperationalError: # Database is not compatible, some rows are missing conn = engine.connect() conn.execute( "ALTER TABLE Settings ADD column `config_ebookconverter` INTEGER DEFAULT 0" ) conn.execute( "ALTER TABLE Settings ADD column `config_converterpath` String DEFAULT ''" ) conn.execute( "ALTER TABLE Settings ADD column `config_calibre` String DEFAULT ''" ) session.commit() try: session.query(exists().where(Settings.config_theme)).scalar() except exc.OperationalError: # Database is not compatible, some rows are missing conn = engine.connect() conn.execute("ALTER TABLE Settings ADD column `config_theme` INTEGER DEFAULT 0") session.commit() try: session.query(exists().where(Settings.config_updatechannel)).scalar() except exc.OperationalError: # Database is not compatible, some rows are missing conn = engine.connect() conn.execute( "ALTER TABLE Settings ADD column `config_updatechannel` INTEGER DEFAULT 0" ) session.commit() # Remove login capability of user Guest conn = engine.connect() conn.execute( "UPDATE user SET password='' where nickname = 'Guest' and password !=''" ) session.commit()
def migrate_Database(): if not engine.dialect.has_table(engine.connect(), "bookmark"): Bookmark.__table__.create(bind=engine) if not engine.dialect.has_table(engine.connect(), "registration"): ReadBook.__table__.create(bind=engine) conn = engine.connect() conn.execute("insert into registration (domain) values('%.%')") session.commit() # Handle table exists, but no content cnt = session.query(Registration).count() if not cnt: conn = engine.connect() conn.execute("insert into registration (domain) values('%.%')") session.commit() try: session.query(exists().where(Settings.config_use_google_drive)).scalar() except exc.OperationalError: conn = engine.connect() conn.execute( "ALTER TABLE Settings ADD column `config_use_google_drive` INTEGER DEFAULT 0" ) conn.execute( "ALTER TABLE Settings ADD column `config_google_drive_folder` String DEFAULT ''" ) conn.execute( "ALTER TABLE Settings ADD column `config_google_drive_watch_changes_response` String DEFAULT ''" ) session.commit() try: session.query(exists().where(Settings.config_columns_to_ignore)).scalar() except exc.OperationalError: conn = engine.connect() conn.execute( "ALTER TABLE Settings ADD column `config_columns_to_ignore` String DEFAULT ''" ) session.commit() try: session.query(exists().where(Settings.config_default_role)).scalar() except exc.OperationalError: # Database is not compatible, some rows are missing conn = engine.connect() conn.execute( "ALTER TABLE Settings ADD column `config_default_role` SmallInteger DEFAULT 0" ) session.commit() try: session.query(exists().where(BookShelf.order)).scalar() except exc.OperationalError: # Database is not compatible, some rows are missing conn = engine.connect() conn.execute("ALTER TABLE book_shelf_link ADD column 'order' INTEGER DEFAULT 1") session.commit() try: session.query(exists().where(Settings.config_rarfile_location)).scalar() session.commit() except exc.OperationalError: # Database is not compatible, some rows are missing conn = engine.connect() conn.execute( "ALTER TABLE Settings ADD column `config_rarfile_location` String DEFAULT ''" ) session.commit() try: create = False session.query(exists().where(User.sidebar_view)).scalar() except exc.OperationalError: # Database is not compatible, some rows are missing conn = engine.connect() conn.execute("ALTER TABLE user ADD column `sidebar_view` Integer DEFAULT 1") session.commit() create = True try: if create: conn = engine.connect() conn.execute("SELECT language_books FROM user") session.commit() except exc.OperationalError: conn = engine.connect() conn.execute( "UPDATE user SET 'sidebar_view' = (random_books* :side_random + language_books * :side_lang " "+ series_books * :side_series + category_books * :side_category + hot_books * " ":side_hot + :side_autor + :detail_random)", { "side_random": SIDEBAR_RANDOM, "side_lang": SIDEBAR_LANGUAGE, "side_series": SIDEBAR_SERIES, "side_category": SIDEBAR_CATEGORY, "side_hot": SIDEBAR_HOT, "side_autor": SIDEBAR_AUTHOR, "detail_random": DETAIL_RANDOM, }, ) session.commit() try: session.query(exists().where(User.mature_content)).scalar() except exc.OperationalError: conn = engine.connect() conn.execute("ALTER TABLE user ADD column `mature_content` INTEGER DEFAULT 1") try: session.query(exists().where(User.theme)).scalar() except exc.OperationalError: conn = engine.connect() conn.execute("ALTER TABLE user ADD column `theme` INTEGER DEFAULT 0") session.commit() if ( session.query(User) .filter(User.role.op("&")(ROLE_ANONYMOUS) == ROLE_ANONYMOUS) .first() is None ): create_anonymous_user() try: session.query(exists().where(Settings.config_remote_login)).scalar() except exc.OperationalError: conn = engine.connect() conn.execute( "ALTER TABLE Settings ADD column `config_remote_login` INTEGER DEFAULT 0" ) try: session.query(exists().where(Settings.config_use_goodreads)).scalar() except exc.OperationalError: conn = engine.connect() conn.execute( "ALTER TABLE Settings ADD column `config_use_goodreads` INTEGER DEFAULT 0" ) conn.execute( "ALTER TABLE Settings ADD column `config_goodreads_api_key` String DEFAULT ''" ) conn.execute( "ALTER TABLE Settings ADD column `config_goodreads_api_secret` String DEFAULT ''" ) try: session.query(exists().where(Settings.config_mature_content_tags)).scalar() except exc.OperationalError: conn = engine.connect() conn.execute( "ALTER TABLE Settings ADD column `config_mature_content_tags` String DEFAULT ''" ) try: session.query(exists().where(Settings.config_default_show)).scalar() except exc.OperationalError: # Database is not compatible, some rows are missing conn = engine.connect() conn.execute( "ALTER TABLE Settings ADD column `config_default_show` SmallInteger DEFAULT 2047" ) session.commit() try: session.query(exists().where(Settings.config_logfile)).scalar() except exc.OperationalError: # Database is not compatible, some rows are missing conn = engine.connect() conn.execute( "ALTER TABLE Settings ADD column `config_logfile` String DEFAULT ''" ) session.commit() try: session.query(exists().where(Settings.config_certfile)).scalar() except exc.OperationalError: # Database is not compatible, some rows are missing conn = engine.connect() conn.execute( "ALTER TABLE Settings ADD column `config_certfile` String DEFAULT ''" ) conn.execute( "ALTER TABLE Settings ADD column `config_keyfile` String DEFAULT ''" ) session.commit() try: session.query(exists().where(Settings.config_read_column)).scalar() except exc.OperationalError: # Database is not compatible, some rows are missing conn = engine.connect() conn.execute( "ALTER TABLE Settings ADD column `config_read_column` INTEGER DEFAULT 0" ) session.commit() try: session.query(exists().where(Settings.config_ebookconverter)).scalar() except exc.OperationalError: # Database is not compatible, some rows are missing conn = engine.connect() conn.execute( "ALTER TABLE Settings ADD column `config_ebookconverter` INTEGER DEFAULT 0" ) conn.execute( "ALTER TABLE Settings ADD column `config_converterpath` String DEFAULT ''" ) conn.execute( "ALTER TABLE Settings ADD column `config_calibre` String DEFAULT ''" ) session.commit() # Remove login capability of user Guest conn = engine.connect() conn.execute( "UPDATE user SET password='' where nickname = 'Guest' and password !=''" ) session.commit()
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def get_locale(): # if a user is logged in, use the locale from the user settings user = getattr(g, "user", None) if user is not None and hasattr(user, "locale"): if ( user.nickname != "Guest" ): # if the account is the guest account bypass the config lang settings return user.locale translations = [str(item) for item in babel.list_translations()] + ["en"] preferred = list() for x in request.accept_languages.values(): try: preferred.append(str(LC.parse(x.replace("-", "_")))) except (UnknownLocaleError, ValueError) as e: app.logger.debug("Could not parse locale: %s", e) preferred.append("en") return negotiate_locale(preferred, translations)
def get_locale(): # if a user is logged in, use the locale from the user settings user = getattr(g, "user", None) if user is not None and hasattr(user, "locale"): if ( user.nickname != "Guest" ): # if the account is the guest account bypass the config lang settings return user.locale translations = [item.language for item in babel.list_translations()] + ["en"] preferred = [x.replace("-", "_") for x in request.accept_languages.values()] # In the case of Simplified Chinese, Accept-Language is "zh-CN", while our translation of Simplified Chinese is "zh_Hans_CN". # TODO: This is Not a good solution, should be improved. if "zh_CN" in preferred: return "zh_Hans_CN" return negotiate_locale(preferred, translations)
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def load_user_from_header(header_val): if header_val.startswith("Basic "): header_val = header_val.replace("Basic ", "", 1) basic_username = basic_password = "" try: header_val = base64.b64decode(header_val).decode("utf-8") basic_username = header_val.split(":")[0] basic_password = header_val.split(":")[1] except TypeError: pass user = ( ub.session.query(ub.User) .filter(func.lower(ub.User.nickname) == basic_username.lower()) .first() ) if user and check_password_hash(user.password, basic_password): return user return
def load_user_from_header(header_val): if header_val.startswith("Basic "): header_val = header_val.replace("Basic ", "", 1) basic_username = basic_password = "" try: header_val = base64.b64decode(header_val) basic_username = header_val.split(":")[0] basic_password = header_val.split(":")[1] except TypeError: pass user = ( ub.session.query(ub.User) .filter(func.lower(ub.User.nickname) == basic_username.lower()) .first() ) if user and check_password_hash(user.password, basic_password): return user return
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def check_auth(username, password): if sys.version_info.major == 3: username = username.encode("windows-1252") user = ( ub.session.query(ub.User) .filter(func.lower(ub.User.nickname) == username.decode("utf-8").lower()) .first() ) return bool(user and check_password_hash(user.password, password))
def check_auth(username, password): user = ( ub.session.query(ub.User) .filter(func.lower(ub.User.nickname) == username.lower()) .first() ) return bool(user and check_password_hash(user.password, password))
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def download_required(f): @wraps(f) def inner(*args, **kwargs): if current_user.role_download(): return f(*args, **kwargs) abort(403) return inner
def download_required(f): @wraps(f) def inner(*args, **kwargs): if current_user.role_download() or current_user.role_admin(): return f(*args, **kwargs) abort(403) return inner
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def inner(*args, **kwargs): if current_user.role_download(): return f(*args, **kwargs) abort(403)
def inner(*args, **kwargs): if current_user.role_download() or current_user.role_admin(): return f(*args, **kwargs) abort(403)
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def fill_indexpage(page, database, db_filter, order, *join): if current_user.show_detail_random(): randm = ( db.session.query(db.Books) .filter(common_filters()) .order_by(func.random()) .limit(config.config_random_books) ) else: randm = false() off = int(int(config.config_books_per_page) * (page - 1)) pagination = Pagination( page, config.config_books_per_page, len( db.session.query(database).filter(db_filter).filter(common_filters()).all() ), ) entries = ( db.session.query(database) .join(*join, isouter=True) .filter(db_filter) .filter(common_filters()) .order_by(*order) .offset(off) .limit(config.config_books_per_page) .all() ) for book in entries: book = order_authors(book) return entries, randm, pagination
def fill_indexpage(page, database, db_filter, order, *join): if current_user.show_detail_random(): randm = ( db.session.query(db.Books) .filter(common_filters()) .order_by(func.random()) .limit(config.config_random_books) ) else: randm = false() off = int(int(config.config_books_per_page) * (page - 1)) pagination = Pagination( page, config.config_books_per_page, len( db.session.query(database).filter(db_filter).filter(common_filters()).all() ), ) entries = ( db.session.query(database) .join(*join, isouter=True) .filter(db_filter) .filter(common_filters()) .order_by(*order) .offset(off) .limit(config.config_books_per_page) .all() ) return entries, randm, pagination
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def modify_database_object( input_elements, db_book_object, db_object, db_session, db_type ): # passing input_elements not as a list may lead to undesired results if not isinstance(input_elements, list): raise TypeError(str(input_elements) + " should be passed as a list") input_elements = [x for x in input_elements if x != ""] # we have all input element (authors, series, tags) names now # 1. search for elements to remove del_elements = [] for c_elements in db_book_object: found = False if db_type == "languages": type_elements = c_elements.lang_code elif db_type == "custom": type_elements = c_elements.value else: type_elements = c_elements.name for inp_element in input_elements: if inp_element.lower() == type_elements.lower(): # if inp_element == type_elements: found = True break # if the element was not found in the new list, add it to remove list if not found: del_elements.append(c_elements) # 2. search for elements that need to be added add_elements = [] for inp_element in input_elements: found = False for c_elements in db_book_object: if db_type == "languages": type_elements = c_elements.lang_code elif db_type == "custom": type_elements = c_elements.value else: type_elements = c_elements.name if inp_element == type_elements: found = True break if not found: add_elements.append(inp_element) # if there are elements to remove, we remove them now if len(del_elements) > 0: for del_element in del_elements: db_book_object.remove(del_element) if len(del_element.books) == 0: db_session.delete(del_element) # if there are elements to add, we add them now! if len(add_elements) > 0: if db_type == "languages": db_filter = db_object.lang_code elif db_type == "custom": db_filter = db_object.value else: db_filter = db_object.name for add_element in add_elements: # check if a element with that name exists db_element = ( db_session.query(db_object).filter(db_filter == add_element).first() ) # if no element is found add it # if new_element is None: if db_type == "author": new_element = db_object( add_element, helper.get_sorted_author(add_element.replace("|", ",")), "", ) elif db_type == "series": new_element = db_object(add_element, add_element) elif db_type == "custom": new_element = db_object(value=add_element) elif db_type == "publisher": new_element = db_object(add_element, None) else: # db_type should be tag or language new_element = db_object(add_element) if db_element is None: db_session.add(new_element) db_book_object.append(new_element) else: if db_type == "custom": if db_element.value != add_element: new_element.value = add_element # new_element = db_element elif db_type == "languages": if db_element.lang_code != add_element: db_element.lang_code = add_element # new_element = db_element elif db_type == "series": if db_element.name != add_element: db_element.name = add_element # = add_element # new_element = db_object(add_element, add_element) db_element.sort = add_element # new_element = db_element elif db_type == "author": if db_element.name != add_element: db_element.name = add_element db_element.sort = add_element.replace("|", ",") # new_element = db_element elif db_type == "publisher": if db_element.name != add_element: db_element.name = add_element db_element.sort = None # new_element = db_element elif db_element.name != add_element: db_element.name = add_element # new_element = db_element # add element to book db_book_object.append(db_element)
def modify_database_object( input_elements, db_book_object, db_object, db_session, db_type ): # passing input_elements not as a list may lead to undesired results if not isinstance(input_elements, list): raise TypeError(str(input_elements) + " should be passed as a list") input_elements = [x for x in input_elements if x != ""] # we have all input element (authors, series, tags) names now # 1. search for elements to remove del_elements = [] for c_elements in db_book_object: found = False if db_type == "languages": type_elements = c_elements.lang_code elif db_type == "custom": type_elements = c_elements.value else: type_elements = c_elements.name for inp_element in input_elements: if inp_element.lower() == type_elements.lower(): found = True break # if the element was not found in the new list, add it to remove list if not found: del_elements.append(c_elements) # 2. search for elements that need to be added add_elements = [] for inp_element in input_elements: found = False for c_elements in db_book_object: if db_type == "languages": type_elements = c_elements.lang_code elif db_type == "custom": type_elements = c_elements.value else: type_elements = c_elements.name if inp_element == type_elements: found = True break if not found: add_elements.append(inp_element) # if there are elements to remove, we remove them now if len(del_elements) > 0: for del_element in del_elements: db_book_object.remove(del_element) if len(del_element.books) == 0: db_session.delete(del_element) # if there are elements to add, we add them now! if len(add_elements) > 0: if db_type == "languages": db_filter = db_object.lang_code elif db_type == "custom": db_filter = db_object.value else: db_filter = db_object.name for add_element in add_elements: # check if a element with that name exists db_element = ( db_session.query(db_object).filter(db_filter == add_element).first() ) # if no element is found add it # if new_element is None: if db_type == "author": new_element = db_object( add_element, helper.get_sorted_author(add_element.replace("|", ",")), "", ) elif db_type == "series": new_element = db_object(add_element, add_element) elif db_type == "custom": new_element = db_object(value=add_element) elif db_type == "publisher": new_element = db_object(add_element, None) else: # db_type should be tag or language new_element = db_object(add_element) if db_element is None: db_session.add(new_element) db_book_object.append(new_element) else: if db_type == "custom" and db_element.value != add_element: new_element.value = add_element # new_element = db_element elif db_type == "language" and db_element.lang_code != add_element: db_element.lang_code = add_element # new_element = db_element elif db_type == "series" and db_element.name != add_element: db_element.name = add_element # = add_element # new_element = db_object(add_element, add_element) db_element.sort = add_element # new_element = db_element elif db_type == "author" and db_element.name != add_element: db_element.name = add_element db_element.sort = add_element.replace("|", ",") # new_element = db_element if db_type == "publisher" and db_element.name != add_element: db_element.name = add_element db_element.sort = None # new_element = db_element elif db_element.name != add_element: db_element.name = add_element # new_element = db_element # add element to book db_book_object.append(db_element)
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def render_title_template(*args, **kwargs): return render_template( instance=config.config_calibre_web_title, accept=EXTENSIONS_UPLOAD, *args, **kwargs, )
def render_title_template(*args, **kwargs): return render_template(instance=config.config_calibre_web_title, *args, **kwargs)
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def before_request(): g.user = current_user g.allow_registration = config.config_public_reg g.allow_upload = config.config_uploading g.current_theme = config.config_theme g.config_authors_max = config.config_authors_max g.public_shelfes = ( ub.session.query(ub.Shelf) .filter(ub.Shelf.is_public == 1) .order_by(ub.Shelf.name) .all() ) if ( not config.db_configured and request.endpoint not in ("basic_configuration", "login") and "/static/" not in request.path ): return redirect(url_for("basic_configuration"))
def before_request(): g.user = current_user g.allow_registration = config.config_public_reg g.allow_upload = config.config_uploading g.public_shelfes = ( ub.session.query(ub.Shelf) .filter(ub.Shelf.is_public == 1) .order_by(ub.Shelf.name) .all() ) if ( not config.db_configured and request.endpoint not in ("basic_configuration", "login") and "/static/" not in request.path ): return redirect(url_for("basic_configuration"))
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def feed_authorindex(): off = request.args.get("offset") or 0 entries = ( db.session.query(db.Authors) .join(db.books_authors_link) .join(db.Books) .filter(common_filters()) .group_by(text("books_authors_link.author")) .order_by(db.Authors.sort) .limit(config.config_books_per_page) .offset(off) ) pagination = Pagination( (int(off) / (int(config.config_books_per_page)) + 1), config.config_books_per_page, len(db.session.query(db.Authors).all()), ) return render_xml_template( "feed.xml", listelements=entries, folder="feed_author", pagination=pagination )
def feed_authorindex(): off = request.args.get("offset") or 0 entries = ( db.session.query(db.Authors) .join(db.books_authors_link) .join(db.Books) .filter(common_filters()) .group_by("books_authors_link.author") .order_by(db.Authors.sort) .limit(config.config_books_per_page) .offset(off) ) pagination = Pagination( (int(off) / (int(config.config_books_per_page)) + 1), config.config_books_per_page, len(db.session.query(db.Authors).all()), ) return render_xml_template( "feed.xml", listelements=entries, folder="feed_author", pagination=pagination )
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def feed_publisherindex(): off = request.args.get("offset") or 0 entries = ( db.session.query(db.Publishers) .join(db.books_publishers_link) .join(db.Books) .filter(common_filters()) .group_by(text("books_publishers_link.publisher")) .order_by(db.Publishers.sort) .limit(config.config_books_per_page) .offset(off) ) pagination = Pagination( (int(off) / (int(config.config_books_per_page)) + 1), config.config_books_per_page, len(db.session.query(db.Publishers).all()), ) return render_xml_template( "feed.xml", listelements=entries, folder="feed_publisher", pagination=pagination )
def feed_publisherindex(): off = request.args.get("offset") or 0 entries = ( db.session.query(db.Publishers) .join(db.books_publishers_link) .join(db.Books) .filter(common_filters()) .group_by("books_publishers_link.publisher") .order_by(db.Publishers.sort) .limit(config.config_books_per_page) .offset(off) ) pagination = Pagination( (int(off) / (int(config.config_books_per_page)) + 1), config.config_books_per_page, len(db.session.query(db.Publishers).all()), ) return render_xml_template( "feed.xml", listelements=entries, folder="feed_publisher", pagination=pagination )
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def feed_categoryindex(): off = request.args.get("offset") or 0 entries = ( db.session.query(db.Tags) .join(db.books_tags_link) .join(db.Books) .filter(common_filters()) .group_by(text("books_tags_link.tag")) .order_by(db.Tags.name) .offset(off) .limit(config.config_books_per_page) ) pagination = Pagination( (int(off) / (int(config.config_books_per_page)) + 1), config.config_books_per_page, len(db.session.query(db.Tags).all()), ) return render_xml_template( "feed.xml", listelements=entries, folder="feed_category", pagination=pagination )
def feed_categoryindex(): off = request.args.get("offset") or 0 entries = ( db.session.query(db.Tags) .join(db.books_tags_link) .join(db.Books) .filter(common_filters()) .group_by("books_tags_link.tag") .order_by(db.Tags.name) .offset(off) .limit(config.config_books_per_page) ) pagination = Pagination( (int(off) / (int(config.config_books_per_page)) + 1), config.config_books_per_page, len(db.session.query(db.Tags).all()), ) return render_xml_template( "feed.xml", listelements=entries, folder="feed_category", pagination=pagination )
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def feed_seriesindex(): off = request.args.get("offset") or 0 entries = ( db.session.query(db.Series) .join(db.books_series_link) .join(db.Books) .filter(common_filters()) .group_by(text("books_series_link.series")) .order_by(db.Series.sort) .offset(off) .all() ) pagination = Pagination( (int(off) / (int(config.config_books_per_page)) + 1), config.config_books_per_page, len(db.session.query(db.Series).all()), ) return render_xml_template( "feed.xml", listelements=entries, folder="feed_series", pagination=pagination )
def feed_seriesindex(): off = request.args.get("offset") or 0 entries = ( db.session.query(db.Series) .join(db.books_series_link) .join(db.Books) .filter(common_filters()) .group_by("books_series_link.series") .order_by(db.Series.sort) .offset(off) .all() ) pagination = Pagination( (int(off) / (int(config.config_books_per_page)) + 1), config.config_books_per_page, len(db.session.query(db.Series).all()), ) return render_xml_template( "feed.xml", listelements=entries, folder="feed_series", pagination=pagination )
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def get_email_status_json(): tasks = helper.global_WorkerThread.get_taskstatus() answer = helper.render_task_status(tasks) js = json.dumps(answer, default=helper.json_serial) response = make_response(js) response.headers["Content-Type"] = "application/json; charset=utf-8" return response
def get_email_status_json(): answer = list() # UIanswer = list() tasks = helper.global_WorkerThread.get_taskstatus() if not current_user.role_admin(): for task in tasks: if task["user"] == current_user.nickname: if task["formStarttime"]: task["starttime"] = format_datetime( task["formStarttime"], format="short", locale=get_locale() ) task["formStarttime"] = "" else: if "starttime" not in task: task["starttime"] = "" answer.append(task) else: for task in tasks: if task["formStarttime"]: task["starttime"] = format_datetime( task["formStarttime"], format="short", locale=get_locale() ) task["formStarttime"] = "" else: if "starttime" not in task: task["starttime"] = "" answer = tasks # UIanswer = copy.deepcopy(answer) answer = helper.render_task_status(answer) js = json.dumps(answer) response = make_response(js) response.headers["Content-Type"] = "application/json; charset=utf-8" return response
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def check_valid_domain(domain_text): domain_text = domain_text.split("@", 1)[-1].lower() sql = "SELECT * FROM registration WHERE :domain LIKE domain;" result = ( ub.session.query(ub.Registration) .from_statement(text(sql)) .params(domain=domain_text) .all() ) return len(result)
def check_valid_domain(domain_text): # result = session.query(Notification).from_statement(text(sql)).params(id=5).all() # ToDo: check possible SQL injection domain_text = domain_text.split("@", 1)[-1].lower() sql = "SELECT * FROM registration WHERE '%s' LIKE domain;" % domain_text result = ub.session.query(ub.Registration).from_statement(text(sql)).all() return len(result)
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def edit_domain(): """POST /post name: 'username', //name of field (column in db) pk: 1 //primary key (record id) value: 'superuser!' //new value""" vals = request.form.to_dict() answer = ( ub.session.query(ub.Registration) .filter(ub.Registration.id == vals["pk"]) .first() ) # domain_name = request.args.get('domain') answer.domain = vals["value"].replace("*", "%").replace("?", "_").lower() ub.session.commit() return ""
def edit_domain(): vals = request.form.to_dict() answer = ( ub.session.query(ub.Registration) .filter(ub.Registration.id == vals["pk"]) .first() ) # domain_name = request.args.get('domain') answer.domain = vals["value"].replace("*", "%").replace("?", "_").lower() ub.session.commit() return ""
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def get_update_status(): return updater_thread.get_available_updates(request.method)
def get_update_status(): status = { "update": False, "success": False, "message": "", "current_commit_hash": "", } parents = [] repository_url = "https://api.github.com/repos/janeczku/calibre-web" tz = datetime.timedelta( seconds=time.timezone if (time.localtime().tm_isdst == 0) else time.altzone ) if request.method == "GET": version = helper.get_current_version_info() if version is False: status["current_commit_hash"] = _("Unknown") else: status["current_commit_hash"] = version["hash"] try: r = requests.get(repository_url + "/git/refs/heads/master") r.raise_for_status() commit = r.json() except requests.exceptions.HTTPError as ex: status["message"] = _("HTTP Error") + " " + str(ex) except requests.exceptions.ConnectionError: status["message"] = _("Connection error") except requests.exceptions.Timeout: status["message"] = _("Timeout while establishing connection") except requests.exceptions.RequestException: status["message"] = _("General error") if status["message"] != "": return json.dumps(status) if "object" not in commit: status["message"] = _("Unexpected data while reading update information") return json.dumps(status) if commit["object"]["sha"] == status["current_commit_hash"]: status.update( { "update": False, "success": True, "message": _( "No update available. You already have the latest version installed" ), } ) return json.dumps(status) # a new update is available status["update"] = True try: r = requests.get(repository_url + "/git/commits/" + commit["object"]["sha"]) r.raise_for_status() update_data = r.json() except requests.exceptions.HTTPError as ex: status["error"] = _("HTTP Error") + " " + str(ex) except requests.exceptions.ConnectionError: status["error"] = _("Connection error") except requests.exceptions.Timeout: status["error"] = _("Timeout while establishing connection") except requests.exceptions.RequestException: status["error"] = _("General error") if status["message"] != "": return json.dumps(status) if "committer" in update_data and "message" in update_data: status["success"] = True status["message"] = _( "A new update is available. Click on the button below to update to the latest version." ) new_commit_date = ( datetime.datetime.strptime( update_data["committer"]["date"], "%Y-%m-%dT%H:%M:%SZ" ) - tz ) parents.append( [ format_datetime( new_commit_date, format="short", locale=get_locale() ), update_data["message"], update_data["sha"], ] ) # it only makes sense to analyze the parents if we know the current commit hash if status["current_commit_hash"] != "": try: parent_commit = update_data["parents"][0] # limit the maximum search depth remaining_parents_cnt = 10 except IndexError: remaining_parents_cnt = None if remaining_parents_cnt is not None: while True: if remaining_parents_cnt == 0: break # check if we are more than one update behind if so, go up the tree if parent_commit["sha"] != status["current_commit_hash"]: try: r = requests.get(parent_commit["url"]) r.raise_for_status() parent_data = r.json() parent_commit_date = ( datetime.datetime.strptime( parent_data["committer"]["date"], "%Y-%m-%dT%H:%M:%SZ", ) - tz ) parent_commit_date = format_datetime( parent_commit_date, format="short", locale=get_locale(), ) parents.append( [ parent_commit_date, parent_data["message"], parent_data["sha"], ] ) parent_commit = parent_data["parents"][0] remaining_parents_cnt -= 1 except Exception: # it isn't crucial if we can't get information about the parent break else: # parent is our current version break else: status["success"] = False status["message"] = _("Could not fetch update information") status["history"] = parents return json.dumps(status)
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def get_updater_status(): status = {} if request.method == "POST": commit = request.form.to_dict() if "start" in commit and commit["start"] == "True": text = { "1": _("Requesting update package"), "2": _("Downloading update package"), "3": _("Unzipping update package"), "4": _("Replacing files"), "5": _("Database connections are closed"), "6": _("Stopping server"), "7": _("Update finished, please press okay and reload page"), "8": _("Update failed:") + " " + _("HTTP Error"), "9": _("Update failed:") + " " + _("Connection error"), "10": _("Update failed:") + " " + _("Timeout while establishing connection"), "11": _("Update failed:") + " " + _("General error"), } status["text"] = text # helper.updater_thread = helper.Updater() updater_thread.status = 0 updater_thread.start() status["status"] = updater_thread.get_update_status() elif request.method == "GET": try: status["status"] = updater_thread.get_update_status() if status["status"] == -1: status["status"] = 7 except AttributeError: # thread is not active, occours after restart on update status["status"] = 7 except Exception: status["status"] = 11 return json.dumps(status)
def get_updater_status(): status = {} if request.method == "POST": commit = request.form.to_dict() if "start" in commit and commit["start"] == "True": text = { "1": _("Requesting update package"), "2": _("Downloading update package"), "3": _("Unzipping update package"), "4": _("Replacing files"), "5": _("Database connections are closed"), "6": _("Stopping server"), "7": _("Update finished, please press okay and reload page"), "8": _("Update failed:") + " " + _("HTTP Error"), "9": _("Update failed:") + " " + _("Connection error"), "10": _("Update failed:") + " " + _("Timeout while establishing connection"), "11": _("Update failed:") + " " + _("General error"), } status["text"] = text helper.updater_thread = helper.Updater() helper.updater_thread.start() status["status"] = helper.updater_thread.get_update_status() elif request.method == "GET": try: status["status"] = helper.updater_thread.get_update_status() except AttributeError: # thread is not active, occours after restart on update status["status"] = 7 except Exception: status["status"] = 11 return json.dumps(status)
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def index(page): entries, random, pagination = fill_indexpage( page, db.Books, True, [db.Books.timestamp.desc()] ) return render_title_template( "index.html", random=random, entries=entries, pagination=pagination, title=_("Recently Added Books"), page="root", config_authors_max=config.config_authors_max, )
def index(page): entries, random, pagination = fill_indexpage( page, db.Books, True, [db.Books.timestamp.desc()] ) return render_title_template( "index.html", random=random, entries=entries, pagination=pagination, title=_("Recently Added Books"), page="root", )
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def author_list(): if current_user.show_author(): entries = ( db.session.query( db.Authors, func.count("books_authors_link.book").label("count") ) .join(db.books_authors_link) .join(db.Books) .filter(common_filters()) .group_by(text("books_authors_link.author")) .order_by(db.Authors.sort) .all() ) for entry in entries: entry.Authors.name = entry.Authors.name.replace("|", ",") return render_title_template( "list.html", entries=entries, folder="author", title="Author list", page="authorlist", ) else: abort(404)
def author_list(): if current_user.show_author(): entries = ( db.session.query( db.Authors, func.count("books_authors_link.book").label("count") ) .join(db.books_authors_link) .join(db.Books) .filter(common_filters()) .group_by("books_authors_link.author") .order_by(db.Authors.sort) .all() ) for entry in entries: entry.Authors.name = entry.Authors.name.replace("|", ",") return render_title_template( "list.html", entries=entries, folder="author", title=_("Author list"), page="authorlist", ) else: abort(404)
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def author(book_id, page): entries, __, pagination = fill_indexpage( page, db.Books, db.Books.authors.any(db.Authors.id == book_id), [db.Series.name, db.Books.series_index], db.books_series_link, db.Series, ) if entries is None: flash( _("Error opening eBook. File does not exist or file is not accessible:"), category="error", ) return redirect(url_for("index")) name = ( db.session.query(db.Authors).filter(db.Authors.id == book_id).first().name ).replace("|", ",") author_info = None other_books = [] if goodreads_support and config.config_use_goodreads: try: gc = GoodreadsClient( config.config_goodreads_api_key, config.config_goodreads_api_secret ) author_info = gc.find_author(author_name=name) other_books = get_unique_other_books(entries.all(), author_info.books) except Exception: # Skip goodreads, if site is down/inaccessible app.logger.error("Goodreads website is down/inaccessible") return render_title_template( "author.html", entries=entries, pagination=pagination, title=name, author=author_info, other_books=other_books, page="author", config_authors_max=config.config_authors_max, )
def author(book_id, page): entries, __, pagination = fill_indexpage( page, db.Books, db.Books.authors.any(db.Authors.id == book_id), [db.Series.name, db.Books.series_index], db.books_series_link, db.Series, ) if entries is None: flash( _("Error opening eBook. File does not exist or file is not accessible:"), category="error", ) return redirect(url_for("index")) name = ( db.session.query(db.Authors).filter(db.Authors.id == book_id).first().name ).replace("|", ",") author_info = None other_books = [] if goodreads_support and config.config_use_goodreads: try: gc = GoodreadsClient( config.config_goodreads_api_key, config.config_goodreads_api_secret ) author_info = gc.find_author(author_name=name) other_books = get_unique_other_books(entries.all(), author_info.books) except Exception: # Skip goodreads, if site is down/inaccessible app.logger.error("Goodreads website is down/inaccessible") return render_title_template( "author.html", entries=entries, pagination=pagination, title=name, author=author_info, other_books=other_books, page="author", )
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def publisher_list(): if current_user.show_publisher(): entries = ( db.session.query( db.Publishers, func.count("books_publishers_link.book").label("count") ) .join(db.books_publishers_link) .join(db.Books) .filter(common_filters()) .group_by(text("books_publishers_link.publisher")) .order_by(db.Publishers.sort) .all() ) return render_title_template( "list.html", entries=entries, folder="publisher", title=_("Publisher list"), page="publisherlist", ) else: abort(404)
def publisher_list(): if current_user.show_publisher(): entries = ( db.session.query( db.Publishers, func.count("books_publishers_link.book").label("count") ) .join(db.books_publishers_link) .join(db.Books) .filter(common_filters()) .group_by("books_publishers_link.publisher") .order_by(db.Publishers.sort) .all() ) return render_title_template( "list.html", entries=entries, folder="publisher", title=_("Publisher list"), page="publisherlist", ) else: abort(404)
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def series_list(): if current_user.show_series(): entries = ( db.session.query( db.Series, func.count("books_series_link.book").label("count") ) .join(db.books_series_link) .join(db.Books) .filter(common_filters()) .group_by(text("books_series_link.series")) .order_by(db.Series.sort) .all() ) return render_title_template( "list.html", entries=entries, folder="series", title=_("Series list"), page="serieslist", ) else: abort(404)
def series_list(): if current_user.show_series(): entries = ( db.session.query( db.Series, func.count("books_series_link.book").label("count") ) .join(db.books_series_link) .join(db.Books) .filter(common_filters()) .group_by("books_series_link.series") .order_by(db.Series.sort) .all() ) return render_title_template( "list.html", entries=entries, folder="series", title=_("Series list"), page="serieslist", ) else: abort(404)
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def series(book_id, page): name = db.session.query(db.Series).filter(db.Series.id == book_id).first() if name: entries, random, pagination = fill_indexpage( page, db.Books, db.Books.series.any(db.Series.id == book_id), [db.Books.series_index], ) return render_title_template( "index.html", random=random, pagination=pagination, entries=entries, title=_("Series: %(serie)s", serie=name.name), page="series", ) else: abort(404)
def series(book_id, page): name = db.session.query(db.Series).filter(db.Series.id == book_id).first() if name: entries, random, pagination = fill_indexpage( page, db.Books, db.Books.series.any(db.Series.id == book_id), [db.Books.series_index], ) if entries: return render_title_template( "index.html", random=random, pagination=pagination, entries=entries, title=_("Series: %(serie)s", serie=name.name), page="series", ) else: flash( _( "Error opening eBook. File does not exist or file is not accessible:" ), category="error", ) return redirect(url_for("index")) else: abort(404)
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def language_overview(): if current_user.show_language(): if current_user.filter_language() == "all": languages = speaking_language() else: try: cur_l = LC.parse(current_user.filter_language()) except UnknownLocaleError: cur_l = None languages = ( db.session.query(db.Languages) .filter(db.Languages.lang_code == current_user.filter_language()) .all() ) if cur_l: languages[0].name = cur_l.get_language_name(get_locale()) else: languages[0].name = _( isoLanguages.get(part3=languages[0].lang_code).name ) lang_counter = ( db.session.query( db.books_languages_link, func.count("books_languages_link.book").label("bookcount"), ) .group_by(text("books_languages_link.lang_code")) .all() ) return render_title_template( "languages.html", languages=languages, lang_counter=lang_counter, title=_("Available languages"), page="langlist", ) else: abort(404)
def language_overview(): if current_user.show_language(): if current_user.filter_language() == "all": languages = speaking_language() else: try: cur_l = LC.parse(current_user.filter_language()) except UnknownLocaleError: cur_l = None languages = ( db.session.query(db.Languages) .filter(db.Languages.lang_code == current_user.filter_language()) .all() ) if cur_l: languages[0].name = cur_l.get_language_name(get_locale()) else: languages[0].name = _( isoLanguages.get(part3=languages[0].lang_code).name ) lang_counter = ( db.session.query( db.books_languages_link, func.count("books_languages_link.book").label("bookcount"), ) .group_by("books_languages_link.lang_code") .all() ) return render_title_template( "languages.html", languages=languages, lang_counter=lang_counter, title=_("Available languages"), page="langlist", ) else: abort(404)
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def category_list(): if current_user.show_category(): entries = ( db.session.query(db.Tags, func.count("books_tags_link.book").label("count")) .join(db.books_tags_link) .join(db.Books) .order_by(db.Tags.name) .filter(common_filters()) .group_by(text("books_tags_link.tag")) .all() ) return render_title_template( "list.html", entries=entries, folder="category", title=_("Category list"), page="catlist", ) else: abort(404)
def category_list(): if current_user.show_category(): entries = ( db.session.query(db.Tags, func.count("books_tags_link.book").label("count")) .join(db.books_tags_link) .join(db.Books) .order_by(db.Tags.name) .filter(common_filters()) .group_by("books_tags_link.tag") .all() ) return render_title_template( "list.html", entries=entries, folder="category", title=_("Category list"), page="catlist", ) else: abort(404)
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def show_book(book_id): entries = ( db.session.query(db.Books) .filter(db.Books.id == book_id) .filter(common_filters()) .first() ) if entries: for index in range(0, len(entries.languages)): try: entries.languages[index].language_name = LC.parse( entries.languages[index].lang_code ).get_language_name(get_locale()) except UnknownLocaleError: entries.languages[index].language_name = _( isoLanguages.get(part3=entries.languages[index].lang_code).name ) tmpcc = ( db.session.query(db.Custom_Columns) .filter(db.Custom_Columns.datatype.notin_(db.cc_exceptions)) .all() ) if config.config_columns_to_ignore: cc = [] for col in tmpcc: r = re.compile(config.config_columns_to_ignore) if r.match(col.label): cc.append(col) else: cc = tmpcc book_in_shelfs = [] shelfs = ( ub.session.query(ub.BookShelf).filter(ub.BookShelf.book_id == book_id).all() ) for entry in shelfs: book_in_shelfs.append(entry.shelf) if not current_user.is_anonymous: if not config.config_read_column: matching_have_read_book = ( ub.session.query(ub.ReadBook) .filter( ub.and_( ub.ReadBook.user_id == int(current_user.id), ub.ReadBook.book_id == book_id, ) ) .all() ) have_read = ( len(matching_have_read_book) > 0 and matching_have_read_book[0].is_read ) else: try: matching_have_read_book = getattr( entries, "custom_column_" + str(config.config_read_column) ) have_read = ( len(matching_have_read_book) > 0 and matching_have_read_book[0].value ) except KeyError: app.logger.error( "Custom Column No.%d is not exisiting in calibre database" % config.config_read_column ) have_read = None else: have_read = None entries.tags = sort(entries.tags, key=lambda tag: tag.name) entries = order_authors(entries) kindle_list = helper.check_send_to_kindle(entries) reader_list = helper.check_read_formats(entries) return render_title_template( "detail.html", entry=entries, cc=cc, is_xhr=request.is_xhr, title=entries.title, books_shelfs=book_in_shelfs, have_read=have_read, kindle_list=kindle_list, reader_list=reader_list, page="book", ) else: flash( _("Error opening eBook. File does not exist or file is not accessible:"), category="error", ) return redirect(url_for("index"))
def show_book(book_id): entries = ( db.session.query(db.Books) .filter(db.Books.id == book_id) .filter(common_filters()) .first() ) if entries: for index in range(0, len(entries.languages)): try: entries.languages[index].language_name = LC.parse( entries.languages[index].lang_code ).get_language_name(get_locale()) except UnknownLocaleError: entries.languages[index].language_name = _( isoLanguages.get(part3=entries.languages[index].lang_code).name ) tmpcc = ( db.session.query(db.Custom_Columns) .filter(db.Custom_Columns.datatype.notin_(db.cc_exceptions)) .all() ) if config.config_columns_to_ignore: cc = [] for col in tmpcc: r = re.compile(config.config_columns_to_ignore) if r.match(col.label): cc.append(col) else: cc = tmpcc book_in_shelfs = [] shelfs = ( ub.session.query(ub.BookShelf).filter(ub.BookShelf.book_id == book_id).all() ) for entry in shelfs: book_in_shelfs.append(entry.shelf) if not current_user.is_anonymous: if not config.config_read_column: matching_have_read_book = ( ub.session.query(ub.ReadBook) .filter( ub.and_( ub.ReadBook.user_id == int(current_user.id), ub.ReadBook.book_id == book_id, ) ) .all() ) have_read = ( len(matching_have_read_book) > 0 and matching_have_read_book[0].is_read ) else: try: matching_have_read_book = getattr( entries, "custom_column_" + str(config.config_read_column) ) have_read = ( len(matching_have_read_book) > 0 and matching_have_read_book[0].value ) except KeyError: app.logger.error( "Custom Column No.%d is not exisiting in calibre database" % config.config_read_column ) have_read = None else: have_read = None entries.tags = sort(entries.tags, key=lambda tag: tag.name) return render_title_template( "detail.html", entry=entries, cc=cc, is_xhr=request.is_xhr, title=entries.title, books_shelfs=book_in_shelfs, have_read=have_read, page="book", ) else: flash( _("Error opening eBook. File does not exist or file is not accessible:"), category="error", ) return redirect(url_for("index"))
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def get_tasks_status(): # if current user admin, show all email, otherwise only own emails answer = list() # UIanswer=list() tasks = helper.global_WorkerThread.get_taskstatus() # answer = tasks # UIanswer = copy.deepcopy(answer) answer = helper.render_task_status(tasks) # foreach row format row return render_title_template( "tasks.html", entries=answer, title=_("Tasks"), page="tasks" )
def get_tasks_status(): # if current user admin, show all email, otherwise only own emails answer = list() # UIanswer=list() tasks = helper.global_WorkerThread.get_taskstatus() # answer = tasks # UIanswer = copy.deepcopy(answer) answer = helper.render_task_status(tasks) # foreach row format row return render_title_template("tasks.html", entries=answer, title=_("Tasks"))
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def authenticate_google_drive(): try: authUrl = gdriveutils.Gauth.Instance().auth.GetAuthUrl() except gdriveutils.InvalidConfigError: flash( _( "Google Drive setup not completed, try to deactivate and activate Google Drive again" ), category="error", ) return redirect(url_for("index")) return redirect(authUrl)
def authenticate_google_drive(): authUrl = gdriveutils.Gauth.Instance().auth.GetAuthUrl() return redirect(authUrl)
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def on_received_watch_confirmation(): app.logger.debug(request.headers) if ( request.headers.get("X-Goog-Channel-Token") == gdrive_watch_callback_token and request.headers.get("X-Goog-Resource-State") == "change" and request.data ): data = request.data def updateMetaData(): app.logger.info("Change received from gdrive") app.logger.debug(data) try: j = json.loads(data) app.logger.info("Getting change details") response = gdriveutils.getChangeById( gdriveutils.Gdrive.Instance().drive, j["id"] ) app.logger.debug(response) if response: dbpath = os.path.join(config.config_calibre_dir, "metadata.db") if ( not response["deleted"] and response["file"]["title"] == "metadata.db" and response["file"]["md5Checksum"] != hashlib.md5(dbpath) ): tmpDir = tempfile.gettempdir() app.logger.info("Database file updated") copyfile( dbpath, os.path.join( tmpDir, "metadata.db_" + str(current_milli_time()) ), ) app.logger.info( "Backing up existing and downloading updated metadata.db" ) gdriveutils.downloadFile( None, "metadata.db", os.path.join(tmpDir, "tmp_metadata.db") ) app.logger.info("Setting up new DB") # prevent error on windows, as os.rename does on exisiting files move(os.path.join(tmpDir, "tmp_metadata.db"), dbpath) db.setup_db() except Exception as e: app.logger.info(e.message) app.logger.exception(e) updateMetaData() return ""
def on_received_watch_confirmation(): app.logger.debug(request.headers) if ( request.headers.get("X-Goog-Channel-Token") == gdrive_watch_callback_token and request.headers.get("X-Goog-Resource-State") == "change" and request.data ): data = request.data def updateMetaData(): app.logger.info("Change received from gdrive") app.logger.debug(data) try: j = json.loads(data) app.logger.info("Getting change details") response = gdriveutils.getChangeById( gdriveutils.Gdrive.Instance().drive, j["id"] ) app.logger.debug(response) if response: dbpath = os.path.join(config.config_calibre_dir, "metadata.db") if ( not response["deleted"] and response["file"]["title"] == "metadata.db" and response["file"]["md5Checksum"] != md5(dbpath) ): tmpDir = tempfile.gettempdir() app.logger.info("Database file updated") copyfile( dbpath, os.path.join( tmpDir, "metadata.db_" + str(current_milli_time()) ), ) app.logger.info( "Backing up existing and downloading updated metadata.db" ) gdriveutils.downloadFile( None, "metadata.db", os.path.join(tmpDir, "tmp_metadata.db") ) app.logger.info("Setting up new DB") # prevent error on windows, as os.rename does on exisiting files move(os.path.join(tmpDir, "tmp_metadata.db"), dbpath) db.setup_db() except Exception as e: app.logger.info(e.message) app.logger.exception(e) updateMetaData() return ""
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def updateMetaData(): app.logger.info("Change received from gdrive") app.logger.debug(data) try: j = json.loads(data) app.logger.info("Getting change details") response = gdriveutils.getChangeById( gdriveutils.Gdrive.Instance().drive, j["id"] ) app.logger.debug(response) if response: dbpath = os.path.join(config.config_calibre_dir, "metadata.db") if ( not response["deleted"] and response["file"]["title"] == "metadata.db" and response["file"]["md5Checksum"] != hashlib.md5(dbpath) ): tmpDir = tempfile.gettempdir() app.logger.info("Database file updated") copyfile( dbpath, os.path.join(tmpDir, "metadata.db_" + str(current_milli_time())), ) app.logger.info( "Backing up existing and downloading updated metadata.db" ) gdriveutils.downloadFile( None, "metadata.db", os.path.join(tmpDir, "tmp_metadata.db") ) app.logger.info("Setting up new DB") # prevent error on windows, as os.rename does on exisiting files move(os.path.join(tmpDir, "tmp_metadata.db"), dbpath) db.setup_db() except Exception as e: app.logger.info(e.message) app.logger.exception(e)
def updateMetaData(): app.logger.info("Change received from gdrive") app.logger.debug(data) try: j = json.loads(data) app.logger.info("Getting change details") response = gdriveutils.getChangeById( gdriveutils.Gdrive.Instance().drive, j["id"] ) app.logger.debug(response) if response: dbpath = os.path.join(config.config_calibre_dir, "metadata.db") if ( not response["deleted"] and response["file"]["title"] == "metadata.db" and response["file"]["md5Checksum"] != md5(dbpath) ): tmpDir = tempfile.gettempdir() app.logger.info("Database file updated") copyfile( dbpath, os.path.join(tmpDir, "metadata.db_" + str(current_milli_time())), ) app.logger.info( "Backing up existing and downloading updated metadata.db" ) gdriveutils.downloadFile( None, "metadata.db", os.path.join(tmpDir, "tmp_metadata.db") ) app.logger.info("Setting up new DB") # prevent error on windows, as os.rename does on exisiting files move(os.path.join(tmpDir, "tmp_metadata.db"), dbpath) db.setup_db() except Exception as e: app.logger.info(e.message) app.logger.exception(e)
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def advanced_search(): # Build custom columns names tmpcc = ( db.session.query(db.Custom_Columns) .filter(db.Custom_Columns.datatype.notin_(db.cc_exceptions)) .all() ) if config.config_columns_to_ignore: cc = [] for col in tmpcc: r = re.compile(config.config_columns_to_ignore) if r.match(col.label): cc.append(col) else: cc = tmpcc db.session.connection().connection.connection.create_function("lower", 1, db.lcase) q = db.session.query(db.Books) # postargs = request.form.to_dict() include_tag_inputs = request.args.getlist("include_tag") exclude_tag_inputs = request.args.getlist("exclude_tag") include_series_inputs = request.args.getlist("include_serie") exclude_series_inputs = request.args.getlist("exclude_serie") include_languages_inputs = request.args.getlist("include_language") exclude_languages_inputs = request.args.getlist("exclude_language") author_name = request.args.get("author_name") book_title = request.args.get("book_title") publisher = request.args.get("publisher") pub_start = request.args.get("Publishstart") pub_end = request.args.get("Publishend") rating_low = request.args.get("ratinghigh") rating_high = request.args.get("ratinglow") description = request.args.get("comment") if author_name: author_name = author_name.strip().lower().replace(",", "|") if book_title: book_title = book_title.strip().lower() if publisher: publisher = publisher.strip().lower() searchterm = [] cc_present = False for c in cc: if request.args.get("custom_column_" + str(c.id)): searchterm.extend( [("%s: %s" % (c.name, request.args.get("custom_column_" + str(c.id))))] ) cc_present = True if ( include_tag_inputs or exclude_tag_inputs or include_series_inputs or exclude_series_inputs or include_languages_inputs or exclude_languages_inputs or author_name or book_title or publisher or pub_start or pub_end or rating_low or rating_high or description or cc_present ): searchterm = [] searchterm.extend((author_name.replace("|", ","), book_title, publisher)) if pub_start: try: searchterm.extend( [ _("Published after ") + format_date( datetime.datetime.strptime(pub_start, "%Y-%m-%d"), format="medium", locale=get_locale(), ) ] ) except ValueError: pub_start = "" if pub_end: try: searchterm.extend( [ _("Published before ") + format_date( datetime.datetime.strptime(pub_end, "%Y-%m-%d"), format="medium", locale=get_locale(), ) ] ) except ValueError: pub_start = "" tag_names = ( db.session.query(db.Tags).filter(db.Tags.id.in_(include_tag_inputs)).all() ) searchterm.extend(tag.name for tag in tag_names) serie_names = ( db.session.query(db.Series) .filter(db.Series.id.in_(include_series_inputs)) .all() ) searchterm.extend(serie.name for serie in serie_names) language_names = ( db.session.query(db.Languages) .filter(db.Languages.id.in_(include_languages_inputs)) .all() ) if language_names: language_names = speaking_language(language_names) searchterm.extend(language.name for language in language_names) if rating_high: searchterm.extend([_("Rating <= %(rating)s", rating=rating_high)]) if rating_low: searchterm.extend([_("Rating >= %(rating)s", rating=rating_low)]) # handle custom columns for c in cc: if request.args.get("custom_column_" + str(c.id)): searchterm.extend( [ ( "%s: %s" % (c.name, request.args.get("custom_column_" + str(c.id))) ) ] ) searchterm = " + ".join(filter(None, searchterm)) q = q.filter() if author_name: q = q.filter( db.Books.authors.any(db.Authors.name.ilike("%" + author_name + "%")) ) if book_title: q = q.filter(db.Books.title.ilike("%" + book_title + "%")) if pub_start: q = q.filter(db.Books.pubdate >= pub_start) if pub_end: q = q.filter(db.Books.pubdate <= pub_end) if publisher: q = q.filter( db.Books.publishers.any(db.Publishers.name.ilike("%" + publisher + "%")) ) for tag in include_tag_inputs: q = q.filter(db.Books.tags.any(db.Tags.id == tag)) for tag in exclude_tag_inputs: q = q.filter(not_(db.Books.tags.any(db.Tags.id == tag))) for serie in include_series_inputs: q = q.filter(db.Books.series.any(db.Series.id == serie)) for serie in exclude_series_inputs: q = q.filter(not_(db.Books.series.any(db.Series.id == serie))) if current_user.filter_language() != "all": q = q.filter( db.Books.languages.any( db.Languages.lang_code == current_user.filter_language() ) ) else: for language in include_languages_inputs: q = q.filter(db.Books.languages.any(db.Languages.id == language)) for language in exclude_languages_inputs: q = q.filter(not_(db.Books.series.any(db.Languages.id == language))) if rating_high: rating_high = int(rating_high) * 2 q = q.filter(db.Books.ratings.any(db.Ratings.rating <= rating_high)) if rating_low: rating_low = int(rating_low) * 2 q = q.filter(db.Books.ratings.any(db.Ratings.rating >= rating_low)) if description: q = q.filter( db.Books.comments.any(db.Comments.text.ilike("%" + description + "%")) ) # search custom culumns for c in cc: custom_query = request.args.get("custom_column_" + str(c.id)) if custom_query: if c.datatype == "bool": getattr(db.Books, "custom_column_1") q = q.filter( getattr(db.Books, "custom_column_" + str(c.id)).any( db.cc_classes[c.id].value == (custom_query == "True") ) ) elif c.datatype == "int": q = q.filter( getattr(db.Books, "custom_column_" + str(c.id)).any( db.cc_classes[c.id].value == custom_query ) ) else: q = q.filter( getattr(db.Books, "custom_column_" + str(c.id)).any( db.cc_classes[c.id].value.ilike("%" + custom_query + "%") ) ) q = q.all() ids = list() for element in q: ids.append(element.id) ub.searched_ids[current_user.id] = ids return render_title_template( "search.html", searchterm=searchterm, entries=q, title=_("search"), page="search", ) # prepare data for search-form tags = db.session.query(db.Tags).order_by(db.Tags.name).all() series = db.session.query(db.Series).order_by(db.Series.name).all() if current_user.filter_language() == "all": languages = speaking_language() else: languages = None return render_title_template( "search_form.html", tags=tags, languages=languages, series=series, title=_("search"), cc=cc, page="advsearch", )
def advanced_search(): # Build custom columns names tmpcc = ( db.session.query(db.Custom_Columns) .filter(db.Custom_Columns.datatype.notin_(db.cc_exceptions)) .all() ) if config.config_columns_to_ignore: cc = [] for col in tmpcc: r = re.compile(config.config_columns_to_ignore) if r.match(col.label): cc.append(col) else: cc = tmpcc db.session.connection().connection.connection.create_function("lower", 1, db.lcase) q = db.session.query(db.Books) # postargs = request.form.to_dict() include_tag_inputs = request.args.getlist("include_tag") exclude_tag_inputs = request.args.getlist("exclude_tag") include_series_inputs = request.args.getlist("include_serie") exclude_series_inputs = request.args.getlist("exclude_serie") include_languages_inputs = request.args.getlist("include_language") exclude_languages_inputs = request.args.getlist("exclude_language") author_name = request.args.get("author_name") book_title = request.args.get("book_title") publisher = request.args.get("publisher") pub_start = request.args.get("Publishstart") pub_end = request.args.get("Publishend") rating_low = request.args.get("ratinghigh") rating_high = request.args.get("ratinglow") description = request.args.get("comment") if author_name: author_name = author_name.strip().lower().replace(",", "|") if book_title: book_title = book_title.strip().lower() if publisher: publisher = publisher.strip().lower() searchterm = [] cc_present = False for c in cc: if request.args.get("custom_column_" + str(c.id)): searchterm.extend( [("%s: %s" % (c.name, request.args.get("custom_column_" + str(c.id))))] ) cc_present = True if ( include_tag_inputs or exclude_tag_inputs or include_series_inputs or exclude_series_inputs or include_languages_inputs or exclude_languages_inputs or author_name or book_title or publisher or pub_start or pub_end or rating_low or rating_high or description or cc_present ): searchterm = [] searchterm.extend((author_name.replace("|", ","), book_title, publisher)) if pub_start: try: searchterm.extend( [ _("Published after ") + format_date( datetime.datetime.strptime(pub_start, "%Y-%m-%d"), format="medium", locale=get_locale(), ) ] ) except ValueError: pub_start = "" if pub_end: try: searchterm.extend( [ _("Published before ") + format_date( datetime.datetime.strptime(pub_end, "%Y-%m-%d"), format="medium", locale=get_locale(), ) ] ) except ValueError: pub_start = "" tag_names = ( db.session.query(db.Tags).filter(db.Tags.id.in_(include_tag_inputs)).all() ) searchterm.extend(tag.name for tag in tag_names) serie_names = ( db.session.query(db.Series) .filter(db.Series.id.in_(include_series_inputs)) .all() ) searchterm.extend(serie.name for serie in serie_names) language_names = ( db.session.query(db.Languages) .filter(db.Languages.id.in_(include_languages_inputs)) .all() ) if language_names: language_names = speaking_language(language_names) searchterm.extend(language.name for language in language_names) if rating_high: searchterm.extend([_("Rating <= %(rating)s", rating=rating_high)]) if rating_low: searchterm.extend([_("Rating >= %(rating)s", rating=rating_low)]) # handle custom columns for c in cc: if request.args.get("custom_column_" + str(c.id)): searchterm.extend( [ ( "%s: %s" % (c.name, request.args.get("custom_column_" + str(c.id))) ) ] ) searchterm = " + ".join(filter(None, searchterm)) q = q.filter() if author_name: q = q.filter( db.Books.authors.any(db.Authors.name.ilike("%" + author_name + "%")) ) if book_title: q = q.filter(db.Books.title.ilike("%" + book_title + "%")) if pub_start: q = q.filter(db.Books.pubdate >= pub_start) if pub_end: q = q.filter(db.Books.pubdate <= pub_end) if publisher: q = q.filter( db.Books.publishers.any(db.Publishers.name.ilike("%" + publisher + "%")) ) for tag in include_tag_inputs: q = q.filter(db.Books.tags.any(db.Tags.id == tag)) for tag in exclude_tag_inputs: q = q.filter(not_(db.Books.tags.any(db.Tags.id == tag))) for serie in include_series_inputs: q = q.filter(db.Books.series.any(db.Series.id == serie)) for serie in exclude_series_inputs: q = q.filter(not_(db.Books.series.any(db.Series.id == serie))) if current_user.filter_language() != "all": q = q.filter( db.Books.languages.any( db.Languages.lang_code == current_user.filter_language() ) ) else: for language in include_languages_inputs: q = q.filter(db.Books.languages.any(db.Languages.id == language)) for language in exclude_languages_inputs: q = q.filter(not_(db.Books.series.any(db.Languages.id == language))) if rating_high: q = q.filter(db.Books.ratings.any(db.Ratings.id <= rating_high)) if rating_low: q = q.filter(db.Books.ratings.any(db.Ratings.id >= rating_low)) if description: q = q.filter( db.Books.comments.any(db.Comments.text.ilike("%" + description + "%")) ) # search custom culumns for c in cc: custom_query = request.args.get("custom_column_" + str(c.id)) if custom_query: if c.datatype == "bool": getattr(db.Books, "custom_column_1") q = q.filter( getattr(db.Books, "custom_column_" + str(c.id)).any( db.cc_classes[c.id].value == (custom_query == "True") ) ) elif c.datatype == "int": q = q.filter( getattr(db.Books, "custom_column_" + str(c.id)).any( db.cc_classes[c.id].value == custom_query ) ) else: q = q.filter( getattr(db.Books, "custom_column_" + str(c.id)).any( db.cc_classes[c.id].value.ilike("%" + custom_query + "%") ) ) q = q.all() ids = list() for element in q: ids.append(element.id) ub.searched_ids[current_user.id] = ids return render_title_template( "search.html", searchterm=searchterm, entries=q, title=_("search"), page="search", ) # prepare data for search-form tags = db.session.query(db.Tags).order_by(db.Tags.name).all() series = db.session.query(db.Series).order_by(db.Series.name).all() if current_user.filter_language() == "all": languages = speaking_language() else: languages = None return render_title_template( "search_form.html", tags=tags, languages=languages, series=series, title=_("search"), cc=cc, page="advsearch", )
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def get_cover(book_id): book = db.session.query(db.Books).filter(db.Books.id == book_id).first() return helper.get_book_cover(book.path)
def get_cover(cover_path): return helper.get_book_cover(cover_path)
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def feed_get_cover(book_id): book = db.session.query(db.Books).filter(db.Books.id == book_id).first() if book: return helper.get_book_cover(book.path) else: abort(404)
def feed_get_cover(book_id): book = db.session.query(db.Books).filter(db.Books.id == book_id).first() return helper.get_book_cover(book.path)
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def register(): if not config.config_public_reg: abort(404) if current_user is not None and current_user.is_authenticated: return redirect(url_for("index")) if request.method == "POST": to_save = request.form.to_dict() if not to_save["nickname"] or not to_save["email"]: flash(_("Please fill out all fields!"), category="error") return render_title_template( "register.html", title=_("register"), page="register" ) existing_user = ( ub.session.query(ub.User) .filter(func.lower(ub.User.nickname) == to_save["nickname"].lower()) .first() ) existing_email = ( ub.session.query(ub.User) .filter(ub.User.email == to_save["email"].lower()) .first() ) if not existing_user and not existing_email: content = ub.User() # content.password = generate_password_hash(to_save["password"]) if check_valid_domain(to_save["email"]): content.nickname = to_save["nickname"] content.email = to_save["email"] password = helper.generate_random_password() content.password = generate_password_hash(password) content.role = config.config_default_role content.sidebar_view = config.config_default_show content.mature_content = bool( config.config_default_show & ub.MATURE_CONTENT ) try: ub.session.add(content) ub.session.commit() helper.send_registration_mail( to_save["email"], to_save["nickname"], password ) except Exception: ub.session.rollback() flash( _("An unknown error occurred. Please try again later."), category="error", ) return render_title_template( "register.html", title=_("register"), page="register" ) else: flash(_("Your e-mail is not allowed to register"), category="error") app.logger.info( 'Registering failed for user "' + to_save["nickname"] + '" e-mail adress: ' + to_save["email"] ) return render_title_template( "register.html", title=_("register"), page="register" ) flash( _("Confirmation e-mail was send to your e-mail account."), category="success", ) return redirect(url_for("login")) else: flash( _("This username or e-mail address is already in use."), category="error", ) return render_title_template( "register.html", title=_("register"), page="register" ) return render_title_template("register.html", title=_("register"), page="register")
def register(): if not config.config_public_reg: abort(404) if current_user is not None and current_user.is_authenticated: return redirect(url_for("index")) if request.method == "POST": to_save = request.form.to_dict() if not to_save["nickname"] or not to_save["email"]: flash(_("Please fill out all fields!"), category="error") return render_title_template( "register.html", title=_("register"), page="register" ) existing_user = ( ub.session.query(ub.User) .filter(func.lower(ub.User.nickname) == to_save["nickname"].lower()) .first() ) existing_email = ( ub.session.query(ub.User) .filter(ub.User.email == to_save["email"].lower()) .first() ) if not existing_user and not existing_email: content = ub.User() # content.password = generate_password_hash(to_save["password"]) if check_valid_domain(to_save["email"]): content.nickname = to_save["nickname"] content.email = to_save["email"] password = helper.generate_random_password() content.password = generate_password_hash(password) content.role = config.config_default_role content.sidebar_view = config.config_default_show try: ub.session.add(content) ub.session.commit() helper.send_registration_mail( to_save["email"], to_save["nickname"], password ) except Exception: ub.session.rollback() flash( _("An unknown error occurred. Please try again later."), category="error", ) return render_title_template( "register.html", title=_("register"), page="register" ) else: flash(_("Your e-mail is not allowed to register"), category="error") app.logger.info( 'Registering failed for user "' + to_save["nickname"] + '" e-mail adress: ' + to_save["email"] ) return render_title_template( "register.html", title=_("register"), page="register" ) flash( _("Confirmation e-mail was send to your e-mail account."), category="success", ) return redirect(url_for("login")) else: flash( _("This username or e-mail address is already in use."), category="error", ) return render_title_template( "register.html", title=_("register"), page="register" ) return render_title_template("register.html", title=_("register"), page="register")
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def send_to_kindle(book_id, book_format, convert): settings = ub.get_mail_settings() if settings.get("mail_server", "mail.example.com") == "mail.example.com": flash(_("Please configure the SMTP mail settings first..."), category="error") elif current_user.kindle_mail: result = helper.send_mail( book_id, book_format, convert, current_user.kindle_mail, config.config_calibre_dir, current_user.nickname, ) if result is None: flash( _( "Book successfully queued for sending to %(kindlemail)s", kindlemail=current_user.kindle_mail, ), category="success", ) ub.update_download(book_id, int(current_user.id)) else: flash( _("There was an error sending this book: %(res)s", res=result), category="error", ) else: flash( _("Please configure your kindle e-mail address first..."), category="error" ) return redirect(request.environ["HTTP_REFERER"])
def send_to_kindle(book_id): settings = ub.get_mail_settings() if settings.get("mail_server", "mail.example.com") == "mail.example.com": flash(_("Please configure the SMTP mail settings first..."), category="error") elif current_user.kindle_mail: result = helper.send_mail( book_id, current_user.kindle_mail, config.config_calibre_dir, current_user.nickname, ) if result is None: flash( _( "Book successfully queued for sending to %(kindlemail)s", kindlemail=current_user.kindle_mail, ), category="success", ) ub.update_download(book_id, int(current_user.id)) else: flash( _("There was an error sending this book: %(res)s", res=result), category="error", ) else: flash( _("Please configure your kindle e-mail address first..."), category="error" ) return redirect(request.environ["HTTP_REFERER"])
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def profile(): content = ( ub.session.query(ub.User).filter(ub.User.id == int(current_user.id)).first() ) downloads = list() languages = speaking_language() translations = babel.list_translations() + [LC("en")] for book in content.downloads: downloadBook = ( db.session.query(db.Books).filter(db.Books.id == book.book_id).first() ) if downloadBook: downloads.append( db.session.query(db.Books).filter(db.Books.id == book.book_id).first() ) else: ub.delete_download(book.book_id) # ub.session.query(ub.Downloads).filter(book.book_id == ub.Downloads.book_id).delete() # ub.session.commit() if request.method == "POST": to_save = request.form.to_dict() content.random_books = 0 if current_user.role_passwd() or current_user.role_admin(): if "password" in to_save and to_save["password"]: content.password = generate_password_hash(to_save["password"]) if "kindle_mail" in to_save and to_save["kindle_mail"] != content.kindle_mail: content.kindle_mail = to_save["kindle_mail"] if to_save["email"] and to_save["email"] != content.email: if config.config_public_reg and not check_valid_domain(to_save["email"]): flash(_("E-mail is not from valid domain"), category="error") return render_title_template( "user_edit.html", content=content, downloads=downloads, title=_("%(name)s's profile", name=current_user.nickname), ) content.email = to_save["email"] if "show_random" in to_save and to_save["show_random"] == "on": content.random_books = 1 if "default_language" in to_save: content.default_language = to_save["default_language"] if "locale" in to_save: content.locale = to_save["locale"] content.sidebar_view = 0 if "show_random" in to_save: content.sidebar_view += ub.SIDEBAR_RANDOM if "show_language" in to_save: content.sidebar_view += ub.SIDEBAR_LANGUAGE if "show_series" in to_save: content.sidebar_view += ub.SIDEBAR_SERIES if "show_category" in to_save: content.sidebar_view += ub.SIDEBAR_CATEGORY if "show_recent" in to_save: content.sidebar_view += ub.SIDEBAR_RECENT if "show_sorted" in to_save: content.sidebar_view += ub.SIDEBAR_SORTED if "show_hot" in to_save: content.sidebar_view += ub.SIDEBAR_HOT if "show_best_rated" in to_save: content.sidebar_view += ub.SIDEBAR_BEST_RATED if "show_author" in to_save: content.sidebar_view += ub.SIDEBAR_AUTHOR if "show_publisher" in to_save: content.sidebar_view += ub.SIDEBAR_PUBLISHER if "show_read_and_unread" in to_save: content.sidebar_view += ub.SIDEBAR_READ_AND_UNREAD if "show_detail_random" in to_save: content.sidebar_view += ub.DETAIL_RANDOM content.mature_content = "show_mature_content" in to_save try: ub.session.commit() except IntegrityError: ub.session.rollback() flash( _("Found an existing account for this e-mail address."), category="error", ) return render_title_template( "user_edit.html", content=content, downloads=downloads, title=_("%(name)s's profile", name=current_user.nickname), ) flash(_("Profile updated"), category="success") return render_title_template( "user_edit.html", translations=translations, profile=1, languages=languages, content=content, downloads=downloads, title=_("%(name)s's profile", name=current_user.nickname), page="me", )
def profile(): content = ( ub.session.query(ub.User).filter(ub.User.id == int(current_user.id)).first() ) downloads = list() languages = speaking_language() translations = babel.list_translations() + [LC("en")] for book in content.downloads: downloadBook = ( db.session.query(db.Books).filter(db.Books.id == book.book_id).first() ) if downloadBook: downloads.append( db.session.query(db.Books).filter(db.Books.id == book.book_id).first() ) else: ub.delete_download(book.book_id) # ub.session.query(ub.Downloads).filter(book.book_id == ub.Downloads.book_id).delete() # ub.session.commit() if request.method == "POST": to_save = request.form.to_dict() content.random_books = 0 if current_user.role_passwd() or current_user.role_admin(): if "password" in to_save and to_save["password"]: content.password = generate_password_hash(to_save["password"]) if "kindle_mail" in to_save and to_save["kindle_mail"] != content.kindle_mail: content.kindle_mail = to_save["kindle_mail"] if to_save["email"] and to_save["email"] != content.email: if config.config_public_reg and not check_valid_domain(to_save["email"]): flash(_("E-mail is not from valid domain"), category="error") return render_title_template( "user_edit.html", content=content, downloads=downloads, title=_("%(name)s's profile", name=current_user.nickname), ) content.email = to_save["email"] if "show_random" in to_save and to_save["show_random"] == "on": content.random_books = 1 if "default_language" in to_save: content.default_language = to_save["default_language"] if "locale" in to_save: content.locale = to_save["locale"] content.sidebar_view = 0 if "show_random" in to_save: content.sidebar_view += ub.SIDEBAR_RANDOM if "show_language" in to_save: content.sidebar_view += ub.SIDEBAR_LANGUAGE if "show_series" in to_save: content.sidebar_view += ub.SIDEBAR_SERIES if "show_category" in to_save: content.sidebar_view += ub.SIDEBAR_CATEGORY if "show_recent" in to_save: content.sidebar_view += ub.SIDEBAR_RECENT if "show_sorted" in to_save: content.sidebar_view += ub.SIDEBAR_SORTED if "show_hot" in to_save: content.sidebar_view += ub.SIDEBAR_HOT if "show_best_rated" in to_save: content.sidebar_view += ub.SIDEBAR_BEST_RATED if "show_author" in to_save: content.sidebar_view += ub.SIDEBAR_AUTHOR if "show_publisher" in to_save: content.sidebar_view += ub.SIDEBAR_PUBLISHER if "show_read_and_unread" in to_save: content.sidebar_view += ub.SIDEBAR_READ_AND_UNREAD if "show_detail_random" in to_save: content.sidebar_view += ub.DETAIL_RANDOM content.mature_content = "show_mature_content" in to_save content.theme = int(to_save["theme"]) try: ub.session.commit() except IntegrityError: ub.session.rollback() flash( _("Found an existing account for this e-mail address."), category="error", ) return render_title_template( "user_edit.html", content=content, downloads=downloads, title=_("%(name)s's profile", name=current_user.nickname), ) flash(_("Profile updated"), category="success") return render_title_template( "user_edit.html", translations=translations, profile=1, languages=languages, content=content, downloads=downloads, title=_("%(name)s's profile", name=current_user.nickname), page="me", )
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def admin(): version = updater_thread.get_current_version_info() if version is False: commit = _("Unknown") else: if "datetime" in version: commit = version["datetime"] tz = datetime.timedelta( seconds=time.timezone if (time.localtime().tm_isdst == 0) else time.altzone ) form_date = datetime.datetime.strptime(commit[:19], "%Y-%m-%dT%H:%M:%S") if len(commit) > 19: # check if string has timezone if commit[19] == "+": form_date -= datetime.timedelta( hours=int(commit[20:22]), minutes=int(commit[23:]) ) elif commit[19] == "-": form_date += datetime.timedelta( hours=int(commit[20:22]), minutes=int(commit[23:]) ) commit = format_datetime( form_date - tz, format="short", locale=get_locale() ) else: commit = version["version"] content = ub.session.query(ub.User).all() settings = ub.session.query(ub.Settings).first() return render_title_template( "admin.html", content=content, email=settings, config=config, commit=commit, title=_("Admin page"), page="admin", )
def admin(): version = helper.get_current_version_info() if version is False: commit = _("Unknown") else: commit = version["datetime"] tz = datetime.timedelta( seconds=time.timezone if (time.localtime().tm_isdst == 0) else time.altzone ) form_date = datetime.datetime.strptime(commit[:19], "%Y-%m-%dT%H:%M:%S") if len(commit) > 19: # check if string has timezone if commit[19] == "+": form_date -= datetime.timedelta( hours=int(commit[20:22]), minutes=int(commit[23:]) ) elif commit[19] == "-": form_date += datetime.timedelta( hours=int(commit[20:22]), minutes=int(commit[23:]) ) commit = format_datetime(form_date - tz, format="short", locale=get_locale()) content = ub.session.query(ub.User).all() settings = ub.session.query(ub.Settings).first() return render_title_template( "admin.html", content=content, email=settings, config=config, commit=commit, title=_("Admin page"), page="admin", )
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def view_configuration(): reboot_required = False if request.method == "POST": to_save = request.form.to_dict() content = ub.session.query(ub.Settings).first() if "config_calibre_web_title" in to_save: content.config_calibre_web_title = to_save["config_calibre_web_title"] if "config_columns_to_ignore" in to_save: content.config_columns_to_ignore = to_save["config_columns_to_ignore"] if "config_read_column" in to_save: content.config_read_column = int(to_save["config_read_column"]) if "config_theme" in to_save: content.config_theme = int(to_save["config_theme"]) if "config_title_regex" in to_save: if content.config_title_regex != to_save["config_title_regex"]: content.config_title_regex = to_save["config_title_regex"] reboot_required = True if "config_random_books" in to_save: content.config_random_books = int(to_save["config_random_books"]) if "config_books_per_page" in to_save: content.config_books_per_page = int(to_save["config_books_per_page"]) # maximum authors to show before we display a 'show more' link if "config_authors_max" in to_save: content.config_authors_max = int(to_save["config_authors_max"]) # Mature Content configuration if "config_mature_content_tags" in to_save: content.config_mature_content_tags = to_save[ "config_mature_content_tags" ].strip() # Default user configuration content.config_default_role = 0 if "admin_role" in to_save: content.config_default_role = content.config_default_role + ub.ROLE_ADMIN if "download_role" in to_save: content.config_default_role = content.config_default_role + ub.ROLE_DOWNLOAD if "upload_role" in to_save: content.config_default_role = content.config_default_role + ub.ROLE_UPLOAD if "edit_role" in to_save: content.config_default_role = content.config_default_role + ub.ROLE_EDIT if "delete_role" in to_save: content.config_default_role = ( content.config_default_role + ub.ROLE_DELETE_BOOKS ) if "passwd_role" in to_save: content.config_default_role = content.config_default_role + ub.ROLE_PASSWD if "edit_shelf_role" in to_save: content.config_default_role = ( content.config_default_role + ub.ROLE_EDIT_SHELFS ) content.config_default_show = 0 if "show_detail_random" in to_save: content.config_default_show = content.config_default_show + ub.DETAIL_RANDOM if "show_language" in to_save: content.config_default_show = ( content.config_default_show + ub.SIDEBAR_LANGUAGE ) if "show_series" in to_save: content.config_default_show = ( content.config_default_show + ub.SIDEBAR_SERIES ) if "show_category" in to_save: content.config_default_show = ( content.config_default_show + ub.SIDEBAR_CATEGORY ) if "show_hot" in to_save: content.config_default_show = content.config_default_show + ub.SIDEBAR_HOT if "show_random" in to_save: content.config_default_show = ( content.config_default_show + ub.SIDEBAR_RANDOM ) if "show_author" in to_save: content.config_default_show = ( content.config_default_show + ub.SIDEBAR_AUTHOR ) if "show_publisher" in to_save: content.config_default_show = ( content.config_default_show + ub.SIDEBAR_PUBLISHER ) if "show_best_rated" in to_save: content.config_default_show = ( content.config_default_show + ub.SIDEBAR_BEST_RATED ) if "show_read_and_unread" in to_save: content.config_default_show = ( content.config_default_show + ub.SIDEBAR_READ_AND_UNREAD ) if "show_recent" in to_save: content.config_default_show = ( content.config_default_show + ub.SIDEBAR_RECENT ) if "show_sorted" in to_save: content.config_default_show = ( content.config_default_show + ub.SIDEBAR_SORTED ) if "show_mature_content" in to_save: content.config_default_show = ( content.config_default_show + ub.MATURE_CONTENT ) ub.session.commit() flash(_("Calibre-Web configuration updated"), category="success") config.loadSettings() before_request() if reboot_required: # db.engine.dispose() # ToDo verify correct # ub.session.close() # ub.engine.dispose() # stop Server server.Server.setRestartTyp(True) server.Server.stopServer() app.logger.info("Reboot required, restarting") readColumn = ( db.session.query(db.Custom_Columns) .filter( db.and_( db.Custom_Columns.datatype == "bool", db.Custom_Columns.mark_for_delete == 0, ) ) .all() ) return render_title_template( "config_view_edit.html", content=config, readColumns=readColumn, title=_("UI Configuration"), page="uiconfig", )
def view_configuration(): reboot_required = False if request.method == "POST": to_save = request.form.to_dict() content = ub.session.query(ub.Settings).first() if "config_calibre_web_title" in to_save: content.config_calibre_web_title = to_save["config_calibre_web_title"] if "config_columns_to_ignore" in to_save: content.config_columns_to_ignore = to_save["config_columns_to_ignore"] if "config_read_column" in to_save: content.config_read_column = int(to_save["config_read_column"]) if "config_title_regex" in to_save: if content.config_title_regex != to_save["config_title_regex"]: content.config_title_regex = to_save["config_title_regex"] reboot_required = True if "config_random_books" in to_save: content.config_random_books = int(to_save["config_random_books"]) if "config_books_per_page" in to_save: content.config_books_per_page = int(to_save["config_books_per_page"]) # Mature Content configuration if "config_mature_content_tags" in to_save: content.config_mature_content_tags = to_save[ "config_mature_content_tags" ].strip() # Default user configuration content.config_default_role = 0 if "admin_role" in to_save: content.config_default_role = content.config_default_role + ub.ROLE_ADMIN if "download_role" in to_save: content.config_default_role = content.config_default_role + ub.ROLE_DOWNLOAD if "upload_role" in to_save: content.config_default_role = content.config_default_role + ub.ROLE_UPLOAD if "edit_role" in to_save: content.config_default_role = content.config_default_role + ub.ROLE_EDIT if "delete_role" in to_save: content.config_default_role = ( content.config_default_role + ub.ROLE_DELETE_BOOKS ) if "passwd_role" in to_save: content.config_default_role = content.config_default_role + ub.ROLE_PASSWD if "passwd_role" in to_save: content.config_default_role = ( content.config_default_role + ub.ROLE_EDIT_SHELFS ) content.config_default_show = 0 if "show_detail_random" in to_save: content.config_default_show = content.config_default_show + ub.DETAIL_RANDOM if "show_language" in to_save: content.config_default_show = ( content.config_default_show + ub.SIDEBAR_LANGUAGE ) if "show_series" in to_save: content.config_default_show = ( content.config_default_show + ub.SIDEBAR_SERIES ) if "show_category" in to_save: content.config_default_show = ( content.config_default_show + ub.SIDEBAR_CATEGORY ) if "show_hot" in to_save: content.config_default_show = content.config_default_show + ub.SIDEBAR_HOT if "show_random" in to_save: content.config_default_show = ( content.config_default_show + ub.SIDEBAR_RANDOM ) if "show_author" in to_save: content.config_default_show = ( content.config_default_show + ub.SIDEBAR_AUTHOR ) if "show_publisher" in to_save: content.config_default_show = ( content.config_default_show + ub.SIDEBAR_PUBLISHER ) if "show_best_rated" in to_save: content.config_default_show = ( content.config_default_show + ub.SIDEBAR_BEST_RATED ) if "show_read_and_unread" in to_save: content.config_default_show = ( content.config_default_show + ub.SIDEBAR_READ_AND_UNREAD ) if "show_recent" in to_save: content.config_default_show = ( content.config_default_show + ub.SIDEBAR_RECENT ) if "show_sorted" in to_save: content.config_default_show = ( content.config_default_show + ub.SIDEBAR_SORTED ) if "show_mature_content" in to_save: content.config_default_show = ( content.config_default_show + ub.MATURE_CONTENT ) ub.session.commit() flash(_("Calibre-Web configuration updated"), category="success") config.loadSettings() if reboot_required: # db.engine.dispose() # ToDo verify correct # ub.session.close() # ub.engine.dispose() # stop Server server.Server.setRestartTyp(True) server.Server.stopServer() app.logger.info("Reboot required, restarting") readColumn = ( db.session.query(db.Custom_Columns) .filter( db.and_( db.Custom_Columns.datatype == "bool", db.Custom_Columns.mark_for_delete == 0, ) ) .all() ) return render_title_template( "config_view_edit.html", content=config, readColumns=readColumn, title=_("UI Configuration"), page="uiconfig", )
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def configuration_helper(origin): reboot_required = False gdriveError = None db_change = False success = False filedata = None if gdriveutils.gdrive_support == False: gdriveError = _("Import of optional Google Drive requirements missing") else: if not os.path.isfile(os.path.join(config.get_main_dir, "client_secrets.json")): gdriveError = _("client_secrets.json is missing or not readable") else: with open( os.path.join(config.get_main_dir, "client_secrets.json"), "r" ) as settings: filedata = json.load(settings) if not "web" in filedata: gdriveError = _( "client_secrets.json is not configured for web application" ) if request.method == "POST": to_save = request.form.to_dict() content = ub.session.query(ub.Settings).first() # type: ub.Settings if "config_calibre_dir" in to_save: if content.config_calibre_dir != to_save["config_calibre_dir"]: content.config_calibre_dir = to_save["config_calibre_dir"] db_change = True # Google drive setup if not os.path.isfile(os.path.join(config.get_main_dir, "settings.yaml")): content.config_use_google_drive = False if ( "config_use_google_drive" in to_save and not content.config_use_google_drive and not gdriveError ): if filedata: if filedata["web"]["redirect_uris"][0].endswith("/"): filedata["web"]["redirect_uris"][0] = filedata["web"][ "redirect_uris" ][0][:-1] with open(os.path.join(config.get_main_dir, "settings.yaml"), "w") as f: yaml = ( "client_config_backend: settings\nclient_config_file: %(client_file)s\n" "client_config:\n" " client_id: %(client_id)s\n client_secret: %(client_secret)s\n" " redirect_uri: %(redirect_uri)s\n\nsave_credentials: True\n" "save_credentials_backend: file\nsave_credentials_file: %(credential)s\n\n" "get_refresh_token: True\n\noauth_scope:\n" " - https://www.googleapis.com/auth/drive\n" ) f.write( yaml % { "client_file": os.path.join( config.get_main_dir, "client_secrets.json" ), "client_id": filedata["web"]["client_id"], "client_secret": filedata["web"]["client_secret"], "redirect_uri": filedata["web"]["redirect_uris"][0], "credential": os.path.join( config.get_main_dir, "gdrive_credentials" ), } ) else: flash( _("client_secrets.json is not configured for web application"), category="error", ) return render_title_template( "config_edit.html", content=config, origin=origin, gdrive=gdriveutils.gdrive_support, gdriveError=gdriveError, goodreads=goodreads_support, title=_("Basic Configuration"), page="config", ) # always show google drive settings, but in case of error deny support if "config_use_google_drive" in to_save and not gdriveError: content.config_use_google_drive = "config_use_google_drive" in to_save else: content.config_use_google_drive = 0 if "config_google_drive_folder" in to_save: if ( content.config_google_drive_folder != to_save["config_google_drive_folder"] ): content.config_google_drive_folder = to_save[ "config_google_drive_folder" ] gdriveutils.deleteDatabaseOnChange() if "config_port" in to_save: if content.config_port != int(to_save["config_port"]): content.config_port = int(to_save["config_port"]) reboot_required = True if "config_keyfile" in to_save: if content.config_keyfile != to_save["config_keyfile"]: if ( os.path.isfile(to_save["config_keyfile"]) or to_save["config_keyfile"] is "" ): content.config_keyfile = to_save["config_keyfile"] reboot_required = True else: ub.session.commit() flash( _("Keyfile location is not valid, please enter correct path"), category="error", ) return render_title_template( "config_edit.html", content=config, origin=origin, gdrive=gdriveutils.gdrive_support, gdriveError=gdriveError, goodreads=goodreads_support, title=_("Basic Configuration"), page="config", ) if "config_certfile" in to_save: if content.config_certfile != to_save["config_certfile"]: if ( os.path.isfile(to_save["config_certfile"]) or to_save["config_certfile"] is "" ): content.config_certfile = to_save["config_certfile"] reboot_required = True else: ub.session.commit() flash( _("Certfile location is not valid, please enter correct path"), category="error", ) return render_title_template( "config_edit.html", content=config, origin=origin, gdrive=gdriveutils.gdrive_support, gdriveError=gdriveError, goodreads=goodreads_support, title=_("Basic Configuration"), page="config", ) content.config_uploading = 0 content.config_anonbrowse = 0 content.config_public_reg = 0 if "config_uploading" in to_save and to_save["config_uploading"] == "on": content.config_uploading = 1 if "config_anonbrowse" in to_save and to_save["config_anonbrowse"] == "on": content.config_anonbrowse = 1 if "config_public_reg" in to_save and to_save["config_public_reg"] == "on": content.config_public_reg = 1 if "config_converterpath" in to_save: content.config_converterpath = to_save["config_converterpath"].strip() if "config_calibre" in to_save: content.config_calibre = to_save["config_calibre"].strip() if "config_ebookconverter" in to_save: content.config_ebookconverter = int(to_save["config_ebookconverter"]) # Remote login configuration content.config_remote_login = ( "config_remote_login" in to_save and to_save["config_remote_login"] == "on" ) if not content.config_remote_login: ub.session.query(ub.RemoteAuthToken).delete() # Goodreads configuration content.config_use_goodreads = ( "config_use_goodreads" in to_save and to_save["config_use_goodreads"] == "on" ) if "config_goodreads_api_key" in to_save: content.config_goodreads_api_key = to_save["config_goodreads_api_key"] if "config_goodreads_api_secret" in to_save: content.config_goodreads_api_secret = to_save["config_goodreads_api_secret"] if "config_updater" in to_save: content.config_updatechannel = int(to_save["config_updater"]) if "config_log_level" in to_save: content.config_log_level = int(to_save["config_log_level"]) if content.config_logfile != to_save["config_logfile"]: # check valid path, only path or file if os.path.dirname(to_save["config_logfile"]): if ( os.path.exists(os.path.dirname(to_save["config_logfile"])) and os.path.basename(to_save["config_logfile"]) and not os.path.isdir(to_save["config_logfile"]) ): content.config_logfile = to_save["config_logfile"] else: ub.session.commit() flash( _("Logfile location is not valid, please enter correct path"), category="error", ) return render_title_template( "config_edit.html", content=config, origin=origin, gdrive=gdriveutils.gdrive_support, gdriveError=gdriveError, goodreads=goodreads_support, title=_("Basic Configuration"), page="config", ) else: content.config_logfile = to_save["config_logfile"] reboot_required = True # Rarfile Content configuration if ( "config_rarfile_location" in to_save and to_save["config_rarfile_location"] is not "" ): check = helper.check_unrar(to_save["config_rarfile_location"].strip()) if not check[0]: content.config_rarfile_location = to_save[ "config_rarfile_location" ].strip() else: flash(check[1], category="error") return render_title_template( "config_edit.html", content=config, origin=origin, gdrive=gdriveutils.gdrive_support, goodreads=goodreads_support, rarfile_support=rar_support, title=_("Basic Configuration"), ) try: if ( content.config_use_google_drive and is_gdrive_ready() and not os.path.exists( os.path.join(content.config_calibre_dir, "metadata.db") ) ): gdriveutils.downloadFile( None, "metadata.db", config.config_calibre_dir + "/metadata.db" ) if db_change: if config.db_configured: db.session.close() db.engine.dispose() ub.session.commit() flash(_("Calibre-Web configuration updated"), category="success") config.loadSettings() app.logger.setLevel(config.config_log_level) logging.getLogger("book_formats").setLevel(config.config_log_level) except Exception as e: flash(e, category="error") return render_title_template( "config_edit.html", content=config, origin=origin, gdrive=gdriveutils.gdrive_support, gdriveError=gdriveError, goodreads=goodreads_support, rarfile_support=rar_support, title=_("Basic Configuration"), page="config", ) if db_change: reload(db) if not db.setup_db(): flash( _("DB location is not valid, please enter correct path"), category="error", ) return render_title_template( "config_edit.html", content=config, origin=origin, gdrive=gdriveutils.gdrive_support, gdriveError=gdriveError, goodreads=goodreads_support, rarfile_support=rar_support, title=_("Basic Configuration"), page="config", ) if reboot_required: # stop Server server.Server.setRestartTyp(True) server.Server.stopServer() app.logger.info("Reboot required, restarting") if origin: success = True if ( is_gdrive_ready() and gdriveutils.gdrive_support == True ): # and config.config_use_google_drive == True: gdrivefolders = gdriveutils.listRootFolders() else: gdrivefolders = list() return render_title_template( "config_edit.html", origin=origin, success=success, content=config, show_authenticate_google_drive=not is_gdrive_ready(), gdrive=gdriveutils.gdrive_support, gdriveError=gdriveError, gdrivefolders=gdrivefolders, rarfile_support=rar_support, goodreads=goodreads_support, title=_("Basic Configuration"), page="config", )
def configuration_helper(origin): reboot_required = False gdriveError = None db_change = False success = False filedata = None if gdriveutils.gdrive_support == False: gdriveError = _("Import of optional Google Drive requirements missing") else: if not os.path.isfile(os.path.join(config.get_main_dir, "client_secrets.json")): gdriveError = _("client_secrets.json is missing or not readable") else: with open( os.path.join(config.get_main_dir, "client_secrets.json"), "r" ) as settings: filedata = json.load(settings) if not "web" in filedata: gdriveError = _( "client_secrets.json is not configured for web application" ) if request.method == "POST": to_save = request.form.to_dict() content = ub.session.query(ub.Settings).first() # type: ub.Settings if "config_calibre_dir" in to_save: if content.config_calibre_dir != to_save["config_calibre_dir"]: content.config_calibre_dir = to_save["config_calibre_dir"] db_change = True # Google drive setup if ( "config_use_google_drive" in to_save and not content.config_use_google_drive and not gdriveError ): if filedata: if filedata["web"]["redirect_uris"][0].endswith("/"): filedata["web"]["redirect_uris"][0] = filedata["web"][ "redirect_uris" ][0][:-1] with open(os.path.join(config.get_main_dir, "settings.yaml"), "w") as f: yaml = ( "client_config_backend: settings\nclient_config_file: %(client_file)s\n" "client_config:\n" " client_id: %(client_id)s\n client_secret: %(client_secret)s\n" " redirect_uri: %(redirect_uri)s\n\nsave_credentials: True\n" "save_credentials_backend: file\nsave_credentials_file: %(credential)s\n\n" "get_refresh_token: True\n\noauth_scope:\n" " - https://www.googleapis.com/auth/drive\n" ) f.write( yaml % { "client_file": os.path.join( config.get_main_dir, "client_secrets.json" ), "client_id": filedata["web"]["client_id"], "client_secret": filedata["web"]["client_secret"], "redirect_uri": filedata["web"]["redirect_uris"][0], "credential": os.path.join( config.get_main_dir, "gdrive_credentials" ), } ) else: flash( _("client_secrets.json is not configured for web application"), category="error", ) return render_title_template( "config_edit.html", content=config, origin=origin, gdrive=gdriveutils.gdrive_support, gdriveError=gdriveError, goodreads=goodreads_support, title=_("Basic Configuration"), page="config", ) # always show google drive settings, but in case of error deny support if "config_use_google_drive" in to_save and not gdriveError: content.config_use_google_drive = "config_use_google_drive" in to_save else: content.config_use_google_drive = 0 if "config_google_drive_folder" in to_save: if ( content.config_google_drive_folder != to_save["config_google_drive_folder"] ): content.config_google_drive_folder = to_save[ "config_google_drive_folder" ] gdriveutils.deleteDatabaseOnChange() if "config_port" in to_save: if content.config_port != int(to_save["config_port"]): content.config_port = int(to_save["config_port"]) reboot_required = True if "config_keyfile" in to_save: if content.config_keyfile != to_save["config_keyfile"]: if ( os.path.isfile(to_save["config_keyfile"]) or to_save["config_keyfile"] is "" ): content.config_keyfile = to_save["config_keyfile"] reboot_required = True else: ub.session.commit() flash( _("Keyfile location is not valid, please enter correct path"), category="error", ) return render_title_template( "config_edit.html", content=config, origin=origin, gdrive=gdriveutils.gdrive_support, gdriveError=gdriveError, goodreads=goodreads_support, title=_("Basic Configuration"), page="config", ) if "config_certfile" in to_save: if content.config_certfile != to_save["config_certfile"]: if ( os.path.isfile(to_save["config_certfile"]) or to_save["config_certfile"] is "" ): content.config_certfile = to_save["config_certfile"] reboot_required = True else: ub.session.commit() flash( _("Certfile location is not valid, please enter correct path"), category="error", ) return render_title_template( "config_edit.html", content=config, origin=origin, gdrive=gdriveutils.gdrive_support, gdriveError=gdriveError, goodreads=goodreads_support, title=_("Basic Configuration"), page="config", ) content.config_uploading = 0 content.config_anonbrowse = 0 content.config_public_reg = 0 if "config_uploading" in to_save and to_save["config_uploading"] == "on": content.config_uploading = 1 if "config_anonbrowse" in to_save and to_save["config_anonbrowse"] == "on": content.config_anonbrowse = 1 if "config_public_reg" in to_save and to_save["config_public_reg"] == "on": content.config_public_reg = 1 if "config_converterpath" in to_save: content.config_converterpath = to_save["config_converterpath"].strip() if "config_calibre" in to_save: content.config_calibre = to_save["config_calibre"].strip() if "config_ebookconverter" in to_save: content.config_ebookconverter = int(to_save["config_ebookconverter"]) # Remote login configuration content.config_remote_login = ( "config_remote_login" in to_save and to_save["config_remote_login"] == "on" ) if not content.config_remote_login: ub.session.query(ub.RemoteAuthToken).delete() # Goodreads configuration content.config_use_goodreads = ( "config_use_goodreads" in to_save and to_save["config_use_goodreads"] == "on" ) if "config_goodreads_api_key" in to_save: content.config_goodreads_api_key = to_save["config_goodreads_api_key"] if "config_goodreads_api_secret" in to_save: content.config_goodreads_api_secret = to_save["config_goodreads_api_secret"] if "config_log_level" in to_save: content.config_log_level = int(to_save["config_log_level"]) if content.config_logfile != to_save["config_logfile"]: # check valid path, only path or file if os.path.dirname(to_save["config_logfile"]): if ( os.path.exists(os.path.dirname(to_save["config_logfile"])) and os.path.basename(to_save["config_logfile"]) and not os.path.isdir(to_save["config_logfile"]) ): content.config_logfile = to_save["config_logfile"] else: ub.session.commit() flash( _("Logfile location is not valid, please enter correct path"), category="error", ) return render_title_template( "config_edit.html", content=config, origin=origin, gdrive=gdriveutils.gdrive_support, gdriveError=gdriveError, goodreads=goodreads_support, title=_("Basic Configuration"), page="config", ) else: content.config_logfile = to_save["config_logfile"] reboot_required = True # Rarfile Content configuration if ( "config_rarfile_location" in to_save and to_save["config_rarfile_location"] is not "" ): check = helper.check_unrar(to_save["config_rarfile_location"].strip()) if not check[0]: content.config_rarfile_location = to_save[ "config_rarfile_location" ].strip() else: flash(check[1], category="error") return render_title_template( "config_edit.html", content=config, origin=origin, gdrive=gdriveutils.gdrive_support, goodreads=goodreads_support, rarfile_support=rar_support, title=_("Basic Configuration"), ) try: if ( content.config_use_google_drive and is_gdrive_ready() and not os.path.exists(config.config_calibre_dir + "/metadata.db") ): gdriveutils.downloadFile( None, "metadata.db", config.config_calibre_dir + "/metadata.db" ) if db_change: if config.db_configured: db.session.close() db.engine.dispose() ub.session.commit() flash(_("Calibre-Web configuration updated"), category="success") config.loadSettings() app.logger.setLevel(config.config_log_level) logging.getLogger("book_formats").setLevel(config.config_log_level) except Exception as e: flash(e, category="error") return render_title_template( "config_edit.html", content=config, origin=origin, gdrive=gdriveutils.gdrive_support, gdriveError=gdriveError, goodreads=goodreads_support, rarfile_support=rar_support, title=_("Basic Configuration"), page="config", ) if db_change: reload(db) if not db.setup_db(): flash( _("DB location is not valid, please enter correct path"), category="error", ) return render_title_template( "config_edit.html", content=config, origin=origin, gdrive=gdriveutils.gdrive_support, gdriveError=gdriveError, goodreads=goodreads_support, rarfile_support=rar_support, title=_("Basic Configuration"), page="config", ) if reboot_required: # stop Server server.Server.setRestartTyp(True) server.Server.stopServer() app.logger.info("Reboot required, restarting") if origin: success = True if ( is_gdrive_ready() and gdriveutils.gdrive_support == True and config.config_use_google_drive == True ): gdrivefolders = gdriveutils.listRootFolders() else: gdrivefolders = list() return render_title_template( "config_edit.html", origin=origin, success=success, content=config, show_authenticate_google_drive=not is_gdrive_ready(), gdrive=gdriveutils.gdrive_support, gdriveError=gdriveError, gdrivefolders=gdrivefolders, rarfile_support=rar_support, goodreads=goodreads_support, title=_("Basic Configuration"), page="config", )
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def new_user(): content = ub.User() languages = speaking_language() translations = [LC("en")] + babel.list_translations() if request.method == "POST": to_save = request.form.to_dict() content.default_language = to_save["default_language"] content.mature_content = "show_mature_content" in to_save if "locale" in to_save: content.locale = to_save["locale"] content.sidebar_view = 0 if "show_random" in to_save: content.sidebar_view += ub.SIDEBAR_RANDOM if "show_language" in to_save: content.sidebar_view += ub.SIDEBAR_LANGUAGE if "show_series" in to_save: content.sidebar_view += ub.SIDEBAR_SERIES if "show_category" in to_save: content.sidebar_view += ub.SIDEBAR_CATEGORY if "show_hot" in to_save: content.sidebar_view += ub.SIDEBAR_HOT if "show_read_and_unread" in to_save: content.sidebar_view += ub.SIDEBAR_READ_AND_UNREAD if "show_best_rated" in to_save: content.sidebar_view += ub.SIDEBAR_BEST_RATED if "show_author" in to_save: content.sidebar_view += ub.SIDEBAR_AUTHOR if "show_publisher" in to_save: content.sidebar_view += ub.SIDEBAR_PUBLISHER if "show_detail_random" in to_save: content.sidebar_view += ub.DETAIL_RANDOM if "show_sorted" in to_save: content.sidebar_view += ub.SIDEBAR_SORTED if "show_recent" in to_save: content.sidebar_view += ub.SIDEBAR_RECENT content.role = 0 if "admin_role" in to_save: content.role = content.role + ub.ROLE_ADMIN if "download_role" in to_save: content.role = content.role + ub.ROLE_DOWNLOAD if "upload_role" in to_save: content.role = content.role + ub.ROLE_UPLOAD if "edit_role" in to_save: content.role = content.role + ub.ROLE_EDIT if "delete_role" in to_save: content.role = content.role + ub.ROLE_DELETE_BOOKS if "passwd_role" in to_save: content.role = content.role + ub.ROLE_PASSWD if "edit_shelf_role" in to_save: content.role = content.role + ub.ROLE_EDIT_SHELFS if not to_save["nickname"] or not to_save["email"] or not to_save["password"]: flash(_("Please fill out all fields!"), category="error") return render_title_template( "user_edit.html", new_user=1, content=content, translations=translations, title=_("Add new user"), ) content.password = generate_password_hash(to_save["password"]) content.nickname = to_save["nickname"] if config.config_public_reg and not check_valid_domain(to_save["email"]): flash(_("E-mail is not from valid domain"), category="error") return render_title_template( "user_edit.html", new_user=1, content=content, translations=translations, title=_("Add new user"), ) else: content.email = to_save["email"] try: ub.session.add(content) ub.session.commit() flash( _("User '%(user)s' created", user=content.nickname), category="success" ) return redirect(url_for("admin")) except IntegrityError: ub.session.rollback() flash( _("Found an existing account for this e-mail address or nickname."), category="error", ) else: content.role = config.config_default_role content.sidebar_view = config.config_default_show content.mature_content = bool(config.config_default_show & ub.MATURE_CONTENT) return render_title_template( "user_edit.html", new_user=1, content=content, translations=translations, languages=languages, title=_("Add new user"), page="newuser", )
def new_user(): content = ub.User() languages = speaking_language() translations = [LC("en")] + babel.list_translations() if request.method == "POST": to_save = request.form.to_dict() content.default_language = to_save["default_language"] content.mature_content = "show_mature_content" in to_save content.theme = int(to_save["theme"]) if "locale" in to_save: content.locale = to_save["locale"] content.sidebar_view = 0 if "show_random" in to_save: content.sidebar_view += ub.SIDEBAR_RANDOM if "show_language" in to_save: content.sidebar_view += ub.SIDEBAR_LANGUAGE if "show_series" in to_save: content.sidebar_view += ub.SIDEBAR_SERIES if "show_category" in to_save: content.sidebar_view += ub.SIDEBAR_CATEGORY if "show_hot" in to_save: content.sidebar_view += ub.SIDEBAR_HOT if "show_read_and_unread" in to_save: content.sidebar_view += ub.SIDEBAR_READ_AND_UNREAD if "show_best_rated" in to_save: content.sidebar_view += ub.SIDEBAR_BEST_RATED if "show_author" in to_save: content.sidebar_view += ub.SIDEBAR_AUTHOR if "show_publisher" in to_save: content.sidebar_view += ub.SIDEBAR_PUBLISHER if "show_detail_random" in to_save: content.sidebar_view += ub.DETAIL_RANDOM if "show_sorted" in to_save: content.sidebar_view += ub.SIDEBAR_SORTED if "show_recent" in to_save: content.sidebar_view += ub.SIDEBAR_RECENT content.role = 0 if "admin_role" in to_save: content.role = content.role + ub.ROLE_ADMIN if "download_role" in to_save: content.role = content.role + ub.ROLE_DOWNLOAD if "upload_role" in to_save: content.role = content.role + ub.ROLE_UPLOAD if "edit_role" in to_save: content.role = content.role + ub.ROLE_DELETE_BOOKS if "delete_role" in to_save: content.role = content.role + ub.ROLE_EDIT if "passwd_role" in to_save: content.role = content.role + ub.ROLE_PASSWD if "edit_shelf_role" in to_save: content.role = content.role + ub.ROLE_EDIT_SHELFS if not to_save["nickname"] or not to_save["email"] or not to_save["password"]: flash(_("Please fill out all fields!"), category="error") return render_title_template( "user_edit.html", new_user=1, content=content, translations=translations, title=_("Add new user"), ) content.password = generate_password_hash(to_save["password"]) content.nickname = to_save["nickname"] if config.config_public_reg and not check_valid_domain(to_save["email"]): flash(_("E-mail is not from valid domain"), category="error") return render_title_template( "user_edit.html", new_user=1, content=content, translations=translations, title=_("Add new user"), ) else: content.email = to_save["email"] try: ub.session.add(content) ub.session.commit() flash( _("User '%(user)s' created", user=content.nickname), category="success" ) return redirect(url_for("admin")) except IntegrityError: ub.session.rollback() flash( _("Found an existing account for this e-mail address or nickname."), category="error", ) else: content.role = config.config_default_role content.sidebar_view = config.config_default_show content.mature_content = bool(config.config_default_show & ub.MATURE_CONTENT) return render_title_template( "user_edit.html", new_user=1, content=content, translations=translations, languages=languages, title=_("Add new user"), page="newuser", )
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def edit_mailsettings(): content = ub.session.query(ub.Settings).first() if request.method == "POST": to_save = request.form.to_dict() content.mail_server = to_save["mail_server"] content.mail_port = int(to_save["mail_port"]) content.mail_login = to_save["mail_login"] content.mail_password = to_save["mail_password"] content.mail_from = to_save["mail_from"] content.mail_use_ssl = int(to_save["mail_use_ssl"]) try: ub.session.commit() except Exception as e: flash(e, category="error") if "test" in to_save and to_save["test"]: if current_user.kindle_mail: result = helper.send_test_mail( current_user.kindle_mail, current_user.nickname ) if result is None: flash( _( "Test e-mail successfully send to %(kindlemail)s", kindlemail=current_user.kindle_mail, ), category="success", ) else: flash( _( "There was an error sending the Test e-mail: %(res)s", res=result, ), category="error", ) else: flash( _("Please configure your kindle e-mail address first..."), category="error", ) else: flash(_("E-mail server settings updated"), category="success") return render_title_template( "email_edit.html", content=content, title=_("Edit e-mail server settings"), page="mailset", )
def edit_mailsettings(): content = ub.session.query(ub.Settings).first() if request.method == "POST": to_save = request.form.to_dict() content.mail_server = to_save["mail_server"] content.mail_port = int(to_save["mail_port"]) content.mail_login = to_save["mail_login"] content.mail_password = to_save["mail_password"] content.mail_from = to_save["mail_from"] content.mail_use_ssl = int(to_save["mail_use_ssl"]) try: ub.session.commit() flash(_("E-mail server settings updated"), category="success") except Exception as e: flash(e, category="error") if "test" in to_save and to_save["test"]: if current_user.kindle_mail: result = helper.send_test_mail( current_user.kindle_mail, current_user.nickname ) if result is None: flash( _( "Test e-mail successfully send to %(kindlemail)s", kindlemail=current_user.kindle_mail, ), category="success", ) else: flash( _( "There was an error sending the Test e-mail: %(res)s", res=result, ), category="error", ) else: flash( _("Please configure your kindle e-mail address first..."), category="error", ) else: flash(_("E-mail server settings updated"), category="success") return render_title_template( "email_edit.html", content=content, title=_("Edit e-mail server settings"), page="mailset", )
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def edit_user(user_id): content = ub.session.query(ub.User).filter(ub.User.id == int(user_id)).first() # type: ub.User downloads = list() languages = speaking_language() translations = babel.list_translations() + [LC("en")] for book in content.downloads: downloadbook = ( db.session.query(db.Books).filter(db.Books.id == book.book_id).first() ) if downloadbook: downloads.append(downloadbook) else: ub.delete_download(book.book_id) # ub.session.query(ub.Downloads).filter(book.book_id == ub.Downloads.book_id).delete() # ub.session.commit() if request.method == "POST": to_save = request.form.to_dict() if "delete" in to_save: ub.session.query(ub.User).filter(ub.User.id == content.id).delete() ub.session.commit() flash( _("User '%(nick)s' deleted", nick=content.nickname), category="success" ) return redirect(url_for("admin")) else: if "password" in to_save and to_save["password"]: content.password = generate_password_hash(to_save["password"]) if "admin_role" in to_save and not content.role_admin(): content.role = content.role + ub.ROLE_ADMIN elif "admin_role" not in to_save and content.role_admin(): content.role = content.role - ub.ROLE_ADMIN if "download_role" in to_save and not content.role_download(): content.role = content.role + ub.ROLE_DOWNLOAD elif "download_role" not in to_save and content.role_download(): content.role = content.role - ub.ROLE_DOWNLOAD if "upload_role" in to_save and not content.role_upload(): content.role = content.role + ub.ROLE_UPLOAD elif "upload_role" not in to_save and content.role_upload(): content.role = content.role - ub.ROLE_UPLOAD if "edit_role" in to_save and not content.role_edit(): content.role = content.role + ub.ROLE_EDIT elif "edit_role" not in to_save and content.role_edit(): content.role = content.role - ub.ROLE_EDIT if "delete_role" in to_save and not content.role_delete_books(): content.role = content.role + ub.ROLE_DELETE_BOOKS elif "delete_role" not in to_save and content.role_delete_books(): content.role = content.role - ub.ROLE_DELETE_BOOKS if "passwd_role" in to_save and not content.role_passwd(): content.role = content.role + ub.ROLE_PASSWD elif "passwd_role" not in to_save and content.role_passwd(): content.role = content.role - ub.ROLE_PASSWD if "edit_shelf_role" in to_save and not content.role_edit_shelfs(): content.role = content.role + ub.ROLE_EDIT_SHELFS elif "edit_shelf_role" not in to_save and content.role_edit_shelfs(): content.role = content.role - ub.ROLE_EDIT_SHELFS if "show_random" in to_save and not content.show_random_books(): content.sidebar_view += ub.SIDEBAR_RANDOM elif "show_random" not in to_save and content.show_random_books(): content.sidebar_view -= ub.SIDEBAR_RANDOM if "show_language" in to_save and not content.show_language(): content.sidebar_view += ub.SIDEBAR_LANGUAGE elif "show_language" not in to_save and content.show_language(): content.sidebar_view -= ub.SIDEBAR_LANGUAGE if "show_series" in to_save and not content.show_series(): content.sidebar_view += ub.SIDEBAR_SERIES elif "show_series" not in to_save and content.show_series(): content.sidebar_view -= ub.SIDEBAR_SERIES if "show_category" in to_save and not content.show_category(): content.sidebar_view += ub.SIDEBAR_CATEGORY elif "show_category" not in to_save and content.show_category(): content.sidebar_view -= ub.SIDEBAR_CATEGORY if "show_recent" in to_save and not content.show_recent(): content.sidebar_view += ub.SIDEBAR_RECENT elif "show_recent" not in to_save and content.show_recent(): content.sidebar_view -= ub.SIDEBAR_RECENT if "show_sorted" in to_save and not content.show_sorted(): content.sidebar_view += ub.SIDEBAR_SORTED elif "show_sorted" not in to_save and content.show_sorted(): content.sidebar_view -= ub.SIDEBAR_SORTED if "show_publisher" in to_save and not content.show_publisher(): content.sidebar_view += ub.SIDEBAR_PUBLISHER elif "show_publisher" not in to_save and content.show_publisher(): content.sidebar_view -= ub.SIDEBAR_PUBLISHER if "show_hot" in to_save and not content.show_hot_books(): content.sidebar_view += ub.SIDEBAR_HOT elif "show_hot" not in to_save and content.show_hot_books(): content.sidebar_view -= ub.SIDEBAR_HOT if "show_best_rated" in to_save and not content.show_best_rated_books(): content.sidebar_view += ub.SIDEBAR_BEST_RATED elif "show_best_rated" not in to_save and content.show_best_rated_books(): content.sidebar_view -= ub.SIDEBAR_BEST_RATED if "show_read_and_unread" in to_save and not content.show_read_and_unread(): content.sidebar_view += ub.SIDEBAR_READ_AND_UNREAD elif ( "show_read_and_unread" not in to_save and content.show_read_and_unread() ): content.sidebar_view -= ub.SIDEBAR_READ_AND_UNREAD if "show_author" in to_save and not content.show_author(): content.sidebar_view += ub.SIDEBAR_AUTHOR elif "show_author" not in to_save and content.show_author(): content.sidebar_view -= ub.SIDEBAR_AUTHOR if "show_detail_random" in to_save and not content.show_detail_random(): content.sidebar_view += ub.DETAIL_RANDOM elif "show_detail_random" not in to_save and content.show_detail_random(): content.sidebar_view -= ub.DETAIL_RANDOM content.mature_content = "show_mature_content" in to_save if "default_language" in to_save: content.default_language = to_save["default_language"] if "locale" in to_save and to_save["locale"]: content.locale = to_save["locale"] if to_save["email"] and to_save["email"] != content.email: content.email = to_save["email"] if ( "kindle_mail" in to_save and to_save["kindle_mail"] != content.kindle_mail ): content.kindle_mail = to_save["kindle_mail"] try: ub.session.commit() flash( _("User '%(nick)s' updated", nick=content.nickname), category="success" ) except IntegrityError: ub.session.rollback() flash(_("An unknown error occured."), category="error") return render_title_template( "user_edit.html", translations=translations, languages=languages, new_user=0, content=content, downloads=downloads, title=_("Edit User %(nick)s", nick=content.nickname), page="edituser", )
def edit_user(user_id): content = ub.session.query(ub.User).filter(ub.User.id == int(user_id)).first() # type: ub.User downloads = list() languages = speaking_language() translations = babel.list_translations() + [LC("en")] for book in content.downloads: downloadbook = ( db.session.query(db.Books).filter(db.Books.id == book.book_id).first() ) if downloadbook: downloads.append(downloadbook) else: ub.delete_download(book.book_id) # ub.session.query(ub.Downloads).filter(book.book_id == ub.Downloads.book_id).delete() # ub.session.commit() if request.method == "POST": to_save = request.form.to_dict() if "delete" in to_save: ub.session.query(ub.User).filter(ub.User.id == content.id).delete() ub.session.commit() flash( _("User '%(nick)s' deleted", nick=content.nickname), category="success" ) return redirect(url_for("admin")) else: if "password" in to_save and to_save["password"]: content.password = generate_password_hash(to_save["password"]) if "admin_role" in to_save and not content.role_admin(): content.role = content.role + ub.ROLE_ADMIN elif "admin_role" not in to_save and content.role_admin(): content.role = content.role - ub.ROLE_ADMIN if "download_role" in to_save and not content.role_download(): content.role = content.role + ub.ROLE_DOWNLOAD elif "download_role" not in to_save and content.role_download(): content.role = content.role - ub.ROLE_DOWNLOAD if "upload_role" in to_save and not content.role_upload(): content.role = content.role + ub.ROLE_UPLOAD elif "upload_role" not in to_save and content.role_upload(): content.role = content.role - ub.ROLE_UPLOAD if "edit_role" in to_save and not content.role_edit(): content.role = content.role + ub.ROLE_EDIT elif "edit_role" not in to_save and content.role_edit(): content.role = content.role - ub.ROLE_EDIT if "delete_role" in to_save and not content.role_delete_books(): content.role = content.role + ub.ROLE_DELETE_BOOKS elif "delete_role" not in to_save and content.role_delete_books(): content.role = content.role - ub.ROLE_DELETE_BOOKS if "passwd_role" in to_save and not content.role_passwd(): content.role = content.role + ub.ROLE_PASSWD elif "passwd_role" not in to_save and content.role_passwd(): content.role = content.role - ub.ROLE_PASSWD if "edit_shelf_role" in to_save and not content.role_edit_shelfs(): content.role = content.role + ub.ROLE_EDIT_SHELFS elif "edit_shelf_role" not in to_save and content.role_edit_shelfs(): content.role = content.role - ub.ROLE_EDIT_SHELFS if "show_random" in to_save and not content.show_random_books(): content.sidebar_view += ub.SIDEBAR_RANDOM elif "show_random" not in to_save and content.show_random_books(): content.sidebar_view -= ub.SIDEBAR_RANDOM if "show_language" in to_save and not content.show_language(): content.sidebar_view += ub.SIDEBAR_LANGUAGE elif "show_language" not in to_save and content.show_language(): content.sidebar_view -= ub.SIDEBAR_LANGUAGE if "show_series" in to_save and not content.show_series(): content.sidebar_view += ub.SIDEBAR_SERIES elif "show_series" not in to_save and content.show_series(): content.sidebar_view -= ub.SIDEBAR_SERIES if "show_category" in to_save and not content.show_category(): content.sidebar_view += ub.SIDEBAR_CATEGORY elif "show_category" not in to_save and content.show_category(): content.sidebar_view -= ub.SIDEBAR_CATEGORY if "show_recent" in to_save and not content.show_recent(): content.sidebar_view += ub.SIDEBAR_RECENT elif "show_recent" not in to_save and content.show_recent(): content.sidebar_view -= ub.SIDEBAR_RECENT if "show_sorted" in to_save and not content.show_sorted(): content.sidebar_view += ub.SIDEBAR_SORTED elif "show_sorted" not in to_save and content.show_sorted(): content.sidebar_view -= ub.SIDEBAR_SORTED if "show_hot" in to_save and not content.show_hot_books(): content.sidebar_view += ub.SIDEBAR_HOT elif "show_hot" not in to_save and content.show_hot_books(): content.sidebar_view -= ub.SIDEBAR_HOT if "show_best_rated" in to_save and not content.show_best_rated_books(): content.sidebar_view += ub.SIDEBAR_BEST_RATED elif "show_best_rated" not in to_save and content.show_best_rated_books(): content.sidebar_view -= ub.SIDEBAR_BEST_RATED if "show_read_and_unread" in to_save and not content.show_read_and_unread(): content.sidebar_view += ub.SIDEBAR_READ_AND_UNREAD elif ( "show_read_and_unread" not in to_save and content.show_read_and_unread() ): content.sidebar_view -= ub.SIDEBAR_READ_AND_UNREAD if "show_author" in to_save and not content.show_author(): content.sidebar_view += ub.SIDEBAR_AUTHOR elif "show_author" not in to_save and content.show_author(): content.sidebar_view -= ub.SIDEBAR_AUTHOR if "show_detail_random" in to_save and not content.show_detail_random(): content.sidebar_view += ub.DETAIL_RANDOM elif "show_detail_random" not in to_save and content.show_detail_random(): content.sidebar_view -= ub.DETAIL_RANDOM content.mature_content = "show_mature_content" in to_save content.theme = int(to_save["theme"]) if "default_language" in to_save: content.default_language = to_save["default_language"] if "locale" in to_save and to_save["locale"]: content.locale = to_save["locale"] if to_save["email"] and to_save["email"] != content.email: content.email = to_save["email"] if ( "kindle_mail" in to_save and to_save["kindle_mail"] != content.kindle_mail ): content.kindle_mail = to_save["kindle_mail"] try: ub.session.commit() flash( _("User '%(nick)s' updated", nick=content.nickname), category="success" ) except IntegrityError: ub.session.rollback() flash(_("An unknown error occured."), category="error") return render_title_template( "user_edit.html", translations=translations, languages=languages, new_user=0, content=content, downloads=downloads, title=_("Edit User %(nick)s", nick=content.nickname), page="edituser", )
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def render_edit_book(book_id): db.session.connection().connection.connection.create_function( "title_sort", 1, db.title_sort ) cc = ( db.session.query(db.Custom_Columns) .filter(db.Custom_Columns.datatype.notin_(db.cc_exceptions)) .all() ) book = ( db.session.query(db.Books) .filter(db.Books.id == book_id) .filter(common_filters()) .first() ) if not book: flash( _("Error opening eBook. File does not exist or file is not accessible"), category="error", ) return redirect(url_for("index")) for indx in range(0, len(book.languages)): book.languages[indx].language_name = language_table[get_locale()][ book.languages[indx].lang_code ] book = order_authors(book) author_names = [] for authr in book.authors: author_names.append(authr.name.replace("|", ",")) # Option for showing convertbook button valid_source_formats = list() if config.config_ebookconverter == 2: for file in book.data: if file.format.lower() in EXTENSIONS_CONVERT: valid_source_formats.append(file.format.lower()) # Determine what formats don't already exist allowed_conversion_formats = EXTENSIONS_CONVERT.copy() for file in book.data: try: allowed_conversion_formats.remove(file.format.lower()) except Exception: app.logger.warning(file.format.lower() + " already removed from list.") return render_title_template( "book_edit.html", book=book, authors=author_names, cc=cc, title=_("edit metadata"), page="editbook", conversion_formats=allowed_conversion_formats, source_formats=valid_source_formats, )
def render_edit_book(book_id): db.session.connection().connection.connection.create_function( "title_sort", 1, db.title_sort ) cc = ( db.session.query(db.Custom_Columns) .filter(db.Custom_Columns.datatype.notin_(db.cc_exceptions)) .all() ) book = ( db.session.query(db.Books) .filter(db.Books.id == book_id) .filter(common_filters()) .first() ) if not book: flash( _("Error opening eBook. File does not exist or file is not accessible"), category="error", ) return redirect(url_for("index")) for indx in range(0, len(book.languages)): book.languages[indx].language_name = language_table[get_locale()][ book.languages[indx].lang_code ] author_names = [] for authr in book.authors: author_names.append(authr.name.replace("|", ",")) # Option for showing convertbook button valid_source_formats = list() if config.config_ebookconverter == 2: for file in book.data: if file.format.lower() in EXTENSIONS_CONVERT: valid_source_formats.append(file.format.lower()) # Determine what formats don't already exist allowed_conversion_formats = EXTENSIONS_CONVERT.copy() for file in book.data: try: allowed_conversion_formats.remove(file.format.lower()) except Exception: app.logger.warning(file.format.lower() + " already removed from list.") return render_title_template( "book_edit.html", book=book, authors=author_names, cc=cc, title=_("edit metadata"), page="editbook", conversion_formats=allowed_conversion_formats, source_formats=valid_source_formats, )
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def upload_single_file(request, book, book_id): # Check and handle Uploaded file if "btn-upload-format" in request.files: requested_file = request.files["btn-upload-format"] # check for empty request if requested_file.filename != "": if "." in requested_file.filename: file_ext = requested_file.filename.rsplit(".", 1)[-1].lower() if file_ext not in EXTENSIONS_UPLOAD: flash( _( "File extension '%(ext)s' is not allowed to be uploaded to this server", ext=file_ext, ), category="error", ) return redirect(url_for("show_book", book_id=book.id)) else: flash(_("File to be uploaded must have an extension"), category="error") return redirect(url_for("show_book", book_id=book.id)) file_name = book.path.rsplit("/", 1)[-1] filepath = os.path.normpath( os.path.join(config.config_calibre_dir, book.path) ) saved_filename = os.path.join(filepath, file_name + "." + file_ext) # check if file path exists, otherwise create it, copy file to calibre path and delete temp file if not os.path.exists(filepath): try: os.makedirs(filepath) except OSError: flash( _( "Failed to create path %(path)s (Permission denied).", path=filepath, ), category="error", ) return redirect(url_for("show_book", book_id=book.id)) try: requested_file.save(saved_filename) except OSError: flash( _("Failed to store file %(file)s.", file=saved_filename), category="error", ) return redirect(url_for("show_book", book_id=book.id)) file_size = os.path.getsize(saved_filename) is_format = ( db.session.query(db.Data) .filter(db.Data.book == book_id) .filter(db.Data.format == file_ext.upper()) .first() ) # Format entry already exists, no need to update the database if is_format: app.logger.info("Book format already existing") else: db_format = db.Data(book_id, file_ext.upper(), file_size, file_name) db.session.add(db_format) db.session.commit() db.session.connection().connection.connection.create_function( "title_sort", 1, db.title_sort ) # Queue uploader info uploadText = _( "File format %(ext)s added to %(book)s", ext=file_ext.upper(), book=book.title, ) helper.global_WorkerThread.add_upload( current_user.nickname, '<a href="' + url_for("show_book", book_id=book.id) + '">' + uploadText + "</a>", )
def upload_single_file(request, book, book_id): # Check and handle Uploaded file if "btn-upload-format" in request.files: requested_file = request.files["btn-upload-format"] # check for empty request if requested_file.filename != "": if "." in requested_file.filename: file_ext = requested_file.filename.rsplit(".", 1)[-1].lower() if file_ext not in EXTENSIONS_UPLOAD: flash( _( "File extension '%(ext)s' is not allowed to be uploaded to this server", ext=file_ext, ), category="error", ) return redirect(url_for("show_book", book_id=book.id)) else: flash(_("File to be uploaded must have an extension"), category="error") return redirect(url_for("show_book", book_id=book.id)) file_name = book.path.rsplit("/", 1)[-1] filepath = os.path.normpath( os.path.join(config.config_calibre_dir, book.path) ) saved_filename = os.path.join(filepath, file_name + "." + file_ext) # check if file path exists, otherwise create it, copy file to calibre path and delete temp file if not os.path.exists(filepath): try: os.makedirs(filepath) except OSError: flash( _( "Failed to create path %(path)s (Permission denied).", path=filepath, ), category="error", ) return redirect(url_for("show_book", book_id=book.id)) try: requested_file.save(saved_filename) except OSError: flash( _("Failed to store file %(file)s.", file=saved_filename), category="error", ) return redirect(url_for("show_book", book_id=book.id)) file_size = os.path.getsize(saved_filename) is_format = ( db.session.query(db.Data) .filter(db.Data.book == book_id) .filter(db.Data.format == file_ext.upper()) .first() ) # Format entry already exists, no need to update the database if is_format: app.logger.info("Book format already existing") else: db_format = db.Data(book_id, file_ext.upper(), file_size, file_name) db.session.add(db_format) db.session.commit() db.session.connection().connection.connection.create_function( "title_sort", 1, db.title_sort ) # Queue uploader info uploadText = _( "File format %(ext)s added to %(book)s", ext=file_ext.upper(), book=book.title, ) helper.global_WorkerThread.add_upload( current_user.nickname, '<a href="' + url_for("show_book", book_id=book.id) + '">' + uploadText + "</a>", )
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def edit_book(book_id): # Show form if request.method != "POST": return render_edit_book(book_id) # create the function for sorting... db.session.connection().connection.connection.create_function( "title_sort", 1, db.title_sort ) book = ( db.session.query(db.Books) .filter(db.Books.id == book_id) .filter(common_filters()) .first() ) # Book not found if not book: flash( _("Error opening eBook. File does not exist or file is not accessible"), category="error", ) return redirect(url_for("index")) upload_single_file(request, book, book_id) upload_cover(request, book) try: to_save = request.form.to_dict() # Update book edited_books_id = None # handle book title if book.title != to_save["book_title"].rstrip().strip(): if to_save["book_title"] == "": to_save["book_title"] = _("unknown") book.title = to_save["book_title"].rstrip().strip() edited_books_id = book.id # handle author(s) input_authors = to_save["author_name"].split("&") input_authors = list( map(lambda it: it.strip().replace(",", "|"), input_authors) ) # we have all author names now if input_authors == [""]: input_authors = [_("unknown")] # prevent empty Author modify_database_object( input_authors, book.authors, db.Authors, db.session, "author" ) # Search for each author if author is in database, if not, authorname and sorted authorname is generated new # everything then is assembled for sorted author field in database sort_authors_list = list() for inp in input_authors: stored_author = ( db.session.query(db.Authors).filter(db.Authors.name == inp).first() ) if not stored_author: stored_author = helper.get_sorted_author(inp) else: stored_author = stored_author.sort sort_authors_list.append(helper.get_sorted_author(stored_author)) sort_authors = " & ".join(sort_authors_list) if book.author_sort != sort_authors: edited_books_id = book.id book.author_sort = sort_authors if config.config_use_google_drive: gdriveutils.updateGdriveCalibreFromLocal() error = False if edited_books_id: error = helper.update_dir_stucture( edited_books_id, config.config_calibre_dir, input_authors[0] ) if not error: if to_save["cover_url"]: if helper.save_cover(to_save["cover_url"], book.path) is True: book.has_cover = 1 else: flash(_("Cover is not a jpg file, can't save"), category="error") if book.series_index != to_save["series_index"]: book.series_index = to_save["series_index"] # Handle book comments/description if len(book.comments): book.comments[0].text = to_save["description"] else: book.comments.append( db.Comments(text=to_save["description"], book=book.id) ) # Handle book tags input_tags = to_save["tags"].split(",") input_tags = list(map(lambda it: it.strip(), input_tags)) modify_database_object(input_tags, book.tags, db.Tags, db.session, "tags") # Handle book series input_series = [to_save["series"].strip()] input_series = [x for x in input_series if x != ""] modify_database_object( input_series, book.series, db.Series, db.session, "series" ) if to_save["pubdate"]: try: book.pubdate = datetime.datetime.strptime( to_save["pubdate"], "%Y-%m-%d" ) except ValueError: book.pubdate = db.Books.DEFAULT_PUBDATE else: book.pubdate = db.Books.DEFAULT_PUBDATE if to_save["publisher"]: publisher = to_save["publisher"].rstrip().strip() if len(book.publishers) == 0 or ( len(book.publishers) > 0 and publisher != book.publishers[0].name ): modify_database_object( [publisher], book.publishers, db.Publishers, db.session, "publisher", ) elif len(book.publishers): modify_database_object( [], book.publishers, db.Publishers, db.session, "publisher" ) # handle book languages input_languages = to_save["languages"].split(",") input_languages = [x.strip().lower() for x in input_languages if x != ""] input_l = [] invers_lang_table = [ x.lower() for x in language_table[get_locale()].values() ] for lang in input_languages: try: res = list(language_table[get_locale()].keys())[ invers_lang_table.index(lang) ] input_l.append(res) except ValueError: app.logger.error("%s is not a valid language" % lang) flash( _("%(langname)s is not a valid language", langname=lang), category="error", ) modify_database_object( input_l, book.languages, db.Languages, db.session, "languages" ) # handle book ratings if to_save["rating"].strip(): old_rating = False if len(book.ratings) > 0: old_rating = book.ratings[0].rating ratingx2 = int(float(to_save["rating"]) * 2) if ratingx2 != old_rating: is_rating = ( db.session.query(db.Ratings) .filter(db.Ratings.rating == ratingx2) .first() ) if is_rating: book.ratings.append(is_rating) else: new_rating = db.Ratings(rating=ratingx2) book.ratings.append(new_rating) if old_rating: book.ratings.remove(book.ratings[0]) else: if len(book.ratings) > 0: book.ratings.remove(book.ratings[0]) # handle cc data edit_cc_data(book_id, book, to_save) db.session.commit() if config.config_use_google_drive: gdriveutils.updateGdriveCalibreFromLocal() if "detail_view" in to_save: return redirect(url_for("show_book", book_id=book.id)) else: flash(_("Metadata successfully updated"), category="success") return render_edit_book(book_id) else: db.session.rollback() flash(error, category="error") return render_edit_book(book_id) except Exception as e: app.logger.exception(e) db.session.rollback() flash( _("Error editing book, please check logfile for details"), category="error" ) return redirect(url_for("show_book", book_id=book.id))
def edit_book(book_id): # Show form if request.method != "POST": return render_edit_book(book_id) # create the function for sorting... db.session.connection().connection.connection.create_function( "title_sort", 1, db.title_sort ) book = ( db.session.query(db.Books) .filter(db.Books.id == book_id) .filter(common_filters()) .first() ) # Book not found if not book: flash( _("Error opening eBook. File does not exist or file is not accessible"), category="error", ) return redirect(url_for("index")) upload_single_file(request, book, book_id) upload_cover(request, book) try: to_save = request.form.to_dict() # Update book edited_books_id = None # handle book title if book.title != to_save["book_title"].rstrip().strip(): if to_save["book_title"] == "": to_save["book_title"] = _("unknown") book.title = to_save["book_title"].rstrip().strip() edited_books_id = book.id # handle author(s) input_authors = to_save["author_name"].split("&") input_authors = list( map(lambda it: it.strip().replace(",", "|"), input_authors) ) # we have all author names now if input_authors == [""]: input_authors = [_("unknown")] # prevent empty Author if book.authors: author0_before_edit = book.authors[0].name else: author0_before_edit = db.Authors(_("unknown"), "", 0) modify_database_object( input_authors, book.authors, db.Authors, db.session, "author" ) if book.authors: if author0_before_edit != book.authors[0].name: edited_books_id = book.id book.author_sort = helper.get_sorted_author(input_authors[0]) if config.config_use_google_drive: gdriveutils.updateGdriveCalibreFromLocal() error = False if edited_books_id: error = helper.update_dir_stucture( edited_books_id, config.config_calibre_dir ) if not error: if to_save["cover_url"]: if helper.save_cover(to_save["cover_url"], book.path) is True: book.has_cover = 1 else: flash(_("Cover is not a jpg file, can't save"), category="error") if book.series_index != to_save["series_index"]: book.series_index = to_save["series_index"] # Handle book comments/description if len(book.comments): book.comments[0].text = to_save["description"] else: book.comments.append( db.Comments(text=to_save["description"], book=book.id) ) # Handle book tags input_tags = to_save["tags"].split(",") input_tags = list(map(lambda it: it.strip(), input_tags)) modify_database_object(input_tags, book.tags, db.Tags, db.session, "tags") # Handle book series input_series = [to_save["series"].strip()] input_series = [x for x in input_series if x != ""] modify_database_object( input_series, book.series, db.Series, db.session, "series" ) if to_save["pubdate"]: try: book.pubdate = datetime.datetime.strptime( to_save["pubdate"], "%Y-%m-%d" ) except ValueError: book.pubdate = db.Books.DEFAULT_PUBDATE else: book.pubdate = db.Books.DEFAULT_PUBDATE if to_save["publisher"]: publisher = to_save["publisher"].rstrip().strip() if len(book.publishers) == 0 or ( len(book.publishers) > 0 and publisher != book.publishers[0].name ): modify_database_object( [publisher], book.publishers, db.Publishers, db.session, "publisher", ) elif len(book.publishers): modify_database_object( [], book.publishers, db.Publishers, db.session, "publisher" ) # handle book languages input_languages = to_save["languages"].split(",") input_languages = [x.strip().lower() for x in input_languages if x != ""] input_l = [] invers_lang_table = [ x.lower() for x in language_table[get_locale()].values() ] for lang in input_languages: try: res = list(language_table[get_locale()].keys())[ invers_lang_table.index(lang) ] input_l.append(res) except ValueError: app.logger.error("%s is not a valid language" % lang) flash( _("%(langname)s is not a valid language", langname=lang), category="error", ) modify_database_object( input_l, book.languages, db.Languages, db.session, "languages" ) # handle book ratings if to_save["rating"].strip(): old_rating = False if len(book.ratings) > 0: old_rating = book.ratings[0].rating ratingx2 = int(float(to_save["rating"]) * 2) if ratingx2 != old_rating: is_rating = ( db.session.query(db.Ratings) .filter(db.Ratings.rating == ratingx2) .first() ) if is_rating: book.ratings.append(is_rating) else: new_rating = db.Ratings(rating=ratingx2) book.ratings.append(new_rating) if old_rating: book.ratings.remove(book.ratings[0]) else: if len(book.ratings) > 0: book.ratings.remove(book.ratings[0]) # handle cc data edit_cc_data(book_id, book, to_save) db.session.commit() if config.config_use_google_drive: gdriveutils.updateGdriveCalibreFromLocal() if "detail_view" in to_save: return redirect(url_for("show_book", book_id=book.id)) else: flash(_("Metadata successfully updated"), category="success") return render_edit_book(book_id) else: db.session.rollback() flash(error, category="error") return render_edit_book(book_id) except Exception as e: app.logger.exception(e) db.session.rollback() flash( _("Error editing book, please check logfile for details"), category="error" ) return redirect(url_for("show_book", book_id=book.id))
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def upload(): if not config.config_uploading: abort(404) if request.method == "POST" and "btn-upload" in request.files: for requested_file in request.files.getlist("btn-upload"): # create the function for sorting... db.session.connection().connection.connection.create_function( "title_sort", 1, db.title_sort ) db.session.connection().connection.connection.create_function( "uuid4", 0, lambda: str(uuid4()) ) # check if file extension is correct if "." in requested_file.filename: file_ext = requested_file.filename.rsplit(".", 1)[-1].lower() if file_ext not in EXTENSIONS_UPLOAD: return Response( _( "File extension '%(ext)s' is not allowed to be uploaded to this server", ext=file_ext, ) ), 422 else: return Response(_("File to be uploaded must have an extension")), 422 # extract metadata from file meta = uploader.upload(requested_file) title = meta.title authr = meta.author tags = meta.tags series = meta.series series_index = meta.series_id title_dir = helper.get_valid_filename(title) author_dir = helper.get_valid_filename(authr) filepath = os.path.join(config.config_calibre_dir, author_dir, title_dir) saved_filename = os.path.join(filepath, title_dir + meta.extension.lower()) # check if file path exists, otherwise create it, copy file to calibre path and delete temp file if not os.path.exists(filepath): try: os.makedirs(filepath) except OSError: return Response( _( "Failed to create path %(path)s (Permission denied).", path=filepath, ) ), 422 try: copyfile(meta.file_path, saved_filename) except OSError: return Response( _( "Failed to store file %(file)s (Permission denied).", file=saved_filename, ) ), 422 try: os.unlink(meta.file_path) except OSError: flash( _( "Failed to delete file %(file)s (Permission denied).", file=meta.file_path, ), category="warning", ) if meta.cover is None: has_cover = 0 copyfile( os.path.join(config.get_main_dir, "cps/static/generic_cover.jpg"), os.path.join(filepath, "cover.jpg"), ) else: has_cover = 1 move(meta.cover, os.path.join(filepath, "cover.jpg")) # handle authors is_author = ( db.session.query(db.Authors).filter(db.Authors.name == authr).first() ) if is_author: db_author = is_author else: db_author = db.Authors(authr, helper.get_sorted_author(authr), "") db.session.add(db_author) # handle series db_series = None is_series = ( db.session.query(db.Series).filter(db.Series.name == series).first() ) if is_series: db_series = is_series elif series != "": db_series = db.Series(series, "") db.session.add(db_series) # add language actually one value in list input_language = meta.languages db_language = None if input_language != "": input_language = isoLanguages.get(name=input_language).part3 hasLanguage = ( db.session.query(db.Languages) .filter(db.Languages.lang_code == input_language) .first() ) if hasLanguage: db_language = hasLanguage else: db_language = db.Languages(input_language) db.session.add(db_language) # combine path and normalize path from windows systems path = os.path.join(author_dir, title_dir).replace("\\", "/") db_book = db.Books( title, "", db_author.sort, datetime.datetime.now(), datetime.datetime(101, 1, 1), series_index, datetime.datetime.now(), path, has_cover, db_author, [], db_language, ) db_book.authors.append(db_author) if db_series: db_book.series.append(db_series) if db_language is not None: db_book.languages.append(db_language) file_size = os.path.getsize(saved_filename) db_data = db.Data(db_book, meta.extension.upper()[1:], file_size, title_dir) # handle tags input_tags = tags.split(",") input_tags = list(map(lambda it: it.strip(), input_tags)) if input_tags[0] != "": modify_database_object( input_tags, db_book.tags, db.Tags, db.session, "tags" ) # flush content, get db_book.id available db_book.data.append(db_data) db.session.add(db_book) db.session.flush() # add comment book_id = db_book.id upload_comment = Markup(meta.description).unescape() if upload_comment != "": db.session.add(db.Comments(upload_comment, book_id)) # save data to database, reread data db.session.commit() db.session.connection().connection.connection.create_function( "title_sort", 1, db.title_sort ) book = ( db.session.query(db.Books) .filter(db.Books.id == book_id) .filter(common_filters()) .first() ) # upload book to gdrive if nesseccary and add "(bookid)" to folder name if config.config_use_google_drive: gdriveutils.updateGdriveCalibreFromLocal() error = helper.update_dir_stucture(book.id, config.config_calibre_dir) db.session.commit() if config.config_use_google_drive: gdriveutils.updateGdriveCalibreFromLocal() if error: flash(error, category="error") uploadText = _("File %(title)s", title=book.title) helper.global_WorkerThread.add_upload( current_user.nickname, '<a href="' + url_for("show_book", book_id=book.id) + '">' + uploadText + "</a>", ) # create data for displaying display Full language name instead of iso639.part3language if db_language is not None: book.languages[0].language_name = _(meta.languages) author_names = [] for author in db_book.authors: author_names.append(author.name) if len(request.files.getlist("btn-upload")) < 2: if current_user.role_edit() or current_user.role_admin(): resp = {"location": url_for("edit_book", book_id=db_book.id)} return Response(json.dumps(resp), mimetype="application/json") else: resp = {"location": url_for("show_book", book_id=db_book.id)} return Response(json.dumps(resp), mimetype="application/json") return Response( json.dumps({"location": url_for("index")}), mimetype="application/json" )
def upload(): if not config.config_uploading: abort(404) if request.method == "POST" and "btn-upload" in request.files: for requested_file in request.files.getlist("btn-upload"): # create the function for sorting... db.session.connection().connection.connection.create_function( "title_sort", 1, db.title_sort ) db.session.connection().connection.connection.create_function( "uuid4", 0, lambda: str(uuid4()) ) # check if file extension is correct if "." in requested_file.filename: file_ext = requested_file.filename.rsplit(".", 1)[-1].lower() if file_ext not in EXTENSIONS_UPLOAD: flash( _( "File extension '%(ext)s' is not allowed to be uploaded to this server", ext=file_ext, ), category="error", ) return redirect(url_for("index")) else: flash(_("File to be uploaded must have an extension"), category="error") return redirect(url_for("index")) # extract metadata from file meta = uploader.upload(requested_file) title = meta.title authr = meta.author tags = meta.tags series = meta.series series_index = meta.series_id title_dir = helper.get_valid_filename(title) author_dir = helper.get_valid_filename(authr) filepath = os.path.join(config.config_calibre_dir, author_dir, title_dir) saved_filename = os.path.join(filepath, title_dir + meta.extension.lower()) # check if file path exists, otherwise create it, copy file to calibre path and delete temp file if not os.path.exists(filepath): try: os.makedirs(filepath) except OSError: flash( _( "Failed to create path %(path)s (Permission denied).", path=filepath, ), category="error", ) return redirect(url_for("index")) try: copyfile(meta.file_path, saved_filename) except OSError: flash( _( "Failed to store file %(file)s (Permission denied).", file=saved_filename, ), category="error", ) return redirect(url_for("index")) try: os.unlink(meta.file_path) except OSError: flash( _( "Failed to delete file %(file)s (Permission denied).", file=meta.file_path, ), category="warning", ) if meta.cover is None: has_cover = 0 copyfile( os.path.join(config.get_main_dir, "cps/static/generic_cover.jpg"), os.path.join(filepath, "cover.jpg"), ) else: has_cover = 1 move(meta.cover, os.path.join(filepath, "cover.jpg")) # handle authors is_author = ( db.session.query(db.Authors).filter(db.Authors.name == authr).first() ) if is_author: db_author = is_author else: db_author = db.Authors(authr, helper.get_sorted_author(authr), "") db.session.add(db_author) # handle series db_series = None is_series = ( db.session.query(db.Series).filter(db.Series.name == series).first() ) if is_series: db_series = is_series elif series != "": db_series = db.Series(series, "") db.session.add(db_series) # add language actually one value in list input_language = meta.languages db_language = None if input_language != "": input_language = isoLanguages.get(name=input_language).part3 hasLanguage = ( db.session.query(db.Languages) .filter(db.Languages.lang_code == input_language) .first() ) if hasLanguage: db_language = hasLanguage else: db_language = db.Languages(input_language) db.session.add(db_language) # combine path and normalize path from windows systems path = os.path.join(author_dir, title_dir).replace("\\", "/") db_book = db.Books( title, "", db_author.sort, datetime.datetime.now(), datetime.datetime(101, 1, 1), series_index, datetime.datetime.now(), path, has_cover, db_author, [], db_language, ) db_book.authors.append(db_author) if db_series: db_book.series.append(db_series) if db_language is not None: db_book.languages.append(db_language) file_size = os.path.getsize(saved_filename) db_data = db.Data(db_book, meta.extension.upper()[1:], file_size, title_dir) # handle tags input_tags = tags.split(",") input_tags = list(map(lambda it: it.strip(), input_tags)) if input_tags[0] != "": modify_database_object( input_tags, db_book.tags, db.Tags, db.session, "tags" ) # flush content, get db_book.id available db_book.data.append(db_data) db.session.add(db_book) db.session.flush() # add comment book_id = db_book.id upload_comment = Markup(meta.description).unescape() if upload_comment != "": db.session.add(db.Comments(upload_comment, book_id)) # save data to database, reread data db.session.commit() db.session.connection().connection.connection.create_function( "title_sort", 1, db.title_sort ) book = ( db.session.query(db.Books) .filter(db.Books.id == book_id) .filter(common_filters()) .first() ) # upload book to gdrive if nesseccary and add "(bookid)" to folder name if config.config_use_google_drive: gdriveutils.updateGdriveCalibreFromLocal() error = helper.update_dir_stucture(book.id, config.config_calibre_dir) db.session.commit() if config.config_use_google_drive: gdriveutils.updateGdriveCalibreFromLocal() if error: flash(error, category="error") uploadText = _("File %(file)s uploaded", file=book.title) helper.global_WorkerThread.add_upload( current_user.nickname, '<a href="' + url_for("show_book", book_id=book.id) + '">' + uploadText + "</a>", ) # create data for displaying display Full language name instead of iso639.part3language if db_language is not None: book.languages[0].language_name = _(meta.languages) author_names = [] for author in db_book.authors: author_names.append(author.name) if len(request.files.getlist("btn-upload")) < 2: cc = ( db.session.query(db.Custom_Columns) .filter(db.Custom_Columns.datatype.notin_(db.cc_exceptions)) .all() ) if current_user.role_edit() or current_user.role_admin(): return render_title_template( "book_edit.html", book=book, authors=author_names, cc=cc, title=_("edit metadata"), page="upload", ) book_in_shelfs = [] return render_title_template( "detail.html", entry=book, cc=cc, title=book.title, books_shelfs=book_in_shelfs, page="upload", ) return redirect(url_for("index"))
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def get_attachment(bookpath, filename): """Get file as MIMEBase message""" calibrepath = web.config.config_calibre_dir if web.ub.config.config_use_google_drive: df = gd.getFileFromEbooksFolder(bookpath, filename) if df: datafile = os.path.join(calibrepath, bookpath, filename) if not os.path.exists(os.path.join(calibrepath, bookpath)): os.makedirs(os.path.join(calibrepath, bookpath)) df.GetContentFile(datafile) else: return None file_ = open(datafile, "rb") data = file_.read() file_.close() os.remove(datafile) else: try: file_ = open(os.path.join(calibrepath, bookpath, filename), "rb") data = file_.read() file_.close() except IOError as e: web.app.logger.exception(e) # traceback.print_exc() web.app.logger.error( "The requested file could not be read. Maybe wrong permissions?" ) return None attachment = MIMEBase("application", "octet-stream") attachment.set_payload(data) encoders.encode_base64(attachment) attachment.add_header("Content-Disposition", "attachment", filename=filename) return attachment
def get_attachment(bookpath, filename): """Get file as MIMEBase message""" calibrepath = web.config.config_calibre_dir if web.ub.config.config_use_google_drive: df = gd.getFileFromEbooksFolder(bookpath, filename) if df: datafile = os.path.join(calibrepath, bookpath, filename) if not os.path.exists(os.path.join(calibrepath, bookpath)): os.makedirs(os.path.join(calibrepath, bookpath)) df.GetContentFile(datafile) else: return None file_ = open(datafile, "rb") data = file_.read() file_.close() os.remove(datafile) else: try: file_ = open(os.path.join(calibrepath, bookpath, filename), "rb") data = file_.read() file_.close() except IOError: web.app.logger.exception(e) # traceback.print_exc() web.app.logger.error( "The requested file could not be read. Maybe wrong permissions?" ) return None attachment = MIMEBase("application", "octet-stream") attachment.set_payload(data) encoders.encode_base64(attachment) attachment.add_header("Content-Disposition", "attachment", filename=filename) return attachment
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def send(self, strg): """Send `strg' to the server.""" if self.debuglevel > 0: print("send:", repr(strg[:300]), file=sys.stderr) if hasattr(self, "sock") and self.sock: try: if self.transferSize: lock = threading.Lock() lock.acquire() self.transferSize = len(strg) lock.release() for i in range(0, self.transferSize, chunksize): if isinstance(strg, bytes): self.sock.send((strg[i : i + chunksize])) else: self.sock.send((strg[i : i + chunksize]).encode("utf-8")) lock.acquire() self.progress = i lock.release() else: self.sock.sendall(strg.encode("utf-8")) except socket.error: self.close() raise smtplib.SMTPServerDisconnected("Server not connected") else: raise smtplib.SMTPServerDisconnected("please run connect() first")
def send(self, strg): """Send `strg' to the server.""" if self.debuglevel > 0: print("send:", repr(strg), file=sys.stderr) if hasattr(self, "sock") and self.sock: try: if self.transferSize: lock = threading.Lock() lock.acquire() self.transferSize = len(strg) lock.release() for i in range(0, self.transferSize, chunksize): if type(strg) == bytes: self.sock.send((strg[i : i + chunksize])) else: self.sock.send((strg[i : i + chunksize]).encode("utf-8")) lock.acquire() self.progress = i lock.release() else: self.sock.sendall(strg.encode("utf-8")) except socket.error: self.close() raise smtplib.SMTPServerDisconnected("Server not connected") else: raise smtplib.SMTPServerDisconnected("please run connect() first")
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def _convert_ebook_format(self): error_message = None file_path = self.queue[self.current]["file_path"] bookid = self.queue[self.current]["bookid"] format_old_ext = ( "." + self.queue[self.current]["settings"]["old_book_format"].lower() ) format_new_ext = ( "." + self.queue[self.current]["settings"]["new_book_format"].lower() ) # check to see if destination format already exists - # if it does - mark the conversion task as complete and return a success # this will allow send to kindle workflow to continue to work if os.path.isfile(file_path + format_new_ext): web.app.logger.info( "Book id %d already converted to %s", bookid, format_new_ext ) cur_book = ( web.db.session.query(web.db.Books).filter(web.db.Books.id == bookid).first() ) self.queue[self.current]["path"] = file_path self.queue[self.current]["title"] = cur_book.title self._handleSuccess() return file_path + format_new_ext else: web.app.logger.info( "Book id %d - target format of %s does not exist. Moving forward with convert.", bookid, format_new_ext, ) # check if converter-executable is existing if not os.path.exists(web.ub.config.config_converterpath): # ToDo Text is not translated self._handleError( "Convertertool %s not found" % web.ub.config.config_converterpath ) return try: # check which converter to use kindlegen is "1" if format_old_ext == ".epub" and format_new_ext == ".mobi": if web.ub.config.config_ebookconverter == 1: if os.name == "nt": command = ( web.ub.config.config_converterpath + ' "' + file_path + '.epub"' ) if sys.version_info < (3, 0): command = command.encode(sys.getfilesystemencoding()) else: command = [web.ub.config.config_converterpath, file_path + ".epub"] if sys.version_info < (3, 0): command = [ x.encode(sys.getfilesystemencoding()) for x in command ] if web.ub.config.config_ebookconverter == 2: # Linux py2.7 encode as list without quotes no empty element for parameters # linux py3.x no encode and as list without quotes no empty element for parameters # windows py2.7 encode as string with quotes empty element for parameters is okay # windows py 3.x no encode and as string with quotes empty element for parameters is okay # separate handling for windows and linux if os.name == "nt": command = ( web.ub.config.config_converterpath + ' "' + file_path + format_old_ext + '" "' + file_path + format_new_ext + '" ' + web.ub.config.config_calibre ) if sys.version_info < (3, 0): command = command.encode(sys.getfilesystemencoding()) else: command = [ web.ub.config.config_converterpath, (file_path + format_old_ext), (file_path + format_new_ext), ] if web.ub.config.config_calibre: parameters = web.ub.config.config_calibre.split(" ") for param in parameters: command.append(param) if sys.version_info < (3, 0): command = [x.encode(sys.getfilesystemencoding()) for x in command] p = subprocess.Popen(command, stdout=subprocess.PIPE, universal_newlines=True) except OSError as e: self._handleError(_("Ebook-converter failed: %(error)s", error=e)) return if web.ub.config.config_ebookconverter == 1: nextline = p.communicate()[0] # Format of error message (kindlegen translates its output texts): # Error(prcgen):E23006: Language not recognized in metadata.The dc:Language field is mandatory.Aborting. conv_error = re.search(".*\(.*\):(E\d+):\s(.*)", nextline, re.MULTILINE) # If error occoures, store error message for logfile if conv_error: error_message = _( "Kindlegen failed with Error %(error)s. Message: %(message)s", error=conv_error.group(1), message=conv_error.group(2).strip(), ) web.app.logger.debug("convert_kindlegen: " + nextline) else: while p.poll() is None: nextline = p.stdout.readline() if os.name == "nt" and sys.version_info < (3, 0): nextline = nextline.decode("windows-1252") web.app.logger.debug(nextline.strip("\r\n")) # parse progress string from calibre-converter progress = re.search("(\d+)%\s.*", nextline) if progress: self.UIqueue[self.current]["progress"] = progress.group(1) + " %" # process returncode check = p.returncode # kindlegen returncodes # 0 = Info(prcgen):I1036: Mobi file built successfully # 1 = Info(prcgen):I1037: Mobi file built with WARNINGS! # 2 = Info(prcgen):I1038: MOBI file could not be generated because of errors! if (check < 2 and web.ub.config.config_ebookconverter == 1) or ( check == 0 and web.ub.config.config_ebookconverter == 2 ): cur_book = ( web.db.session.query(web.db.Books).filter(web.db.Books.id == bookid).first() ) if os.path.isfile(file_path + format_new_ext): new_format = web.db.Data( name=cur_book.data[0].name, book_format=self.queue[self.current]["settings"][ "new_book_format" ].upper(), book=bookid, uncompressed_size=os.path.getsize(file_path + format_new_ext), ) cur_book.data.append(new_format) web.db.session.commit() self.queue[self.current]["path"] = cur_book.path self.queue[self.current]["title"] = cur_book.title if web.ub.config.config_use_google_drive: os.remove(file_path + format_old_ext) self._handleSuccess() return file_path + format_new_ext else: error_message = format_new_ext.upper() + " format not found on disk" web.app.logger.info("ebook converter failed with error while converting book") if not error_message: error_message = "Ebook converter failed with unknown error" self._handleError(error_message) return
def _convert_ebook_format(self): error_message = None file_path = self.queue[self.current]["file_path"] bookid = self.queue[self.current]["bookid"] format_old_ext = ( "." + self.queue[self.current]["settings"]["old_book_format"].lower() ) format_new_ext = ( "." + self.queue[self.current]["settings"]["new_book_format"].lower() ) # check to see if destination format already exists - # if it does - mark the conversion task as complete and return a success # this will allow send to kindle workflow to continue to work if os.path.isfile(file_path + format_new_ext): web.app.logger.info( "Book id %d already converted to %s", bookid, format_new_ext ) cur_book = ( web.db.session.query(web.db.Books).filter(web.db.Books.id == bookid).first() ) self.queue[self.current]["path"] = file_path self.queue[self.current]["title"] = cur_book.title self._handleSuccess() return file_path + format_new_ext else: web.app.logger.info( "Book id %d - target format of %s does not exist. Moving forward with convert.", bookid, format_new_ext, ) # check if converter-executable is existing if not os.path.exists(web.ub.config.config_converterpath): # ToDo Text is not translated self._handleError( "Convertertool %s not found" % web.ub.config.config_converterpath ) return try: # check which converter to use kindlegen is "1" if format_old_ext == ".epub" and format_new_ext == ".mobi": if web.ub.config.config_ebookconverter == 1: if os.name == "nt": command = ( web.ub.config.config_converterpath + ' "' + file_path + '.epub"' ) if sys.version_info < (3, 0): command = command.encode(sys.getfilesystemencoding()) else: command = [web.ub.config.config_converterpath, file_path + ".epub"] if sys.version_info < (3, 0): command = [ x.encode(sys.getfilesystemencoding()) for x in command ] if web.ub.config.config_ebookconverter == 2: # Linux py2.7 encode as list without quotes no empty element for parameters # linux py3.x no encode and as list without quotes no empty element for parameters # windows py2.7 encode as string with quotes empty element for parameters is okay # windows py 3.x no encode and as string with quotes empty element for parameters is okay # separate handling for windows and linux if os.name == "nt": command = ( web.ub.config.config_converterpath + ' "' + file_path + format_old_ext + '" "' + file_path + format_new_ext + '" ' + web.ub.config.config_calibre ) if sys.version_info < (3, 0): command = command.encode(sys.getfilesystemencoding()) else: command = [ web.ub.config.config_converterpath, (file_path + format_old_ext), (file_path + format_new_ext), ] if web.ub.config.config_calibre: command.append(web.ub.config.config_calibre) if sys.version_info < (3, 0): command = [x.encode(sys.getfilesystemencoding()) for x in command] p = subprocess.Popen(command, stdout=subprocess.PIPE, universal_newlines=True) except OSError as e: self._handleError(_("Ebook-converter failed: %(error)s", error=e)) return if web.ub.config.config_ebookconverter == 1: nextline = p.communicate()[0] # Format of error message (kindlegen translates its output texts): # Error(prcgen):E23006: Language not recognized in metadata.The dc:Language field is mandatory.Aborting. conv_error = re.search(".*\(.*\):(E\d+):\s(.*)", nextline, re.MULTILINE) # If error occoures, store error message for logfile if conv_error: error_message = _( "Kindlegen failed with Error %(error)s. Message: %(message)s", error=conv_error.group(1), message=conv_error.group(2).strip(), ) web.app.logger.debug("convert_kindlegen: " + nextline) else: while p.poll() is None: nextline = p.stdout.readline() if os.name == "nt" and sys.version_info < (3, 0): nextline = nextline.decode("windows-1252") web.app.logger.debug(nextline.strip("\r\n")) # parse progress string from calibre-converter progress = re.search("(\d+)%\s.*", nextline) if progress: self.UIqueue[self.current]["progress"] = progress.group(1) + " %" # process returncode check = p.returncode # kindlegen returncodes # 0 = Info(prcgen):I1036: Mobi file built successfully # 1 = Info(prcgen):I1037: Mobi file built with WARNINGS! # 2 = Info(prcgen):I1038: MOBI file could not be generated because of errors! if (check < 2 and web.ub.config.config_ebookconverter == 1) or ( check == 0 and web.ub.config.config_ebookconverter == 2 ): cur_book = ( web.db.session.query(web.db.Books).filter(web.db.Books.id == bookid).first() ) if os.path.isfile(file_path + format_new_ext): new_format = web.db.Data( name=cur_book.data[0].name, book_format=self.queue[self.current]["settings"]["new_book_format"], book=bookid, uncompressed_size=os.path.getsize(file_path + format_new_ext), ) cur_book.data.append(new_format) web.db.session.commit() self.queue[self.current]["path"] = cur_book.path self.queue[self.current]["title"] = cur_book.title if web.ub.config.config_use_google_drive: os.remove(file_path + format_old_ext) self._handleSuccess() return file_path + format_new_ext else: error_message = format_new_ext.upper() + " format not found on disk" web.app.logger.info("ebook converter failed with error while converting book") if not error_message: error_message = "Ebook converter failed with unknown error" self._handleError(error_message) return
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def _send_raw_email(self): self.queue[self.current]["starttime"] = datetime.now() self.UIqueue[self.current]["formStarttime"] = self.queue[self.current]["starttime"] # self.queue[self.current]['status'] = STAT_STARTED self.UIqueue[self.current]["stat"] = STAT_STARTED obj = self.queue[self.current] # create MIME message msg = MIMEMultipart() msg["Subject"] = self.queue[self.current]["subject"] msg["Message-Id"] = make_msgid("calibre-web") msg["Date"] = formatdate(localtime=True) text = self.queue[self.current]["text"] msg.attach(MIMEText(text.encode("UTF-8"), "plain", "UTF-8")) if obj["attachment"]: result = get_attachment(obj["filepath"], obj["attachment"]) if result: msg.attach(result) else: self._handleError("Attachment not found") return msg["From"] = obj["settings"]["mail_from"] msg["To"] = obj["recipent"] use_ssl = int(obj["settings"].get("mail_use_ssl", 0)) try: # convert MIME message to string fp = StringIO() gen = Generator(fp, mangle_from_=False) gen.flatten(msg) msg = fp.getvalue() # send email timeout = 600 # set timeout to 5mins org_stderr = sys.stderr sys.stderr = StderrLogger() if use_ssl == 2: self.asyncSMTP = email_SSL( obj["settings"]["mail_server"], obj["settings"]["mail_port"], timeout ) else: self.asyncSMTP = email( obj["settings"]["mail_server"], obj["settings"]["mail_port"], timeout ) # link to logginglevel if web.ub.config.config_log_level != logging.DEBUG: self.asyncSMTP.set_debuglevel(0) else: self.asyncSMTP.set_debuglevel(1) if use_ssl == 1: self.asyncSMTP.starttls() if obj["settings"]["mail_password"]: self.asyncSMTP.login( str(obj["settings"]["mail_login"]), str(obj["settings"]["mail_password"]), ) self.asyncSMTP.sendmail(obj["settings"]["mail_from"], obj["recipent"], msg) self.asyncSMTP.quit() self._handleSuccess() sys.stderr = org_stderr except MemoryError as e: self._handleError("Error sending email: " + e.message) return None except smtplib.SMTPException as e: if hasattr(e, "smtp_error"): text = e.smtp_error.replace("\n", ". ") elif hasattr(e, "message"): text = e.message else: text = "" self._handleError("Error sending email: " + text) return None except socket.error as e: self._handleError("Error sending email: " + e.strerror) return None
def _send_raw_email(self): self.queue[self.current]["starttime"] = datetime.now() self.UIqueue[self.current]["formStarttime"] = self.queue[self.current]["starttime"] # self.queue[self.current]['status'] = STAT_STARTED self.UIqueue[self.current]["stat"] = STAT_STARTED obj = self.queue[self.current] # create MIME message msg = MIMEMultipart() msg["Subject"] = self.queue[self.current]["subject"] msg["Message-Id"] = make_msgid("calibre-web") msg["Date"] = formatdate(localtime=True) text = self.queue[self.current]["text"] msg.attach(MIMEText(text.encode("UTF-8"), "plain", "UTF-8")) if obj["attachment"]: result = get_attachment(obj["filepath"], obj["attachment"]) if result: msg.attach(result) else: self._handleError("Attachment not found") return msg["From"] = obj["settings"]["mail_from"] msg["To"] = obj["recipent"] use_ssl = int(obj["settings"].get("mail_use_ssl", 0)) try: # convert MIME message to string fp = StringIO() gen = Generator(fp, mangle_from_=False) gen.flatten(msg) msg = fp.getvalue() # send email timeout = 600 # set timeout to 5mins org_stderr = sys.stderr sys.stderr = StderrLogger() if use_ssl == 2: self.asyncSMTP = email_SSL( obj["settings"]["mail_server"], obj["settings"]["mail_port"], timeout ) else: self.asyncSMTP = email( obj["settings"]["mail_server"], obj["settings"]["mail_port"], timeout ) # link to logginglevel if web.ub.config.config_log_level != logging.DEBUG: self.asyncSMTP.set_debuglevel(0) else: self.asyncSMTP.set_debuglevel(1) if use_ssl == 1: self.asyncSMTP.starttls() if obj["settings"]["mail_password"]: self.asyncSMTP.login( str(obj["settings"]["mail_login"]), str(obj["settings"]["mail_password"]), ) self.asyncSMTP.sendmail(obj["settings"]["mail_from"], obj["recipent"], msg) self.asyncSMTP.quit() self._handleSuccess() sys.stderr = org_stderr except MemoryError as e: self._handleError("Error sending email: " + e.message) return None except smtplib.SMTPException as e: if hasattr(e, "smtp_error"): text = e.smtp_error.replace("\n", ". ") else: text = "" self._handleError("Error sending email: " + text) return None except socket.error as e: self._handleError("Error sending email: " + e.strerror) return None
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def write(self, message): try: if message == "\n": self.logger.debug(self.buffer) print(self.buffer) self.buffer = "" else: self.buffer += message except: pass
def write(self, message): if message == "\n": self.logger.debug(self.buffer) print(self.buffer) self.buffer = "" else: self.buffer += message
https://github.com/janeczku/calibre-web/issues/20
ERROR:cps.web:Exception on /book/125 [GET] Traceback (most recent call last): File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/jgillman/Code/calibre-web/vendor/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/jgillman/Code/calibre-web/vendor/flask_login.py", line 717, in decorated_view return func(*args, **kwargs) File "/Users/jgillman/Code/calibre-web/cps/web.py", line 381, in show_book return render_template('detail.html', entry=entries, cc=cc, title=entries.title, books_shelfs=book_in_shelfs) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 128, in render_template context, ctx.app) File "/Users/jgillman/Code/calibre-web/vendor/flask/templating.py", line 110, in _render rv = template.render(context) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/jgillman/Code/calibre-web/cps/templates/layout.html", line 136, in top-level template code {% block body %}{% endblock %} File "/Users/jgillman/Code/calibre-web/cps/templates/detail.html", line 66, in block "body" {% if entry['custom_column_' ~ c.id]|length > 0 %} File "/Users/jgillman/Code/calibre-web/vendor/jinja2/environment.py", line 387, in getitem return getattr(obj, attr) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 316, in __get__ return self.impl.get(instance_state(instance), dict_) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/attributes.py", line 613, in get value = self.callable_(state, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 524, in _load_for_state return self._emit_lazyload(session, state, ident_key, passive) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/strategies.py", line 585, in _emit_lazyload result = q.all() File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2241, in all return list(self) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2353, in __iter__ return self._execute_and_instances(context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/orm/query.py", line 2368, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 662, in execute params) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement compiled_sql, distilled_params File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 874, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception exc_info File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/util/compat.py", line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/base.py", line 867, in _execute_context context) File "/Users/jgillman/Code/calibre-web/vendor/sqlalchemy/engine/default.py", line 324, in do_execute cursor.execute(statement, parameters) OperationalError: (OperationalError) no such table: books_custom_column_1_link u'SELECT custom_column_1.id AS custom_column_1_id, custom_column_1.value AS custom_column_1_value \ nFROM custom_column_1, books_custom_column_1_link \nWHERE ? = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value' (125,) ERROR:tornado.access:500 GET /book/125 (::1) 89.60ms
OperationalError
def _starts_debugging(func): def debug(address, **kwargs): if _settrace.called: raise RuntimeError("this process already has a debug adapter") try: _, port = address except Exception: port = address address = ("127.0.0.1", port) try: port.__index__() # ensure it's int-like except Exception: raise ValueError("expected port or (host, port)") if not (0 <= port < 2**16): raise ValueError("invalid port number") ensure_logging() log.debug("{0}({1!r}, **{2!r})", func.__name__, address, kwargs) log.info("Initial debug configuration: {0!j}", _config) qt_mode = _config.get("qt", "none") if qt_mode != "none": pydevd.enable_qt_support(qt_mode) settrace_kwargs = { "suspend": False, "patch_multiprocessing": _config.get("subProcess", True), } debugpy_path = os.path.dirname(absolute_path(debugpy.__file__)) settrace_kwargs["dont_trace_start_patterns"] = (debugpy_path,) settrace_kwargs["dont_trace_end_patterns"] = (str("debugpy_launcher.py"),) try: return func(address, settrace_kwargs, **kwargs) except Exception: log.reraise_exception("{0}() failed:", func.__name__, level="info") return debug
def _starts_debugging(func): def debug(address, **kwargs): if _settrace.called: raise RuntimeError("this process already has a debug adapter") try: _, port = address except Exception: port = address address = ("127.0.0.1", port) try: port.__index__() # ensure it's int-like except Exception: raise ValueError("expected port or (host, port)") if not (0 <= port < 2**16): raise ValueError("invalid port number") ensure_logging() log.debug("{0}({1!r}, **{2!r})", func.__name__, address, kwargs) log.info("Initial debug configuration: {0!j}", _config) qt_mode = _config.get("qt", "none") if qt_mode != "none": pydevd.enable_qt_support(qt_mode) settrace_kwargs = { "suspend": False, "patch_multiprocessing": _config.get("subProcess", True), } debugpy_path = os.path.dirname(absolute_path(debugpy.__file__)) settrace_kwargs["dont_trace_start_patterns"] = (debugpy_path,) settrace_kwargs["dont_trace_end_patterns"] = ("debugpy_launcher.py",) try: return func(address, settrace_kwargs, **kwargs) except Exception: log.reraise_exception("{0}() failed:", func.__name__, level="info") return debug
https://github.com/microsoft/debugpy/issues/206
Traceback (most recent call last): File "c:/Users/kanadig/.vscode/extensions/ms-python.python-2019.5.17059/pythonFiles/ptvsd_launcher.py", line 43, in <module> main(ptvsdArgs) File "C:\GIT\ptvsd\src\ptvsd\__main__.py", line 434, in main run() File "C:\GIT\ptvsd\src\ptvsd\__main__.py", line 312, in run_file runpy.run_path(target, run_name='__main__') File "C:\Python27\lib\runpy.py", line 251, in run_path code = _get_code_from_file(path_name) File "C:\Python27\lib\runpy.py", line 227, in _get_code_from_file with open(fname, "rb") as f: IOError: [Errno 22] invalid mode ('rb') or filename: 'c:\\GIT\\pyscratch2\\??\\experiment.py'
IOError
def debug(address, **kwargs): if _settrace.called: raise RuntimeError("this process already has a debug adapter") try: _, port = address except Exception: port = address address = ("127.0.0.1", port) try: port.__index__() # ensure it's int-like except Exception: raise ValueError("expected port or (host, port)") if not (0 <= port < 2**16): raise ValueError("invalid port number") ensure_logging() log.debug("{0}({1!r}, **{2!r})", func.__name__, address, kwargs) log.info("Initial debug configuration: {0!j}", _config) qt_mode = _config.get("qt", "none") if qt_mode != "none": pydevd.enable_qt_support(qt_mode) settrace_kwargs = { "suspend": False, "patch_multiprocessing": _config.get("subProcess", True), } debugpy_path = os.path.dirname(absolute_path(debugpy.__file__)) settrace_kwargs["dont_trace_start_patterns"] = (debugpy_path,) settrace_kwargs["dont_trace_end_patterns"] = (str("debugpy_launcher.py"),) try: return func(address, settrace_kwargs, **kwargs) except Exception: log.reraise_exception("{0}() failed:", func.__name__, level="info")
def debug(address, **kwargs): if _settrace.called: raise RuntimeError("this process already has a debug adapter") try: _, port = address except Exception: port = address address = ("127.0.0.1", port) try: port.__index__() # ensure it's int-like except Exception: raise ValueError("expected port or (host, port)") if not (0 <= port < 2**16): raise ValueError("invalid port number") ensure_logging() log.debug("{0}({1!r}, **{2!r})", func.__name__, address, kwargs) log.info("Initial debug configuration: {0!j}", _config) qt_mode = _config.get("qt", "none") if qt_mode != "none": pydevd.enable_qt_support(qt_mode) settrace_kwargs = { "suspend": False, "patch_multiprocessing": _config.get("subProcess", True), } debugpy_path = os.path.dirname(absolute_path(debugpy.__file__)) settrace_kwargs["dont_trace_start_patterns"] = (debugpy_path,) settrace_kwargs["dont_trace_end_patterns"] = ("debugpy_launcher.py",) try: return func(address, settrace_kwargs, **kwargs) except Exception: log.reraise_exception("{0}() failed:", func.__name__, level="info")
https://github.com/microsoft/debugpy/issues/206
Traceback (most recent call last): File "c:/Users/kanadig/.vscode/extensions/ms-python.python-2019.5.17059/pythonFiles/ptvsd_launcher.py", line 43, in <module> main(ptvsdArgs) File "C:\GIT\ptvsd\src\ptvsd\__main__.py", line 434, in main run() File "C:\GIT\ptvsd\src\ptvsd\__main__.py", line 312, in run_file runpy.run_path(target, run_name='__main__') File "C:\Python27\lib\runpy.py", line 251, in run_path code = _get_code_from_file(path_name) File "C:\Python27\lib\runpy.py", line 227, in _get_code_from_file with open(fname, "rb") as f: IOError: [Errno 22] invalid mode ('rb') or filename: 'c:\\GIT\\pyscratch2\\??\\experiment.py'
IOError
def set_target(kind, parser=(lambda x: x), positional=False): def do(arg, it): options.target_kind = kind target = parser(arg if positional else next(it)) if isinstance(target, bytes): # target may be the code, so, try some additional encodings... try: target = target.decode(sys.getfilesystemencoding()) except UnicodeDecodeError: try: target = target.decode("utf-8") except UnicodeDecodeError: import locale target = target.decode(locale.getpreferredencoding(False)) options.target = target return do
def set_target(kind, parser=(lambda x: x), positional=False): def do(arg, it): options.target_kind = kind options.target = parser(arg if positional else next(it)) return do
https://github.com/microsoft/debugpy/issues/206
Traceback (most recent call last): File "c:/Users/kanadig/.vscode/extensions/ms-python.python-2019.5.17059/pythonFiles/ptvsd_launcher.py", line 43, in <module> main(ptvsdArgs) File "C:\GIT\ptvsd\src\ptvsd\__main__.py", line 434, in main run() File "C:\GIT\ptvsd\src\ptvsd\__main__.py", line 312, in run_file runpy.run_path(target, run_name='__main__') File "C:\Python27\lib\runpy.py", line 251, in run_path code = _get_code_from_file(path_name) File "C:\Python27\lib\runpy.py", line 227, in _get_code_from_file with open(fname, "rb") as f: IOError: [Errno 22] invalid mode ('rb') or filename: 'c:\\GIT\\pyscratch2\\??\\experiment.py'
IOError
def do(arg, it): options.target_kind = kind target = parser(arg if positional else next(it)) if isinstance(target, bytes): # target may be the code, so, try some additional encodings... try: target = target.decode(sys.getfilesystemencoding()) except UnicodeDecodeError: try: target = target.decode("utf-8") except UnicodeDecodeError: import locale target = target.decode(locale.getpreferredencoding(False)) options.target = target
def do(arg, it): options.target_kind = kind options.target = parser(arg if positional else next(it))
https://github.com/microsoft/debugpy/issues/206
Traceback (most recent call last): File "c:/Users/kanadig/.vscode/extensions/ms-python.python-2019.5.17059/pythonFiles/ptvsd_launcher.py", line 43, in <module> main(ptvsdArgs) File "C:\GIT\ptvsd\src\ptvsd\__main__.py", line 434, in main run() File "C:\GIT\ptvsd\src\ptvsd\__main__.py", line 312, in run_file runpy.run_path(target, run_name='__main__') File "C:\Python27\lib\runpy.py", line 251, in run_path code = _get_code_from_file(path_name) File "C:\Python27\lib\runpy.py", line 227, in _get_code_from_file with open(fname, "rb") as f: IOError: [Errno 22] invalid mode ('rb') or filename: 'c:\\GIT\\pyscratch2\\??\\experiment.py'
IOError
def run_file(): target = options.target start_debugging(target) target_as_str = compat.filename_str(target) # run_path has one difference with invoking Python from command-line: # if the target is a file (rather than a directory), it does not add its # parent directory to sys.path. Thus, importing other modules from the # same directory is broken unless sys.path is patched here. if os.path.isfile(target_as_str): dir = os.path.dirname(target_as_str) sys.path.insert(0, dir) else: log.debug("Not a file: {0!r}", target) log.describe_environment("Pre-launch environment:") log.info("Running file {0!r}", target) runpy.run_path(target_as_str, run_name=compat.force_str("__main__"))
def run_file(): start_debugging(options.target) # run_path has one difference with invoking Python from command-line: # if the target is a file (rather than a directory), it does not add its # parent directory to sys.path. Thus, importing other modules from the # same directory is broken unless sys.path is patched here. if os.path.isfile(options.target): dir = os.path.dirname(options.target) sys.path.insert(0, dir) else: log.debug("Not a file: {0!r}", options.target) log.describe_environment("Pre-launch environment:") log.info("Running file {0!r}", options.target) runpy.run_path(options.target, run_name=compat.force_str("__main__"))
https://github.com/microsoft/debugpy/issues/206
Traceback (most recent call last): File "c:/Users/kanadig/.vscode/extensions/ms-python.python-2019.5.17059/pythonFiles/ptvsd_launcher.py", line 43, in <module> main(ptvsdArgs) File "C:\GIT\ptvsd\src\ptvsd\__main__.py", line 434, in main run() File "C:\GIT\ptvsd\src\ptvsd\__main__.py", line 312, in run_file runpy.run_path(target, run_name='__main__') File "C:\Python27\lib\runpy.py", line 251, in run_path code = _get_code_from_file(path_name) File "C:\Python27\lib\runpy.py", line 227, in _get_code_from_file with open(fname, "rb") as f: IOError: [Errno 22] invalid mode ('rb') or filename: 'c:\\GIT\\pyscratch2\\??\\experiment.py'
IOError
def run_module(): # Add current directory to path, like Python itself does for -m. This must # be in place before trying to use find_spec below to resolve submodules. sys.path.insert(0, str("")) # We want to do the same thing that run_module() would do here, without # actually invoking it. On Python 3, it's exposed as a public API, but # on Python 2, we have to invoke a private function in runpy for this. # Either way, if it fails to resolve for any reason, just leave argv as is. argv_0 = sys.argv[0] target_as_str = compat.filename_str(options.target) try: if sys.version_info >= (3,): from importlib.util import find_spec spec = find_spec(target_as_str) if spec is not None: argv_0 = spec.origin else: _, _, _, argv_0 = runpy._get_module_details(target_as_str) except Exception: log.swallow_exception("Error determining module path for sys.argv") start_debugging(argv_0) # On Python 2, module name must be a non-Unicode string, because it ends up # a part of module's __package__, and Python will refuse to run the module # if __package__ is Unicode. log.describe_environment("Pre-launch environment:") log.info("Running module {0!r}", options.target) # Docs say that runpy.run_module is equivalent to -m, but it's not actually # the case for packages - -m sets __name__ to "__main__", but run_module sets # it to "pkg.__main__". This breaks everything that uses the standard pattern # __name__ == "__main__" to detect being run as a CLI app. On the other hand, # runpy._run_module_as_main is a private function that actually implements -m. try: run_module_as_main = runpy._run_module_as_main except AttributeError: log.warning("runpy._run_module_as_main is missing, falling back to run_module.") runpy.run_module(target_as_str, alter_sys=True) else: run_module_as_main(target_as_str, alter_argv=True)
def run_module(): # Add current directory to path, like Python itself does for -m. This must # be in place before trying to use find_spec below to resolve submodules. sys.path.insert(0, "") # We want to do the same thing that run_module() would do here, without # actually invoking it. On Python 3, it's exposed as a public API, but # on Python 2, we have to invoke a private function in runpy for this. # Either way, if it fails to resolve for any reason, just leave argv as is. argv_0 = sys.argv[0] try: if sys.version_info >= (3,): from importlib.util import find_spec spec = find_spec(options.target) if spec is not None: argv_0 = spec.origin else: _, _, _, argv_0 = runpy._get_module_details(options.target) except Exception: log.swallow_exception("Error determining module path for sys.argv") start_debugging(argv_0) # On Python 2, module name must be a non-Unicode string, because it ends up # a part of module's __package__, and Python will refuse to run the module # if __package__ is Unicode. target = ( compat.filename_bytes(options.target) if sys.version_info < (3,) else options.target ) log.describe_environment("Pre-launch environment:") log.info("Running module {0!r}", target) # Docs say that runpy.run_module is equivalent to -m, but it's not actually # the case for packages - -m sets __name__ to "__main__", but run_module sets # it to "pkg.__main__". This breaks everything that uses the standard pattern # __name__ == "__main__" to detect being run as a CLI app. On the other hand, # runpy._run_module_as_main is a private function that actually implements -m. try: run_module_as_main = runpy._run_module_as_main except AttributeError: log.warning("runpy._run_module_as_main is missing, falling back to run_module.") runpy.run_module(target, alter_sys=True) else: run_module_as_main(target, alter_argv=True)
https://github.com/microsoft/debugpy/issues/206
Traceback (most recent call last): File "c:/Users/kanadig/.vscode/extensions/ms-python.python-2019.5.17059/pythonFiles/ptvsd_launcher.py", line 43, in <module> main(ptvsdArgs) File "C:\GIT\ptvsd\src\ptvsd\__main__.py", line 434, in main run() File "C:\GIT\ptvsd\src\ptvsd\__main__.py", line 312, in run_file runpy.run_path(target, run_name='__main__') File "C:\Python27\lib\runpy.py", line 251, in run_path code = _get_code_from_file(path_name) File "C:\Python27\lib\runpy.py", line 227, in _get_code_from_file with open(fname, "rb") as f: IOError: [Errno 22] invalid mode ('rb') or filename: 'c:\\GIT\\pyscratch2\\??\\experiment.py'
IOError
def run_code(): # Add current directory to path, like Python itself does for -c. sys.path.insert(0, str("")) code = compile(options.target, str("<string>"), str("exec")) start_debugging(str("-c")) log.describe_environment("Pre-launch environment:") log.info("Running code:\n\n{0}", options.target) eval(code, {})
def run_code(): # Add current directory to path, like Python itself does for -c. sys.path.insert(0, "") code = compile(options.target, "<string>", "exec") start_debugging("-c") log.describe_environment("Pre-launch environment:") log.info("Running code:\n\n{0}", options.target) eval(code, {})
https://github.com/microsoft/debugpy/issues/206
Traceback (most recent call last): File "c:/Users/kanadig/.vscode/extensions/ms-python.python-2019.5.17059/pythonFiles/ptvsd_launcher.py", line 43, in <module> main(ptvsdArgs) File "C:\GIT\ptvsd\src\ptvsd\__main__.py", line 434, in main run() File "C:\GIT\ptvsd\src\ptvsd\__main__.py", line 312, in run_file runpy.run_path(target, run_name='__main__') File "C:\Python27\lib\runpy.py", line 251, in run_path code = _get_code_from_file(path_name) File "C:\Python27\lib\runpy.py", line 227, in _get_code_from_file with open(fname, "rb") as f: IOError: [Errno 22] invalid mode ('rb') or filename: 'c:\\GIT\\pyscratch2\\??\\experiment.py'
IOError
def main(): original_argv = list(sys.argv) try: parse_argv() except Exception as exc: print(str(HELP) + str("\nError: ") + str(exc), file=sys.stderr) sys.exit(2) if options.log_to is not None: debugpy.log_to(options.log_to) if options.log_to_stderr: debugpy.log_to(sys.stderr) api.ensure_logging() log.info( str("sys.argv before parsing: {0!r}\n after parsing: {1!r}"), original_argv, sys.argv, ) try: run = { "file": run_file, "module": run_module, "code": run_code, "pid": attach_to_pid, }[options.target_kind] run() except SystemExit as exc: log.reraise_exception( "Debuggee exited via SystemExit: {0!r}", exc.code, level="debug" )
def main(): original_argv = list(sys.argv) try: parse_argv() except Exception as exc: print(HELP + "\nError: " + str(exc), file=sys.stderr) sys.exit(2) if options.log_to is not None: debugpy.log_to(options.log_to) if options.log_to_stderr: debugpy.log_to(sys.stderr) api.ensure_logging() log.info( "sys.argv before parsing: {0!r}\n after parsing: {1!r}", original_argv, sys.argv, ) try: run = { "file": run_file, "module": run_module, "code": run_code, "pid": attach_to_pid, }[options.target_kind] run() except SystemExit as exc: log.reraise_exception( "Debuggee exited via SystemExit: {0!r}", exc.code, level="debug" )
https://github.com/microsoft/debugpy/issues/206
Traceback (most recent call last): File "c:/Users/kanadig/.vscode/extensions/ms-python.python-2019.5.17059/pythonFiles/ptvsd_launcher.py", line 43, in <module> main(ptvsdArgs) File "C:\GIT\ptvsd\src\ptvsd\__main__.py", line 434, in main run() File "C:\GIT\ptvsd\src\ptvsd\__main__.py", line 312, in run_file runpy.run_path(target, run_name='__main__') File "C:\Python27\lib\runpy.py", line 251, in run_path code = _get_code_from_file(path_name) File "C:\Python27\lib\runpy.py", line 227, in _get_code_from_file with open(fname, "rb") as f: IOError: [Errno 22] invalid mode ('rb') or filename: 'c:\\GIT\\pyscratch2\\??\\experiment.py'
IOError
def list_all(resolve=False): """Return the list of vendored projects.""" # TODO: Derive from os.listdir(VENDORED_ROOT)? projects = ["pydevd"] if not resolve: return projects return [project_root(name) for name in projects]
def list_all(resolve=False): """Return the list of vendored projects.""" # TODO: Derive from os.listdir(VENDORED_ROOT)? projects = [ "pydevd", ] if not resolve: return projects return [project_root(name) for name in projects]
https://github.com/microsoft/debugpy/issues/475
/usr/bin/env /usr/bin/python3 /Users/jeffery/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/launcher 60731 -- odoo-bin -c odoo.conf ~/git-repo/odoo(master ✗) /usr/bin/env /usr/bin/python3 /Users/jeffery/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/launcher 60731 -- odoo-bin -c odoo.conf Traceback (most recent call last): File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code exec(code, run_globals) File "/Users/jeffery/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/__main__.py", line 43, in <module> from debugpy.server import cli File "/Users/jeffery/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/../debugpy/server/__init__.py", line 9, in <module> import debugpy._vendored.force_pydevd # noqa File "/Users/jeffery/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/../debugpy/_vendored/force_pydevd.py", line 15, in <module> prefix_matcher('pydev', '_pydev')) File "/Users/jeffery/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/../debugpy/_vendored/__init__.py", line 106, in check_modules elif not mod.__file__.startswith(root): AttributeError: 'NoneType' object has no attribute 'startswith'
AttributeError
def project_root(project): """Return the path the root dir of the vendored project. If "project" is an empty string then the path prefix for vendored projects (e.g. "debugpy/_vendored/") will be returned. """ if not project: project = "" return os.path.join(VENDORED_ROOT, project)
def project_root(project): """Return the path the root dir of the vendored project. If "project" is an empty string then the path prefix for vendored projects (e.g. "debugpy/_vendored/") will be returned. """ if not project: project = "" return os.path.join(VENDORED_ROOT, project)
https://github.com/microsoft/debugpy/issues/475
/usr/bin/env /usr/bin/python3 /Users/jeffery/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/launcher 60731 -- odoo-bin -c odoo.conf ~/git-repo/odoo(master ✗) /usr/bin/env /usr/bin/python3 /Users/jeffery/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/launcher 60731 -- odoo-bin -c odoo.conf Traceback (most recent call last): File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code exec(code, run_globals) File "/Users/jeffery/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/__main__.py", line 43, in <module> from debugpy.server import cli File "/Users/jeffery/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/../debugpy/server/__init__.py", line 9, in <module> import debugpy._vendored.force_pydevd # noqa File "/Users/jeffery/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/../debugpy/_vendored/force_pydevd.py", line 15, in <module> prefix_matcher('pydev', '_pydev')) File "/Users/jeffery/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/../debugpy/_vendored/__init__.py", line 106, in check_modules elif not mod.__file__.startswith(root): AttributeError: 'NoneType' object has no attribute 'startswith'
AttributeError
def iter_packaging_files(project): """Yield the filenames for all files in the project. The filenames are relative to "debugpy/_vendored". This is most useful for the "package data" in a setup.py. """ # TODO: Use default filters? __pycache__ and .pyc? prune_dir = None exclude_file = None try: mod = import_module("._{}_packaging".format(project), __name__) except ImportError: pass else: prune_dir = getattr(mod, "prune_dir", prune_dir) exclude_file = getattr(mod, "exclude_file", exclude_file) results = iter_project_files( project, relative=True, prune_dir=prune_dir, exclude_file=exclude_file ) for _, _, filename in results: yield filename
def iter_packaging_files(project): """Yield the filenames for all files in the project. The filenames are relative to "debugpy/_vendored". This is most useful for the "package data" in a setup.py. """ # TODO: Use default filters? __pycache__ and .pyc? prune_dir = None exclude_file = None try: mod = import_module("._{}_packaging".format(project), __name__) except ImportError: pass else: prune_dir = getattr(mod, "prune_dir", prune_dir) exclude_file = getattr(mod, "exclude_file", exclude_file) results = iter_project_files( project, relative=True, prune_dir=prune_dir, exclude_file=exclude_file, ) for _, _, filename in results: yield filename
https://github.com/microsoft/debugpy/issues/475
/usr/bin/env /usr/bin/python3 /Users/jeffery/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/launcher 60731 -- odoo-bin -c odoo.conf ~/git-repo/odoo(master ✗) /usr/bin/env /usr/bin/python3 /Users/jeffery/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/launcher 60731 -- odoo-bin -c odoo.conf Traceback (most recent call last): File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code exec(code, run_globals) File "/Users/jeffery/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/__main__.py", line 43, in <module> from debugpy.server import cli File "/Users/jeffery/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/../debugpy/server/__init__.py", line 9, in <module> import debugpy._vendored.force_pydevd # noqa File "/Users/jeffery/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/../debugpy/_vendored/force_pydevd.py", line 15, in <module> prefix_matcher('pydev', '_pydev')) File "/Users/jeffery/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/../debugpy/_vendored/__init__.py", line 106, in check_modules elif not mod.__file__.startswith(root): AttributeError: 'NoneType' object has no attribute 'startswith'
AttributeError
def check_modules(project, match, root=None): """Verify that only vendored modules have been imported.""" if root is None: root = project_root(project) extensions = [] unvendored = {} for modname, mod in list(sys.modules.items()): if not match(modname, mod): continue try: filename = getattr(mod, "__file__", None) except: # In theory it's possible that any error is raised when accessing __file__ filename = None if not filename: # extension module extensions.append(modname) elif not filename.startswith(root): unvendored[modname] = filename return unvendored, extensions
def check_modules(project, match, root=None): """Verify that only vendored modules have been imported.""" if root is None: root = project_root(project) extensions = [] unvendored = {} for modname, mod in list(sys.modules.items()): if not match(modname, mod): continue if not hasattr(mod, "__file__"): # extension module extensions.append(modname) elif not mod.__file__.startswith(root): unvendored[modname] = mod.__file__ return unvendored, extensions
https://github.com/microsoft/debugpy/issues/475
/usr/bin/env /usr/bin/python3 /Users/jeffery/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/launcher 60731 -- odoo-bin -c odoo.conf ~/git-repo/odoo(master ✗) /usr/bin/env /usr/bin/python3 /Users/jeffery/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/launcher 60731 -- odoo-bin -c odoo.conf Traceback (most recent call last): File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code exec(code, run_globals) File "/Users/jeffery/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/__main__.py", line 43, in <module> from debugpy.server import cli File "/Users/jeffery/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/../debugpy/server/__init__.py", line 9, in <module> import debugpy._vendored.force_pydevd # noqa File "/Users/jeffery/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/../debugpy/_vendored/force_pydevd.py", line 15, in <module> prefix_matcher('pydev', '_pydev')) File "/Users/jeffery/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/../debugpy/_vendored/__init__.py", line 106, in check_modules elif not mod.__file__.startswith(root): AttributeError: 'NoneType' object has no attribute 'startswith'
AttributeError
def get_file(mod): f = None try: f = inspect.getsourcefile(mod) or inspect.getfile(mod) except: try: f = getattr(mod, "__file__", None) except: f = None if f and f.lower(f[-4:]) in [".pyc", ".pyo"]: filename = f[:-4] + ".py" if os.path.exists(filename): f = filename return f
def get_file(mod): f = None try: f = inspect.getsourcefile(mod) or inspect.getfile(mod) except: if hasattr_checked(mod, "__file__"): f = mod.__file__ if f.lower(f[-4:]) in [".pyc", ".pyo"]: filename = f[:-4] + ".py" if os.path.exists(filename): f = filename return f
https://github.com/microsoft/debugpy/issues/475
/usr/bin/env /usr/bin/python3 /Users/jeffery/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/launcher 60731 -- odoo-bin -c odoo.conf ~/git-repo/odoo(master ✗) /usr/bin/env /usr/bin/python3 /Users/jeffery/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/launcher 60731 -- odoo-bin -c odoo.conf Traceback (most recent call last): File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code exec(code, run_globals) File "/Users/jeffery/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/__main__.py", line 43, in <module> from debugpy.server import cli File "/Users/jeffery/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/../debugpy/server/__init__.py", line 9, in <module> import debugpy._vendored.force_pydevd # noqa File "/Users/jeffery/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/../debugpy/_vendored/force_pydevd.py", line 15, in <module> prefix_matcher('pydev', '_pydev')) File "/Users/jeffery/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/../debugpy/_vendored/__init__.py", line 106, in check_modules elif not mod.__file__.startswith(root): AttributeError: 'NoneType' object has no attribute 'startswith'
AttributeError
def Find(name): f = None if name.startswith("__builtin__"): if name == "__builtin__.str": name = "org.python.core.PyString" elif name == "__builtin__.dict": name = "org.python.core.PyDictionary" mod = _imp(name) parent = mod foundAs = "" try: f = getattr(mod, "__file__", None) except: f = None components = name.split(".") old_comp = None for comp in components[1:]: try: # this happens in the following case: # we have mx.DateTime.mxDateTime.mxDateTime.pyd # but after importing it, mx.DateTime.mxDateTime does shadows access to mxDateTime.pyd mod = getattr(mod, comp) except AttributeError: if old_comp != comp: raise if hasattr(mod, "__file__"): f = mod.__file__ else: if len(foundAs) > 0: foundAs = foundAs + "." foundAs = foundAs + comp old_comp = comp if f is None and name.startswith("java.lang"): # Hack: java.lang.__file__ is None on Jython 2.7 (whereas it pointed to rt.jar on Jython 2.5). f = _java_rt_file if f is not None: if f.endswith(".pyc"): f = f[:-1] elif f.endswith("$py.class"): f = f[: -len("$py.class")] + ".py" return f, mod, parent, foundAs
def Find(name): f = None if name.startswith("__builtin__"): if name == "__builtin__.str": name = "org.python.core.PyString" elif name == "__builtin__.dict": name = "org.python.core.PyDictionary" mod = _imp(name) parent = mod foundAs = "" if hasattr(mod, "__file__"): f = mod.__file__ components = name.split(".") old_comp = None for comp in components[1:]: try: # this happens in the following case: # we have mx.DateTime.mxDateTime.mxDateTime.pyd # but after importing it, mx.DateTime.mxDateTime does shadows access to mxDateTime.pyd mod = getattr(mod, comp) except AttributeError: if old_comp != comp: raise if hasattr(mod, "__file__"): f = mod.__file__ else: if len(foundAs) > 0: foundAs = foundAs + "." foundAs = foundAs + comp old_comp = comp if f is None and name.startswith("java.lang"): # Hack: java.lang.__file__ is None on Jython 2.7 (whereas it pointed to rt.jar on Jython 2.5). f = _java_rt_file if f is not None: if f.endswith(".pyc"): f = f[:-1] elif f.endswith("$py.class"): f = f[: -len("$py.class")] + ".py" return f, mod, parent, foundAs
https://github.com/microsoft/debugpy/issues/475
/usr/bin/env /usr/bin/python3 /Users/jeffery/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/launcher 60731 -- odoo-bin -c odoo.conf ~/git-repo/odoo(master ✗) /usr/bin/env /usr/bin/python3 /Users/jeffery/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/launcher 60731 -- odoo-bin -c odoo.conf Traceback (most recent call last): File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code exec(code, run_globals) File "/Users/jeffery/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/__main__.py", line 43, in <module> from debugpy.server import cli File "/Users/jeffery/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/../debugpy/server/__init__.py", line 9, in <module> import debugpy._vendored.force_pydevd # noqa File "/Users/jeffery/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/../debugpy/_vendored/force_pydevd.py", line 15, in <module> prefix_matcher('pydev', '_pydev')) File "/Users/jeffery/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/../debugpy/_vendored/__init__.py", line 106, in check_modules elif not mod.__file__.startswith(root): AttributeError: 'NoneType' object has no attribute 'startswith'
AttributeError
def on_setexceptionbreakpoints_request(self, py_db, request): """ :param SetExceptionBreakpointsRequest request: """ # : :type arguments: SetExceptionBreakpointsArguments arguments = request.arguments filters = arguments.filters exception_options = arguments.exceptionOptions self.api.remove_all_exception_breakpoints(py_db) # Can't set these in the DAP. condition = None expression = None notify_on_first_raise_only = False ignore_libraries = 1 if py_db.get_use_libraries_filter() else 0 if exception_options: break_raised = False break_uncaught = False for option in exception_options: option = ExceptionOptions(**option) if not option.path: continue # never: never breaks # # always: always breaks # # unhandled: breaks when exception unhandled # # userUnhandled: breaks if the exception is not handled by user code notify_on_handled_exceptions = 1 if option.breakMode == "always" else 0 notify_on_unhandled_exceptions = ( 1 if option.breakMode in ("unhandled", "userUnhandled") else 0 ) exception_paths = option.path break_raised |= notify_on_handled_exceptions break_uncaught |= notify_on_unhandled_exceptions exception_names = [] if len(exception_paths) == 0: continue elif len(exception_paths) == 1: if "Python Exceptions" in exception_paths[0]["names"]: exception_names = ["BaseException"] else: path_iterator = iter(exception_paths) if "Python Exceptions" in next(path_iterator)["names"]: for path in path_iterator: for ex_name in path["names"]: exception_names.append(ex_name) for exception_name in exception_names: self.api.add_python_exception_breakpoint( py_db, exception_name, condition, expression, notify_on_handled_exceptions, notify_on_unhandled_exceptions, notify_on_first_raise_only, ignore_libraries, ) else: break_raised = "raised" in filters break_uncaught = "uncaught" in filters if break_raised or break_uncaught: notify_on_handled_exceptions = 1 if break_raised else 0 notify_on_unhandled_exceptions = 1 if break_uncaught else 0 exception = "BaseException" self.api.add_python_exception_breakpoint( py_db, exception, condition, expression, notify_on_handled_exceptions, notify_on_unhandled_exceptions, notify_on_first_raise_only, ignore_libraries, ) if break_raised: btype = None if self._options.django_debug: btype = "django" elif self._options.flask_debug: btype = "jinja2" if btype: self.api.add_plugins_exception_breakpoint( py_db, btype, "BaseException" ) # Note: Exception name could be anything here. # Note: no body required on success. set_breakpoints_response = pydevd_base_schema.build_response(request) return NetCommand(CMD_RETURN, 0, set_breakpoints_response, is_json=True)
def on_setexceptionbreakpoints_request(self, py_db, request): """ :param SetExceptionBreakpointsRequest request: """ # : :type arguments: SetExceptionBreakpointsArguments arguments = request.arguments filters = arguments.filters exception_options = arguments.exceptionOptions self.api.remove_all_exception_breakpoints(py_db) # Can't set these in the DAP. condition = None expression = None notify_on_first_raise_only = False ignore_libraries = 1 if py_db.get_use_libraries_filter() else 0 if exception_options: break_raised = True break_uncaught = True for option in exception_options: option = ExceptionOptions(**option) if not option.path: continue notify_on_handled_exceptions = 1 if option.breakMode == "always" else 0 notify_on_unhandled_exceptions = ( 1 if option.breakMode in ("unhandled", "userUnhandled") else 0 ) exception_paths = option.path exception_names = [] if len(exception_paths) == 0: continue elif len(exception_paths) == 1: if "Python Exceptions" in exception_paths[0]["names"]: exception_names = ["BaseException"] else: path_iterator = iter(exception_paths) if "Python Exceptions" in next(path_iterator)["names"]: for path in path_iterator: for ex_name in path["names"]: exception_names.append(ex_name) for exception_name in exception_names: self.api.add_python_exception_breakpoint( py_db, exception_name, condition, expression, notify_on_handled_exceptions, notify_on_unhandled_exceptions, notify_on_first_raise_only, ignore_libraries, ) else: break_raised = "raised" in filters break_uncaught = "uncaught" in filters if break_raised or break_uncaught: notify_on_handled_exceptions = 1 if break_raised else 0 notify_on_unhandled_exceptions = 1 if break_uncaught else 0 exception = "BaseException" self.api.add_python_exception_breakpoint( py_db, exception, condition, expression, notify_on_handled_exceptions, notify_on_unhandled_exceptions, notify_on_first_raise_only, ignore_libraries, ) if break_raised or break_uncaught: btype = None if self._options.django_debug: btype = "django" elif self._options.flask_debug: btype = "jinja2" if btype: self.api.add_plugins_exception_breakpoint( py_db, btype, "BaseException" ) # Note: Exception name could be anything here. # Note: no body required on success. set_breakpoints_response = pydevd_base_schema.build_response(request) return NetCommand(CMD_RETURN, 0, set_breakpoints_response, is_json=True)
https://github.com/microsoft/debugpy/issues/128
---------------------------------------- Exception happened during processing of request from ('127.0.0.1', 59880) [20/Feb/2020 20:57:16] "GET /ajax/ing/setup/json/ HTTP/1.1" 200 712 Traceback (most recent call last): File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\socketserver.py", line 650, in process_request_thread self.finish_request(request, client_address) File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\socketserver.py", line 360, in finish_request self. RequestHandlerClass(request, client_address, self) File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\socketserver.py", line 720, in __init__ self.handle() File "[venvpath]\lib\site-packages\django\core\servers\basehttp.py", line 174, in handle self.handle_one_request() File "[venvpath]\lib\site-packages\django\core\servers\basehttp.py", line 182, in handle_one_request self.raw_requestline = self.rfile.readline(65537) File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\socket.py", line 589, in readinto return self._sock.recv_into(b) ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine ----------------------------------------
ConnectionAbortedError
def trace_dispatch(self, frame, event, arg): # ENDIF # Note: this is a big function because most of the logic related to hitting a breakpoint and # stepping is contained in it. Ideally this could be split among multiple functions, but the # problem in this case is that in pure-python function calls are expensive and even more so # when tracing is on (because each function call will get an additional tracing call). We # try to address this by using the info.is_tracing for the fastest possible return, but the # cost is still high (maybe we could use code-generation in the future and make the code # generation be better split among what each part does). # DEBUG = '_debugger_case_generator.py' in frame.f_code.co_filename main_debugger, filename, info, thread, frame_skips_cache, frame_cache_key = ( self._args ) # if DEBUG: print('frame trace_dispatch %s %s %s %s %s %s, stop: %s' % (frame.f_lineno, frame.f_code.co_name, frame.f_code.co_filename, event, constant_to_str(info.pydev_step_cmd), arg, info.pydev_step_stop)) try: info.is_tracing += 1 line = frame.f_lineno line_cache_key = (frame_cache_key, line) if main_debugger.pydb_disposed: return None if event == "call" else NO_FTRACE plugin_manager = main_debugger.plugin has_exception_breakpoints = ( main_debugger.break_on_caught_exceptions or main_debugger.has_plugin_exception_breaks ) stop_frame = info.pydev_step_stop step_cmd = info.pydev_step_cmd if ( frame.f_code.co_flags & 0xA0 ): # 0xa0 == CO_GENERATOR = 0x20 | CO_COROUTINE = 0x80 # Dealing with coroutines and generators: # When in a coroutine we change the perceived event to the debugger because # a call, StopIteration exception and return are usually just pausing/unpausing it. if event == "line": is_line = True is_call = False is_return = False is_exception_event = False elif event == "return": is_line = False is_call = False is_return = True is_exception_event = False returns_cache_key = (frame_cache_key, "returns") return_lines = frame_skips_cache.get(returns_cache_key) if return_lines is None: # Note: we're collecting the return lines by inspecting the bytecode as # there are multiple returns and multiple stop iterations when awaiting and # it doesn't give any clear indication when a coroutine or generator is # finishing or just pausing. return_lines = set() for x in main_debugger.collect_return_info(frame.f_code): # Note: cython does not support closures in cpdefs (so we can't use # a list comprehension). return_lines.add(x.return_line) frame_skips_cache[returns_cache_key] = return_lines if line not in return_lines: # Not really a return (coroutine/generator paused). return self.trace_dispatch else: # Tricky handling: usually when we're on a frame which is about to exit # we set the step mode to step into, but in this case we'd end up in the # asyncio internal machinery, which is not what we want, so, we just # ask the stop frame to be a level up. # # Note that there's an issue here which we may want to fix in the future: if # the back frame is a frame which is filtered, we won't stop properly. # Solving this may not be trivial as we'd need to put a scope in the step # in, but we may have to do it anyways to have a step in which doesn't end # up in asyncio). if stop_frame is frame: if step_cmd in ( CMD_STEP_OVER, CMD_STEP_OVER_MY_CODE, CMD_STEP_INTO, CMD_STEP_INTO_MY_CODE, ): f = self._get_unfiltered_back_frame(main_debugger, frame) if f is not None: info.pydev_step_cmd = CMD_STEP_INTO_COROUTINE info.pydev_step_stop = f else: if step_cmd == CMD_STEP_OVER: info.pydev_step_cmd = CMD_STEP_INTO info.pydev_step_stop = None elif step_cmd == CMD_STEP_OVER_MY_CODE: info.pydev_step_cmd = CMD_STEP_INTO_MY_CODE info.pydev_step_stop = None elif step_cmd == CMD_STEP_INTO_COROUTINE: # We're exiting this one, so, mark the new coroutine context. f = self._get_unfiltered_back_frame(main_debugger, frame) if f is not None: info.pydev_step_stop = f else: info.pydev_step_cmd = CMD_STEP_INTO info.pydev_step_stop = None elif event == "exception": breakpoints_for_file = None if has_exception_breakpoints: should_stop, frame = self.should_stop_on_exception( frame, event, arg ) if should_stop: self.handle_exception(frame, event, arg) return self.trace_dispatch return self.trace_dispatch else: # event == 'call' or event == 'c_XXX' return self.trace_dispatch else: if event == "line": is_line = True is_call = False is_return = False is_exception_event = False elif event == "return": is_line = False is_return = True is_call = False is_exception_event = False # If we are in single step mode and something causes us to exit the current frame, we need to make sure we break # eventually. Force the step mode to step into and the step stop frame to None. # I.e.: F6 in the end of a function should stop in the next possible position (instead of forcing the user # to make a step in or step over at that location). # Note: this is especially troublesome when we're skipping code with the # @DontTrace comment. if ( stop_frame is frame and is_return and step_cmd in ( CMD_STEP_OVER, CMD_STEP_RETURN, CMD_STEP_OVER_MY_CODE, CMD_STEP_RETURN_MY_CODE, ) ): if step_cmd in (CMD_STEP_OVER, CMD_STEP_RETURN): info.pydev_step_cmd = CMD_STEP_INTO else: info.pydev_step_cmd = CMD_STEP_INTO_MY_CODE info.pydev_step_stop = None elif event == "call": is_line = False is_call = True is_return = False is_exception_event = False elif event == "exception": is_exception_event = True breakpoints_for_file = None if has_exception_breakpoints: should_stop, frame = self.should_stop_on_exception( frame, event, arg ) if should_stop: self.handle_exception(frame, event, arg) return self.trace_dispatch is_line = False is_return = False is_call = False else: # Unexpected: just keep the same trace func (i.e.: event == 'c_XXX'). return self.trace_dispatch if not is_exception_event: breakpoints_for_file = main_debugger.breakpoints.get(filename) can_skip = False if info.pydev_state == 1: # STATE_RUN = 1 # we can skip if: # - we have no stop marked # - we should make a step return/step over and we're not in the current frame # - we're stepping into a coroutine context and we're not in that context if step_cmd == -1: can_skip = True elif ( step_cmd in ( CMD_STEP_OVER, CMD_STEP_RETURN, CMD_STEP_OVER_MY_CODE, CMD_STEP_RETURN_MY_CODE, ) and stop_frame is not frame ): can_skip = True elif step_cmd == CMD_STEP_INTO_MY_CODE: if main_debugger.apply_files_filter( frame, frame.f_code.co_filename, True ) and ( frame.f_back is None or main_debugger.apply_files_filter( frame.f_back, frame.f_back.f_code.co_filename, True ) ): can_skip = True elif step_cmd == CMD_STEP_INTO_COROUTINE: f = frame while f is not None: if f is stop_frame: break f = f.f_back else: can_skip = True if can_skip: if plugin_manager is not None and ( main_debugger.has_plugin_line_breaks or main_debugger.has_plugin_exception_breaks ): can_skip = plugin_manager.can_skip(main_debugger, frame) if ( can_skip and main_debugger.show_return_values and info.pydev_step_cmd in (CMD_STEP_OVER, CMD_STEP_OVER_MY_CODE) and frame.f_back is stop_frame ): # trace function for showing return values after step over can_skip = False # Let's check to see if we are in a function that has a breakpoint. If we don't have a breakpoint, # we will return nothing for the next trace # also, after we hit a breakpoint and go to some other debugging state, we have to force the set trace anyway, # so, that's why the additional checks are there. if not breakpoints_for_file: if can_skip: if has_exception_breakpoints: return self.trace_exception else: return None if is_call else NO_FTRACE else: # When cached, 0 means we don't have a breakpoint and 1 means we have. if can_skip: breakpoints_in_line_cache = frame_skips_cache.get( line_cache_key, -1 ) if breakpoints_in_line_cache == 0: return self.trace_dispatch breakpoints_in_frame_cache = frame_skips_cache.get(frame_cache_key, -1) if breakpoints_in_frame_cache != -1: # Gotten from cache. has_breakpoint_in_frame = breakpoints_in_frame_cache == 1 else: has_breakpoint_in_frame = False func_lines = _get_func_lines(frame.f_code) if func_lines is None: # This is a fallback for implementations where we can't get the function # lines -- i.e.: jython (in this case clients need to provide the function # name to decide on the skip or we won't be able to skip the function # completely). # Checks the breakpoint to see if there is a context match in some function. curr_func_name = frame.f_code.co_name # global context is set with an empty name if curr_func_name in ("?", "<module>", "<lambda>"): curr_func_name = "" for bp in dict_iter_values( breakpoints_for_file ): # jython does not support itervalues() # will match either global or some function if bp.func_name in ("None", curr_func_name): has_breakpoint_in_frame = True break else: for bp_line in breakpoints_for_file: # iterate on keys if bp_line in func_lines: has_breakpoint_in_frame = True break # Cache the value (1 or 0 or -1 for default because of cython). if has_breakpoint_in_frame: frame_skips_cache[frame_cache_key] = 1 else: frame_skips_cache[frame_cache_key] = 0 if can_skip and not has_breakpoint_in_frame: if has_exception_breakpoints: return self.trace_exception else: return None if is_call else NO_FTRACE # We may have hit a breakpoint or we are already in step mode. Either way, let's check what we should do in this frame # if DEBUG: print('NOT skipped: %s %s %s %s' % (frame.f_lineno, frame.f_code.co_name, event, frame.__class__.__name__)) try: flag = False # return is not taken into account for breakpoint hit because we'd have a double-hit in this case # (one for the line and the other for the return). stop_info = {} breakpoint = None exist_result = False stop = False bp_type = None if ( not is_return and info.pydev_state != STATE_SUSPEND and breakpoints_for_file is not None and line in breakpoints_for_file ): breakpoint = breakpoints_for_file[line] new_frame = frame stop = True if step_cmd in (CMD_STEP_OVER, CMD_STEP_OVER_MY_CODE) and ( stop_frame is frame and is_line ): stop = False # we don't stop on breakpoint if we have to stop by step-over (it will be processed later) elif plugin_manager is not None and main_debugger.has_plugin_line_breaks: result = plugin_manager.get_breakpoint( main_debugger, self, frame, event, self._args ) if result: exist_result = True flag, breakpoint, new_frame, bp_type = result if breakpoint: # ok, hit breakpoint, now, we have to discover if it is a conditional breakpoint # lets do the conditional stuff here if stop or exist_result: eval_result = False if breakpoint.has_condition: eval_result = main_debugger.handle_breakpoint_condition( info, breakpoint, new_frame ) if breakpoint.expression is not None: main_debugger.handle_breakpoint_expression( breakpoint, info, new_frame ) if ( breakpoint.is_logpoint and info.pydev_message is not None and len(info.pydev_message) > 0 ): cmd = main_debugger.cmd_factory.make_io_message( info.pydev_message + os.linesep, "1" ) main_debugger.writer.add_command(cmd) if breakpoint.has_condition: if not eval_result: stop = False elif breakpoint.is_logpoint: stop = False if is_call and frame.f_code.co_name in ("<module>", "<lambda>"): # If we find a call for a module, it means that the module is being imported/executed for the # first time. In this case we have to ignore this hit as it may later duplicated by a # line event at the same place (so, if there's a module with a print() in the first line # the user will hit that line twice, which is not what we want). # # As for lambda, as it only has a single statement, it's not interesting to trace # its call and later its line event as they're usually in the same line. return self.trace_dispatch if main_debugger.show_return_values: if is_return and ( ( info.pydev_step_cmd in (CMD_STEP_OVER, CMD_STEP_OVER_MY_CODE) and (frame.f_back is stop_frame) ) or ( info.pydev_step_cmd in (CMD_STEP_RETURN, CMD_STEP_RETURN_MY_CODE) and (frame is stop_frame) ) or (info.pydev_step_cmd in (CMD_STEP_INTO, CMD_STEP_INTO_COROUTINE)) or ( info.pydev_step_cmd == CMD_STEP_INTO_MY_CODE and frame.f_back is not None and not main_debugger.apply_files_filter( frame.f_back, frame.f_back.f_code.co_filename, True ) ) ): self.show_return_values(frame, arg) elif main_debugger.remove_return_values_flag: try: self.remove_return_values(main_debugger, frame) finally: main_debugger.remove_return_values_flag = False if stop: self.set_suspend( thread, CMD_SET_BREAK, suspend_other_threads=breakpoint and breakpoint.suspend_policy == "ALL", ) elif flag and plugin_manager is not None: result = plugin_manager.suspend(main_debugger, thread, frame, bp_type) if result: frame = result # if thread has a suspend flag, we suspend with a busy wait if info.pydev_state == STATE_SUSPEND: self.do_wait_suspend(thread, frame, event, arg) return self.trace_dispatch else: if not breakpoint and is_line: # No stop from anyone and no breakpoint found in line (cache that). frame_skips_cache[line_cache_key] = 0 except: pydev_log.exception() raise # step handling. We stop when we hit the right frame try: should_skip = 0 if pydevd_dont_trace.should_trace_hook is not None: if self.should_skip == -1: # I.e.: cache the result on self.should_skip (no need to evaluate the same frame multiple times). # Note that on a code reload, we won't re-evaluate this because in practice, the frame.f_code # Which will be handled by this frame is read-only, so, we can cache it safely. if not pydevd_dont_trace.should_trace_hook(frame, filename): # -1, 0, 1 to be Cython-friendly should_skip = self.should_skip = 1 else: should_skip = self.should_skip = 0 else: should_skip = self.should_skip plugin_stop = False if should_skip: stop = False elif step_cmd in ( CMD_STEP_INTO, CMD_STEP_INTO_MY_CODE, CMD_STEP_INTO_COROUTINE, ): force_check_project_scope = step_cmd == CMD_STEP_INTO_MY_CODE if is_line: if ( force_check_project_scope or main_debugger.is_files_filter_enabled ): stop = not main_debugger.apply_files_filter( frame, frame.f_code.co_filename, force_check_project_scope ) else: stop = True elif is_return and frame.f_back is not None: if ( main_debugger.get_file_type(frame.f_back) == main_debugger.PYDEV_FILE ): stop = False else: if ( force_check_project_scope or main_debugger.is_files_filter_enabled ): stop = not main_debugger.apply_files_filter( frame.f_back, frame.f_back.f_code.co_filename, force_check_project_scope, ) else: stop = True else: stop = False if stop: if step_cmd == CMD_STEP_INTO_COROUTINE: # i.e.: Check if we're stepping into the proper context. f = frame while f is not None: if f is stop_frame: break f = f.f_back else: stop = False if plugin_manager is not None: result = plugin_manager.cmd_step_into( main_debugger, frame, event, self._args, stop_info, stop ) if result: stop, plugin_stop = result elif step_cmd in (CMD_STEP_OVER, CMD_STEP_OVER_MY_CODE): # Note: when dealing with a step over my code it's the same as a step over (the # difference is that when we return from a frame in one we go to regular step # into and in the other we go to a step into my code). stop = stop_frame is frame and is_line # Note: don't stop on a return for step over, only for line events # i.e.: don't stop in: (stop_frame is frame.f_back and is_return) as we'd stop twice in that line. if plugin_manager is not None: result = plugin_manager.cmd_step_over( main_debugger, frame, event, self._args, stop_info, stop ) if result: stop, plugin_stop = result elif step_cmd == CMD_SMART_STEP_INTO: stop = False if info.pydev_smart_step_stop is frame: info.pydev_func_name = ".invalid." # Must match the type in cython info.pydev_smart_step_stop = None if is_line or is_exception_event: curr_func_name = frame.f_code.co_name # global context is set with an empty name if curr_func_name in ("?", "<module>") or curr_func_name is None: curr_func_name = "" if curr_func_name == info.pydev_func_name: stop = True elif step_cmd in (CMD_STEP_RETURN, CMD_STEP_RETURN_MY_CODE): stop = is_return and stop_frame is frame else: stop = False if ( stop and step_cmd != -1 and is_return and IS_PY3K and hasattr(frame, "f_back") ): f_code = getattr(frame.f_back, "f_code", None) if f_code is not None: if ( main_debugger.get_file_type(frame.f_back) == main_debugger.PYDEV_FILE ): stop = False if plugin_stop: stopped_on_plugin = plugin_manager.stop( main_debugger, frame, event, self._args, stop_info, arg, step_cmd ) elif stop: if is_line: self.set_suspend( thread, step_cmd, original_step_cmd=info.pydev_original_step_cmd ) self.do_wait_suspend(thread, frame, event, arg) elif is_return: # return event back = frame.f_back if back is not None: # When we get to the pydevd run function, the debugging has actually finished for the main thread # (note that it can still go on for other threads, but for this one, we just make it finish) # So, just setting it to None should be OK _, back_filename, base = ( get_abs_path_real_path_and_base_from_frame(back) ) if (base, back.f_code.co_name) in ( DEBUG_START, DEBUG_START_PY3K, ): back = None elif base == TRACE_PROPERTY: # We dont want to trace the return event of pydevd_traceproperty (custom property for debugging) # if we're in a return, we want it to appear to the user in the previous frame! return None if is_call else NO_FTRACE elif pydevd_dont_trace.should_trace_hook is not None: if not pydevd_dont_trace.should_trace_hook( back, back_filename ): # In this case, we'll have to skip the previous one because it shouldn't be traced. # Also, we have to reset the tracing, because if the parent's parent (or some # other parent) has to be traced and it's not currently, we wouldn't stop where # we should anymore (so, a step in/over/return may not stop anywhere if no parent is traced). # Related test: _debugger_case17a.py main_debugger.set_trace_for_frame_and_parents(back) return None if is_call else NO_FTRACE if back is not None: # if we're in a return, we want it to appear to the user in the previous frame! self.set_suspend( thread, step_cmd, original_step_cmd=info.pydev_original_step_cmd, ) self.do_wait_suspend(thread, back, event, arg) else: # in jython we may not have a back frame info.pydev_step_stop = None info.pydev_original_step_cmd = -1 info.pydev_step_cmd = -1 info.pydev_state = STATE_RUN except KeyboardInterrupt: raise except: try: pydev_log.exception() info.pydev_original_step_cmd = -1 info.pydev_step_cmd = -1 info.pydev_step_stop = None except: return None if is_call else NO_FTRACE # if we are quitting, let's stop the tracing if not main_debugger.quitting: return self.trace_dispatch else: return None if is_call else NO_FTRACE finally: info.is_tracing -= 1
def trace_dispatch(self, frame, event, arg): # ENDIF # Note: this is a big function because most of the logic related to hitting a breakpoint and # stepping is contained in it. Ideally this could be split among multiple functions, but the # problem in this case is that in pure-python function calls are expensive and even more so # when tracing is on (because each function call will get an additional tracing call). We # try to address this by using the info.is_tracing for the fastest possible return, but the # cost is still high (maybe we could use code-generation in the future and make the code # generation be better split among what each part does). # DEBUG = '_debugger_case_generator.py' in frame.f_code.co_filename main_debugger, filename, info, thread, frame_skips_cache, frame_cache_key = ( self._args ) # if DEBUG: print('frame trace_dispatch %s %s %s %s %s %s, stop: %s' % (frame.f_lineno, frame.f_code.co_name, frame.f_code.co_filename, event, constant_to_str(info.pydev_step_cmd), arg, info.pydev_step_stop)) try: info.is_tracing += 1 line = frame.f_lineno line_cache_key = (frame_cache_key, line) if main_debugger.pydb_disposed: return None if event == "call" else NO_FTRACE plugin_manager = main_debugger.plugin has_exception_breakpoints = ( main_debugger.break_on_caught_exceptions or main_debugger.has_plugin_exception_breaks ) stop_frame = info.pydev_step_stop step_cmd = info.pydev_step_cmd if ( frame.f_code.co_flags & 0xA0 ): # 0xa0 == CO_GENERATOR = 0x20 | CO_COROUTINE = 0x80 # Dealing with coroutines and generators: # When in a coroutine we change the perceived event to the debugger because # a call, StopIteration exception and return are usually just pausing/unpausing it. if event == "line": is_line = True is_call = False is_return = False is_exception_event = False elif event == "return": is_line = False is_call = False is_return = True is_exception_event = False returns_cache_key = (frame_cache_key, "returns") return_lines = frame_skips_cache.get(returns_cache_key) if return_lines is None: # Note: we're collecting the return lines by inspecting the bytecode as # there are multiple returns and multiple stop iterations when awaiting and # it doesn't give any clear indication when a coroutine or generator is # finishing or just pausing. return_lines = set() for x in main_debugger.collect_return_info(frame.f_code): # Note: cython does not support closures in cpdefs (so we can't use # a list comprehension). return_lines.add(x.return_line) frame_skips_cache[returns_cache_key] = return_lines if line not in return_lines: # Not really a return (coroutine/generator paused). return self.trace_dispatch else: # Tricky handling: usually when we're on a frame which is about to exit # we set the step mode to step into, but in this case we'd end up in the # asyncio internal machinery, which is not what we want, so, we just # ask the stop frame to be a level up. # # Note that there's an issue here which we may want to fix in the future: if # the back frame is a frame which is filtered, we won't stop properly. # Solving this may not be trivial as we'd need to put a scope in the step # in, but we may have to do it anyways to have a step in which doesn't end # up in asyncio). if stop_frame is frame: if step_cmd in ( CMD_STEP_OVER, CMD_STEP_OVER_MY_CODE, CMD_STEP_INTO, CMD_STEP_INTO_MY_CODE, ): f = self._get_unfiltered_back_frame(main_debugger, frame) if f is not None: info.pydev_step_cmd = CMD_STEP_INTO_COROUTINE info.pydev_step_stop = f else: if step_cmd == CMD_STEP_OVER: info.pydev_step_cmd = CMD_STEP_INTO info.pydev_step_stop = None elif step_cmd == CMD_STEP_OVER_MY_CODE: info.pydev_step_cmd = CMD_STEP_INTO_MY_CODE info.pydev_step_stop = None elif step_cmd == CMD_STEP_INTO_COROUTINE: # We're exiting this one, so, mark the new coroutine context. f = self._get_unfiltered_back_frame(main_debugger, frame) if f is not None: info.pydev_step_stop = f else: info.pydev_step_cmd = CMD_STEP_INTO info.pydev_step_stop = None elif event == "exception": breakpoints_for_file = None if has_exception_breakpoints: should_stop, frame = self.should_stop_on_exception( frame, event, arg ) if should_stop: self.handle_exception(frame, event, arg) return self.trace_dispatch return self.trace_dispatch else: # event == 'call' or event == 'c_XXX' return self.trace_dispatch else: if event == "line": is_line = True is_call = False is_return = False is_exception_event = False elif event == "return": is_line = False is_return = True is_call = False is_exception_event = False # If we are in single step mode and something causes us to exit the current frame, we need to make sure we break # eventually. Force the step mode to step into and the step stop frame to None. # I.e.: F6 in the end of a function should stop in the next possible position (instead of forcing the user # to make a step in or step over at that location). # Note: this is especially troublesome when we're skipping code with the # @DontTrace comment. if ( stop_frame is frame and is_return and step_cmd in ( CMD_STEP_OVER, CMD_STEP_RETURN, CMD_STEP_OVER_MY_CODE, CMD_STEP_RETURN_MY_CODE, ) ): if step_cmd in (CMD_STEP_OVER, CMD_STEP_RETURN): info.pydev_step_cmd = CMD_STEP_INTO else: info.pydev_step_cmd = CMD_STEP_INTO_MY_CODE info.pydev_step_stop = None elif event == "call": is_line = False is_call = True is_return = False is_exception_event = False elif event == "exception": is_exception_event = True breakpoints_for_file = None if has_exception_breakpoints: should_stop, frame = self.should_stop_on_exception( frame, event, arg ) if should_stop: self.handle_exception(frame, event, arg) return self.trace_dispatch is_line = False is_return = False is_call = False else: # Unexpected: just keep the same trace func (i.e.: event == 'c_XXX'). return self.trace_dispatch if not is_exception_event: breakpoints_for_file = main_debugger.breakpoints.get(filename) can_skip = False if info.pydev_state == 1: # STATE_RUN = 1 # we can skip if: # - we have no stop marked # - we should make a step return/step over and we're not in the current frame # - we're stepping into a coroutine context and we're not in that context if step_cmd == -1: can_skip = True elif ( step_cmd in ( CMD_STEP_OVER, CMD_STEP_RETURN, CMD_STEP_OVER_MY_CODE, CMD_STEP_RETURN_MY_CODE, ) and stop_frame is not frame ): can_skip = True elif step_cmd == CMD_STEP_INTO_COROUTINE: f = frame while f is not None: if f is stop_frame: break f = f.f_back else: can_skip = True if can_skip: if plugin_manager is not None and ( main_debugger.has_plugin_line_breaks or main_debugger.has_plugin_exception_breaks ): can_skip = plugin_manager.can_skip(main_debugger, frame) if ( can_skip and main_debugger.show_return_values and info.pydev_step_cmd in (CMD_STEP_OVER, CMD_STEP_OVER_MY_CODE) and frame.f_back is stop_frame ): # trace function for showing return values after step over can_skip = False # Let's check to see if we are in a function that has a breakpoint. If we don't have a breakpoint, # we will return nothing for the next trace # also, after we hit a breakpoint and go to some other debugging state, we have to force the set trace anyway, # so, that's why the additional checks are there. if not breakpoints_for_file: if can_skip: if has_exception_breakpoints: return self.trace_exception else: return None if is_call else NO_FTRACE else: # When cached, 0 means we don't have a breakpoint and 1 means we have. if can_skip: breakpoints_in_line_cache = frame_skips_cache.get( line_cache_key, -1 ) if breakpoints_in_line_cache == 0: return self.trace_dispatch breakpoints_in_frame_cache = frame_skips_cache.get(frame_cache_key, -1) if breakpoints_in_frame_cache != -1: # Gotten from cache. has_breakpoint_in_frame = breakpoints_in_frame_cache == 1 else: has_breakpoint_in_frame = False func_lines = _get_func_lines(frame.f_code) if func_lines is None: # This is a fallback for implementations where we can't get the function # lines -- i.e.: jython (in this case clients need to provide the function # name to decide on the skip or we won't be able to skip the function # completely). # Checks the breakpoint to see if there is a context match in some function. curr_func_name = frame.f_code.co_name # global context is set with an empty name if curr_func_name in ("?", "<module>", "<lambda>"): curr_func_name = "" for bp in dict_iter_values( breakpoints_for_file ): # jython does not support itervalues() # will match either global or some function if bp.func_name in ("None", curr_func_name): has_breakpoint_in_frame = True break else: for bp_line in breakpoints_for_file: # iterate on keys if bp_line in func_lines: has_breakpoint_in_frame = True break # Cache the value (1 or 0 or -1 for default because of cython). if has_breakpoint_in_frame: frame_skips_cache[frame_cache_key] = 1 else: frame_skips_cache[frame_cache_key] = 0 if can_skip and not has_breakpoint_in_frame: if has_exception_breakpoints: return self.trace_exception else: return None if is_call else NO_FTRACE # We may have hit a breakpoint or we are already in step mode. Either way, let's check what we should do in this frame # if DEBUG: print('NOT skipped: %s %s %s %s' % (frame.f_lineno, frame.f_code.co_name, event, frame.__class__.__name__)) try: flag = False # return is not taken into account for breakpoint hit because we'd have a double-hit in this case # (one for the line and the other for the return). stop_info = {} breakpoint = None exist_result = False stop = False bp_type = None if ( not is_return and info.pydev_state != STATE_SUSPEND and breakpoints_for_file is not None and line in breakpoints_for_file ): breakpoint = breakpoints_for_file[line] new_frame = frame stop = True if step_cmd in (CMD_STEP_OVER, CMD_STEP_OVER_MY_CODE) and ( stop_frame is frame and is_line ): stop = False # we don't stop on breakpoint if we have to stop by step-over (it will be processed later) elif plugin_manager is not None and main_debugger.has_plugin_line_breaks: result = plugin_manager.get_breakpoint( main_debugger, self, frame, event, self._args ) if result: exist_result = True flag, breakpoint, new_frame, bp_type = result if breakpoint: # ok, hit breakpoint, now, we have to discover if it is a conditional breakpoint # lets do the conditional stuff here if stop or exist_result: eval_result = False if breakpoint.has_condition: eval_result = main_debugger.handle_breakpoint_condition( info, breakpoint, new_frame ) if breakpoint.expression is not None: main_debugger.handle_breakpoint_expression( breakpoint, info, new_frame ) if ( breakpoint.is_logpoint and info.pydev_message is not None and len(info.pydev_message) > 0 ): cmd = main_debugger.cmd_factory.make_io_message( info.pydev_message + os.linesep, "1" ) main_debugger.writer.add_command(cmd) if breakpoint.has_condition: if not eval_result: stop = False elif breakpoint.is_logpoint: stop = False if is_call and frame.f_code.co_name in ("<module>", "<lambda>"): # If we find a call for a module, it means that the module is being imported/executed for the # first time. In this case we have to ignore this hit as it may later duplicated by a # line event at the same place (so, if there's a module with a print() in the first line # the user will hit that line twice, which is not what we want). # # As for lambda, as it only has a single statement, it's not interesting to trace # its call and later its line event as they're usually in the same line. return self.trace_dispatch if main_debugger.show_return_values: if is_return and ( ( info.pydev_step_cmd in (CMD_STEP_OVER, CMD_STEP_OVER_MY_CODE) and (frame.f_back is stop_frame) ) or ( info.pydev_step_cmd in (CMD_STEP_RETURN, CMD_STEP_RETURN_MY_CODE) and (frame is stop_frame) ) or ( info.pydev_step_cmd in ( CMD_STEP_INTO, CMD_STEP_INTO_MY_CODE, CMD_STEP_INTO_COROUTINE, ) ) ): self.show_return_values(frame, arg) elif main_debugger.remove_return_values_flag: try: self.remove_return_values(main_debugger, frame) finally: main_debugger.remove_return_values_flag = False if stop: self.set_suspend( thread, CMD_SET_BREAK, suspend_other_threads=breakpoint and breakpoint.suspend_policy == "ALL", ) elif flag and plugin_manager is not None: result = plugin_manager.suspend(main_debugger, thread, frame, bp_type) if result: frame = result # if thread has a suspend flag, we suspend with a busy wait if info.pydev_state == STATE_SUSPEND: self.do_wait_suspend(thread, frame, event, arg) return self.trace_dispatch else: if not breakpoint and is_line: # No stop from anyone and no breakpoint found in line (cache that). frame_skips_cache[line_cache_key] = 0 except: pydev_log.exception() raise # step handling. We stop when we hit the right frame try: should_skip = 0 if pydevd_dont_trace.should_trace_hook is not None: if self.should_skip == -1: # I.e.: cache the result on self.should_skip (no need to evaluate the same frame multiple times). # Note that on a code reload, we won't re-evaluate this because in practice, the frame.f_code # Which will be handled by this frame is read-only, so, we can cache it safely. if not pydevd_dont_trace.should_trace_hook(frame, filename): # -1, 0, 1 to be Cython-friendly should_skip = self.should_skip = 1 else: should_skip = self.should_skip = 0 else: should_skip = self.should_skip plugin_stop = False if should_skip: stop = False elif step_cmd in ( CMD_STEP_INTO, CMD_STEP_INTO_MY_CODE, CMD_STEP_INTO_COROUTINE, ): force_check_project_scope = step_cmd == CMD_STEP_INTO_MY_CODE if is_line: if ( force_check_project_scope or main_debugger.is_files_filter_enabled ): stop = not main_debugger.apply_files_filter( frame, frame.f_code.co_filename, force_check_project_scope ) else: stop = True elif is_return and frame.f_back is not None: if ( main_debugger.get_file_type(frame.f_back) == main_debugger.PYDEV_FILE ): stop = False else: if ( force_check_project_scope or main_debugger.is_files_filter_enabled ): stop = not main_debugger.apply_files_filter( frame.f_back, frame.f_back.f_code.co_filename, force_check_project_scope, ) else: stop = True else: stop = False if stop: if step_cmd == CMD_STEP_INTO_COROUTINE: # i.e.: Check if we're stepping into the proper context. f = frame while f is not None: if f is stop_frame: break f = f.f_back else: stop = False if plugin_manager is not None: result = plugin_manager.cmd_step_into( main_debugger, frame, event, self._args, stop_info, stop ) if result: stop, plugin_stop = result elif step_cmd in (CMD_STEP_OVER, CMD_STEP_OVER_MY_CODE): # Note: when dealing with a step over my code it's the same as a step over (the # difference is that when we return from a frame in one we go to regular step # into and in the other we go to a step into my code). stop = stop_frame is frame and is_line # Note: don't stop on a return for step over, only for line events # i.e.: don't stop in: (stop_frame is frame.f_back and is_return) as we'd stop twice in that line. if plugin_manager is not None: result = plugin_manager.cmd_step_over( main_debugger, frame, event, self._args, stop_info, stop ) if result: stop, plugin_stop = result elif step_cmd == CMD_SMART_STEP_INTO: stop = False if info.pydev_smart_step_stop is frame: info.pydev_func_name = ".invalid." # Must match the type in cython info.pydev_smart_step_stop = None if is_line or is_exception_event: curr_func_name = frame.f_code.co_name # global context is set with an empty name if curr_func_name in ("?", "<module>") or curr_func_name is None: curr_func_name = "" if curr_func_name == info.pydev_func_name: stop = True elif step_cmd in (CMD_STEP_RETURN, CMD_STEP_RETURN_MY_CODE): stop = is_return and stop_frame is frame else: stop = False if ( stop and step_cmd != -1 and is_return and IS_PY3K and hasattr(frame, "f_back") ): f_code = getattr(frame.f_back, "f_code", None) if f_code is not None: if ( main_debugger.get_file_type(frame.f_back) == main_debugger.PYDEV_FILE ): stop = False if plugin_stop: stopped_on_plugin = plugin_manager.stop( main_debugger, frame, event, self._args, stop_info, arg, step_cmd ) elif stop: if is_line: self.set_suspend( thread, step_cmd, original_step_cmd=info.pydev_original_step_cmd ) self.do_wait_suspend(thread, frame, event, arg) elif is_return: # return event back = frame.f_back if back is not None: # When we get to the pydevd run function, the debugging has actually finished for the main thread # (note that it can still go on for other threads, but for this one, we just make it finish) # So, just setting it to None should be OK _, back_filename, base = ( get_abs_path_real_path_and_base_from_frame(back) ) if (base, back.f_code.co_name) in ( DEBUG_START, DEBUG_START_PY3K, ): back = None elif base == TRACE_PROPERTY: # We dont want to trace the return event of pydevd_traceproperty (custom property for debugging) # if we're in a return, we want it to appear to the user in the previous frame! return None if is_call else NO_FTRACE elif pydevd_dont_trace.should_trace_hook is not None: if not pydevd_dont_trace.should_trace_hook( back, back_filename ): # In this case, we'll have to skip the previous one because it shouldn't be traced. # Also, we have to reset the tracing, because if the parent's parent (or some # other parent) has to be traced and it's not currently, we wouldn't stop where # we should anymore (so, a step in/over/return may not stop anywhere if no parent is traced). # Related test: _debugger_case17a.py main_debugger.set_trace_for_frame_and_parents(back) return None if is_call else NO_FTRACE if back is not None: # if we're in a return, we want it to appear to the user in the previous frame! self.set_suspend( thread, step_cmd, original_step_cmd=info.pydev_original_step_cmd, ) self.do_wait_suspend(thread, back, event, arg) else: # in jython we may not have a back frame info.pydev_step_stop = None info.pydev_original_step_cmd = -1 info.pydev_step_cmd = -1 info.pydev_state = STATE_RUN except KeyboardInterrupt: raise except: try: pydev_log.exception() info.pydev_original_step_cmd = -1 info.pydev_step_cmd = -1 info.pydev_step_stop = None except: return None if is_call else NO_FTRACE # if we are quitting, let's stop the tracing if not main_debugger.quitting: return self.trace_dispatch else: return None if is_call else NO_FTRACE finally: info.is_tracing -= 1
https://github.com/microsoft/debugpy/issues/106
mneilly@Docker:/local/mneilly/foo$ env DEBUGPY_LAUNCHER_PORT=34608 /usr/bin/python3 /eng/mneilly/.vscode-server/extensions/ms-python.python-2020.3.71659/pythonFiles/lib/python/debugpy/no_wheels/debugpy/launcher -m pytest -s --verbose /local/mneilly/foo/foo.py Traceback (most recent call last): File "/usr/lib64/python3.6/runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code exec(code, run_globals) File "/eng/mneilly/.vscode-server/extensions/ms-python.python-2020.3.71659/pythonFiles/lib/python/debugpy/no_wheels/debugpy/__main__.py", line 45, in <module> cli.main() File "/eng/mneilly/.vscode-server/extensions/ms-python.python-2020.3.71659/pythonFiles/lib/python/debugpy/no_wheels/debugpy/../debugpy/server/cli.py", line 429, in main run() File "/eng/mneilly/.vscode-server/extensions/ms-python.python-2020.3.71659/pythonFiles/lib/python/debugpy/no_wheels/debugpy/../debugpy/server/cli.py", line 316, in run_module run_module_as_main(target, alter_argv=True) File "/usr/lib64/python3.6/runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code exec(code, run_globals) File "/usr/local/lib/python3.6/site-packages/pytest.py", line 17, in <module> from _pytest.main import ExitCode File "/usr/local/lib/python3.6/site-packages/_pytest/main.py", line 21, in <module> class ExitCode(enum.IntEnum): File "/usr/lib64/python3.6/enum.py", line 201, in __new__ enum_member = __new__(enum_class, *args) TypeError: int() argument must be a string, a bytes-like object or a number, not 'dict' mneilly@Docker:/local/mneilly/foo$ cat /etc/redhat-release CentOS Linux release 7.5.1804 (Core)
TypeError
def apply_files_filter(self, frame, filename, force_check_project_scope): """ Should only be called if `self.is_files_filter_enabled == True` or `force_check_project_scope == True`. Note that it covers both the filter by specific paths includes/excludes as well as the check which filters out libraries if not in the project scope. :param force_check_project_scope: Check that the file is in the project scope even if the global setting is off. :return bool: True if it should be excluded when stepping and False if it should be included. """ cache_key = ( frame.f_code.co_firstlineno, filename, force_check_project_scope, frame.f_code, ) try: return self._apply_filter_cache[cache_key] except KeyError: if self.plugin is not None and ( self.has_plugin_line_breaks or self.has_plugin_exception_breaks ): # If it's explicitly needed by some plugin, we can't skip it. if not self.plugin.can_skip(self, frame): pydev_log.debug_once("File traced (included by plugins): %s", filename) self._apply_filter_cache[cache_key] = False return False if self._exclude_filters_enabled: exclude_by_filter = self._exclude_by_filter(frame, filename) if exclude_by_filter is not None: if exclude_by_filter: # ignore files matching stepping filters pydev_log.debug_once( "File not traced (excluded by filters): %s", filename ) self._apply_filter_cache[cache_key] = True return True else: pydev_log.debug_once( "File traced (explicitly included by filters): %s", filename ) self._apply_filter_cache[cache_key] = False return False if ( self._is_libraries_filter_enabled or force_check_project_scope ) and not self.in_project_scope(frame): # ignore library files while stepping self._apply_filter_cache[cache_key] = True if force_check_project_scope: pydev_log.debug_once("File not traced (not in project): %s", filename) else: pydev_log.debug_once( "File not traced (not in project - force_check_project_scope): %s", filename, ) return True if force_check_project_scope: pydev_log.debug_once( "File traced: %s (force_check_project_scope)", filename ) else: pydev_log.debug_once("File traced: %s", filename) self._apply_filter_cache[cache_key] = False return False
def apply_files_filter(self, frame, filename, force_check_project_scope): """ Should only be called if `self.is_files_filter_enabled == True`. Note that it covers both the filter by specific paths includes/excludes as well as the check which filters out libraries if not in the project scope. :param force_check_project_scope: Check that the file is in the project scope even if the global setting is off. :return bool: True if it should be excluded when stepping and False if it should be included. """ cache_key = ( frame.f_code.co_firstlineno, filename, force_check_project_scope, frame.f_code, ) try: return self._apply_filter_cache[cache_key] except KeyError: if self.plugin is not None and ( self.has_plugin_line_breaks or self.has_plugin_exception_breaks ): # If it's explicitly needed by some plugin, we can't skip it. if not self.plugin.can_skip(self, frame): pydev_log.debug_once("File traced (included by plugins): %s", filename) self._apply_filter_cache[cache_key] = False return False if self._exclude_filters_enabled: exclude_by_filter = self._exclude_by_filter(frame, filename) if exclude_by_filter is not None: if exclude_by_filter: # ignore files matching stepping filters pydev_log.debug_once( "File not traced (excluded by filters): %s", filename ) self._apply_filter_cache[cache_key] = True return True else: pydev_log.debug_once( "File traced (explicitly included by filters): %s", filename ) self._apply_filter_cache[cache_key] = False return False if ( self._is_libraries_filter_enabled or force_check_project_scope ) and not self.in_project_scope(frame): # ignore library files while stepping self._apply_filter_cache[cache_key] = True if force_check_project_scope: pydev_log.debug_once("File not traced (not in project): %s", filename) else: pydev_log.debug_once( "File not traced (not in project - force_check_project_scope): %s", filename, ) return True if force_check_project_scope: pydev_log.debug_once( "File traced: %s (force_check_project_scope)", filename ) else: pydev_log.debug_once("File traced: %s", filename) self._apply_filter_cache[cache_key] = False return False
https://github.com/microsoft/debugpy/issues/106
mneilly@Docker:/local/mneilly/foo$ env DEBUGPY_LAUNCHER_PORT=34608 /usr/bin/python3 /eng/mneilly/.vscode-server/extensions/ms-python.python-2020.3.71659/pythonFiles/lib/python/debugpy/no_wheels/debugpy/launcher -m pytest -s --verbose /local/mneilly/foo/foo.py Traceback (most recent call last): File "/usr/lib64/python3.6/runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code exec(code, run_globals) File "/eng/mneilly/.vscode-server/extensions/ms-python.python-2020.3.71659/pythonFiles/lib/python/debugpy/no_wheels/debugpy/__main__.py", line 45, in <module> cli.main() File "/eng/mneilly/.vscode-server/extensions/ms-python.python-2020.3.71659/pythonFiles/lib/python/debugpy/no_wheels/debugpy/../debugpy/server/cli.py", line 429, in main run() File "/eng/mneilly/.vscode-server/extensions/ms-python.python-2020.3.71659/pythonFiles/lib/python/debugpy/no_wheels/debugpy/../debugpy/server/cli.py", line 316, in run_module run_module_as_main(target, alter_argv=True) File "/usr/lib64/python3.6/runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code exec(code, run_globals) File "/usr/local/lib/python3.6/site-packages/pytest.py", line 17, in <module> from _pytest.main import ExitCode File "/usr/local/lib/python3.6/site-packages/_pytest/main.py", line 21, in <module> class ExitCode(enum.IntEnum): File "/usr/lib64/python3.6/enum.py", line 201, in __new__ enum_member = __new__(enum_class, *args) TypeError: int() argument must be a string, a bytes-like object or a number, not 'dict' mneilly@Docker:/local/mneilly/foo$ cat /etc/redhat-release CentOS Linux release 7.5.1804 (Core)
TypeError
def main(args): from debugpy import adapter from debugpy.common import compat, log, sockets from debugpy.adapter import ide, servers, sessions if args.for_server is not None: if os.name == "posix": # On POSIX, we need to leave the process group and its session, and then # daemonize properly by double-forking (first fork already happened when # this process was spawned). os.setsid() if os.fork() != 0: sys.exit(0) for stdio in sys.stdin, sys.stdout, sys.stderr: if stdio is not None: stdio.close() if args.log_stderr: log.stderr.levels |= set(log.LEVELS) if args.log_dir is not None: log.log_dir = args.log_dir log.to_file(prefix="debugpy.adapter") log.describe_environment("debugpy.adapter startup environment:") servers.access_token = args.server_access_token if args.for_server is None: adapter.access_token = compat.force_str(codecs.encode(os.urandom(32), "hex")) try: server_host, server_port = servers.serve() except Exception as exc: if args.for_server is None: raise endpoints = {"error": "Can't listen for server connections: " + str(exc)} else: endpoints = {"server": {"host": server_host, "port": server_port}} try: ide_host, ide_port = ide.serve(args.host, args.port) except Exception as exc: if args.for_server is None: raise endpoints = {"error": "Can't listen for IDE connections: " + str(exc)} else: endpoints["ide"] = {"host": ide_host, "port": ide_port} if args.for_server is not None: log.info( "Sending endpoints info to debug server at localhost:{0}:\n{1!j}", args.for_server, endpoints, ) try: sock = sockets.create_client() try: sock.settimeout(None) sock.connect(("127.0.0.1", args.for_server)) sock_io = sock.makefile("wb", 0) try: sock_io.write(json.dumps(endpoints).encode("utf-8")) finally: sock_io.close() finally: sockets.close_socket(sock) except Exception: raise log.exception("Error sending endpoints info to debug server:") if "error" in endpoints: log.error("Couldn't set up endpoints; exiting.") sys.exit(1) listener_file = os.getenv("DEBUGPY_ADAPTER_ENDPOINTS") if listener_file is not None: log.info("Writing endpoints info to {0!r}:\n{1!j}", listener_file, endpoints) def delete_listener_file(): log.info("Listener ports closed; deleting {0!r}", listener_file) try: os.remove(listener_file) except Exception: log.exception("Failed to delete {0!r}", listener_file, level="warning") try: with open(listener_file, "w") as f: atexit.register(delete_listener_file) print(json.dumps(endpoints), file=f) except Exception: raise log.exception("Error writing endpoints info to file:") if args.port is None: ide.IDE("stdio") # These must be registered after the one above, to ensure that the listener sockets # are closed before the endpoint info file is deleted - this way, another process # can wait for the file to go away as a signal that the ports are no longer in use. atexit.register(servers.stop_serving) atexit.register(ide.stop_serving) servers.wait_until_disconnected() log.info("All debug servers disconnected; waiting for remaining sessions...") sessions.wait_until_ended() log.info("All debug sessions have ended; exiting.")
def main(args): from debugpy import adapter from debugpy.common import compat, log, sockets from debugpy.adapter import ide, servers, sessions if args.for_server is not None: if os.name == "posix": # On POSIX, we need to leave the process group and its session, and then # daemonize properly by double-forking (first fork already happened when # this process was spawned). os.setsid() if os.fork() != 0: sys.exit(0) for stdio in sys.stdin, sys.stdout, sys.stderr: if stdio is not None: stdio.close() if args.log_stderr: log.stderr.levels |= set(log.LEVELS) if args.log_dir is not None: log.log_dir = args.log_dir log.to_file(prefix="debugpy.adapter") log.describe_environment("debugpy.adapter startup environment:") servers.access_token = args.server_access_token if args.for_server is None: adapter.access_token = compat.force_str(codecs.encode(os.urandom(32), "hex")) try: server_host, server_port = servers.listen() except Exception as exc: if args.for_server is None: raise endpoints = {"error": "Can't listen for server connections: " + str(exc)} else: endpoints = {"server": {"host": server_host, "port": server_port}} try: ide_host, ide_port = ide.listen(host=args.host, port=args.port) except Exception as exc: if args.for_server is None: raise endpoints = {"error": "Can't listen for IDE connections: " + str(exc)} else: endpoints["ide"] = {"host": ide_host, "port": ide_port} if args.for_server is not None: log.info( "Sending endpoints info to debug server at localhost:{0}:\n{1!j}", args.for_server, endpoints, ) try: sock = sockets.create_client() try: sock.settimeout(None) sock.connect(("127.0.0.1", args.for_server)) sock_io = sock.makefile("wb", 0) try: sock_io.write(json.dumps(endpoints).encode("utf-8")) finally: sock_io.close() finally: sockets.close_socket(sock) except Exception: raise log.exception("Error sending endpoints info to debug server:") if "error" in endpoints: log.error("Couldn't set up endpoints; exiting.") sys.exit(1) listener_file = os.getenv("DEBUGPY_ADAPTER_ENDPOINTS") if listener_file is not None: log.info("Writing endpoints info to {0!r}:\n{1!j}", listener_file, endpoints) def delete_listener_file(): log.info("Listener ports closed; deleting {0!r}", listener_file) try: os.remove(listener_file) except Exception: log.exception("Failed to delete {0!r}", listener_file, level="warning") try: with open(listener_file, "w") as f: atexit.register(delete_listener_file) print(json.dumps(endpoints), file=f) except Exception: raise log.exception("Error writing endpoints info to file:") if args.port is None: ide.IDE("stdio") # These must be registered after the one above, to ensure that the listener sockets # are closed before the endpoint info file is deleted - this way, another process # can wait for the file to go away as a signal that the ports are no longer in use. atexit.register(servers.stop_listening) atexit.register(ide.stop_listening) servers.wait_until_disconnected() log.info("All debug servers disconnected; waiting for remaining sessions...") sessions.wait_until_ended() log.info("All debug sessions have ended; exiting.")
https://github.com/microsoft/debugpy/issues/20
C:\Python37\python.exe c:\Users\kanadig\.vscode\extensions\ms-python.python-2020.2.60897-dev\pythonFiles\lib\python\new_ptvsd\wheels\ptvsd\launcher C:\GIT\issues\issue9214/test_mp.py Could not connect to 127.0.0.1: 50734 Traceback (most recent call last): File "c:\Users\kanadig\.vscode\extensions\ms-python.python-2020.2.60897-dev\pythonFiles\lib\python\new_ptvsd\wheels\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_comm.py", line 514, in start_client s.connect((host, port)) ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it Traceback (most recent call last): File "<string>", line 1, in <module> File "c:\Users\kanadig\.vscode\extensions\ms-python.python-2020.2.60897-dev\pythonFiles\lib\python\new_ptvsd\wheels\ptvsd\_vendored\pydevd\pydevd.py", line 2550, in settrace client_access_token, File "c:\Users\kanadig\.vscode\extensions\ms-python.python-2020.2.60897-dev\pythonFiles\lib\python\new_ptvsd\wheels\ptvsd\_vendored\pydevd\pydevd.py", line 2610, in _locked_settrace py_db.connect(host, port) # Note: connect can raise error. File "c:\Users\kanadig\.vscode\extensions\ms-python.python-2020.2.60897-dev\pythonFiles\lib\python\new_ptvsd\wheels\ptvsd\_vendored\pydevd\pydevd.py", line 1179, in connect s = start_client(host, port) File "c:\Users\kanadig\.vscode\extensions\ms-python.python-2020.2.60897-dev\pythonFiles\lib\python\new_ptvsd\wheels\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_comm.py", line 514, in start_client s.connect((host, port)) ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it Error in atexit._run_exitfuncs: Traceback (most recent call last): File "C:\Python37\lib\concurrent\futures\process.py", line 102, in _python_exit thread_wakeup.wakeup() File "C:\Python37\lib\concurrent\futures\process.py", line 90, in wakeup self._writer.send_bytes(b"") File "C:\Python37\lib\multiprocessing\connection.py", line 183, in send_bytes self._check_closed() File "C:\Python37\lib\multiprocessing\connection.py", line 136, in _check_closed raise OSError("handle is closed") OSError: handle is closed
ConnectionRefusedError
def notify_of_subprocess(self, conn): with self.session: if self.start_request is None or conn in self._known_subprocesses: return if "processId" in self.start_request.arguments: log.warning( "Not reporting subprocess for {0}, because the parent process " 'was attached to using "processId" rather than "port".', self.session, ) return log.info("Notifying {0} about {1}.", self, conn) body = dict(self.start_request.arguments) self._known_subprocesses.add(conn) body["name"] = fmt("Subprocess {0}", conn.pid) body["request"] = "attach" if "host" not in body: body["host"] = "127.0.0.1" if "port" not in body: _, body["port"] = listener.getsockname() if "processId" in body: del body["processId"] body["subProcessId"] = conn.pid self.channel.send_event("debugpyAttach", body)
def notify_of_subprocess(self, conn): with self.session: if self.start_request is None or conn in self._known_subprocesses: return if "processId" in self.start_request.arguments: log.warning( "Not reporting subprocess for {0}, because the parent process " 'was attached to using "processId" rather than "port".', self.session, ) return log.info("Notifying {0} about {1}.", self, conn) body = dict(self.start_request.arguments) self._known_subprocesses.add(conn) body["name"] = fmt("Subprocess {0}", conn.pid) body["request"] = "attach" if "host" not in body: body["host"] = "127.0.0.1" if "port" not in body: _, body["port"] = self.listener.getsockname() if "processId" in body: del body["processId"] body["subProcessId"] = conn.pid self.channel.send_event("debugpyAttach", body)
https://github.com/microsoft/debugpy/issues/20
C:\Python37\python.exe c:\Users\kanadig\.vscode\extensions\ms-python.python-2020.2.60897-dev\pythonFiles\lib\python\new_ptvsd\wheels\ptvsd\launcher C:\GIT\issues\issue9214/test_mp.py Could not connect to 127.0.0.1: 50734 Traceback (most recent call last): File "c:\Users\kanadig\.vscode\extensions\ms-python.python-2020.2.60897-dev\pythonFiles\lib\python\new_ptvsd\wheels\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_comm.py", line 514, in start_client s.connect((host, port)) ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it Traceback (most recent call last): File "<string>", line 1, in <module> File "c:\Users\kanadig\.vscode\extensions\ms-python.python-2020.2.60897-dev\pythonFiles\lib\python\new_ptvsd\wheels\ptvsd\_vendored\pydevd\pydevd.py", line 2550, in settrace client_access_token, File "c:\Users\kanadig\.vscode\extensions\ms-python.python-2020.2.60897-dev\pythonFiles\lib\python\new_ptvsd\wheels\ptvsd\_vendored\pydevd\pydevd.py", line 2610, in _locked_settrace py_db.connect(host, port) # Note: connect can raise error. File "c:\Users\kanadig\.vscode\extensions\ms-python.python-2020.2.60897-dev\pythonFiles\lib\python\new_ptvsd\wheels\ptvsd\_vendored\pydevd\pydevd.py", line 1179, in connect s = start_client(host, port) File "c:\Users\kanadig\.vscode\extensions\ms-python.python-2020.2.60897-dev\pythonFiles\lib\python\new_ptvsd\wheels\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_comm.py", line 514, in start_client s.connect((host, port)) ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it Error in atexit._run_exitfuncs: Traceback (most recent call last): File "C:\Python37\lib\concurrent\futures\process.py", line 102, in _python_exit thread_wakeup.wakeup() File "C:\Python37\lib\concurrent\futures\process.py", line 90, in wakeup self._writer.send_bytes(b"") File "C:\Python37\lib\multiprocessing\connection.py", line 183, in send_bytes self._check_closed() File "C:\Python37\lib\multiprocessing\connection.py", line 136, in _check_closed raise OSError("handle is closed") OSError: handle is closed
ConnectionRefusedError
def spawn_debuggee(session, start_request, sudo, args, console, console_title): cmdline = ["sudo"] if sudo else [] cmdline += [sys.executable, os.path.dirname(launcher.__file__)] cmdline += args env = {} arguments = dict(start_request.arguments) if not session.no_debug: _, arguments["port"] = servers.listener.getsockname() arguments["clientAccessToken"] = adapter.access_token def on_launcher_connected(sock): listener.close() stream = messaging.JsonIOStream.from_socket(sock) Launcher(session, stream) listener = sockets.serve("Launcher", on_launcher_connected, "127.0.0.1", backlog=0) try: _, launcher_port = listener.getsockname() env[str("DEBUGPY_LAUNCHER_PORT")] = str(launcher_port) if log.log_dir is not None: env[str("DEBUGPY_LOG_DIR")] = compat.filename_str(log.log_dir) if log.stderr.levels != {"warning", "error"}: env[str("DEBUGPY_LOG_STDERR")] = str(" ".join(log.stderr.levels)) if console == "internalConsole": log.info("{0} spawning launcher: {1!r}", session, cmdline) # If we are talking to the IDE over stdio, sys.stdin and sys.stdout are # redirected to avoid mangling the DAP message stream. Make sure the # launcher also respects that. subprocess.Popen( cmdline, env=dict(list(os.environ.items()) + list(env.items())), stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr, ) else: log.info('{0} spawning launcher via "runInTerminal" request.', session) session.ide.capabilities.require("supportsRunInTerminalRequest") kinds = { "integratedTerminal": "integrated", "externalTerminal": "external", } session.ide.channel.request( "runInTerminal", { "kind": kinds[console], "title": console_title, "args": cmdline, "env": env, }, ) if not session.wait_for(lambda: session.launcher, timeout=10): raise start_request.cant_handle( "{0} timed out waiting for {1} to connect", session, session.launcher, ) try: session.launcher.channel.request(start_request.command, arguments) except messaging.MessageHandlingError as exc: exc.propagate(start_request) if session.no_debug: return if not session.wait_for(lambda: session.launcher.pid is not None, timeout=10): raise start_request.cant_handle( '{0} timed out waiting for "process" event from {1}', session, session.launcher, ) # Wait for the first incoming connection regardless of the PID - it won't # necessarily match due to the use of stubs like py.exe or "conda run". conn = servers.wait_for_connection(session, lambda conn: True, timeout=10) if conn is None: raise start_request.cant_handle( "{0} timed out waiting for debuggee to spawn", session ) conn.attach_to_session(session) finally: listener.close()
def spawn_debuggee(session, start_request, sudo, args, console, console_title): cmdline = ["sudo"] if sudo else [] cmdline += [sys.executable, os.path.dirname(launcher.__file__)] cmdline += args env = {} def spawn_launcher(): with session.accept_connection_from_launcher() as (_, launcher_port): env[str("DEBUGPY_LAUNCHER_PORT")] = str(launcher_port) if log.log_dir is not None: env[str("DEBUGPY_LOG_DIR")] = compat.filename_str(log.log_dir) if log.stderr.levels != {"warning", "error"}: env[str("DEBUGPY_LOG_STDERR")] = str(" ".join(log.stderr.levels)) if console == "internalConsole": log.info("{0} spawning launcher: {1!r}", session, cmdline) # If we are talking to the IDE over stdio, sys.stdin and sys.stdout are # redirected to avoid mangling the DAP message stream. Make sure the # launcher also respects that. subprocess.Popen( cmdline, env=dict(list(os.environ.items()) + list(env.items())), stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr, ) else: log.info('{0} spawning launcher via "runInTerminal" request.', session) session.ide.capabilities.require("supportsRunInTerminalRequest") kinds = { "integratedTerminal": "integrated", "externalTerminal": "external", } session.ide.channel.request( "runInTerminal", { "kind": kinds[console], "title": console_title, "args": cmdline, "env": env, }, ) try: session.launcher.channel.request(start_request.command, arguments) except messaging.MessageHandlingError as exc: exc.propagate(start_request) if session.no_debug: arguments = start_request.arguments spawn_launcher() else: _, port = servers.Connection.listener.getsockname() arguments = dict(start_request.arguments) arguments["port"] = port arguments["clientAccessToken"] = adapter.access_token spawn_launcher() if not session.wait_for( lambda: session.launcher is not None and session.launcher.pid is not None, timeout=5, ): raise start_request.cant_handle( '{0} timed out waiting for "process" event from {1}', session, session.launcher, ) # Wait for the first incoming connection regardless of the PID - it won't # necessarily match due to the use of stubs like py.exe or "conda run". conn = servers.wait_for_connection(session, lambda conn: True, timeout=10) if conn is None: raise start_request.cant_handle( "{0} timed out waiting for debuggee to spawn", session ) conn.attach_to_session(session)
https://github.com/microsoft/debugpy/issues/20
C:\Python37\python.exe c:\Users\kanadig\.vscode\extensions\ms-python.python-2020.2.60897-dev\pythonFiles\lib\python\new_ptvsd\wheels\ptvsd\launcher C:\GIT\issues\issue9214/test_mp.py Could not connect to 127.0.0.1: 50734 Traceback (most recent call last): File "c:\Users\kanadig\.vscode\extensions\ms-python.python-2020.2.60897-dev\pythonFiles\lib\python\new_ptvsd\wheels\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_comm.py", line 514, in start_client s.connect((host, port)) ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it Traceback (most recent call last): File "<string>", line 1, in <module> File "c:\Users\kanadig\.vscode\extensions\ms-python.python-2020.2.60897-dev\pythonFiles\lib\python\new_ptvsd\wheels\ptvsd\_vendored\pydevd\pydevd.py", line 2550, in settrace client_access_token, File "c:\Users\kanadig\.vscode\extensions\ms-python.python-2020.2.60897-dev\pythonFiles\lib\python\new_ptvsd\wheels\ptvsd\_vendored\pydevd\pydevd.py", line 2610, in _locked_settrace py_db.connect(host, port) # Note: connect can raise error. File "c:\Users\kanadig\.vscode\extensions\ms-python.python-2020.2.60897-dev\pythonFiles\lib\python\new_ptvsd\wheels\ptvsd\_vendored\pydevd\pydevd.py", line 1179, in connect s = start_client(host, port) File "c:\Users\kanadig\.vscode\extensions\ms-python.python-2020.2.60897-dev\pythonFiles\lib\python\new_ptvsd\wheels\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_comm.py", line 514, in start_client s.connect((host, port)) ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it Error in atexit._run_exitfuncs: Traceback (most recent call last): File "C:\Python37\lib\concurrent\futures\process.py", line 102, in _python_exit thread_wakeup.wakeup() File "C:\Python37\lib\concurrent\futures\process.py", line 90, in wakeup self._writer.send_bytes(b"") File "C:\Python37\lib\multiprocessing\connection.py", line 183, in send_bytes self._check_closed() File "C:\Python37\lib\multiprocessing\connection.py", line 136, in _check_closed raise OSError("handle is closed") OSError: handle is closed
ConnectionRefusedError
def inject(pid, debugpy_args): host, port = listener.getsockname() cmdline = [ sys.executable, compat.filename(os.path.dirname(debugpy.__file__)), "--client", "--host", host, "--port", str(port), ] if adapter.access_token is not None: cmdline += ["--client-access-token", adapter.access_token] cmdline += debugpy_args cmdline += ["--pid", str(pid)] log.info("Spawning attach-to-PID debugger injector: {0!r}", cmdline) try: injector = subprocess.Popen( cmdline, bufsize=0, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, ) except Exception as exc: log.exception("Failed to inject debug server into process with PID={0}", pid) raise messaging.MessageHandlingError( fmt( "Failed to inject debug server into process with PID={0}: {1}", pid, exc ) ) # We need to capture the output of the injector - otherwise it can get blocked # on a write() syscall when it tries to print something. def capture_output(): while True: line = injector.stdout.readline() if not line: break log.info("Injector[PID={0}] output:\n{1}", pid, line.rstrip()) log.info("Injector[PID={0}] exited.", pid) thread = threading.Thread( target=capture_output, name=fmt("Injector[PID={0}] output", pid) ) thread.daemon = True thread.start()
def inject(pid, debugpy_args): host, port = Connection.listener.getsockname() cmdline = [ sys.executable, compat.filename(os.path.dirname(debugpy.__file__)), "--client", "--host", host, "--port", str(port), ] if adapter.access_token is not None: cmdline += ["--client-access-token", adapter.access_token] cmdline += debugpy_args cmdline += ["--pid", str(pid)] log.info("Spawning attach-to-PID debugger injector: {0!r}", cmdline) try: injector = subprocess.Popen( cmdline, bufsize=0, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, ) except Exception as exc: log.exception("Failed to inject debug server into process with PID={0}", pid) raise messaging.MessageHandlingError( fmt( "Failed to inject debug server into process with PID={0}: {1}", pid, exc ) ) # We need to capture the output of the injector - otherwise it can get blocked # on a write() syscall when it tries to print something. def capture_output(): while True: line = injector.stdout.readline() if not line: break log.info("Injector[PID={0}] output:\n{1}", pid, line.rstrip()) log.info("Injector[PID={0}] exited.", pid) thread = threading.Thread( target=capture_output, name=fmt("Injector[PID={0}] output", pid) ) thread.daemon = True thread.start()
https://github.com/microsoft/debugpy/issues/20
C:\Python37\python.exe c:\Users\kanadig\.vscode\extensions\ms-python.python-2020.2.60897-dev\pythonFiles\lib\python\new_ptvsd\wheels\ptvsd\launcher C:\GIT\issues\issue9214/test_mp.py Could not connect to 127.0.0.1: 50734 Traceback (most recent call last): File "c:\Users\kanadig\.vscode\extensions\ms-python.python-2020.2.60897-dev\pythonFiles\lib\python\new_ptvsd\wheels\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_comm.py", line 514, in start_client s.connect((host, port)) ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it Traceback (most recent call last): File "<string>", line 1, in <module> File "c:\Users\kanadig\.vscode\extensions\ms-python.python-2020.2.60897-dev\pythonFiles\lib\python\new_ptvsd\wheels\ptvsd\_vendored\pydevd\pydevd.py", line 2550, in settrace client_access_token, File "c:\Users\kanadig\.vscode\extensions\ms-python.python-2020.2.60897-dev\pythonFiles\lib\python\new_ptvsd\wheels\ptvsd\_vendored\pydevd\pydevd.py", line 2610, in _locked_settrace py_db.connect(host, port) # Note: connect can raise error. File "c:\Users\kanadig\.vscode\extensions\ms-python.python-2020.2.60897-dev\pythonFiles\lib\python\new_ptvsd\wheels\ptvsd\_vendored\pydevd\pydevd.py", line 1179, in connect s = start_client(host, port) File "c:\Users\kanadig\.vscode\extensions\ms-python.python-2020.2.60897-dev\pythonFiles\lib\python\new_ptvsd\wheels\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_comm.py", line 514, in start_client s.connect((host, port)) ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it Error in atexit._run_exitfuncs: Traceback (most recent call last): File "C:\Python37\lib\concurrent\futures\process.py", line 102, in _python_exit thread_wakeup.wakeup() File "C:\Python37\lib\concurrent\futures\process.py", line 90, in wakeup self._writer.send_bytes(b"") File "C:\Python37\lib\multiprocessing\connection.py", line 183, in send_bytes self._check_closed() File "C:\Python37\lib\multiprocessing\connection.py", line 136, in _check_closed raise OSError("handle is closed") OSError: handle is closed
ConnectionRefusedError
def _finalize(self, why, terminate_debuggee): # If the IDE started a session, and then disconnected before issuing "launch" # or "attach", the main thread will be blocked waiting for the first server # connection to come in - unblock it, so that we can exit. servers.dont_wait_for_first_connection() if self.server: if self.server.is_connected: if terminate_debuggee and self.launcher and self.launcher.is_connected: # If we were specifically asked to terminate the debuggee, and we # can ask the launcher to kill it, do so instead of disconnecting # from the server to prevent debuggee from running any more code. self.launcher.terminate_debuggee() else: # Otherwise, let the server handle it the best it can. try: self.server.channel.request( "disconnect", {"terminateDebuggee": terminate_debuggee} ) except Exception: pass self.server.detach_from_session() if self.launcher and self.launcher.is_connected: # If there was a server, we just disconnected from it above, which should # cause the debuggee process to exit - so let's wait for that first. if self.server: log.info('{0} waiting for "exited" event...', self) if not self.wait_for( lambda: self.launcher.exit_code is not None, timeout=5 ): log.warning('{0} timed out waiting for "exited" event.', self) # Terminate the debuggee process if it's still alive for any reason - # whether it's because there was no server to handle graceful shutdown, # or because the server couldn't handle it for some reason. self.launcher.terminate_debuggee() # Wait until the launcher message queue fully drains. There is no timeout # here, because the final "terminated" event will only come after reading # user input in wait-on-exit scenarios. log.info("{0} waiting for {1} to disconnect...", self, self.launcher) self.wait_for(lambda: not self.launcher.is_connected) try: self.launcher.channel.close() except Exception: log.exception() if self.ide: if self.ide.is_connected: # Tell the IDE that debugging is over, but don't close the channel until it # tells us to, via the "disconnect" request. try: self.ide.channel.send_event("terminated") except Exception: pass if ( self.ide.start_request is not None and self.ide.start_request.command == "launch" ): servers.stop_serving() log.info('"launch" session ended - killing remaining debuggee processes.') pids_killed = set() if self.launcher and self.launcher.pid is not None: # Already killed above. pids_killed.add(self.launcher.pid) while True: conns = [ conn for conn in servers.connections() if conn.pid not in pids_killed ] if not len(conns): break for conn in conns: log.info("Killing {0}", conn) try: os.kill(conn.pid, signal.SIGTERM) except Exception: log.exception("Failed to kill {0}", conn) pids_killed.add(conn.pid)
def _finalize(self, why, terminate_debuggee): # If the IDE started a session, and then disconnected before issuing "launch" # or "attach", the main thread will be blocked waiting for the first server # connection to come in - unblock it, so that we can exit. servers.dont_wait_for_first_connection() if self.server: if self.server.is_connected: if terminate_debuggee and self.launcher and self.launcher.is_connected: # If we were specifically asked to terminate the debuggee, and we # can ask the launcher to kill it, do so instead of disconnecting # from the server to prevent debuggee from running any more code. self.launcher.terminate_debuggee() else: # Otherwise, let the server handle it the best it can. try: self.server.channel.request( "disconnect", {"terminateDebuggee": terminate_debuggee} ) except Exception: pass self.server.detach_from_session() if self.launcher and self.launcher.is_connected: # If there was a server, we just disconnected from it above, which should # cause the debuggee process to exit - so let's wait for that first. if self.server: log.info('{0} waiting for "exited" event...', self) if not self.wait_for( lambda: self.launcher.exit_code is not None, timeout=5 ): log.warning('{0} timed out waiting for "exited" event.', self) # Terminate the debuggee process if it's still alive for any reason - # whether it's because there was no server to handle graceful shutdown, # or because the server couldn't handle it for some reason. self.launcher.terminate_debuggee() # Wait until the launcher message queue fully drains. There is no timeout # here, because the final "terminated" event will only come after reading # user input in wait-on-exit scenarios. log.info("{0} waiting for {1} to disconnect...", self, self.launcher) self.wait_for(lambda: not self.launcher.is_connected) try: self.launcher.channel.close() except Exception: log.exception() if self.ide: if self.ide.is_connected: # Tell the IDE that debugging is over, but don't close the channel until it # tells us to, via the "disconnect" request. try: self.ide.channel.send_event("terminated") except Exception: pass if ( self.ide.start_request is not None and self.ide.start_request.command == "launch" ): servers.stop_listening() log.info('"launch" session ended - killing remaining debuggee processes.') pids_killed = set() if self.launcher and self.launcher.pid is not None: # Already killed above. pids_killed.add(self.launcher.pid) while True: conns = [ conn for conn in servers.connections() if conn.pid not in pids_killed ] if not len(conns): break for conn in conns: log.info("Killing {0}", conn) try: os.kill(conn.pid, signal.SIGTERM) except Exception: log.exception("Failed to kill {0}", conn) pids_killed.add(conn.pid)
https://github.com/microsoft/debugpy/issues/20
C:\Python37\python.exe c:\Users\kanadig\.vscode\extensions\ms-python.python-2020.2.60897-dev\pythonFiles\lib\python\new_ptvsd\wheels\ptvsd\launcher C:\GIT\issues\issue9214/test_mp.py Could not connect to 127.0.0.1: 50734 Traceback (most recent call last): File "c:\Users\kanadig\.vscode\extensions\ms-python.python-2020.2.60897-dev\pythonFiles\lib\python\new_ptvsd\wheels\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_comm.py", line 514, in start_client s.connect((host, port)) ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it Traceback (most recent call last): File "<string>", line 1, in <module> File "c:\Users\kanadig\.vscode\extensions\ms-python.python-2020.2.60897-dev\pythonFiles\lib\python\new_ptvsd\wheels\ptvsd\_vendored\pydevd\pydevd.py", line 2550, in settrace client_access_token, File "c:\Users\kanadig\.vscode\extensions\ms-python.python-2020.2.60897-dev\pythonFiles\lib\python\new_ptvsd\wheels\ptvsd\_vendored\pydevd\pydevd.py", line 2610, in _locked_settrace py_db.connect(host, port) # Note: connect can raise error. File "c:\Users\kanadig\.vscode\extensions\ms-python.python-2020.2.60897-dev\pythonFiles\lib\python\new_ptvsd\wheels\ptvsd\_vendored\pydevd\pydevd.py", line 1179, in connect s = start_client(host, port) File "c:\Users\kanadig\.vscode\extensions\ms-python.python-2020.2.60897-dev\pythonFiles\lib\python\new_ptvsd\wheels\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_comm.py", line 514, in start_client s.connect((host, port)) ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it Error in atexit._run_exitfuncs: Traceback (most recent call last): File "C:\Python37\lib\concurrent\futures\process.py", line 102, in _python_exit thread_wakeup.wakeup() File "C:\Python37\lib\concurrent\futures\process.py", line 90, in wakeup self._writer.send_bytes(b"") File "C:\Python37\lib\multiprocessing\connection.py", line 183, in send_bytes self._check_closed() File "C:\Python37\lib\multiprocessing\connection.py", line 136, in _check_closed raise OSError("handle is closed") OSError: handle is closed
ConnectionRefusedError
def create_server(host, port=0, backlog=socket.SOMAXCONN, timeout=None): """Return a local server socket listening on the given port.""" if host is None: host = "127.0.0.1" if port is None: port = 0 try: server = _new_sock() server.bind((host, port)) if timeout is not None: server.settimeout(timeout) server.listen(backlog) except Exception: server.close() raise return server
def create_server(host, port, timeout=None): """Return a local server socket listening on the given port.""" if host is None: host = "127.0.0.1" if port is None: port = 0 try: server = _new_sock() server.bind((host, port)) if timeout is not None: server.settimeout(timeout) server.listen(1) except Exception: server.close() raise return server
https://github.com/microsoft/debugpy/issues/20
C:\Python37\python.exe c:\Users\kanadig\.vscode\extensions\ms-python.python-2020.2.60897-dev\pythonFiles\lib\python\new_ptvsd\wheels\ptvsd\launcher C:\GIT\issues\issue9214/test_mp.py Could not connect to 127.0.0.1: 50734 Traceback (most recent call last): File "c:\Users\kanadig\.vscode\extensions\ms-python.python-2020.2.60897-dev\pythonFiles\lib\python\new_ptvsd\wheels\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_comm.py", line 514, in start_client s.connect((host, port)) ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it Traceback (most recent call last): File "<string>", line 1, in <module> File "c:\Users\kanadig\.vscode\extensions\ms-python.python-2020.2.60897-dev\pythonFiles\lib\python\new_ptvsd\wheels\ptvsd\_vendored\pydevd\pydevd.py", line 2550, in settrace client_access_token, File "c:\Users\kanadig\.vscode\extensions\ms-python.python-2020.2.60897-dev\pythonFiles\lib\python\new_ptvsd\wheels\ptvsd\_vendored\pydevd\pydevd.py", line 2610, in _locked_settrace py_db.connect(host, port) # Note: connect can raise error. File "c:\Users\kanadig\.vscode\extensions\ms-python.python-2020.2.60897-dev\pythonFiles\lib\python\new_ptvsd\wheels\ptvsd\_vendored\pydevd\pydevd.py", line 1179, in connect s = start_client(host, port) File "c:\Users\kanadig\.vscode\extensions\ms-python.python-2020.2.60897-dev\pythonFiles\lib\python\new_ptvsd\wheels\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_comm.py", line 514, in start_client s.connect((host, port)) ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it Error in atexit._run_exitfuncs: Traceback (most recent call last): File "C:\Python37\lib\concurrent\futures\process.py", line 102, in _python_exit thread_wakeup.wakeup() File "C:\Python37\lib\concurrent\futures\process.py", line 90, in wakeup self._writer.send_bytes(b"") File "C:\Python37\lib\multiprocessing\connection.py", line 183, in send_bytes self._check_closed() File "C:\Python37\lib\multiprocessing\connection.py", line 136, in _check_closed raise OSError("handle is closed") OSError: handle is closed
ConnectionRefusedError