Exemple #1
0
def profile_main():
    setup_project()
    setup_logging()

    import logging, cProfile, pstats, StringIO
    prof = cProfile.Profile()
    prof = prof.runctx('real_main()', globals(), locals())
    stream = StringIO.StringIO()
    stats = pstats.Stats(prof, stream=stream)
    sort_by = getattr(settings, 'SORT_PROFILE_RESULTS_BY', 'time')
    if not isinstance(sort_by, (list, tuple)):
        sort_by = (sort_by,)
    stats.sort_stats(*sort_by)

    restrictions = []
    profile_pattern = getattr(settings, 'PROFILE_PATTERN', None)
    if profile_pattern:
        restrictions.append(profile_pattern)
    max_results = getattr(settings, 'MAX_PROFILE_RESULTS', 80)
    if max_results and max_results != 'all':
        restrictions.append(max_results)
    stats.print_stats(*restrictions)
    extra_output = getattr(settings, 'EXTRA_PROFILE_OUTPUT', None) or ()
    if not isinstance(sort_by, (list, tuple)):
        extra_output = (extra_output,)
    if 'callees' in extra_output:
        stats.print_callees()
    if 'callers' in extra_output:
        stats.print_callers()
    logging.info('Profile data:\n%s', stream.getvalue())
Exemple #2
0
def real_main():
    setup_project()
    setup_logging()

    # Create a Django application for WSGI.
    application = django.core.handlers.wsgi.WSGIHandler()

    # Run the WSGI CGI handler with that application.
    util.run_wsgi_app(application)
Exemple #3
0
# -*- coding: utf-8 -*-
import os, sys

# Add current folder to sys.path, so we can import aecmd
current_dir = os.path.abspath(os.path.dirname(__file__))
sys.path = [current_dir] + sys.path

import aecmd
aecmd.setup_project()

from appenginepatcher.patch import patch_all, setup_logging
patch_all()

import django.core.handlers.wsgi
from google.appengine.ext.webapp import util
from django.conf import settings

def real_main():
    os.environ.update(aecmd.env_ext)
    setup_logging()

    # Create a Django application for WSGI.
    application = django.core.handlers.wsgi.WSGIHandler()

    # Run the WSGI CGI handler with that application.
    util.run_wsgi_app(application)

def profile_main():
    import logging, cProfile, pstats, random, StringIO
    only_forced_profile = getattr(settings, 'ONLY_FORCED_PROFILE', False)
    profile_percentage = getattr(settings, 'PROFILE_PERCENTAGE', None)
Exemple #4
0
# -*- coding: utf-8 -*-
import os, sys

# Add current folder to sys.path, so we can import aecmd
current_dir = os.path.abspath(os.path.dirname(__file__))
sys.path = [current_dir] + sys.path

import aecmd
aecmd.setup_project()

from appenginepatcher.patch import patch_all, setup_logging
patch_all()

import django.core.handlers.wsgi
from google.appengine.ext.webapp import util
from django.conf import settings


def real_main():
    os.environ.update(aecmd.env_ext)
    setup_logging()

    # Create a Django application for WSGI.
    application = django.core.handlers.wsgi.WSGIHandler()

    # Run the WSGI CGI handler with that application.
    util.run_wsgi_app(application)


def profile_main():
    import logging, cProfile, pstats, random, StringIO
Exemple #5
0
import os, sys

import logging
# Add folder to sys.path, so we can import aecmd
sys.path = [os.path.abspath(os.path.dirname(__file__) + "/../common/appenginepatch/"),] + sys.path

from aecmd import setup_project
setup_project()

from appenginepatcher.patch import patch_all, setup_logging
patch_all()

import bulkload
from google.appengine.api import datastore_types
from google.appengine.ext import search
from google.appengine.api import datastore
from google.appengine.ext import db

import datetime

from ts.search.models import TallstreetUrls, TallstreetTags, TallstreetUniverse, TallstreetHistory
from ts.traders.models import TallstreetPortfolio


from django.contrib.auth.models import User


class URLLoader(bulkload.Loader):
  def __init__(self):
    bulkload.Loader.__init__(self, 'TallstreetUrls',
                         [('url', datastore_types.Link),