2017年10月30日
摘要: import os from os.path import join, getsize def getdirsize(dir): size = 0L for root, dirs, files in os.walk(dir): size += sum([getsize(join(root, name)) for name in files]) ... 阅读全文
posted @ 2017-10-30 23:52 那个踩到香蕉皮的妖怪 阅读(197) 评论(0) 推荐(0) 编辑
摘要: 这个最简单,但是也最不靠谱,依赖hosts文件,如果hosts文件没配置,一般容易获取到127.0.0.1 linux上根据网卡名获取ip 仅限windows 第三方库 https://github.com/ftao/python-ifcfg 阅读全文
posted @ 2017-10-30 23:35 那个踩到香蕉皮的妖怪 阅读(3608) 评论(0) 推荐(0) 编辑
摘要: 有时候需要获取进程的pid,但又无法使用第三方库的时候. 方法适用linux平台. 方法1 使用subprocess 的check_output函数执行pidof命令 方法2 使用pgrep命令,pgrep获取的结果与pidof获得的结果稍有不同.pgrep的进程id稍多几个.pgrep命令可以使适 阅读全文
posted @ 2017-10-30 22:54 那个踩到香蕉皮的妖怪 阅读(26246) 评论(0) 推荐(2) 编辑
摘要: pexpect是python的标准库.使用python标准库可以很方便在局域网内的linux服务器上执行运维脚本. 阅读全文
posted @ 2017-10-30 22:20 那个踩到香蕉皮的妖怪 阅读(3406) 评论(0) 推荐(0) 编辑