python ftp and local compare md5
来源:互联网 发布:电视直播网站源码 编辑:程序博客网 时间:2024/05/16 12:39
文件不同,MD5值不同
通过获取 ftp 服务器 md5 的值,并保存在文件中,
本地也可以用,获取md5的值,比较不同
实现对比文件,获取下载,类似svn的功能
class GetFileMd5():
''''''
def getfilemd5(self, filename):
'''
get md5 of each file
'''
myhash = hashlib.md5()
f = file(filename, 'rb')
while True:
b = f.read(8096)
if not b :
break
myhash.update(b)
f.close()
return myhash.hexdigest()
def record_md5(self, path, result):
'''
record md5 of each file
'''
filename = '../../res/' + result
filename = os.path.abspath(filename)
file = []
filemd5 = {}
for root, dirs, files in os.walk(path, topdown=False):
for name in files:
file.append(os.path.join(root, name))
for f in file:
md5 = self.getfilemd5(f)
filemd5[f] = md5
content = json.dumps(filemd5, indent=4)
f=open(filename,'w')
f.write(content)
f.close()
1 0
- python ftp and local compare md5
- Compare JRuby, Groovy and Python
- Global and Local Variables python
- python global and local variable
- python get local ip and sth. others
- Python--lnheritance,Priavte and class-local
- #/usr/bin/env python and #!/usr/local/bin/python
- compare JUnit and TestNG
- Compare File and Object
- Compare and Swap(CAS)
- Compare json and xml
- Compare VDI and RDS
- Python string compare
- Python datetime compare
- [Python]Compare __repr__ & __str__
- Compare files' differ and backup
- compare of java and c++
- Beyond compare download and installation.
- .net里如何很好的使用cs页面,js文件与aspx页面里的各个参数相互使用
- 2017.3.16 聪聪可可 思考记录(非常不容易)
- 【经验分享】IMX6开发板编译问题及解决方法
- UnicodeEncodeError:ascii codec can't encode characters in position 9-16:ordinal not in range(128)
- 复习1. --Java基础之switch--
- python ftp and local compare md5
- 怎样从Eclipse当中打开一个存在的项目?
- Android 小程序:随身记
- 恢复数据库gpsdb11
- 前端涉及的所有知识体系
- L3-008. 喊山
- 软件测试工程师的发展方向? 功能测试&自动化测试&测试开发
- js 监听移动端web触屏事件 滑动响应
- deferred对象详解