ImportError: No module named Cheetah.Template

1,429 views
Skip to first unread message

oneman

unread,
Jul 5, 2008, 6:41:43 PM7/5/08
to skel...@googlegroups.com
Hi All,


I'm trying to get skeletonz installed as a deamon on debian etch. I
found the excellent init script by Martin Kaffanke (http://
groups.google.com/group/skeletonz/browse_thread/thread/
aed4bcfce161328d/471728359388fe2a?lnk=gst&q=init
+script#471728359388fe2a) in the archives and it seems to run fine.
However, I get importerrors that I don't get when executing the
original launch_server.py.

I get the following error message:

Traceback (most recent call last):
File "/usr/local/lib/skeletonz/skeletonzd", line 46, in ?
run(path)
File "/usr/local/lib/skeletonz/skeletonzd", line 10, in run
import general_config
File "/usr/local/lib/skeletonz/general_config.py", line 2, in ?
from templates.Default_Template import template
File "/usr/local/lib/skeletonz/templates/Default_Template/
template.py", line 1, in ?
from skeletonz.server import getConfig
File "/usr/local/lib/skeletonz/skeletonz/server.py", line 4, in ?
from Cheetah.Template import Template
ImportError: No module named Cheetah.Template

The cause if this lies in the fact that 'Cheetah' is a subfolder of
amilib. If I change

from Cheetah.Template import Template

into

from amilib.Cheetah.Template import Template

in /skeletonz/server.py, then the error goes away but is replaced by
a similar Cheeta module import error in /amilib/Cheetah/Template.py


I get an uneasy feeling that I'm overlooking the obvious. I works
fine when called from launch_server.py, but not from Kaffanke's
skeletonzd script. So the problem must lie there.

What can I change in Kaffanke's init scripts or somewhere else to get
this running without hunting down all Cheetah refrences in the code?


Thx,


Peter

Tim Kersten

unread,
Jul 6, 2008, 7:43:24 AM7/6/08
to skel...@googlegroups.com
> amilib. If I change
>
> from Cheetah.Template import Template
>
> into
>
> from amilib.Cheetah.Template import Template
>
> in /skeletonz/server.py, then the error goes away

I haven't looked at skeletonz in a while, but you could check if the
python paths are the same in launch_server.py as they in Kaffanke's
init scripts.

I'm not sure if this is the correct approach, but it seems to my that
the problem would go away if you make sure Cheetah is directly in the
python path.

Tim

oneman

unread,
Jul 6, 2008, 4:02:49 PM7/6/08
to skel...@googlegroups.com
On 6-jul-2008, at 13:43, Tim Kersten wrote:

>
>> amilib. If I change
>>
>> from Cheetah.Template import Template
>>
>> into
>>
>> from amilib.Cheetah.Template import Template
>>
>> in /skeletonz/server.py, then the error goes away
>
> I haven't looked at skeletonz in a while, but you could check if the
> python paths are the same in launch_server.py as they in Kaffanke's
> init scripts.
>

Thanks for you help Tim.

I looked at the path stuff in all the scripts, please keep in mind
that I'm no python expert...

The only pythonpath setting I could find is in Kaffanke's
skeletonzd.py file, and it is adding the amilib part in which Cheetah
is contained too:

sys.path.insert(0, os.path.abspath("amilib"))

this seems to add the amilib dir to the pythonpath, right? It's also
part of the launch_server.py script. Somehow the 'os.path.abspath'
part doesn't seem to work properly. So I replaced it with an absolute
path:

sys.path.insert(0, "/usr/local/lib/skeletonz/amilib")

Now it works. I found that abspath was introduced with python 2.5,
but the script uses 2.4 ...

Is there a solution that would work with 2.4 and doesn't need a
hardcoded path?


But more important, once skeletonz is running, it shouts a sort of
logging output all over the place. I've got no clue as to how to stop
it doing that.

Peter

Tim Kersten

unread,
Jul 6, 2008, 6:23:02 PM7/6/08
to skel...@googlegroups.com
Hi Peter,

> sys.path.insert(0, os.path.abspath("amilib"))
>
> this seems to add the amilib dir to the pythonpath, right?

Yes.

> So I replaced it with an absolute
> path:
>
> sys.path.insert(0, "/usr/local/lib/skeletonz/amilib")
>
> Now it works. I found that abspath was introduced with python 2.5,
> but the script uses 2.4 ...

abspath is in 2.4 if I'm not mistaken....
http://www.python.org/doc/2.4/lib/module-os.path.html

Now, the behaviour _may_ have changed, I don't know, just seems that
it does exist in python 2.4.

> Is there a solution that would work with 2.4 and doesn't need a
> hardcoded path?

Well, yes, but it's sort of hackish in my opinion. How about passing
the python path you want to the script when call it? i.e.:

$ PYTHONPATH=/usr/local/lib/skeletonz/amilib scriptname.py

> But more important, once skeletonz is running, it shouts a sort of
> logging output all over the place. I've got no clue as to how to stop
> it doing that.

I imagine that the script is outputting information to standard error
(strerr) so that you can optionally save it to a log file. You can
redirect this output as such:

$ # This will redirect stderr to logfile
$ scriptname.py 2> /path/to/logfile

$ # This will redirect stderr to /dev/null - which will let it disappear
$ # into sweet nothing.
$ scriptname.py 2> /dev/null


Please remember that I'm telling you all this from the top of my head,
so don't take my word for it. I hope it still helps you somewhat.

Tim

oneman

unread,
Jul 7, 2008, 2:00:25 PM7/7/08
to skel...@googlegroups.com

Yep, I know the trick and tried it. But the python script does some
neat forking tricks and in doing so detaches itself from the init
process. So, the only way to change this will be to change the python
script and make it log nicely to the syslogger. But I don't know how
and it will take a considerable amount of time. Time that I don't
have for this little project, alas. I'm going to try to setup my
(already up and running) moinmoinwiki as a temporary makeshift CMS.


>
>
> Please remember that I'm telling you all this from the top of my head,
> so don't take my word for it. I hope it still helps you somewhat.

You've been a great help. Thanks.
>
> Tim
>
> >

Tim Kersten

unread,
Jul 7, 2008, 5:27:29 PM7/7/08
to skel...@googlegroups.com
Hi Peter,

Mind if I ask how you are (were?) trying to deploy skeletonz? I only
ever deployed it once using lighttpd with delegate and it worked out
of the box for me.

Delegate was quite impressive and easy.

http://orangoo.com/skeletonz/User_guide/Running_Skeletonz_behind_Delegate/

Tim

oneman

unread,
Jul 8, 2008, 2:23:27 PM7/8/08
to skel...@googlegroups.com

On 7-jul-2008, at 23:27, Tim Kersten wrote:

>
> Hi Peter,
>
> Mind if I ask how you are (were?) trying to deploy skeletonz? I only
> ever deployed it once using lighttpd with delegate and it worked out
> of the box for me.
>

I've tried to get it to run on an Debian Linux Etch box, behind
apache2. It runs fine behind apache2 using mod_proxy and mod_rewrite.
In fact, using

# nohup python launch_server.py

works just fine as a launch method. Skeleton runs stable and output
goes into hohup.out. But that's, IMHO only good for running in a /
home on a shared server. (exactly what sketonz is mostly used for it
seems). I need to have it running as a service, since I won't be
close to the box once it's needed most (site will be hit by quite
some traffic on july 16th and the week after that while I'll be
camping in France) and so I need it to come up automagically and
safely after a reboot without any intervention. Some good logging to
syslogd would be nice too.

