예제 #1
0
def setup(app_name='kitty', settings_module=""):

    from kitty.utils import log
    from kitty.conf import KITTY_SETTINGS_MODULE, settings

    os.environ.setdefault(KITTY_SETTINGS_MODULE, settings_module)

    if not app_name:
        app_name = 'kitty'

    if not os.path.isdir(settings.LOG_PATH):
        os.mkdir(settings.LOG_PATH)

    LOG_CONFIG = {
        'name': app_name,
        'filename': settings.LOG_PATH + "/" + app_name + ".log",
        'level': settings.LOG_LEVEL
    }

    log.getLogger(**LOG_CONFIG)
예제 #2
0
def test_conf():
    app_name = 'test'
    kitty.setup(app_name, "kitty.test.settings")
    # kitty.setup()

    from kitty.conf import settings
    from kitty.utils.log import getLogger
    from kitty.utils.function import empty
    from kitty.utils.log import root

    print settings.is_overridden('LOG_PATH')
    print 'TEST_CONF' in settings._wrapped._explicit_settings

    logger = getLogger(app_name)

    print "app name", app_name
    print "logger name ", logger.name
    print "logger parent name ", logger.parent.name
예제 #3
0
파일: test_conf.py 프로젝트: zoumo/kitty
def test_conf():
    app_name = 'test'
    kitty.setup(app_name, "kitty.test.settings")
    # kitty.setup()

    from kitty.conf import settings
    from kitty.utils.log import getLogger
    from kitty.utils.function import empty
    from kitty.utils.log import root

    print settings.is_overridden('LOG_PATH')
    print 'TEST_CONF' in settings._wrapped._explicit_settings

    logger = getLogger(app_name)

    print "app name", app_name
    print "logger name ", logger.name
    print "logger parent name ", logger.parent.name
예제 #4
0
        end = end if end < query_len else query_len
        l = query_list[start:end]
        sub_thread = ImgPress(i, site, l)
        sub_thread.start()


def opt_parse():
    parser = argparse.ArgumentParser(description='this is a spider')
    parser.add_argument('file',
                        help='query list file path')
    parser.add_argument('-p', action='store', dest='velocity', type=int, default=20,
                        help='request velocity(per second), default 20')
    args = parser.parse_args()
    return args

if __name__ == "__main__":
    global logger

    args = opt_parse()

    app_name = 'spider'
    kitty.setup(app_name, "bin.settings")

    from kitty.utils.log import getLogger

    logger = getLogger(app_name)

    logger.notice('start')
    doPress('10.46.128.15:8090', args.file, args.velocity)
, args.velocity)
예제 #5
0
파일: spider.py 프로젝트: zoumo/kitty
        if not json_str:
            print "getImageJsonStr error, query[%s]" % (query)
            continue
        # print json_str
        if not parseJson(json_str, query, pn, file_out):
            print "parseJson error, query[%s]" % (query)
            continue


def opt_parse():
    parser = argparse.ArgumentParser(description='this is a spider')
    parser.add_argument('-i', action='store', dest='file_in', type=argparse.FileType('r'), help='query list file path')
    parser.add_argument('-o', action='store', dest='file_out', type=argparse.FileType('w'), help='')
    args = parser.parse_args()
    return args

if __name__ == "__main__":
    global logger

    args = opt_parse()

    app_name = 'spider'
    kitty.setup(app_name, "bin.settings")

    from kitty.utils.log import getLogger

    logger = getLogger(app_name)

    logger.notice('start')
    spider('tc-img-sweb0.tc.baidu.com:8090', args.file_in, args.file_out)