存档

2009年12月 的存档

简明python教程

2009年12月22日 没有评论

在例10.4 备份脚本——版本四的代码中有些需要注意的地方。

#!/usr/bin/python
# Filename: backup_ver4.py
import os
import time
# 1. The files and directories to be backed up are specified in a list.
source = [‘/home/swaroop/byte’, ‘/home/swaroop/bin’]
# If you are using Windows, use source = [r'C:\Documents', r'D:\Work'] or something like that
# 2. The backup must be stored in a main backup directory
target_dir = ‘/mnt/e/backup/’ # Remember to change this to what you will be using
# 3. The files are backed up into a zip file.
# 4. The current day is the name of the subdirectory in the main directory
today = target_dir + time.strftime(‘%Y%m%d’)
# The current time is the name of the zip archive
now = time.strftime(‘%H%M%S’)
# Take a comment from the user to create the name of the zip file
comment = raw_input(‘Enter a comment –> ‘)
if len(comment) == 0: # check if a comment was entered
target = today + os.sep + now + ‘.zip’
else:
target = today + os.sep + now + ‘_’ + \
comment.replace(‘ ‘, ‘_’) + ‘.zip’
# Notice the backslash!
# Create the subdirectory if it isn’t already there
if not os.path.exists(today):
os.mkdir(today) # make directory
print ‘Successfully created directory’, today
# 5. We use the zip command (in Unix/Linux) to put the files in a zip archive
zip_command = "zip -qr ‘%s’ %s" % (target, ‘ ‘.join(source))
# Run the backup
if os.system(zip_command) == 0:
print ‘Successful backup to’, target
else:
print ‘Backup FAILED’

文中提到“我还希望有的一个优化是使用tar命令替代zip命令。这样做的一个优势是在你结合使用tar和gzip
命令的时候,备份会更快更小。如果你想要在Windows中使用这些归档,WinZip也能方便地处
理这些.tar.gz文件。tar命令在大多数Linux/Unix系统中都是默认可用的。Windows用户也可以
载安装它

命令字符串现在将成为:
tar = ‘tar -cvzf %s %s -X /home/swaroop/excludes.txt’ % (target, ‘ ‘.join(srcdir))

需要补充的是Windows用户安装完LibArchive后命令为bsdtar,而且若想使用-z这个选项,还需安装gzip软件。

代码中的

target = today + os.sep + now + ‘.zip’

改为

target = today + os.sep + now + ‘.tar.gz’

使用bsdtar -cvzf %s %s -X /home/swaroop/excludes.txt’ % (target, ‘ ‘.join(source))

英文原版已经没有用tar替换zip的内容了,提出建议用Python标准库中zipfile和tarfile来重写ver5。

分类: python 标签:

70-300VR 防抖效果实测

2009年12月20日 没有评论

70-300VR

70-300VR是廉价的好头,暗角不明显,9片光圈页面,防抖效果出众,对焦迅速,不足之处是300端的最大光圈仅中心成像说得过去,还有就是竖向色差可见。

防抖效果可参见下面图片,1/10秒手持。

分类: 摄影 标签: , ,

尼康DX用户微距好选择

2009年12月20日 没有评论

AF-S DX Micro NIKKOR 85mm f/3.5G ED VR现已经上市,3500元左右的价格,口径为52mm,与18-55相同,滤片可以通用;重要的一点是有9片光圈叶片,焦外成像更好。最近拍摄距离为0.286 m。最大光圈F/3.5,放大比例可以到1:1。价格为105VR的近一半,若不想今后用FX相机那么这款就是理想的选择。

DX_MC_85_VR_iMTF图

分类: 摄影 标签: , ,

又见nikon镜头焦距缩水

2009年12月9日 没有评论

nikkor大三元之一的70-200/2.8VR (XZP)推出更新版后,万众期待,想看看7片ED镜片和新增纳米涂层后的表现,新镜头发布2个月后进入市场,发烧友们急切的拿回家使用后一致的惊叹于70-200/2.8VRⅡ的画质表现,四角失光和锐度好多了,抗眩光也好了,但新来的焦距缩水问题也出现在了各大评测网站论坛。如同一代的18-200VR一样,在长焦端焦距缩水明显。

相信原因很多人已知道,这是由内对焦IF引起的,在焦距不变调整对焦点时,镜头移动较少的后组镜片以增快对焦速度,但这会使实际的焦距发生变化。英语中叫做focus breathing。变焦镜头都或多或少的有点。70-200/2.8VRⅡ在对焦到无穷远时是标称的焦距,随着对焦距离的缩短,实际焦距也变小即放大比例减小。有人经测试70-200/2.8VRⅡ在最近的对焦距离1.4m处实际焦距才130mm左右,严重缩水。这对需要精确构图的人来讲是无法接受的。

18-200,18-70都有焦距缩水,但这么贵的镜头有这么明显的缩水实在是讲不过去。

105VR也有此现象。

分类: 摄影 标签: ,