ludovicchabant / PieCrust2

A simple yet powerful static website generator and lightweight CMS
Other
43 stars 8 forks source link

Missing attributes and unexpected keyword #32

Closed wazari972 closed 8 years ago

wazari972 commented 8 years ago

Hello, I see several problems with the last version of PieCrust (chef 2.0.0rc1) (on Archlinux, piecrust up to date with pip)

Let me know if you need further details about this problem, and thank you for the tool you're building, it's great :-)

chef --debug admin

[piecrust.main] Using cache key: default
[piecrust.app] Creating site configuration...
[piecrust.appconfig] Loading configuration from cache...
[piecrust.cache] Reading cache: /home/kevin/git/mcgdb_website/_cache/c21f969b5f03d33d43e04f8f136e7682/app/config.json
[piecrust.commands.builtin.scaffolding] Skipping source 'theme_pages' because it's a theme source.
[piecrust.main] [   168.7 ms] initialized PieCrust
[piecrust.main] 'Namespace' object has no attribute 'monitor_assets'
Traceback (most recent call last):
  File "/usr/lib/python3.5/site-packages/piecrust/main.py", line 70, in main
    exit_code = _run_chef(pre_args, argv)
  File "/usr/lib/python3.5/site-packages/piecrust/main.py", line 296, in _run_chef
    exit_code = result.func(ctx)
  File "/usr/lib/python3.5/site-packages/piecrust/commands/builtin/admin.py", line 53, in checkedRun
    return self._runFoodTruck(ctx)
  File "/usr/lib/python3.5/site-packages/piecrust/commands/builtin/admin.py", line 59, in _runFoodTruck
    if (ctx.args.monitor_assets and (
AttributeError: 'Namespace' object has no attribute 'monitor_assets'

chef --debug admin run

[piecrust.main] Using cache key: default
[piecrust.app] Creating site configuration...
[piecrust.appconfig] Loading configuration from cache...
[piecrust.cache] Reading cache: /home/kevin/git/mcgdb_website/_cache/c21f969b5f03d33d43e04f8f136e7682/app/config.json
[piecrust.commands.builtin.scaffolding] Skipping source 'theme_pages' because it's a theme source.
[piecrust.main] [   169.9 ms] initialized PieCrust
[foodtruck.web] Using FoodTruck admin root: /home/kevin/git/mcgdb_website
[werkzeug]  * Running on http://localhost:8090/ (Press CTRL+C to quit)
[werkzeug]  * Restarting with stat
[piecrust.main] Using cache key: default
[piecrust.app] Creating site configuration...
[piecrust.appconfig] Loading configuration from cache...
[piecrust.cache] Reading cache: /home/kevin/git/mcgdb_website/_cache/c21f969b5f03d33d43e04f8f136e7682/app/config.json
[piecrust.commands.builtin.scaffolding] Skipping source 'theme_pages' because it's a theme source.
[piecrust.main] [   164.5 ms] initialized PieCrust
[piecrust.main] __init__() got an unexpected keyword argument 'debug'
Traceback (most recent call last):
  File "/usr/lib/python3.5/site-packages/piecrust/main.py", line 70, in main
    exit_code = _run_chef(pre_args, argv)
  File "/usr/lib/python3.5/site-packages/piecrust/main.py", line 296, in _run_chef
    exit_code = result.func(ctx)
  File "/usr/lib/python3.5/site-packages/piecrust/commands/builtin/admin.py", line 54, in checkedRun
    return ctx.args.sub_func(ctx)
  File "/usr/lib/python3.5/site-packages/piecrust/commands/builtin/admin.py", line 64, in _runFoodTruck
    proc_loop = ProcessingLoop(ctx.app.root_dir, out_dir, debug=ctx.args.debug)
TypeError: __init__() got an unexpected keyword argument 'debug'
[foodtruck.main] Shutting down SSE generators from main...

chef --debug publish sync

[piecrust.publishing.publisher] Running publish target 'sync' with publisher: rsync
[piecrust.main] Error publishing to target: sync
Traceback (most recent call last):
  File "/usr/lib/python3.5/site-packages/piecrust/publishing/publisher.py", line 111, in run
    success = pub.run(ctx)
  File "/usr/lib/python3.5/site-packages/piecrust/publishing/base.py", line 52, in run
    args = self._getCommandArgs(ctx)
  File "/usr/lib/python3.5/site-packages/piecrust/publishing/rsync.py", line 13, in _getCommandArgs
    orig = self.getConfigValue('source', ctx.bake_our_dir)
AttributeError: 'PublishingContext' object has no attribute 'bake_our_dir'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3.5/site-packages/piecrust/main.py", line 70, in main
    exit_code = _run_chef(pre_args, argv)
  File "/usr/lib/python3.5/site-packages/piecrust/main.py", line 296, in _run_chef
    exit_code = result.func(ctx)
  File "/usr/lib/python3.5/site-packages/piecrust/commands/base.py", line 36, in checkedRun
    return self.run(ctx)
  File "/usr/lib/python3.5/site-packages/piecrust/commands/builtin/publishing.py", line 77, in run
    log_file=ctx.args.log_publisher)
  File "/usr/lib/python3.5/site-packages/piecrust/publishing/publisher.py", line 114, in run
    "Error publishing to target: %s" % target) from ex
piecrust.publishing.publisher.PublishingError: Error publishing to target: sync
ludovicchabant commented 8 years ago

