Next to do

Next to do

Next to do

自从在了TE,每天的工作都挺饱和的,当然这个和自己想要做更多的事情有关系。还是要理一理目前的状况和接下去主要的目标。

Read more
Send email by python

Send email by python

Send email by python

python有两个原生库(smtplib,email)可以用来发送邮件,只要你有smtp server就行。之前在公司已经写过简单的类来实现,回来又重新写了一个使用163邮箱来发送的工具类。

目前已经能够完成基本发送功能,包括html格式,添加附件等,只是弄了好久,还是没有办法在正文中添加图片,一直554错误,被网易认为垃圾信息(错误代码一览)而发送不了,之后有时间再看。

Read more
Process Info

Process Info

Process Info

之前的测试中,使用psutil可以得到系统的CPU/Memory的使用百分比,但是没试过读取个别进程的信息。现在想要实现这样的功能,方便更好的分析java.exe的内存使用变化。

有一种思路是使用系统本身提供的查看进程的shell cmdsubprocess.check_output组合得到信息。

Read more
Father

Father

今天是父亲走了的第5天。

根据老家的风俗和迷信,出殡的日子定在了下周一的早上。

他们喜欢用生辰八字和黄历来算合适的日子,讲究时辰。而对于我和母亲来说,父亲走了,早点操办完后事,可能不会难过那么久。

我现在倒是还好,心中已然接受了事实,就担心母亲。

Read more
Create Excel with line chart by openpyxl

Create Excel with line chart by openpyxl

Create Excel with line chart by openpyxl

之前有用过openpyxl做了简单的介绍

但是我今天在尝试画chart的时候,发现没有很好用的api可以参考,可能是我没找到吧,一些细节只能google,或者从源代码里找。

好在之前在做AMS报表的时候,有用ChartFX画过一些图表,大体上的api设计是一致的。

Read more
Multi-parameters performance test

Multi-parameters performance test

Multi-variables performance test

最近一直在忙,都没有时间总结和改进现在的测试流程,瓶颈已经显现出来。下周的一个主要的任务就是大批量的测试不同虚拟机下不同参数执行任务的性能,从而得到CPU和Memory消耗适合的一些参数,并做为benchmark。可以预见之后还有类似的测试的任务,那必要要提前做好改变。今天主要是把思路整理出来。

Read more
Catch CPU/Memory Monitor

Catch CPU/Memory Monitor

根据log中的实际取得monitor中的数据。

现在有一个完整的导数据的log,类似于如下ImportLog.txt:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
...略...
2018-06-14 00:07:58,156 [INFO ] -----START IMPORT-----
2018-06-14 00:07:58,515 [INFO ] xxx
2018-06-14 00:10:39,065 [INFO ] xxx
2018-06-14 00:10:39,081 [INFO ] Import Time(s):160.55
2018-06-14 00:10:39,128 [INFO ] xxx
2018-06-14 00:10:39,128 [INFO ] Finished:xxxAAxxx
2018-06-14 00:10:39,128 [INFO ] Import Time(s):160.96
2018-06-14 00:10:39,128 [INFO ] -----END IMPORT-----
2018-06-14 00:10:44,201 [INFO ] -----START IMPORT-----
2018-06-14 00:10:46,590 [INFO ] xxx\\IMPORT.exe BBB
2018-06-14 00:57:30,360 [INFO ] Finished:\xxx_BBB_xxx
2018-06-14 00:57:30,360 [INFO ] Import Time(s):2803.77
2018-06-14 00:57:31,125 [INFO ] -----END IMPORT-----
...略...
<!-- more -->

而整个过程有监控数据类似如下Monitor.csv:

1
2
3
4
5
6
7
8
9
Time,CPU(%),Memory(%)
2018/06/13 23:51:17,2.7,12.17
2018/06/13 23:51:19,0.0,12.16
2018/06/13 23:51:21,0.0,12.16
2018/06/13 23:51:23,0.0,12.14
2018/06/13 23:51:25,0.4,12.15
2018/06/13 23:51:28,0.0,12.15
2018/06/13 23:51:30,0.0,12.15
...略...

那么现在的问题是只需要在跑BBB的时候的那段时间的监控数据,于是临时写了个简单的HardCode的过程达到目的,主要用到了datetime对时间的处理。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"""
author: xiche
create at: 06/14/2018
description:
Catch monitor data from whole proces
"""
from datetime import datetime

# datetime_object = datetime.strptime('Jun 1 2005 1:33PM', '%b %d %Y %I:%M%p')
dateformat1 = "%Y-%m-%d %H:%M:%S" #"2018-06-13 23:51:17"
dateformat2 = "%Y/%m/%d %H:%M:%S" #"2018/06/13 23:51:52"

def __main__():
dt_start = None
dt_end = None
lines_new = []
with open("ImportLog.txt", "r") as f:
lines = f.readlines()
for line in lines:
if("BBB" in line and "Finished" in line):
dt_end = datetime.strptime(line[0:19], dateformat1)
break
if("BBB" in line):
dt_start = datetime.strptime(line[0:19], dateformat1)

with open("Monitor.csv", "r") as f:
lines = f.readlines()
dt_current = None
for line in lines:
try:
dt_current = datetime.strptime(line[0:19], dateformat2)
if(dt_current < dt_start):
continue
elif(dt_current > dt_end):
break #之前竟然是continue。。。。
else:
lines_new.append(line)
except:
print("No expect formated:{}".format(line))

with open("Monitor_BBB.csv", "w") as f:
f.writelines(lines_new)
# dt_start = datetime.strptime(dt_start_str, dateformat1)
# dt_end = datetime.strptime(dt_start_str, dateformat2)

# a = datetime.strptime("2018-06-13 23:51:17", "%Y-%m-%d %H:%M:%S")
# b = datetime.strptime("2018/06/13 23:51:52", "%Y/%m/%d %H:%M:%S")
# print(a, b)
__main__()
ACM with Python

ACM with Python

使用python编写acm题目

ACM一般来说都是用C或者C++来编写,因为国内的大学入门教程就是以C和C++为主,而且编译后的执行效率也比较高。但是很多的Online Judge都支持别的语言,例如Java,Python,Perl,Pascal,PHP,FPC,C#等等。

省内我们之前常用的几个学校的OJ系统(浙大杭电工大),只有浙大的才支持Python,而且只有2.7.3,不支持Python3+。不过大同小异,下面就用简单的例子来演示下用python来写acm。

Read more
Regex in python

Regex in python

Regex in python 简介

正则表达式 是在文本处理的时候非常高效有用的一种方式,一般的编程语言都会内置相应的模块。

不同的编程语言使用方式不尽相同,核心的表达式模式都是一致的。

最近使用python生成Message,有用到正则表达式,今天简单的总结下python使用的方式。对于表达式本身的使用,之后有时间再详细介绍。

Read more
chart.js

chart.js

chart.js

Chart.js 是一个开源的的 js 图表库,它支持大多数常用的图表。之前就用过它来展示内存和 CPU 的监测结果,现在来回顾总结一下。

Read more