def report_week(self, _num_week=None): """ :param num_week: :return: """ if _num_week is None: _num_week = this_week() wn = WeekNumber() ext = Extract() act = Activity() _pla = Planned() _week = wn.get_or_create(_num_week, True) gap_week = wn.get_gap_week(_week.date_init) import ipdb; ipdb.set_trace() if _num_week == this_week(): _pla.get_tasks_week() wn.import_extract_itau() wn.import_extract_mycap() m_summary_ext = self.get_matrix(gap_week, _week, Extract.__name__, None) m_summary_activ = self.get_matrix(gap_week, _week, Activity.__name__, None) m_details_ext = self.get_matrix(gap_week, _week, None, Extract.__name__) m_details_activ = self.get_matrix(gap_week, _week, None, Activity.__name__) for day in gap_week: cost_week = ext.get_cost_week(m_details_ext, day) try: activ_week = act.report_activity(m_details_activ, day) except Exception: print("trello unauthorized permission requested.") pass
def __init__(self, app): Activity.__init__(self, app) # self.cat = MySprite(self.surf) # self.cat.load("assets/test.png", 100, 100, 4) # self.group = pygame.sprite.Group() # self.group.add(self.cat) # self.cat.position = (100,100,100,100) self.pics = [] self.texts = [] state = self.app.activityData['state'] if 'pics' in state: for pic in state['pics']: content = eval(pic['content']) if isinstance(content,tuple): self.pics.append(content) else: position = eval(pic['position']) size = eval(pic['size']) self.pics.append(self.getPicture(content, size, position)) if 'texts' in state: for text in state['texts']: color = BLACK size = FONT_NORMAL if 'color' in text : color = eval(text['color']) if 'size' in text : size = eval(text['size']) t = self.getText(text=text['content'], size=size, position=eval(text['position']), color=color) self.texts.append(t)
def __init__(self, app): Activity.__init__(self, app) self.state = START self.conf = None self.start() self.stopShow = True self.stopThread = False self.image_thread() self.time_thread()
def update_graphic(self, _num_week=None): """ :param num_week: :return: """ if _num_week is None: _num_week = this_week() _act = Activity() _wn = WeekNumber() _week = _wn.get_or_create(_num_week, True) _plan = Planned().get_tasks_week(_week) gap_week = _wn.get_gap_week(_week.date_init) for day in gap_week: activ_week = _act.sync_activity(day)
def onKeyDown(self, key, e): if Activity.onKeyDown(self, key, e): return if e == key.btn_key1: self.app.activityData['status'] = CHOICE_YES self.close() elif e == key.btn_key2: self.app.activityData['status'] = CHOICE_NO self.close()
def graphic_time_activity_day(): """ :return: """ output_file = open(_time_activity_day, 'w') _num_week = int(this_week()) - 1 _week = WeekNumber.objects.get(num_week= _num_week) _act = Activity() _tp_acts = TypeActivity.objects.values('group').distinct() # xdata = ["Orange", "Banana", "Pear", "Kiwi", "Apple", "Strawberry", "Pineapple"] # ydata = [3, 4, 0, 1, 5, 7, 3] xdata = [] ydata = [] _time = 0 for _type_act in _tp_acts: _time_week = _act.get_time_activity(_week, _type_act['group']) if not _time_week is None and _time_week > 0: xdata.append(_type_act['group']) ydata.append(float(_time_week)) _time += float(_time_week) type = 'Closed %s - time activity (%s hours weeks)' %(DayL[int(_time/24)-1], str(_time)) chart = pieChart(name=type, color_category='category20c', height=450, width=450) chart.set_containerheader("\n\n<h2>" + type + "</h2>\n\n") extra_serie = {"tooltip": {"y_start": "", "y_end": " hs"}} chart.add_serie(y=ydata, x=xdata, extra=extra_serie) chart.buildhtml() output_file.write(chart.htmlcontent) output_file.close() # data = { # 'charttype': charttype, # 'chartdata': chartdata, # } # return render_to_response("graphic.html") # new_uri = '%s://%s%s%s' % ( # request.is_secure() and 'https' or 'http', # site.domain, # urlquote(request.path), # (request.method == 'GET' and len(request.GET) > 0) and '?%s' % request.GET.urlencode() or '' # ) http://eikke.com/django-domain-redirect-middleware/ graphic_view(_time_activity_day)
def onKeyDown(self, key, e): if Activity.onKeyDown(self, key, e): return if self.state == TAN_START: if e == key.btn_left: self.state = TAN_SEEK self.seek() self.activity_state = ANIMATE_START self.setAnimateIn(animate=activityLinearMove, start=(1,0), end=(0,0)) elif e == key.btn_right: self.state = TAN_SEEK self.seek() self.activity_state = ANIMATE_START self.setAnimateIn(animate=activityLinearMove, start=(-1,0), end=(0,0)) elif self.state == TAN_SEEK: if e == key.btn_key1: self.state = TAN_CONFIRM self.pics.append(self.getPicture(PIC_SPEEK_P_LEFT,(1,1),(0,0.2))) self.texts = [self.getText('你确定选择他吗?', FONT_NORMAL, (CENTER,LINE_2), BLACK)] self.texts.append(self.getText('A 确定 B 再看看', FONT_NORMAL, (CENTER,LINE_1), BLACK)) elif e == key.btn_left: self.app.background = self.men[self.selectNum] self.selectNum -= 1 self.selectNum = self.selectNum % len(self.men) man = self.men[self.selectNum] self.pics[1] = self.getPicture(man,(1,1),(CENTER,CENTER)) self.activity_state = ANIMATE_START self.setAnimateIn(animate=activityLinearMove, start=(1,0), end=(0,0)) elif e == key.btn_right: self.app.background = self.men[self.selectNum] self.selectNum += 1 self.selectNum = self.selectNum % len(self.men) man = self.men[self.selectNum] self.pics[1] = self.getPicture(man,(1,1),(CENTER,CENTER)) self.activity_state = ANIMATE_START self.setAnimateIn(animate=activityLinearMove, start=(-1,0), end=(0,0)) elif self.state == TAN_CONFIRM: if e == key.btn_key1: # choose game yaml conf = self.config[self.selectNum] self.app.switchConfig(conf, 0) self.close() elif e == key.btn_key2: self.pics.pop() self.seek() self.state = TAN_SEEK
def __init__(self, app): Activity.__init__(self, app) self.state = CATGAME_INIT self.initBricks()
def get_summary_week(self, _week, summary, tp_launch, tot_week_before): """ :param _week: :param summary: :param tp_launch: :param tot_week_before: :return: """ first_day = name_day(_week.date_init) last_day = name_day(_week.date_final) ext = Extract() act = Activity() value_week = ext.get_total_week(_week, _type=None) line = 0 summary[line].append(first_day) summary[line].append("TO") summary[line].append(last_day) _today = datetime.today() summary[line].append("Account Itau day %s %s:%s" %(_today.day, str(_today.hour), str(_today.minute))) if value_week.__len__() > 1: line = 1 value_debit = value_week[0] value_credit = value_week[1] total_week = value_week[2] # tot_week_before = value_week[3] total_week = tot_week_before - value_debit + value_credit if value_credit > value_debit: summary[line].append("Result Positive") else: summary[line].append("Result Negative") summary[line].append(str(value_debit).replace('.',',')) summary[line].append(str(value_credit).replace('.',',')) summary[line].append(str(total_week).replace('.',',')) line = 2 _local = 'local' if not settings.DATABASE_LOCAL: _local = 'heroku' summary[line].append("Cost Week") summary[line].append("Debit" + _local) summary[line].append("Credit") summary[line].append("Total") summary[line].append("Time") summary[line].append("Cost per time") summary[line].append("Recipe per time") line = 3 for tp in tp_launch: tot_week_type = ext.get_total_week(_week, tp.id) if tot_week_type.__len__() > 1: value_debit = str(tot_week_type[0]).replace('.',',') value_credit = str(tot_week_type[1]).replace('.',',') value_total = str(tot_week_type[2]).replace('.',',') summary[line].append(tp.type_name) summary[line].append(value_debit) summary[line].append(value_credit) summary[line].append(value_total) time_cost = act.get_time_type_launch(_week, tp.id) if time_cost is None: time_cost = '' cost_per_time = '' receit_per_time = '' else: _cost_type = str_to_float(value_debit) cost_per_time = round(_cost_type / float(time_cost), 2) _receit_type = str_to_float(value_credit) receit_per_time = round(_receit_type / float(time_cost), 2) time_cost = str(time_cost).replace('.',',') cost_per_time = str(cost_per_time).replace('.',',') receit_per_time = str(receit_per_time).replace('.',',') summary[line].append(time_cost) summary[line].append(cost_per_time) summary[line].append(receit_per_time) line += 1 return summary
def onKeyDown(self, key, e): if Activity.onKeyDown(self, key, e): return if self.state == START: self.app.background = (138, 163, 161) if self.conf != None: if e == key.btn_key1: self.app.switchConfig(self.conf, self.gameState) self.close() elif e == key.btn_key2: self.state = SHOW_TIP_NEWGAME self.pics.append(self.getPicture(PIC_SPEEK_P_LEFT,(1,1),(0,0))) self.texts = [self.getText('开始新游戏', FONT_NORMAL, (CENTER,LINE_4), BLACK)] self.texts.append(self.getText('将清空之前的游戏记录', FONT_NORMAL, (CENTER,LINE_3), BLACK)) self.texts.append(self.getText('A 新游戏 B 取消', FONT_NORMAL, (CENTER,LINE_1), BLACK)) elif e == key.btn_key3: self.state = SETTING self.setting() self.activity_state = ANIMATE_START self.app.background = self.surf.copy() self.setAnimateIn(animate=activityLinearMove, start=(1,0), end=(0,0)) else: if e == key.btn_key1: self.close() elif e == key.btn_key2: self.state = SETTING self.setting() self.activity_state = ANIMATE_START self.app.background = self.surf.copy() self.setAnimateIn(animate=activityLinearMove, start=(1,0), end=(0,0)) elif self.state == SETTING: if e == key.btn_key1: images = os.listdir(IMAGES_ROOT) self.images = [] for i in images: self.images.append(IMAGES_ROOT+'/'+i) random.shuffle(self.images) self.imageNum = 0 self.stopShow = False self.time = datetime.datetime.now().strftime('%H:%M:%S') self.texts = [self.getText(self.time, size=FONT_LARGE, position=(0.05,CENTER),color=WHITE)] self.pics = [BLACK,self.getPicture(self.images[0],(1,1),(0,0))] self.state = IMAGES elif e == key.btn_key2: self.state = UPDATE self.pics.append(self.getPicture(PIC_SPEEK_P_LEFT,(1,1),(0,0.2))) self.texts = [self.getText('按任意键开始检查更新', FONT_NORMAL, (CENTER,LINE_2), BLACK)] elif e == key.btn_key3: self.pics = [PINK] self.texts = [self.getText('送给小陈', FONT_NORMAL, (CENTER,CENTER), BLACK)] self.state = RETURN_SETTING elif e == key.btn_press: self.state = START self.start() self.activity_state = ANIMATE_START self.app.background = self.surf.copy() self.setAnimateIn(animate=activityLinearMove, start=(-1,0), end=(0,0)) elif self.state == SHOW_TIP_NEWGAME: if e == key.btn_key1: self.close() elif e == key.btn_key2: self.state = START self.start() elif self.state == UPDATE: try: res = os.popen('git pull').readlines() if res[0] == 'Already up to date.\n': self.state = RETURN_SETTING self.texts = [self.getText('已经是最新的版本了', FONT_NORMAL, (CENTER,LINE_2), BLACK)] else: self.state = SHOW_TIP_REBOOT self.texts = [self.getText('检查到新版本 按任意键重启', FONT_NORMAL, (CENTER,LINE_2), BLACK)] self.stopThread = True except Exception as e: self.state = RETURN_SETTING self.pics = [self.getPicture(PIC_QRCODE,(1,1),(0,0))] self.texts = [] elif self.state == RETURN_SETTING: self.state = SETTING self.setting() elif self.state == SHOW_TIP_REBOOT: os.system('sudo reboot now') elif self.state == IMAGES: self.stopShow= True self.app.background = BROWN self.state = SETTING self.setting()
def close(self): Activity.close(self) self.stopThread = True