系统管理任务的简单工具
s的Python项目详细描述
此库是一组易于使用的模块,可帮助实现 系统管理任务:
import sy.path, sy.net.intf, sy.net.ip, sy.cmd # Replace lines in '/etc/hosts' that match nis.* sy.path.replace_lines('/etc/hosts', 'nis.*', '10.2.3.1 ldap') 1 # Fetch information about the interface hme0 hme0 = sy.net.intf.get('hme0') # Get the IP of hme0 hme0.ipaddress '192.168.2.2' # Check if hme0 is up hme0.is_up True # Find files named '*.pl' but time out after 10 seconds out, err = sy.cmd.do('find /mnt -name {}', '*.pl', timeout=10) # Check if port 22 is answering on bart if not sy.net.ip.port_is_open('bart', 22): sy.log.warning('Ssh is down on bart')
这个库深受Werkzeug的启发,这是一个很棒的wsgi实用程序 收藏。
开发
sy的存储库路径位于 http://github.com/afajl/sy。通过键入git克隆:
$ git clone http://github.com/afajl/sy.git
开发的需求列在dev-reqs.pip中 可使用pip安装,使用:
$ pip install -r dev-reqs.pip
这个库目前的目标是Python2.4.4-2.6。
测试
要运行测试套件,请使用nose:
$ nosetests -a '!host' tests
!host参数告诉套件不要运行更改主机的测试 配置(如重新配置网络接口)。
目前还没有任何在虚拟机上运行测试套件的自动化方法。 为了能够测试库的所有部分以及 在不同版本和操作系统上测试。
文件
文档是用sphinx构建的,位于docs文件夹下。