~ubuntu-branches/debian/jessie/cherrypy3/jessie

« back to all changes in this revision

Viewing changes to cherrypy/test/test_states_demo.py

  • Committer: Package Import Robot
  • Author(s): Gustavo Noronha Silva, JCF Ploemen, Stéphane Graber, Gustavo Noronha
  • Date: 2012-01-06 10:13:27 UTC
  • mfrom: (1.1.4) (7.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20120106101327-smxnhguqs14ubl7e
Tags: 3.2.2-1
[ JCF Ploemen ]
* New upstream release (Closes: #571196).
* Bumped Standards-Version to 3.8.4 (no changes needed).
* Removing patch 02: no longer needed, incorporated upstream.
* Updating patch 00 to match release.
* Install cherryd man page via debian/manpages.
* debian/copyright:
  + Added notice for cherrypy/lib/httpauth.py.
  + Fixed years.
* debian/watch:
  + Don't hit on the -py3 release by blocking '-' from the version.
  + Mangle upstream version, inserting a tilde for beta/rc.

[ Stéphane Graber <stgraber@ubuntu.com> ]
 * Convert from python-support to dh_python2 (#654375)
  - debian/pyversions: Removed (no longer needed)
  - debian/rules
   + Replace call to dh_pysupport by dh_python2
   + Add --with=python2 to all dh calls
  - debian/control
   + Drop build-depends on python-support
   + Bump build-depends on python-all to >= 2.6.6-3~
   + Replace XS-Python-Version by X-Python-Version
   + Remove XB-Python-Version from binary package

[ Gustavo Noronha ]
* debian/control, debian/rules, debian/manpages:
 - use help2man to generate a manpage for cherryd at build time, since
  one is no longer shipped along with the source code
* debian/control:
- add python-nose to Build-Depends, since it's used during the
  documentation build for cross-reference generation

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
import os
2
 
import sys
3
 
import time
4
 
starttime = time.time()
5
 
 
6
 
import cherrypy
7
 
 
8
 
 
9
 
class Root:
10
 
    
11
 
    def index(self):
12
 
        return "Hello World"
13
 
    index.exposed = True
14
 
    
15
 
    def mtimes(self):
16
 
        return repr(cherrypy.engine.publish("Autoreloader", "mtimes"))
17
 
    mtimes.exposed = True
18
 
    
19
 
    def pid(self):
20
 
        return str(os.getpid())
21
 
    pid.exposed = True
22
 
    
23
 
    def start(self):
24
 
        return repr(starttime)
25
 
    start.exposed = True
26
 
    
27
 
    def exit(self):
28
 
        # This handler might be called before the engine is STARTED if an
29
 
        # HTTP worker thread handles it before the HTTP server returns
30
 
        # control to engine.start. We avoid that race condition here
31
 
        # by waiting for the Bus to be STARTED.
32
 
        cherrypy.engine.wait(state=cherrypy.engine.states.STARTED)
33
 
        cherrypy.engine.exit()
34
 
    exit.exposed = True
35
 
    
36
 
try:
37
 
    from signal import signal, SIGTERM
38
 
except ImportError:
39
 
    pass
40
 
else:
41
 
    def old_term_handler(signum=None, frame=None):
42
 
        cherrypy.log("I am an old SIGTERM handler.")
43
 
        sys.exit(0)
44
 
    signal(SIGTERM, old_term_handler)
45
 
 
46
 
def unsub_sig():
47
 
    if cherrypy.config.get('unsubsig', False):
48
 
        cherrypy.engine.signal_handler.unsubscribe()
49
 
cherrypy.engine.subscribe('start', unsub_sig, priority=100)
50
 
 
51
 
 
52
 
def starterror():
53
 
    if cherrypy.config.get('starterror', False):
54
 
        zerodiv = 1 / 0
55
 
cherrypy.engine.subscribe('start', starterror, priority=6)
56
 
 
57
 
 
58
 
cherrypy.tree.mount(Root(), '/', {'/': {}})