Exemplo n.º 1
0
#!/usr/bin/env python

# from system
import sys, site, os, time, re, select, struct, traceback, socket, getopt, logging, logging.config

# from kpython
from kpg import exec_pg_query_rb_on_except, exec_pg_select_rb, ntos
from kfile import first_existing_file

# Paster configuration file.
paster_config_path = first_existing_file([
        os.path.join(os.environ['KWMO_PATH'], 'production.ini'),
        'production.ini',
        'development.ini'])

# Path for storing kwsfetcher information.
fetcher_path = "/var/cache/teambox/kwsfetcher"

# Keepalive parameters. See the Linux documentation for details. We want the
# connection to time out after 6 minutes.
tcp_keepalive_time = 60
tcp_keepalive_intvl = 60
tcp_keepalive_probes = 5

# Append kwmo application path to python path.
sys.path.append(os.environ['KWMO_PATH'])

# Add site directory (would work with PYTHONPATH but not with sys.path because sys.path does not 
# handle PTH files).
site.addsitedir(os.path.join(os.environ['VIRTUALENV'],
                'lib',
Exemplo n.º 2
0
# WARNING: Make sure the database you set in the config file does not contain important informations, in case 
# the method overriding fails (see the execute function).
# WARNING 2: Make sure to dump with the same database engine that is used in production (postgres).

import sys, os, elixir, re
from paste.deploy import appconfig
from kwmo.config.environment import load_environment
from kwmo.model.meta import metadata
from sqlalchemy.engine.base import SchemaIterator

# from kpython
from kfile import first_existing_file

# Paster configuration file.
paster_config_file = first_existing_file([
    'development.ini'])

# Print SQL queries that would normally be executed by sqlalchemy
# (by overriding the SchemaIterator execute method - is this way safe?
#  SQLAlchemy does not provide a way to do this and we don't want 
#  to modify this package).
def execute(self):
    try:
        # Get lines in buffer.
        lines = self.buffer.getvalue().split('\n')

        # Strip empty lines.
        lines = filter(lambda x: bool(x), lines)

        # print query.
        query = '\n'.join(lines) + ';'
Exemplo n.º 3
0
#!/usr/bin/env python

# from system
import sys, site, os, time, re, select, struct, traceback, socket, getopt, logging, logging.config

# from kpython
from kpg import exec_pg_query_rb_on_except, exec_pg_select_rb, ntos
from kfile import first_existing_file

# Paster configuration file.
paster_config_path = first_existing_file([
    os.path.join(os.environ['KWMO_PATH'], 'production.ini'), 'production.ini',
    'development.ini'
])

# Path for storing kwsfetcher information.
fetcher_path = "/var/cache/teambox/kwsfetcher"

# Keepalive parameters. See the Linux documentation for details. We want the
# connection to time out after 6 minutes.
tcp_keepalive_time = 60
tcp_keepalive_intvl = 60
tcp_keepalive_probes = 5

# Append kwmo application path to python path.
sys.path.append(os.environ['KWMO_PATH'])

# Add site directory (would work with PYTHONPATH but not with sys.path because sys.path does not
# handle PTH files).
site.addsitedir(
    os.path.join(os.environ['VIRTUALENV'], 'lib', 'python' + sys.version[:3],