Ah shit, thanks! Should be fixed on master now -- I'll publish a new version on PyPi tomorrow. Cheers!

kpouget commented 8 years ago

if I did everything right ... I got this error now :

chef --debug publish test

[piecrust.main] Using cache key: default [piecrust.app] Creating site configuration... [piecrust.appconfig] Loading configuration from cache... [piecrust.cache] Reading cache: /home/kevin/travail/Documents/mcgdb_website/_cache/c21f969b5f03d33d43e04f8f136e7682/app/config.json [piecrust.commands.builtin.scaffolding] Skipping source 'theme_pages' because it's a theme source. [piecrust.main] init() takes 3 positional arguments but 4 were given Traceback (most recent call last): File "/home/kevin/travail/tools/PieCrust2/piecrust/main.py", line 70, in main exit_code = _run_chef(pre_args, argv) File "/home/kevin/travail/tools/PieCrust2/piecrust/main.py", line 269, in _run_chef c.setupParser(p, app) File "/home/kevin/travail/tools/PieCrust2/piecrust/commands/builtin/publishing.py", line 30, in setupParser for pub in app.publishers: File "/usr/lib/python3.5/site-packages/werkzeug/utils.py", line 71, in get value = self.func(obj) File "/home/kevin/travail/tools/PieCrust2/piecrust/app.py", line 195, in publishers tgt = cls(self, n, t) TypeError: init() takes 3 positional arguments but 4 were given

(with last git commit)

kpouget commented 8 years ago

another nit while I'm at it :)

diff --git a/foodtruck/scm/git.py b/foodtruck/scm/git.py

index 84350cb..871cc2e 100644
--- a/foodtruck/scm/git.py
+++ b/foodtruck/scm/git.py
@@ -31,7 +31,7 @@ class GitSourceControl(SourceControl):
                 else:
                     res.new_files.append(path)
             elif line.startswith(' M '):
-                res.edited_files.append(path[3:])
+                res.edited_files.append(line[3:])
         print(res.__dict__)
         return res

and by the way, I can't get the foodtruck to work (well), in particular the static pages are not accessible, in particular http://localhost:8090/static/css/foodtruck.min.css is 404, http://localhost:8090/static/img/foodtruck.png as well ... and I can't find where you hook to treat static content differently from dynamic pages ... !

kpouget commented 8 years ago

still playing around, I share my 'fixes' for just information, the first part of the diff tell you where are the problems :

diff --git a/foodtruck/web.py b/foodtruck/web.py
index 22f7113..376e300 100644
--- a/foodtruck/web.py
+++ b/foodtruck/web.py
@@ -34,7 +34,8 @@ if (app.config.get('FOODTRUCK_CMDLINE_MODE', False) and
 # Add a special route for the `.well-known` directory.
 app.wsgi_app = SharedDataMiddleware(
         app.wsgi_app,
-        {'/.well-known': os.path.join(admin_root, '.well-known')})
+        {'/.well-known': os.path.join(admin_root, '.well-known'),
+         '/static': "/path/to/PieCrust2/foodtruck/assets"})

 if os.path.isfile(config_path):
     app.config.from_pyfile(config_path)

get https://github.com/twbs/bootstrap-sass and useruby scss to build foodtruck.css


diff --git a/foodtruck/views/create.py b/foodtruck/views/create.py
index 841d192..4adf46b 100644
--- a/foodtruck/views/create.py
+++ b/foodtruck/views/create.py
@@ -45,8 +45,7 @@ def write_page(source_name):
                 fp.write('')
             flash("%s was created." % os.path.relpath(fac.path, site.root_dir))

-            route = site.getRoute(source.name, fac.metadata,
-                                  skip_taxonomies=True)
+            route = site.getSourceRoute(source.name, fac.metadata)
             if route is None:
                 logger.error("Can't find route for page: %s" % fac.path)
                 abort(500)

and

diff --git a/foodtruck/views/dashboard.py b/foodtruck/views/dashboard.py
index e4f1b1c..1409323 100644
--- a/foodtruck/views/dashboard.py
+++ b/foodtruck/views/dashboard.py
@@ -79,8 +79,9 @@ def _getWipData(path, site, fs_endpoints):
         return None

     fac = source.buildPageFactory(os.path.join(site.root_dir, path))
-    route = site.piecrust_app.getRoute(
-            source.name, fac.metadata, skip_taxonomies=True)
+    
+    route = site.piecrust_app.getSourceRoute(
+            source.name, fac.metadata)
     if not route:
         return None

--> naming problem?

ludovicchabant commented 8 years ago

Hey, sorry for the trouble... I didn't do a very good job with the test coverage on these parts of PieCrust :(

Anyway, first, I failed to document properly how to use FoodTruck with a source version of PieCrust. The problems you have with missing FoodTruck assets is that you have to run bower install and gulp (notice the Bower and Gulp files at the root of the PieCrust repo). This should make sure the FoodTruck assets are compiled into the static directory (and therefore you shouldn't have to edit the SharedDataMiddleware code).

Second, the Git support for FoodTruck is fairly experimental (I don't personally use Git), and I actually thought it wasn't included in the source! (i.e. I thought I kept it local). Oh well.

The other bugs should be fixed -- some I had fixes for already but it wasn't pushed yet (it is now). I'm refactoring things to make it possible to run automated tests on FoodTruck so it should get better. Sorry again!