statik
statik copied to clipboard
Error messages useless
Hi,
thank you for this very interesting project, which could fit perfectly my needs.
The first problem I encounter is the error message, quite useless. For example:
`--- Logging error --- Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/statik/cmdline.py", line 127, in main generate(config_file_path, output_path=output_path, in_memory=False, safe_mode=args.safe_mode) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/statik/generator.py", line 15, in generate return project.generate(output_path=output_path, in_memory=in_memory) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/statik/project.py", line 105, in generate in_memory_result = self.process_views() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/statik/project.py", line 220, in process_views extra_context=self.project_context File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/statik/views.py", line 366, in process extra_context=extra_context File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/statik/views.py", line 277, in render inst_path = self.path.render(inst=inst, context=ctx) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/statik/views.py", line 175, in render result = self.template.render(ctx) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/statik/templating.py", line 293, in render return self.template.render(**context) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jinja2/asyncsupport.py", line 76, in render return original_render(self, *args, **kwargs) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jinja2/environment.py", line 1008, in render return self.environment.handle_exception(exc_info, True) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jinja2/environment.py", line 780, in handle_exception reraise(exc_type, exc_value, tb) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jinja2/_compat.py", line 37, in reraise raise value.with_traceback(tb) File "", line 1, in top-level template code File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jinja2/environment.py", line 430, in getattr return getattr(obj, attribute) jinja2.exceptions.UndefinedError: 'master' is undefined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/init.py", line 992, in emit
msg = self.format(record)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/init.py", line 838, in format
return fmt.format(record)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/init.py", line 575, in format
record.message = record.getMessage()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/init.py", line 338, in getMessage
msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
File "/Library/Frameworks/Python.framework/Versions/3.6/bin/statik", line 11, in
I just know there is a jinja
problem somewhere, but I even don't which of my file is incorrect.
Agreed. That kind of error handling is pretty useless 😁 I'll take a look and see if there's a more meaningful way I can handle such errors.
Try v0.19.0 when you get a chance and see if the error handling is better for you? It's quite hard to keep track of the error context throughout Statik's build system, so there may be cases where you'll see template errors without references to specific files. From the testing I've done so far, it seems to work a little better and more intuitively.
Thank you for your answer.
As far as I can see it's not better, but now it's colored ! :-)
I will test further and let you know.
Send me one or two examples of the error messages you're getting now - I need more info to see where to improve the error handling.
Also, can you send me an example as to what kind of error output you'd find more useful?
I past another examples (quite long) at the end of this comment.
I've seen the message for the template error : it's nice, exactly what I need.
What I would like:
sqlite error :
EXAMPLE 1:
Here the many to many relationship was badly defined. This message was useful, since a the end of it I have enough information to detect the problematic file.
Requirement already satisfied: statik in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages Requirement already satisfied: six>=1.10.0 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from statik) Requirement already satisfied: mlalchemy>=0.2.1 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from statik) Requirement already satisfied: httpwatcher>=0.5.1 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from statik) Requirement already satisfied: lipsum>=0.1.1 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from statik) Requirement already satisfied: pystache>=0.5.4 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from statik) Requirement already satisfied: jinja2>=2.8 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from statik) Requirement already satisfied: future>=0.16.0 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from statik) Requirement already satisfied: markdown>=2.6.6 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from statik) Requirement already satisfied: SQLAlchemy>=1.0.14 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from statik) Requirement already satisfied: python-slugify>=1.2.1 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from statik) Requirement already satisfied: PyYAML>=3.11 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from statik) Collecting colorlog>=3.1.0 (from statik) Using cached colorlog-3.1.0-py2.py3-none-any.whl Requirement already satisfied: tornado in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from httpwatcher>=0.5.1->statik) Requirement already satisfied: watchdog in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from httpwatcher>=0.5.1->statik) Requirement already satisfied: MarkupSafe>=0.23 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from jinja2>=2.8->statik) Requirement already satisfied: Unidecode>=0.04.16 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from python-slugify>=1.2.1->statik) Requirement already satisfied: argh>=0.24.1 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from watchdog->httpwatcher>=0.5.1->statik) Requirement already satisfied: pathtools>=0.1.1 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from watchdog->httpwatcher>=0.5.1->statik) Installing collected packages: colorlog Successfully installed colorlog-3.1.0 [lemac]~/Zen/dharmalib > statik Generating Statik build... Exception caught while attempting to generate project Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context context) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 507, in do_execute cursor.execute(statement, parameters) sqlite3.InterfaceError: Error binding parameter 3 - probably unsupported type.
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/statik/cmdline.py", line 171, in main error_context=error_context File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/statik/generator.py", line 15, in generate return project.generate(output_path=output_path, in_memory=in_memory) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/statik/project.py", line 108, in generate self.db = self.load_db_data(self.models) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/statik/project.py", line 198, in load_db_data markdown_config=self.config.markdown_config File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/statik/database.py", line 86, in init self.create_db(models) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/statik/database.py", line 106, in create_db self.load_all_model_data(models) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/statik/database.py", line 118, in load_all_model_data self.load_model_data(model_data_path, model) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/statik/database.py", line 182, in load_model_data self.session.commit() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 937, in commit self.transaction.commit() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 461, in commit self._prepare_impl() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 441, in _prepare_impl self.session.flush() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2237, in flush self._flush(objects) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2363, in _flush transaction.rollback(_capture_exception=True) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 66, in exit compat.reraise(exc_type, exc_value, exc_tb) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 187, in reraise raise value File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2327, in _flush flush_context.execute() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/unitofwork.py", line 391, in execute rec.execute(self) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/unitofwork.py", line 556, in execute uow File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/persistence.py", line 181, in save_obj mapper, table, insert) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/persistence.py", line 830, in _emit_insert_statements execute(statement, multiparams) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 948, in execute return meth(self, multiparams, params) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/sql/elements.py", line 269, in _execute_on_connection return connection._execute_clauseelement(self, multiparams, params) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1060, in _execute_clauseelement compiled_sql, distilled_params File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1200, in _execute_context context) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1413, in _handle_dbapi_exception exc_info File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause reraise(type(exception), exception, tb=exc_tb, cause=cause) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 186, in reraise raise value.with_traceback(tb) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context context) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 507, in do_execute cursor.execute(statement, parameters) sqlalchemy.exc.InterfaceError: (sqlite3.InterfaceError) Error binding parameter 3 - probably unsupported type. [SQL: 'INSERT INTO "Koan" (pk, title, published, master_id, content) VALUES (?, ?, ?, ?, ?)'] [parameters: ('Seigen-1', 'Seigen lève son hossu', '2018-07-01 00:00:00.000000', ['Seigen Gyoshi', 'Sekito Kisen'], '
Maître Seigen Gyoshi, du monastère de [Jingju] demande un jour à Sekito Kisen « D’où venez vous ? ».
\nS ... (1067 characters truncated) ... 3;. ↩
\n\n\n')] (Background on this error at: http://sqlalche.me/e/rvf5)EXAMPLE 2:
here the keyword argument was not defined. Here I have to find the wrongly formatted file by myself.
Exception caught while attempting to generate project
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/statik/cmdline.py", line 171, in main
error_context=error_context
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/statik/generator.py", line 15, in generate
return project.generate(output_path=output_path, in_memory=in_memory)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/statik/project.py", line 108, in generate
self.db = self.load_db_data(self.models)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/statik/project.py", line 198, in load_db_data
markdown_config=self.config.markdown_config
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/statik/database.py", line 86, in init
self.create_db(models)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/statik/database.py", line 106, in create_db
self.load_all_model_data(models)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/statik/database.py", line 118, in load_all_model_data
self.load_model_data(model_data_path, model)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/statik/database.py", line 181, in load_model_data
self.load_model_data_from_files(path, model)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/statik/database.py", line 254, in load_model_data_from_files
db_entry = db_model(**entry.field_values)
File "
Okay cool, I see that the libraries that Statik depends on can generate errors from all sorts of angles, so I'm attempting to catch these a little better in v0.19.1.