Ejemplo n.º 1
0
 def __init__(self, *args, **kwargs):
     super(Testcases, self).__init__(*args, **kwargs)
     self.maxDiff = None
     self.hive = hve.Hive()
Ejemplo n.º 2
0
            if xiaoqu in xiaoquDic:
                sumUV = sumUV + xiaoquDic[xiaoqu]['uv']
                sumPV = sumPV + xiaoquDic[xiaoqu]['pv']
    return sumUV, sumPV


#}}

#def getData(startDate,endDate):

dts = ["2013-09-" + (str(i), str(i))[len(str(i)) - 1] for i in range(10, 29)]

dyn = globals()

for day in dts:
    dyn['hive' + day] = hive.Hive()
    #sql = "select regexp_extract(url, '/xiaoqu/([^/]*)/(.*|$)',1), uuid from web_pv_log_detail3 where dt = '" + day + "' and gjch regexp 'xiaoqu'"

    sql = "select regexp_extract(url, '/xiaoqu/([^/]*)/(.*|$)',1), uuid from web_pv_log_detail3 where dt = '" + day + "' and url regexp 'http://bj.ganji.com/xiaoqu/' and ca_name='se'"

    dyn['hive' + day].desc = day + 'xiaoquPvLog'
    dyn['hive' + day].session_name = day + 'xiaoquPvLog'
    print dyn['hive' + day].desc
    dyn['hive' + day].select(sql, dyn['hive' + day].desc,
                             dyn['hive' + day].session_name)

xiaoquSEOUV = {}
for day in dts:
    #print dyn['hive'+day]
    print day
    print dyn['hive' + day].getData()
Ejemplo n.º 3
0
    def __init__(self, telegram=False, temperature_game_over=True):
        # Define Screen Size
        self.disp_height = DISP_HEIGHT
        self.disp_width = DISP_WIDTH

        self.t0 = time.time()

        # self.screen = pygame.display.set_mode((self.disp_width, self.disp_height))
        self.screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)

        self.grid_height = GRID_HEIGHT
        self.grid_width = GRID_WIDTH

        self.map = Map(self.grid_height, self.grid_width)

        self.bees = {}

        self.thermometer = pygame.image.load(
            os.path.join(current_path, 'Thermometer_grey.png'))
        self.game_over_win = pygame.image.load(
            os.path.join(current_path, 'Game_Finished_Repaired.png'))
        self.game_over_heat = pygame.image.load(
            os.path.join(current_path, 'Game_Finished_T_high.png'))
        self.game_over_cold = pygame.image.load(
            os.path.join(current_path, 'Game_Finished_T_low.png'))

        h = self.game_over_win.get_height()
        w = self.game_over_win.get_width()
        scale = min(0.8 * DISP_HEIGHT / h, 0.8 * DISP_WIDTH / w)

        self.game_over_win = pygame.transform.scale(
            self.game_over_win, (int(w * scale), int(h * scale)))
        self.game_over_heat = pygame.transform.scale(
            self.game_over_heat, (int(w * scale), int(h * scale)))
        self.game_over_cold = pygame.transform.scale(
            self.game_over_cold, (int(w * scale), int(h * scale)))

        self.queue = queue.Queue(maxsize=10)

        self.webserver = make_app(self.queue)
        self.webserver.listen(8090)

        self.hive = hive.Hive(self.grid_height, self.grid_width)

        self.tornado_target = tornado.ioloop.IOLoop.current()
        self.tornado_thread = threading.Thread(
            target=self.tornado_target.start)
        self.tornado_thread.start()

        self.bot_queue = queue.Queue()
        if telegram:
            self.bot = bot.Bot(self.bot_queue)

        self.temperature = 150
        self.temperature_game_over = temperature_game_over
        self.temperature_limits = [0, 210]

        background_path = os.path.join(current_path, 'background_bees.ogg')
        dance_path = os.path.join(current_path, 'wild_bees.ogg')

        self.base_volume = 0.2
        self.background_sound = pygame.mixer.Sound(background_path)
        self.background_sound.set_volume(self.base_volume)
        self.dance_sound = pygame.mixer.Sound(dance_path)
        self.dance_sound.set_volume(self.base_volume)
Ejemplo n.º 4
0
#coding:utf-8
import sys
import html
import hive
from commonFunction import dateVal

hiveHandle = hive.Hive()


def fromAnalysisSimple(dt, conditions):

    sql = 'select dt,count(distinct uuid) as uv, count(1) as pv from web_pv_log_detail3 where dt="' + dt + '" and ' + conditions + ' and cat regexp "/fang/" group by dt;'
    print sql
    hiveHandle.desc = 'temp' + dt
    hiveHandle.session_name = 'temp' + dt
    try:
        hiveHandle.select(sql, hiveHandle.desc, hiveHandle.session_name)
        hiveHandle.getData()
    except Exception, e:
        print e


def fromAnalysisAll(select, conditions):

    sql = 'select ' + select + ' from web_pv_log_detail3 where ' + conditions + ';'
    print sql
    hiveHandle.desc = 'temp'
    hiveHandle.session_name = 'temp'
    try:
        hiveHandle.select(sql, hiveHandle.desc, hiveHandle.session_name)
        hiveHandle.getData()
Ejemplo n.º 5
0
    return str(int(string_num.upper(), 16))


UvPv = {}
UvPv['all'] = {}
UvPv['all']["uv"] = 0
UvPv['all']["pv"] = 0
count = 0

import hive
#查询数据
sql = 'select topn(1,array(FROM_UNIXTIME(access_at),cat,ca_source,url_decoding(ca_kw),url_decoding(refer),url),array(access_at),array(true)),uuid,sum(if(instr(cat,"list")>0,1,0)), sum(if(instr(cat,"search")>0,1,0)) as search_pv, sum(if(instr(cat,"detail")>0,1,0)) as detail_pv, sum(if(instr(cat,"index")>0,1,0)) as index_pv, count(1) as pv from web_pv_log_detail3 where dt>="' + dateEarly + '" and dt<="' + dateToday + '" and cat regexp "/fang/" group by uuid order by pv desc;'
desc = 'FangLastSevenDayPVUV'
session_name = 'FangLastSevenDayPVUV'

hive = hive.Hive()
hive.select(sql, desc, session_name)
hive.getData()

source = hive.outContent

for userCase in source:
    try:
        #print userCase
        access_at, cat, ca_source, ca_kw, refer, url, uuid, list_pv, search_pv, detail_pv, index_pv, pv = userCase.split(
            '\t')
        '''if int(pv[:-1]) >= 100 or uuid == "-":
            continue'''
    except:
        continue