473,386 Members | 1,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

cgi-tb after os.chdir

I find that cgitb fails to show error context if I've changed my
default directory, so I tried to subclass cgitb and get it to save the
directory we were in when the program started. Didn't work. I'd
appreciate your eyes.

Problem--this apparently fails to find my sourcefile when #os.chdir is
uncommented from this cgi program
..........................

#! /usr/local/bin/python
import cgitb
cgitb.enable()

import os
#os.chdir('../')
1/0
..........................
What I thought would work:
..........................
from cgitb import Hook
import os
import sys

class myHook(Hook):
def __init__(self, display=1, logdir=None, context=5,
file=None,wkdir='xx'):
self.wkdir=wkdir
Hook.__init__(self, display=1, logdir=None, context=5, file=None)

def handle(self, info=None):
os.cwd(self.wkdir)
Hook.handle(self,info)

handler = myHook().handle
def enable(display=1, logdir=None, context=5):
wkdir=os.getcwd()
sys.excepthook = myHook(display, logdir, context,wkdir=wkdir)

..........................
But in fact, my exception handler doesn't even seem to get installed.
(I get python's usual tracebacks)

I'm probably over my head here, but...

What's wrong with the program where I attempt to subclass myHook?

Is this a reasonable way to get cgitb to survive directory changes?
Jul 18 '05 #1
0 1464

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Andrew DeFaria | last post by:
I have somebody or some people who are abusing a Perl based .cgi script. I have written a PHP page which reports this abuse as per $_SERVER. My intentions were to replace the .cgi script with this...
1
by: Mike S. Nowostawsky | last post by:
I am getting this error when I try to run a program in my cgi-bin directory (don't know what I'm still missing to make it work): *** Authentication required! This server could not verify that...
2
by: David | last post by:
I've looked all over the place for an answer, and the only one I can find doesn't mean anything to me. The end of line issue with writting it in Windows and then uploading it doesn't help me since...
0
by: David Staschover | last post by:
I'm trying to set up sessions in perl. The session is initialized fine in session1.cgi In session2.cgi, the correct session id is returned from the cookie, but when I initialize the session, a...
14
by: ccdetail | last post by:
http://www.tiobe.com/index.htm?tiobe_index Python is the 7th most commonly used language, up from 8th. The only one gaining ground besides VB in the top 10. We're glad, our app is written in...
11
by: Cecil Westerhof | last post by:
I have a cgi-script dat uses the modules cgi, os, sys and time. Offcourse I can not time the time used to import time, but os and sys do not take more as a millisecond. My script itself takes 3 or...
3
by: Adrian Smith | last post by:
While waiting for my paid-for web-hosting company to get back to me about my difficulties running python scripts on their servers......
4
by: arorap | last post by:
I've mod_php installed with Apache 2.2. In one of my folders, I'm using the cgihandler as the PythonHandler as my target host runs python only as CGI. Here cgi.FieldStorage() doesn't seem to work....
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
1
by: vikjohn | last post by:
I have a new perl script sent to me which is a revision of the one I am currently running. The permissions are the same on each, the paths are correct but I am getting the infamous : The specified...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.