Posts tagged: python

简单的移动文件的脚本

家里的home server,使用mldonkey下载资源(见这里),有视频和电子书等,需要编写个脚本,将不同后缀的文件移动到指定的目录下。 这里使用python,写了个简单的脚本: #!/usr/bin/python # -*- coding: utf-8 -*- import os scan_path=”/Users/marshal” book_path=”/Users/marshal/books” def file_action(file): if(file.endswith(“.pdf”) or file.endswith(“.epub”)): os.rename(scan_path+’/’+file, book_path+’/’+file) print ‘移动文件:’,file print “开始文件整理,目录:”,scan_path,” …” if(os.path.exists(book_path) is False): os.mkdir(book_path) #print os.getcwd() files=os.listdir(scan_path) for file in os.listdir(scan_path): file_action(file) print “整理完毕。”      发送文章为PDF   

星期四 十一月 10th, 2011 in , , | No Comments »

通过mod_rewrite解决trac源代码宏的bug

trac在使用中一直很正常,除了响应速度慢一点儿外。最近写的trac wiki文档,开始通过/来设置wiki的父子关系。比如/Hibernate编写的是hibernate总的目录wiki页面,/Hibernate/GetStart是其子wiki页面。网站在这里: https://dev.easymorse.com/trac/tutorials/wiki/Hibernate/GetStart    发送文章为PDF   

星期四 四月 2nd, 2009 in , , , | No Comments »

trac插件的卸载

trac插件卸载,其实也是python插件卸载的方式。可以先尝试用easy_install命令: easy_install -m [plugin name] 有的时候不能生效,往往是插件名字不匹配,可以手工修改: /usr/lib/python2.5/site-packages/easy-install.pth 在里面找到插件的行,直接删除即可。之后,trac需要重新启动。    发送文章为PDF   

星期三 三月 18th, 2009 in , , | No Comments »