It would be another possibility to run it with mod_python or as a
CGI, but I'm not sure how to do that and there's no docs either. It
would make it possible to get rid of the need for an init script /
deamon and apache2 would take care of the logging.


Well, as it stands I'm going for Moinmoinwiki and the beautiful 'dew'
cms like theme. That'll do for now. For the final site I'll look into
something bigger like Joomla or Drupal. But then I'll need to invest
some more time.


Peter

Tim Kersten

unread,
Jul 8, 2008, 6:25:28 PM7/8/08
to skel...@googlegroups.com
That's fair. If all you need is an init script for whatever way it works for you, I can write one and then you can run it as a service. Of coure moinmoin isn't bad either. I use both, but haven't played with skeletonz since several months. If you don't need the init script, good luck with moinmoin! Else, get back to me :-)

Tim

oneman

unread,
Jul 9, 2008, 1:20:50 AM7/9/08
to skel...@googlegroups.com

On 9-jul-2008, at 0:25, Tim Kersten wrote:

> That's fair. If all you need is an init script for whatever way it
> works for you, I can write one and then you can run it as a
> service. Of coure moinmoin isn't bad either. I use both, but
> haven't played with skeletonz since several months. If you don't
> need the init script, good luck with moinmoin! Else, get back to
> me :-)
>

Well, my moinmoin 'CMS' is up and running now, so I won't need the
init script. But I think it would be a great idea anyway to write
them for the bigger distro's and add them to the Skeletonz download!
It really is the only thing lacking from a great simple CMS.

Thanks,


Peter

Reply all
Reply to author
Forward
0 new messages