12月 16

python 在linux上处理图片的错误处理

在CentOS 5.4 64位上安装了python2.6和PIL模块处理图片。
遇到问题1:
Traceback (most recent call last):
 File “aimg.py”, line 3, in
  img.save(‘/program/upload/b.jpg’,’JPEG’)
 File “/usr/local/lib/python2.6/site-packages/PIL-1.1.7-py2.6-linux-

x86_64.egg/Image.py”, line 1406, in save
 self.load()
 File “/usr/local/lib/python2.6/site-packages/PIL-1.1.7-py2.6-linux-

x86_64.egg/ImageFile.py”, line 189, in load
  d = Image._getdecoder(self.mode, d, a, self.decoderconfig)
 File “/usr/local/lib/python2.6/site-packages/PIL-1.1.7-py2.6-linux-

x86_64.egg/Image.py”, line 385, in _getdecoder
  raise IOError(“decoder %s not available” % decoder_name)
IOError: decoder jpeg not available

处理方法:
# rm -rf /usr/local/lib/python2.6/site-packages/PIL-1.1.7-py2.6-linux-x86_64.egg
# rm -rf /usr/local/lib/python2.6/site-packages/PIL.pth
# yum install -y libjpeg* freetype* zlib*
# easy_install PIL

遇到问题2:
WARNING: ” not a valid package name; please use only.-separated package names in setup.py
_imaging.c:75:20: error: Python.h: No such file or directory
In file included from libImaging/Imaging.h:14,
from _imaging.c:77:
libImaging/ImPlatform.h:14:2: error: #error Sorry, this library requires support for ANSI prototypes.
libImaging/ImPlatform.h:17:2: error: #error Sorry, this library requires ANSI header files.
libImaging/ImPlatform.h:55:2: error: #error Cannot find required 32-bit integer type
In file included from _imaging.c:77

处理方法:
yum install python-imaging
yum install python-dev
python PIL

再次测试问题解决。

12月 11

新服务器的硬件测试

【2011-12-09 整理人:simon-zzm@163.com】
新买的服务器安装CentOS的操作系统,需要测试服务器硬件的稳定性。如果不运行服务
空跑根本没有意义,所以使用压测软件进行测试。
本次测试使用到stress软件,网站地址如下:
http://weather.ou.edu/~apw/projects/stress/
如果是服务器没有安装操作系统也可以到以下的网站下载iso或usb基本操作系统加压力软件的
集合。网站地址如下:
www.stresslinux.org

本次只是记录使用stress的过程。
stress用C编写,可以运行在x86,ppc64和PPC 32 GNU / Linux的,Tru64的,SPARC Solaris的平台。
可以自由配置参数,对cpu、内存、IO进行测试。

软件下载、编译、测试
为了避免编译失败,建议先确认已经安装gcc编译器。
# yum -y gcc*
# wget http://weather.ou.edu/~apw/projects/stress/stress-1.0.4.tar.gz
# tar zxvf stress-1.0.4.tar.gz
# cd stress-1.0.4
# ./configure && make

至此已经编译完毕,本软件不打算安装,所以直接使用。
# cd /root/stress-1.0.4/src
# ./stress –cpu 8 –io 8 –vm 8 –vm-bytes 32000M –timeout 180s

服务器的硬件为4核双cpu,32G内存,测试180秒中。所以使用以上命令,io和vm后的8为8个
进行,vm-bytes为32G的内存。

使用感受,能将所有的硬件资源耗尽,但是如果运行时间过长,就不知道是死机还是再测试了。
更主要的是测试完毕也没有测试报告生成。