Ejemplo n.º 1
0
def main(argv):
    logger = None
    if config.LOGGER_ENABLED:
        logger = util.initLog(config.LOGGER_NAME_FILE_HANDLER)
    multiprocessing.current_process().name = 'tmpfile_hander_process_main'
    tmpfile_hander = Tmpfile_hander(logger = logger, host = config.REDIS_HOST, port = config.REDIS_PORT)
    util.write_log_info(tmpfile_hander.lock, tmpfile_hander.logger,"[+]start tmpfile_hander...")
    tmpfile_hander.launch()
    try:
        content=raw_input()
        while content != 'exit':
            content=raw_input()
    except KeyboardInterrupt:
        pass
    util.write_log_info(tmpfile_hander.lock, tmpfile_hander.logger,"user determined tmpfile_hander")
    tmpfile_hander.quit()
Ejemplo n.º 2
0
def main(argv):
    import socket
    socket.setdefaulttimeout(config.SOCKET_TIMEOUT)
    logger = None
    if config.LOGGER_ENABLED:
        logger = util.initLog(config.LOGGER_NAME_DETAIL_PAGE_HANDLER)
    multiprocessing.current_process().name = 'detail_page_handler_process_main'
    detail_page_handler = Detail_page_handler(logger = logger, host = config.REDIS_HOST, port = config.REDIS_PORT)
    util.write_log_info(detail_page_handler.lock, detail_page_handler.logger,"[+]start detail_page_handler...")
    detail_page_handler.launch()
    try:
        content=raw_input()
        while content != 'exit':
            content=raw_input()
    except KeyboardInterrupt:
        pass
    util.write_log_info(detail_page_handler.lock, detail_page_handler.logger,"user determined detail_page_handler")
    detail_page_handler.quit()
Ejemplo n.º 3
0
def main():
    logger = initLog('get_data','./get_data.log') 
    logger.info('---------- begin get_log_data ----------')
    readSettingFile('./setting.ini',settings) 
    logger.info('read setting.ini file success.')
    logger.info("[hive_server] ip:'%s',port:'%d' cycle:'%d'days" %(settings['hive_ip'],settings['hive_port'],settings['cycle']))

    date_today = datetime.datetime.date(datetime.datetime.now())
    date_end = date_today - datetime.timedelta(days=1)    #截止到1天前
    date_begin = date_today - datetime.timedelta(days=settings['cycle'])    #从cycle天前开始

    date_today = date_today.strftime("%Y%m%d")      #程序执行日期,比统计结束日期多一天
    date_end   = date_end.strftime("%Y%m%d")        #统计结束日期
    date_begin = date_begin.strftime("%Y%m%d")      #统计开始日期

    if settings['time_begin'].strip():
        date_begin = settings['time_begin']
    if settings['time_end'].strip():
        date_end = settings['time_end']

    logger.info("date_begin = %s date_end = %s date_today = %s" %(date_begin, date_end,date_today))

    if "%s" in settings['sql']:
        sql_str = settings['sql'].rstrip(';') %(date_begin,date_end)
        result_file=settings['result_file']+'.'+date_begin+'-'+date_end
    else:
        sql_str = settings['sql'].rstrip(';')
        result_file=settings['result_file']+'.'+date_today
    

    if os.path.exists(result_file):
        os.remove(result_file)
        logger.info("remove %s from hive last cycle."%result_file)
   
    logger.info("begin get data form hive and write to %s file..." %result_file)
    if getSearchLog(settings['hive_ip'],settings['hive_port'],settings['database'],sql_str,result_file,settings['limit_num'],logger):
        logger.info('---------- end get_log_data ----------')
        return True
    else:
        logger.info("get data failed!")
        if os.path.exists(result_file):
            os.remove(result_file)
        logger.info('---------- end get_log_data ----------')
        return False
