Re: DHCP query script not work.

2014-06-25 Thread 不坏阿峰
anyone can help ?

在 2014年6月19日星期四UTC+7下午8时56分06秒,不坏阿峰写道:
 On Thursday, June 19, 2014 8:49:21 PM UTC+7, Anssi Saari wrote:
 
  不坏阿峰 onlydeb...@gmail.com writes:
 
  
 
  
 
  
 
   Dear all
 
  
 
  
 
  
 
   i got code recipes from here. and i want to run it on win 7. 
 
  
 
   http://code.activestate.com/recipes/577649-dhcp-query/
 
  
 
  
 
  
 
  It works for me as is in Windows 7. It's a Python 3 script though which
 
  
 
  might be your problem.
 
 
 
 
 
 i got that my issue is the Python version , my is 2.7. i am not familiar with 
 3.and my tools coded by 2.7.   
 
 
 
 i am stucked on this script.  tks for ur reply.  hope have someone change 
 this script work on 2.7
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: DHCP query script not work.

2014-06-19 Thread Steven D'Aprano
On Thu, 19 Jun 2014 05:56:57 -0700, 不坏阿峰 wrote:


 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'


data[268] returns a string. You cannot divide a string by an int.

Perhaps you need to change the line to this?

dnsNB = int(data[268]) / 4



-- 
Steven D'Aprano
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: DHCP query script not work.

2014-06-19 Thread Peter Otten
不坏阿峰 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.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: DHCP query script not work.

2014-06-19 Thread soneedu
On Thursday, June 19, 2014 8:23:17 PM UTC+7, Peter Otten wrote:
 不坏阿峰 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.

yes, i use Python 2.7. i am a beginner learn network program part.  i can not 
modify it myself now, i have trid some days.  hope some expert can help me 
correct this code in Python 2.7.

many thanks in advanced.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: DHCP query script not work.

2014-06-19 Thread 不坏阿峰
在 2014年6月19日星期四UTC+7下午8时23分17秒,Peter Otten写道:
 不坏阿峰 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.

yes, i use Python 2.7. i am a beginner learn network program part.  i can not 
modify it myself now, i have trid some days.  hope some expert can help me 
correct this code in Python 2.7. 

many thanks in advanced.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: DHCP query script not work.

2014-06-19 Thread Anssi Saari
不坏阿峰 onlydeb...@gmail.com writes:

 Dear all

 i got code recipes from here. and i want to run it on win 7. 
 http://code.activestate.com/recipes/577649-dhcp-query/

It works for me as is in Windows 7. It's a Python 3 script though which
might be your problem.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: DHCP query script not work.

2014-06-19 Thread 不坏阿峰
On Thursday, June 19, 2014 8:49:21 PM UTC+7, Anssi Saari wrote:
 不坏阿峰 onlydeb...@gmail.com writes:
 
 
 
  Dear all
 
 
 
  i got code recipes from here. and i want to run it on win 7. 
 
  http://code.activestate.com/recipes/577649-dhcp-query/
 
 
 
 It works for me as is in Windows 7. It's a Python 3 script though which
 
 might be your problem.


i got that my issue is the Python version , my is 2.7. i am not familiar with 
3.and my tools coded by 2.7.   

i am stucked on this script.  tks for ur reply.  hope have someone change this 
script work on 2.7


-- 
https://mail.python.org/mailman/listinfo/python-list