GithubHelp home page GithubHelp logo

yorkoliu / pyauto Goto Github PK

View Code? Open in Web Editor NEW
1.5K 194.0 1.1K 97.07 MB

《python自动化运维:技术与最佳实践》书中示例及案例源码

Python 56.78% PHP 0.21% Perl 0.07% Shell 3.42% CSS 16.56% JavaScript 10.08% HTML 12.10% Batchfile 0.09% SaltStack 0.26% Nginx 0.42%

pyauto's Issues

第一章例子无结果

看了第一章,在centos7 python2.7.5上做,照着书上的代码敲,除了A记录那个脚本能有结果,其他都报错了:

#!/usr/bin/env python
# coding=utf-8
import dns.resolver
domain = raw_input("Please input an domain: ")
MX = dns.resolver.query(domain,'MX')
for i in MX: 
    print("MX preference = ",i.preference,"mail exchange = ",i.exchange)

报错如下:

Traceback (most recent call last):
  File "dnsMX.py", line 5, in <module>
    MX = dns.resolver.query(domain,'MX')
  File "/usr/lib/python2.7/site-packages/dns/resolver.py", line 1102, in query
    lifetime)
  File "/usr/lib/python2.7/site-packages/dns/resolver.py", line 992, in query
    timeout = self._compute_timeout(start, lifetime)
  File "/usr/lib/python2.7/site-packages/dns/resolver.py", line 799, in _compute_timeout
    raise Timeout(timeout=duration)
dns.exception.Timeout: The DNS operation timed out after 30.0029888153 seconds

dnspython实例代码中查询A记录无效

在代码中使用:
A = dns.resolver.query(domain, 'A')
查询A记录,但实际上查询条件:'A' 无效,得到的结果集中包含CNAME记录,导致出现:

Please input an domain: www.baidu.com
Traceback (most recent call last):
File "aquery.py", line 9, in
print j.address
AttributeError: 'CNAME' object has no attribute 'address'
root@i-7n13qavy:/opt/soft/dnspython-1.9.4# vim aquery.py

异常。
执行环境:Python 2.7.3 , linux Ubuntu 12.04

期待得带你的回复

python 脚本执行报错,是什么问题

Traceback (most recent call last):
File "test.py", line 5, in
import smtplib
File "/usr/lib64/python2.6/smtplib.py", line 46, in
import email.utils
File "/tmp/email.py", line 5, in
from email.mime.multipart import MIMEMultipart
ImportError: No module named mime.multipart

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.