Пример #1
0
    def __call__(self):

        with clepy.spinning_distraction():

            p = self.setup_p()

            # Call to the first specialized function.
            self.handle_p(p)

            options, args = self.setup_options_and_args(p)

            pitz.setup_logging(getattr(logging, options.log_level))

            # Call the second specialized function.
            self.handle_options_and_args(p, options, args)

            proj = self.setup_proj(p, options, args)

        # Third special function.
        if options.pdb:
            clepy.into_debugger(self.handle_proj)(p, options, args, proj)
        else:
            self.handle_proj(p, options, args, proj)

        if self.save_proj:
            proj.save_entities_to_yaml_files()

        os.remove(proj.pidfile)
Пример #2
0
def pitz_webapp():

    """
    This function gets run by the command-line script pitz-webapp.
    """

    p = setup_options()

    p.add_option('-p', '--port', help='HTTP port (default is 9876)',
       type='int', action='store', default=9876)

    options, args = p.parse_args()
    pitz.setup_logging(getattr(logging, options.log_level))

    if options.version:
        print_version()
        return

    pitzdir = Project.find_pitzdir(options.pitzdir)

    proj = Project.from_pitzdir(pitzdir)
    proj.find_me()

    app = webapp.SimpleWSGIApp(proj)

    # Remember that the order that you add handlers matters.  When a
    # request arrives, the app starts with the first handler added and
    # asks it if wants to handle that request.  So, the default handler
    # (if you make one) belongs at the end.

    # Consider this section below the same as the urls.py file in
    # django.

    static_files = os.path.join(os.path.split(
        os.path.dirname(__file__))[0], 'static')

    app.handlers.append(handlers.FaviconHandler(static_files))
    app.handlers.append(handlers.StaticHandler(static_files))
    app.handlers.append(handlers.HelpHandler(proj))
    app.handlers.append(handlers.Update(proj))
    app.handlers.append(handlers.ByFragHandler(proj))
    app.handlers.append(handlers.EditAttributes(proj))
    app.handlers.append(handlers.Project(proj))
    app.handlers.append(handlers.Team(proj))

    httpd = make_server('', options.port, app)
    print "Serving on port %d..." % options.port
    httpd.serve_forever()