Skip to content
This repository has been archived by the owner on Jan 12, 2022. It is now read-only.

Commit

Permalink
Use mozhttpd for webserver and print tracebacks to debug
Browse files Browse the repository at this point in the history
  • Loading branch information
ahal-test committed Nov 7, 2011
1 parent 112e19a commit 250120b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 74 deletions.
54 changes: 0 additions & 54 deletions peptest/pepserver.py

This file was deleted.

37 changes: 17 additions & 20 deletions peptest/runpeptests.py
Expand Up @@ -37,18 +37,19 @@
from optparse import OptionParser
from mozprofile import FirefoxProfile, ThunderbirdProfile, Profile
from mozrunner import FirefoxRunner, ThunderbirdRunner, Runner
from mozhttpd import MozHttpd
from manifestparser import TestManifest
from pepserver import PepHTTPServer
from pepprocess import PepProcess
from pepresults import Results

import peputils as utils
import glob
import traceback
import mozlog
import os
import glob
import shutil
import sys
import signal
import os
import sys

results = Results()
here = os.path.dirname(os.path.realpath(__file__))
Expand All @@ -64,7 +65,7 @@ class Peptest():

def __init__(self, options, **kwargs):
self.options = options
self.child_pid = None
self.server = None
self.logger = mozlog.getLogger('PEP')

# create the profile
Expand Down Expand Up @@ -140,15 +141,10 @@ def runServer(self):
if not self.options.serverPath:
self.logger.warning('Can\'t start HTTP server, --server-path not specified')
return
pId = os.fork()
# if child process
if pId == 0:
os.chdir(os.path.dirname(self.options.serverPath))
self.server = PepHTTPServer(self.options.serverPort)
self.logger.debug('Starting server on port ' + str(self.options.serverPort))
self.server.serve_forever()
else:
self.child_pid = pId
self.logger.debug('Starting server on port ' + str(self.options.serverPort))
self.server = MozHttpd(port=self.options.serverPort,
docroot=self.options.serverPath)
self.server.start(block=False)

def stop(self):
"""Kill the app"""
Expand All @@ -157,9 +153,8 @@ def stop(self):
self.runner.stop()

# kill the server process
if self.child_pid is not None:
# TODO Kill properly (?)
os.kill(self.child_pid, signal.SIGKILL)
if self.server:
self.server.stop()

# remove harness related files
files = ['manifest.json']
Expand Down Expand Up @@ -310,7 +305,7 @@ def __init__(self, **kwargs):

self.add_option("--server-port",
action="store", type="int", dest="serverPort",
default=8080,
default=8888,
help="The port to host test related files on")

self.add_option("--server-path",
Expand Down Expand Up @@ -375,8 +370,10 @@ def main(args=sys.argv[1:]):
try:
peptest = applications[options.app](options)
return peptest.start()
except Exception, e:
logger.error(str(type(e)) + ' ' + str(e))
except Exception:
cla, exc = sys.exc_info()[:2]
logger.error("%s: %s" % (cla.__name__, exc))
logger.debug("Traceback:\n%s" % (traceback.format_exc()))
return 2

if __name__ == '__main__':
Expand Down

0 comments on commit 250120b

Please sign in to comment.