Esempio n. 1
0
def dbgMsg(*args):
    if not debug:
        return
    errStr = getCallString(1)+" : "+string.join(map(str, args), " ")
    for handler in _messageHandlers:
        handler.handleDbgMsg(errStr)


registerMessageHandler(defaultMessageHandler())
#end of messaging.py

#test.py
#here is a simple use case for the above module
from messaging import stdMsg, dbgMsg, errMsg, setDebugging

setDebugging(0)

dbgMsg("this won't be printed")
stdMsg("but this will")

setDebugging(1)

def foo():
    dbgMsg("this is a debug message in", "foo")
    
class bar:
    def baz(self):
        errMsg("this is an error message in bar")

foo()
b = bar()
Esempio n. 2
0
import time

from os import environ
from socket import gethostname
from hashlib import md5
from random import randint
from httplib2 import Http, HttpLib2Error
from urllib import quote
from Cookie import SimpleCookie, CookieError
from messaging import dbgMsg, setDebugging

# Conf

ACCOUNT = "MO-19693661-1"
DOMAIN = 'mp-metrics.phms.com.br'
setDebugging(0)

##

VERSION = "4.4sh"
COOKIE_NAME = "__utmmobile"
COOKIE_PATH = "/"
COOKIE_USER_PERSISTENCE = 63072000

ENVIRON = environ
ENVIRON['HTTP_USER_AGENT'] = "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.12) Gecko/20101027 Ubuntu/10.04 (lucid) Firefox/3.6.12"
ENVIRON['HTTP_ACCEPT_LANGUAGE'] = "pt-br,pt;q=0.8,en-us;q=0.5,en;q=0.3"

def get_ip():
    remote_address = ENVIRON.get("REMOTE_ADDR",'')
Created by Peter McLachlan on 2009-07-19.
Copyright (c) 2009 Mobify. All rights reserved.
"""

import sys
import os
import getopt
from urlparse import urlparse
from flup.server.fcgi_fork import WSGIServer
from socket import gethostname
from datetime import datetime, timedelta
from ga import track_page_view

from messaging import stdMsg, dbgMsg, errMsg, setDebugging
setDebugging(1)

MINSPARE = 3
MAXSPARE = 7
MAXCHILDREN = 50
MAXREQUESTS = 500
HOST = '127.0.0.1'
PORT = 8009
PIDFILE = '/tmp/g_analytic_server.pid'
HELP_MESSAGE = """

This is some help.

"""

class Usage(Exception):