Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #73424

Re: DHCP query script not work.

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:not': 0.03; 'error:': 0.07; 'interpreter.': 0.07; 'made.': 0.07; 'modify': 0.07; 'subject:query': 0.07; '__init__': 0.09; 'operand': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:script': 0.09; 'url:activestate': 0.09; 'python': 0.11; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'recipes': 0.16; 'typeerror:': 0.16; 'unpack': 0.16; '(you': 0.16; 'fix': 0.17; 'wrote:': 0.18; 'work,': 0.20; 'written': 0.21; 'print': 0.22; 'install': 0.23; 'header:User-Agent:1': 0.23; 'script': 0.25; 'skip:" 40': 0.26; 'header:X-Complaints-To:1': 0.27; 'url:code': 0.29; 'code': 0.31; 'lot.': 0.31; 'file': 0.32; 'probably': 0.32; 'run': 0.32; '(most': 0.33; 'skip:d 20': 0.34; 'but': 0.35; 'thanks': 0.36; 'easiest': 0.38; 'to:addr:python- list': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'is.': 0.60; 'hope': 0.61; 'offer': 0.62; 'become': 0.64; '138,': 0.84; '3.4': 0.84; '95,': 0.84; 'type(s)': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Peter Otten <__peter__@web.de>
Subject Re: DHCP query script not work.
Date Thu, 19 Jun 2014 15:23:17 +0200
Organization None
References <1fe9debc-e3fc-4236-8669-31ba61683865@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset="UTF-8"
Content-Transfer-Encoding 8Bit
X-Gmane-NNTP-Posting-Host p57bdb706.dip0.t-ipconnect.de
User-Agent KNode/4.11.5
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.11149.1403184213.18130.python-list@python.org> (permalink)
Lines 34
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1403184213 news.xs4all.nl 2853 [2001:888:2000:d::a6]:46068
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:73424

Show key headers only | View raw


不坏阿峰 wrote:

> i got code recipes from here. and i want to run it on win 7.
> http://code.activestate.com/recipes/577649-dhcp-query/
> 
> i have do some modify and use print to check how it is work, but i am
> stucked now.
> 
> hope someone can help me. thanks a lot.
> 
> i meet this error:
> 
> Traceback (most recent call last):
>   File "D:/Workspace/TestExcel/Test/test_DHCP.py", line 138, in <module>
>     offer = DHCPOffer(data, discoverPacket.transactionID)
>   File "D:/Workspace/TestExcel/Test/test_DHCP.py", line 82, in __init__
>     self.unpack()
>   File "D:/Workspace/TestExcel/Test/test_DHCP.py", line 95, in unpack
>     dnsNB = int(data[268] / 4)
> TypeError: unsupported operand type(s) for /: 'str' and 'int'

The script is written for Python 3, and you seem to be using a Python 2 
interpreter. While

dnsNB = int(data[268]/4)

would become

dnsNB = ord(data[268])/4

in Python 2 that's probably not the only change that needs to be made. For 
someone not familiar with Python the easiest fix is to install Python 3.4 
(you don't need to unistall Python 2) and to run the script as is.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

DHCP query script not work. 不坏阿峰 <onlydebian@gmail.com> - 2014-06-19 05:56 -0700
  Re: DHCP query script not work. Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-06-19 13:14 +0000
  Re: DHCP query script not work. Peter Otten <__peter__@web.de> - 2014-06-19 15:23 +0200
    Re: DHCP query script not work. soneedu@gmail.com - 2014-06-19 06:30 -0700
    Re: DHCP query script not work. 不坏阿峰 <onlydebian@gmail.com> - 2014-06-19 06:32 -0700
  Re: DHCP query script not work. Anssi Saari <as@sci.fi> - 2014-06-19 16:49 +0300
    Re: DHCP query script not work. 不坏阿峰 <onlydebian@gmail.com> - 2014-06-19 06:56 -0700
      Re: DHCP query script not work. 不坏阿峰 <onlydebian@gmail.com> - 2014-06-25 03:53 -0700

csiph-web