Ejemplo n.º 4
0
def main(argv):
    import socket

    socket.setdefaulttimeout(config.SOCKET_TIMEOUT)
    logger = None
    if config.LOGGER_ENABLED:
        logger = util.initLog(config.LOGGER_NAME_DOWNLOADER)
    threading.current_thread().setName("downloader_thread_main")
    downloader = Downloader(logger=logger, host=config.REDIS_HOST, port=config.REDIS_PORT)
    util.write_log_info(downloader.lock, downloader.logger, "[+]start downloader...")
    downloader.launch()
    try:
        content = raw_input()
        while content != "exit":
            content = raw_input()
    except KeyboardInterrupt:
        pass
    util.write_log_info(downloader.lock, downloader.logger, "user determined downloader")
    downloader.quit()
Ejemplo n.º 5
0
def main(argv):
    logger = None
    if config.LOGGER_ENABLED:
        logger = util.initLog(config.LOGGER_NAME_FILE_HANDLER)
    multiprocessing.current_process().name = 'tmpfile_hander_process_main'
    tmpfile_hander = Tmpfile_hander(logger=logger,
                                    host=config.REDIS_HOST,
                                    port=config.REDIS_PORT)
    util.write_log_info(tmpfile_hander.lock, tmpfile_hander.logger,
                        "[+]start tmpfile_hander...")
    tmpfile_hander.launch()
    try:
        content = raw_input()
        while content != 'exit':
            content = raw_input()
    except KeyboardInterrupt:
        pass
    util.write_log_info(tmpfile_hander.lock, tmpfile_hander.logger,
                        "user determined tmpfile_hander")
    tmpfile_hander.quit()
Ejemplo n.º 6
0
def main(argv):
    import socket
    socket.setdefaulttimeout(config.SOCKET_TIMEOUT)
    logger = None
    if config.LOGGER_ENABLED:
        logger = util.initLog(config.LOGGER_NAME_DOWNLOADER)
    threading.current_thread().setName('downloader_thread_main')
    downloader = Downloader(logger=logger,
                            host=config.REDIS_HOST,
                            port=config.REDIS_PORT)
    util.write_log_info(downloader.lock, downloader.logger,
                        "[+]start downloader...")
    downloader.launch()
    try:
        content = raw_input()
        while content != 'exit':
            content = raw_input()
    except KeyboardInterrupt:
        pass
    util.write_log_info(downloader.lock, downloader.logger,
                        "user determined downloader")
    downloader.quit()
