Python Screen Gif

2018-10-22

Background

最近用了一些 gif 生成工具,感觉挺好用的,就想着 python 是不是也可以实现,自己做一个。

浏览了一些文章,发现有一些现成的库可以用。

最终的想法还是做成一个 GUI,今天是第一步,思路利用PILImageGrab抓取屏幕,然后使用opencsv写入视频流,再用moviepy截取视频的画面生成 gif。

Read more

Python Windows Service

Background

最近在优化LoadTest的流程,在执行测试的时候,我们需要在10台虚拟机上运行HostProxy, 这意味着需要登陆这10台机子并且一个个运行代理程序,这简直要人命。

所以我第一个想到的就是把这个过程做成一个windows service,让他们一直监控一个文件命令,当下达运行指令的时候,10台机子就会自动运行,同理也能停止。

虽然最后发现通过service启的进程不能被Host Manager访问到(有时间再仔细研究,应该有解决方案),用Scheduler替代了,但其它操作还是没有问题的。

Read more

Progress Bar in Python

Progress Bar in Python

很多时候,我们在测试的过程中,希望能够直观的看到测试的进度,而不是去看 log 或者查询数据库得到信息。

这个时候,如果有数据完成的进度的话就非常的方便。

今天就简单总结下这两天查询的资料,并且已经在实际中用到。

Read more

XPath in Python

XPath In Python

在对XML文件进行处理的时候,可以使用标准DOM的 api,但是相对来说不是很方便。

使用XPath的话就可以快速的定位节点,选取得到想要的值。

下面就对在Python中使用XPath处理XML文档做简单的介绍。

Read more

Class In Python

Class In Python

今天简单总结下在Python中定义类的方法,包括属性,方法,继承等方面的内容。

主要还是根据自己的实践和踩过的坑来描述,后续如果有新的内容,会继续更新。

Read more

Files Operation In Python

1
2
# update log:
# 08/30/2018: update the method name style

Files Operation In Python

We usually need to handle files like read/write files with different type, so today I’ll show some codes to do this.

Read more

Data Structure In Python

Data Structure In Python

Today I met a problem that I would like to count the duplicate items in a list. Generally, I could iterate the list and count it by myself.

But I don’t think that’s a good idea, and python perhaps have the easiest way to do this.

So I searched for the solution and find it. there is a build-in function to do this.

1
2
3
4
5
6
7
8
9
>>> list_test = ['test','test','xiche','xiche','xiche',1,1,1,1,1,['a']]
>>> print(list_test.count('test'))
2
>>> print(list_test.count('xiche'))
3
>>> print(list_test.count(1))
5
>>> print(list_test.count(['a']))
1

So it’s important to be familar with the usage of data structure in python and it will help you to code more efficient.

And let me summarize some basic operations about them and I will continue to update this article when I find some new interesting tips.

Learn to look into offical document is very import.

Read more

Performance Test Training (2)

Performance Test Training (2)

性能测试培训的第二天,主要内容是性能测试一些实例,这些要总结好难,还是要实际操作。

核心的规则还是从进程,到线程,CPU,内存,堆栈,IO,网络一步步分析。

培训上基本上是都是 linux 的命令,我下面简单罗列了一些window下的命令,而且很不全,参考意义不大。

之后有时候再一块一块深入,每一块都有好多细节。。。今天就算给自己交个差吧(捂脸)

Read more

Performance Test Training (1)

Performance Test Training (1)

今天是性能测试培训的第一天,主要内容是性能测试涉及到的概念,以及讲师自己的一些实践,个人感觉还是有些收获的。

下面就简单总结下一点知识。

Read more

Spider for Douban (01)

Top n Movies of Spider for Douban

网上有许多爬虫的入门脚本,都是去爬豆瓣前 250 的电影信息,我也参考并写了一个,做为入门。

因为豆瓣的网页结构相对稳定,变化不多,不然要花太多时候去维护。

在代码中可以修改 page 的值来取得更多的页数,我发现其实是可以超过 250 个的,排名 250 后的资源,也可以通过手动修改得到。

Read more