Ejemplo n.º 7
0
The DBPasswordChecker is based on an example from the book
Twisted Network Programming Essentials by Abe Fettig. Copyright 2006
O'Reilly Media, Inc., ISBN 0-596-10032-9
"""

import sys, os, random
import signal

# keyboardinterrupt should simply terminate
signal.signal(signal.SIGINT, signal.SIG_DFL)

from common import InternalParameters
InternalParameters.isServer = True
InternalParameters.logPrefix = 'S'
from util import initLog
initLog('kajonggserver')

from PyQt4.QtCore import QCoreApplication
from twisted.spread import pb
from twisted.internet import error
from twisted.internet.defer import maybeDeferred, fail
from zope.interface import implements
from twisted.cred import checkers, portal, credentials, error as credError
from twisted.internet import reactor

from game import RemoteGame
from player import Players
from wall import WallEmpty
from client import Client
from query import Transaction, Query, initDb
from predefined import loadPredefinedRulesets
    sql = 'select * from stock'
    ret = _db.query(sql)
    return ret

def getAllOriUsStocks():
    sql = 'select * from ori_stock_us'
    ret = _db.query(sql)
    return ret

def getAllOriSzStocks():
    sql = 'select * from ori_stock_A_sz'
    ret = _db.query(sql)
    return ret

def getAllOriShStocks():
    sql = 'select * from ori_stock_A_sh'
    ret = _db.query(sql)
    return ret

def getAllOriHkStocks():
    sql = 'select * from ori_stock_hk'
    ret = _db.query(sql)
    return ret

if __name__ == '__main__':
    initDb()
    util.initLog()
    update(30)
    quitDb()

Ejemplo n.º 9
0
        result.append(variants[0].string)
        for hand in variants:
            score = hand.score
            roofOff = ' roofOff' if hand.ruleset.roofOff else ''
            if score != expected:
                result.append('%s%s: %s should be %s' % (
                    hand.ruleset.name, roofOff, score.__str__(), expected.__str__()))
                result.append('hand:%s' % hand)
            if total is not None:
                if score.total() != total:
                    result.append('%s%s: total %s for %s should be %s' % (hand.ruleset.name, roofOff,
                        score.total(), score.__str__(), total))
                result.append('hand:%s' % hand)
            result.extend(hand.explain())
            result.append('base=%d,doubles=%d,total=%d' % (score.points, score.doubles, hand.total()))
            result.append('')
        return '\n'.join(result).encode('ascii', 'ignore')

class TstProgram(unittest.TestProgram):
    """we want global access to this program so we can check for verbosity in our tests"""
    def __init__(self, *args, **kwargs):
        global PROGRAM # pylint: disable=W0603
        PROGRAM = self
        unittest.TestProgram.__init__(self, *args, **kwargs)

if __name__ == '__main__':
    initLog('kajonggtest')
    Debug.profileRegex = True
   # Debug.handMatch = True
    TstProgram()
Ejemplo n.º 10
0
def getAllOriUsStocks():
    sql = 'select * from ori_stock_us'
    ret = _db.query(sql)
    return ret


def getAllOriSzStocks():
    sql = 'select * from ori_stock_A_sz'
    ret = _db.query(sql)
    return ret


def getAllOriShStocks():
    sql = 'select * from ori_stock_A_sh'
    ret = _db.query(sql)
    return ret


def getAllOriHkStocks():
    sql = 'select * from ori_stock_hk'
    ret = _db.query(sql)
    return ret


if __name__ == '__main__':
    initDb()
    util.initLog()
    update(30)
    quitDb()
Ejemplo n.º 11
0
                    value = str(event.text())
                else:
                    value = ''
                if value:
                    value = '(%s)' % value
                msg = '%s%s->%s' % (name, value, receiver)
                if hasattr(receiver, 'text'):
                    msg += '(%s)' % receiver.text()
                elif hasattr(receiver, 'objectName'):
                    msg += '(%s)' % receiver.objectName()
                logDebug(msg)
        return QObject.eventFilter(self, receiver, event)

if __name__ == "__main__":
    from util import initLog
    initLog('kajongg')

    ABOUT = About()
    KCmdLineArgs.init (sys.argv, ABOUT.about)
    KCmdLineArgs.addCmdLineOptions(defineOptions())
    KApplication.setGraphicsSystem('raster')
    APP = KApplication()
    parseOptions()

    if Debug.events:
        EVHANDLER = EvHandler()
        APP.installEventFilter(EVHANDLER)

    from config import SetupPreferences
    SetupPreferences()
Ejemplo n.º 12
0
        result.append(variants[0].string)
        for hand in variants:
            score = hand.score
            roofOff = ' roofOff' if hand.ruleset.roofOff else ''
            if score != expected:
                result.append('%s%s: %s should be %s' % (
                    hand.ruleset.name, roofOff, score.__str__(), expected.__str__()))
                result.append('hand:%s' % hand)
            if total is not None:
                if score.total() != total:
                    result.append('%s%s: total %s for %s should be %s' % (hand.ruleset.name, roofOff,
                        score.total(), score.__str__(), total))
                result.append('hand:%s' % hand)
            result.extend(hand.explain())
            result.append('base=%d,doubles=%d,total=%d' % (score.points, score.doubles, hand.total()))
            result.append('')
        return '\n'.join(result).encode('ascii', 'ignore')

class TstProgram(unittest.TestProgram):
    """we want global access to this program so we can check for verbosity in our tests"""
    def __init__(self, *args, **kwargs):
        global PROGRAM # pylint: disable=W0603
        PROGRAM = self
        unittest.TestProgram.__init__(self, *args, **kwargs)

if __name__ == '__main__':
    initLog('kajonggtest')
    Debug.profileRegex = True
   # Debug.handMatch = True
    TstProgram()