[Tutor] Writing to Windows 64-bit event log

2012-06-18 Thread Johan Geldenhuys
Hi there, I've looked all over, but couldn't find any help as far as an API goes to log to a 64-bit Windows7 machine event log. My Python version is 2.7.1 and I am running the 32-bit Windows version on a Windows 7 laptop. Is there a way I can log entries to the Windows event log on my lapt

Re: [Tutor] urllib2 sslerror

2011-10-09 Thread Johan Geldenhuys
read binary data or is that only applicable when I write it to a file to write it as binary? Any help would be appreciated. Thanks Johan From: nehal dattani [mailto:nehal.datt...@gmail.com] Sent: Friday, 7 October 2011 7:49 PM To: Johan Geldenhuys Subject: Re: [Tutor] urllib2 ssl

[Tutor] urllib2 sslerror

2011-10-07 Thread Johan Geldenhuys
Hi everybody, Almost weekend, hang in there. I need some advice and hope somebody can help me. I have the follow piece of code that I use to get some data from a https webpage. --- < some other stuff up here> try: return_object = urllib2.u

Re: [Tutor] urllib2 issue getting realm

2011-08-31 Thread Johan Geldenhuys
Thanks Sanders Will give that a go Johan Sent from my iPhone 4 On 31/08/2011, at 23:03, Sander Sweers wrote: > On 31 August 2011 14:27, Johan Geldenhuys wrote: >> On 31/08/2011, at 22:09, Sander Sweers wrote: >>> On 31 August 2011 09:46, Johan Geldenhuys wrote: >>

Re: [Tutor] urllib2 issue getting realm

2011-08-31 Thread Johan Geldenhuys
Focusing on the code below, do you know why it would raise the exception for the first IP and not for the second? Thank you Johan Sent from my iPhone 4 On 31/08/2011, at 22:09, Sander Sweers wrote: > On 31 August 2011 09:46, Johan Geldenhuys wrote: >> I am trying to use a very sim

[Tutor] urllib2 issue getting realm

2011-08-31 Thread Johan Geldenhuys
Hi everybody, I am trying to use a very simple piece of code to get the realm from different HTTPS URLs. This realm is essential for successful authentication on the HTTPS session. If have to run this for a few different hosts and capture the realm. For one host, it works perfectly, but when I t

Re: [Tutor] Confirmation if command worked

2011-08-24 Thread Johan Geldenhuys
Hi Christian, Thanks for that. I'll give it a shot and see if I can catch the error. Lekker dag Johan From: Christian Witts [mailto:cwi...@compuscan.co.za] Sent: Thursday, 25 August 2011 4:25 PM To: Johan Geldenhuys Cc: tutor@python.org Subject: Re: [Tutor] Confirmati

[Tutor] Confirmation if command worked

2011-08-24 Thread Johan Geldenhuys
Hi all, I have the following code that uses pexpect to execute a system command. My problem is, I don't know how to identify if the command was successfully executed. The code works as it is to execute the SCP command, but it executes regardless if the SCP session can actually connect to somethin

[Tutor] Resend: Using pexpect to SCP files

2011-07-19 Thread Johan Geldenhuys
Resend in text format Hi there all, I am using pexpect in a script to SCP files to a inux server. Here is a snippet from the code: def doScp(self, user, password, host, path, files):         fNames = " ".join(files)     self.logger.log('Running command for %s' % fNames)     try:       

[Tutor] Using pexpect to SCP files

2011-07-19 Thread Johan Geldenhuys
Hi there all, I am using pexpect in a script to SCP files to a inux server. Here is a snippet from the code: def doScp(self, user, password, host, path, files): fNames = " ".join(files) self.logger.log('Running command for %s' % fNames) try:

Re: [Tutor] sftp get single file

2011-06-21 Thread Johan Geldenhuys
Hi all, This topic is old, but I have a similar issue and I know everybody will say I should use piramiko, but it is not that simple. The device I have to run my python scripts on is a simple, small, scaled down version of Suse linux and I can't install other packages like piramiko. All the file

Re: [Tutor] Saving data as jpg file

2011-06-12 Thread Johan Geldenhuys
riginal Message- From: tutor-bounces+johan=accesstel.com...@python.org [mailto:tutor-bounces+johan=accesstel.com...@python.org] On Behalf Of Steven D'Aprano Sent: Sunday, 12 June 2011 10:14 AM To: Tutor@python.org Subject: Re: [Tutor] Saving data as jpg file Johan Geldenhuys wrote: > Hi, >

[Tutor] Saving data as jpg file

2011-06-11 Thread Johan Geldenhuys
Hi, I have a Axis IP camera that I can send a HTTP command to and the data returned is the jpg image. When I get this data, I want to save it as a .jpg file, but I think my encoding is not correct, because the image is all distorted. I looked at using PIL, but the device I will install my scr

[Tutor] XML: changing value of elements and writing to a file

2009-07-16 Thread Johan Geldenhuys
new thread. Especially after a longer time, replies to older threads tend to remain unread as people simply don't scroll down far enough to notice them. You were lucky. :) Johan Geldenhuys wrote: > I have another question about writing the xml tree to a file. > > Now, I have parse

Re: [Tutor] XML: changing value of elements

2009-07-15 Thread Johan Geldenhuys
s Hi, it's funny how many times I see Python users go: "I have an XML problem, so I'll use minidom." Because then they have two problems. Johan Geldenhuys wrote: > I have a rather complex XML file and I need to change some values inside > this file. > > So far

Re: [Tutor] XML: changing value of elements

2009-06-11 Thread Johan Geldenhuys
ments Hi, it's funny how many times I see Python users go: "I have an XML problem, so I'll use minidom." Because then they have two problems. Johan Geldenhuys wrote: > I have a rather complex XML file and I need to change some values inside > this file. > > So

[Tutor] XML: changing value of elements

2009-06-09 Thread Johan Geldenhuys
Hi all, I have a rather complex XML file and I need to change some values inside this file. So far I have been using minidom, but I can't find the thing I am looking for. My code so far: """ from xml.dom import minidom xmlFile = 'signal1.xml' xmlDocument = minidom.parse(xmlFile)

Re: [Tutor] No Blank Separator between Date and Time Valid?

2008-09-11 Thread Johan Geldenhuys
It all depends how you specify the format of the time you want, look at the example. >>> time.strftime('%Y%M%D%H%M%S') '200820092030' >>> >>> >>> time.strftime('%Y%M%D %H%M%S') '200820 092055' >>> Notice in the second statement, I added the space separator between the %D and %H.

Re: [Tutor] Support for datetime module

2008-09-08 Thread Johan Geldenhuys
etime module > > On Sat, Sep 6, 2008 at 2:42 AM, Johan Geldenhuys > <[EMAIL PROTECTED]> wrote: > > Hi all, > > > > I have want to use the datetime module on a system with ver > 2.2.3 installed. > > I know it's very old, but that's wha

Re: [Tutor] Support for datetime module

2008-09-07 Thread Johan Geldenhuys
Sent: Sunday, 7 September 2008 21:04 PM To: [EMAIL PROTECTED] Cc: tutor@python.org Subject: Re: [Tutor] Support for datetime module On Sun, Sep 7, 2008 at 6:17 AM, Johan Geldenhuys <[EMAIL PROTECTED]> wrote: > Thanks Kent, > > Let me explain what I need it for. > > I have a systemUp

Re: [Tutor] Support for datetime module

2008-09-07 Thread Johan Geldenhuys
Sat, Sep 6, 2008 at 2:42 AM, Johan Geldenhuys <[EMAIL PROTECTED]> wrote: > Hi all, > > I have want to use the datetime module on a system with ver 2.2.3 installed. > I know it's very old, but that's what I have to deal with and can't upgrade. > So please do

[Tutor] Support for datetime module

2008-09-06 Thread Johan Geldenhuys
Hi all, I have want to use the datetime module on a system with ver 2.2.3 installed. I know it's very old, but that's what I have to deal with and can't upgrade. So please don't suggest that. As you know datetime was available from version 2.3. I want to know where can I get the datetim

Re: [Tutor] convert hex number to decimal

2007-03-16 Thread Johan Geldenhuys
>>> ord('\x0D') 13 Johan -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Rikard Bosnjakovic Sent: 16 March 2007 01:12 PM To: Tutor@python.org Subject: Re: [Tutor] convert hex number to decimal On 3/16/07, ammar azif <[EMAIL PROTECTED]> wrote: > Is the

Re: [Tutor] Telnet and special characters

2007-02-28 Thread Johan Geldenhuys
I have used special characters before in Telnet sessions, but always use hex characters. i.e.: \x0B for ESC. Maybe F-keys are some form of internal OS signals and are not send out on the network connection. In that case, I'm not sure how to send it. Johan -Original Message- From: [EMAIL

Re: [Tutor] Explanation of this lambda

2007-02-22 Thread Johan Geldenhuys
t: Re: [Tutor] Explanation of this lambda "Johan Geldenhuys" <[EMAIL PROTECTED]> wrote > Would somebody care to explain what is happening in this process? > > def intToBin(self, x, count=8): >return "".join(map(lambda y:str((x>>y)&1), range(c

[Tutor] Explanation of this lambda

2007-02-21 Thread Johan Geldenhuys
Hi all, I found this function that converts a integer into a 8 bit binary string. Would somebody care to explain what is happening in this process? def intToBin(self, x, count=8): """ Parameters: `x`: integer Returns a 8 bit binary string of x """

Re: [Tutor] Struct the solution for Hex translation

2007-02-19 Thread Johan Geldenhuys
Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David Perlman Sent: 19 February 2007 05:56 PM To: tutor@python.org Subject: Re: [Tutor] Struct the solution for Hex translation You're way off base... :) On Feb 19, 2007, at 9:25 AM, Johan Geldenhuys wrote

Re: [Tutor] Struct the solution for Hex translation

2007-02-19 Thread Johan Geldenhuys
101", "e" : "1110", "f" : "" } >>> def hexBin(hexchars): ... s = "" for hexchar in hexchars: s += hex2bin[hexchar] return s.rstrip("\n") ... >>> hexBin('a5') '1010

[Tutor] Struct the solution for Hex translation

2007-02-19 Thread Johan Geldenhuys
Hi all, I read in some conversations that the struct module maybe helpful in converting Hex values to binary or decimal. Maybe I understood it incorrectly. Here is my problem. I have a 22 byte data packet on a tcp socket connection. My data field is from the 6th byte to byte 20. 14 bytes in t

Re: [Tutor] control multiple FTP sessions using multiple ipconnectionsvia different com ports

2007-02-18 Thread Johan Geldenhuys
Will it be possible to disconnect one of the links during your test and reconnect it and disconnect the other connection once the ftp test is finished on the first connection? This way it will force the test script to use the active route to the internet. Not the most elegant way, but something t

Re: [Tutor] control multiple FTP sessions using multiple ip connectionsvia different com ports

2007-02-17 Thread Johan Geldenhuys
Well, I'm not a great expert on this, but in the FTPlib, it makes use of sockets. Maybe Alan can comment if socket.getaddrinfo(host, port) can be manipulated to change the outgoing interface. Good topic. Johan _ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of ray sa

Re: [Tutor] Range of float value

2007-02-08 Thread Johan Geldenhuys
PROTECTED] Sent: 08 February 2007 07:17 PM To: [EMAIL PROTECTED] Cc: tutor@python.org Subject: Re: [Tutor] Range of float value 2007/2/8, Johan Geldenhuys mailto:[EMAIL PROTECTED]"[EMAIL PROTECTED]>: Hi all, I have a value that ranges between 48.01 and 48.57. a Float value in othe

[Tutor] Range of float value

2007-02-08 Thread Johan Geldenhuys
Hi all, I have a value that ranges between 48.01 and 48.57. a Float value in other words. I want to look at changes in the value. If my normal range is between 48.35 and 48.45, how will I identify the value below 48.35 and above 48.45? Something I tried was: for a in range(48.35, 48.45):

Re: [Tutor] CRC calculation with python

2007-02-06 Thread Johan Geldenhuys
Thanks for all the replies, I got this code from a protocol spec that I must use for communications to a RS232 interface and this the way they calculate the CRC for the data in the packet. I have never done any C programming and thought that somebody in this list may be able to assist. The idea

[Tutor] CRC calculation with python

2007-02-06 Thread Johan Geldenhuys
Hi all, I'm not a C++ expert at all and I would like to find out if somebody can explain to me how the statement below can be done in Python? """ _uint16 ComCRC16(_uint8 val, _uint16 crc) { _uint8 i; _uint16 cval; for (i=0;i<8;i++) { if (((crc & 0x0001)^(val &

Re: [Tutor] The best way to implement a config file ???

2007-02-01 Thread Johan Geldenhuys
I've used two options in the past. The one is as Kent suggested, by using a module that is imported by all others and share the values. This doesn't allow for users to change the values, without changing the code. The second is to make use of a other file format. I used xml with all the info in an

Re: [Tutor] Python code to connect using PPPoE

2007-01-29 Thread Johan Geldenhuys
on is some work, but doable. Implementing PPPoE in Python, reading the device files and all that... well... it's almost nonsense. For this, you have to use the kernel. Johan Geldenhuys wrote: > Kent, > I want to establish the connection with Python. I think in Linux you > can use

Re: [Tutor] Python code to connect using PPPoE

2007-01-24 Thread Johan Geldenhuys
Is there a module that I can use for this or is it a "os" function? Johan -Original Message- From: Kent Johnson [mailto:[EMAIL PROTECTED] Sent: 24 January 2007 04:39 PM To: [EMAIL PROTECTED] Cc: tutor@python.org Subject: Re: [Tutor] Python code to connect using PPPoE Johan

Re: [Tutor] Python code to connect using PPPoE

2007-01-24 Thread Johan Geldenhuys
EMAIL PROTECTED] Cc: tutor@python.org Subject: Re: [Tutor] Python code to connect using PPPoE Johan Geldenhuys wrote: > Hi all, > > I don't know if this the right place to ask the question, but I did > some Googling and struggled to get decent examples of code to use for > PPPoE c

[Tutor] Python code to connect using PPPoE

2007-01-24 Thread Johan Geldenhuys
Hi all, I don't know if this the right place to ask the question, but I did some Googling and struggled to get decent examples of code to use for PPPoE connection. I have a wireless modem that uses PPPoE to connect and want to use Python to connect to the internet through this modem using PPPoE

Re: [Tutor] Division doesn't work

2007-01-18 Thread Johan Geldenhuys
Thanks at lot. Something as simple as that... J _ From: Geoframer [mailto:[EMAIL PROTECTED] Sent: 18 January 2007 02:10 PM To: Johan Geldenhuys Cc: tutor@python.org Subject: Re: [Tutor] Division doesn't work You assign s as an integer... it should be a float to get the right r

[Tutor] Division doesn't work

2007-01-18 Thread Johan Geldenhuys
Hi all, In my script I want to convert 14105 bytes to kilobytes and and this is what I do: >>> s = 14105 >>> print '%0.2f' % (s/1024) 13.00 This not correct and I don't know why. The answer is 13.77. Any pointers please that would help my in the right direction? Thanks Johan -- No vi

Re: [Tutor] quick ?

2006-09-15 Thread Johan Geldenhuys
I would make list of all the numbers in the beginning and then just add numbers in a range to the list. It's much easier to test for something in a list than to compare each number with the previous one. Here is a example: import random def randnum():     c = []     l = len(c)        # Nu

Re: [Tutor] HTML page status

2006-09-12 Thread Johan Geldenhuys
eilly wrote: On 9/12/06, Johan Geldenhuys <[EMAIL PROTECTED]> wrote: Hi all, I looked a little bit at the urllib and it all looks fairly easy. What I didn't see, if it is there, was how to know or identify if a page was successfully downloaded. I want to do tests to see if a co

[Tutor] HTML page status

2006-09-12 Thread Johan Geldenhuys
Hi all, I looked a little bit at the urllib and it all looks fairly easy. What I didn't see, if it is there, was how to know or identify if a page was successfully downloaded. I want to do tests to see if a connection to a webpage was successful by parsing whatever came back. Will this be the e

[Tutor] HTML page status

2006-09-12 Thread Johan Geldenhuys
Hi all, I looked a little bit at the urllib and it all looks fairly easy. What I didn't see, if it is there, was how to know or identify if a page was successfully downloaded. I want to do tests to see if a connection to a webpage was successful by parsing whatever came back. Will this be the

Re: [Tutor] parsing

2006-07-13 Thread Johan Geldenhuys
rezult is not a dictionary in your example, it's a list. You can create a dictionary with all your keys and values: rezult ={ 'title': 'TITLE', 'body':['body_1', 'body_2'], 'h1':['1_1', 'END'], 'h2':['2_1', '2_2'], 'h3':['3_1'], 'p':['p_1', 'p_2'], 'id_one':['div_one_1', 'div_one_2', 'div_o

Re: [Tutor] Internet programming with python

2006-01-18 Thread Johan Geldenhuys
Thanks, Kent. I found this one also. There is a wide range of tutorials here. Johan Kent Johnson wrote: >Johan Geldenhuys wrote: > > >>Wesley, >> >>I am doing some socket programming in my work and I need to learn about >>writing webpages and CGI stuff in

Re: [Tutor] Internet programming with python

2006-01-18 Thread Johan Geldenhuys
beneficial. I read about your tutorial in Feb. but can't make it, unless you come to South Africa ;-) . I will check out "Foundations of Python Network Programming" by John Goerzen. Any tutorials on the net I could use? Thanks for he help Johan w chun wrote: >On 1/18/06, Johan

[Tutor] Internet programming with python

2006-01-18 Thread Johan Geldenhuys
Hi all, Has the book 'Internet programming with Python' (ISBN: 1558514848, publisher: M&T Books, 1996) ever been revised or is there a secod editin available? I don't have it, but I would like this or something simular very much. Any ideas what the status is or where I can find it? Thanks, Joh

Re: [Tutor] Numeric import error

2005-12-22 Thread Johan Geldenhuys
>>> import Numeric Traceback (most recent call last):   File "", line 1, in ? ImportError: No module named Numeric Pujo Aji wrote: Can you open the python interpreter and write: import Numeric What kind of error message you have? Cheers, pujo On 12/22/05, Johan Ge

[Tutor] Numeric import error

2005-12-22 Thread Johan Geldenhuys
Hi all, I have installed Numeric (Suse 10.0) and it is in my site-packages folder, but I can't import the module. Any idea how to fix this/ TIA Johan ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Pygame mailing list info needed

2005-12-21 Thread Johan Geldenhuys
This will do, thanks. Johan Lee Harr wrote: I subscribed to the pygame-users mailing list through [EMAIL PROTECTED], but I don't know where to send the mail too so that everybody can see it. Any suggestion on how to use that mailing list? http://www.google.com/search?q=p

Re: [Tutor] Books

2005-12-21 Thread Johan Geldenhuys
Are here any new books on web programming with Python? Johan David Holland wrote: >I would recommend python programming for the absolute beginner. > > > > > >___ >Yahoo! Messenger - NEW crystal clear PC to PC c

[Tutor] Print random letters

2005-12-21 Thread Johan Geldenhuys
Hi all, I want to print out random letters from A - Z. I know how to do this with numbers, but don't know with letters. Any ideas wil be greatly appreciated. Johan ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Pygame mailing list info needed

2005-12-21 Thread Johan Geldenhuys
Hi, I subscribed to the pygame-users mailing list through [EMAIL PROTECTED], but I don't know where to send the mail too so that everybody can see it. Any suggestion on how to use that mailing list? Thanks, Johan ___ Tutor maillist - Tutor@python.or

Re: [Tutor] opts and try except

2005-11-20 Thread Johan Geldenhuys
Maybe this recipe will help. Here I used and tested the arguments that the user must enter before using the module: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440476 Johan Eric Walker wrote: >All, >I have a program now that works just like I want it. Now I want to >integerate som

Re: [Tutor] new topic draft

2005-11-17 Thread Johan Geldenhuys
ect for external commands, that allows to kill them after later.. ::Author: Johan Geldenhuys [EMAIL PROTECTED] ::Version: 0.0.2 ::Date last updated: 2005-11-16 ::Changes: - refactored by Christopher Arndt :: TODO: Capture the output from line 41 to a file. &qu

Re: [Tutor] new topic draft

2005-11-17 Thread Johan Geldenhuys
t more reusable. See attached file. Chris """Wrapper object for external commands, that allows to kill them after later.. ::Author: Johan Geldenhuys [EMAIL PROTECTED] ::Version: 0.0.2 ::Date last updated: 2005-11-16 ::Changes: - refactored by Chri

Re: [Tutor] new topic draft

2005-11-17 Thread Johan Geldenhuys
27;t mind? > > Alan G. > > > - Original Message - From: "Johan Geldenhuys" > <[EMAIL PROTECTED]> > To: "Alan Gauld" <[EMAIL PROTECTED]> > Cc: "Python Tutor list" > Sent: Wednesday, November 16, 2005 8:12 AM > Subject: Re: [Tutor] new t

Re: [Tutor] new topic draft

2005-11-16 Thread Johan Geldenhuys
www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor """ This class will execute the command, let it run for 5 seconds and kill the process. ::Author: Johan

Re: [Tutor] Looking for suggestions

2005-11-14 Thread Johan Geldenhuys
Haven't look at the code in detail, but it would be great exercise to write a web gui for this game like the one for Tick-Tack-Toe. Any suggestions where to start with something like this? Johan PS: Fun to play. ->Terry<- wrote: >-BEGIN PGP SIGNED MESSAGE- >Hash: SHA1 > > >I have writ

Re: [Tutor] Another Quick Question

2005-11-13 Thread Johan Geldenhuys
Could this be a OS thing? I use Linux and it works here. Steve Haley wrote: Folks,   I’m one of the people new to Python who has started going through a beginner’s book to learn the basics of the language (“Python Programming for the Absolute Beginner”).  In the second chapt

Re: [Tutor] simple report writing?

2005-11-10 Thread Johan Geldenhuys
Did you manage to get something that worked for you? Johan CPIM Ronin wrote: >Can someone suggest a specific tutorial strictly on report writing? > >I'm able to write reports fairly easily in Python. I know the stuff like >str(round(x,2)) where x = 3.145678 will yield 3.14. What I'm looking for

Re: [Tutor] logging to a database

2005-11-10 Thread Johan Geldenhuys
Try looking here; http://sourceforge.net/projects/mysql-python Johan captnswing wrote: >Hello all, >I would like to log messages to a database (mysql) >I found the example log_test14.py that comes with python logging >module http://www.red-dove.com/python_logging.html >but that example is a bi

Re: [Tutor] Percentage

2005-11-08 Thread Johan Geldenhuys
Thanks, that helps. Jorge Godoy wrote: Johan Geldenhuys <[EMAIL PROTECTED]> writes: Now that I have the answer (16.801), How do I round it of to 16.80 ? I only need it to be to the closest 1/100. print

Re: [Tutor] Percentage

2005-11-08 Thread Johan Geldenhuys
Now that I have the answer (16.801), How do I round it of to 16.80 ? I only need it to be to the closest 1/100. TIA Jorge Godoy wrote: Frank Moore <[EMAIL PROTECTED]> writes: Johan, You could try: percentage = (42 * 250)/100 This gives the answer 105. A

Re: [Tutor] Percentage

2005-11-07 Thread Johan Geldenhuys
Wow, you gave 105% on this one. ;-) Frank Moore wrote: Johan Geldenhuys wrote: Hi all, What is the syntax if I want to work out what percentage 42 is out of 250? Johan, You could try: percentage = (42 * 250)/100 This gives the answer 105. Cheers, F

Re: [Tutor] Percentage

2005-11-07 Thread Johan Geldenhuys
I have it like that, just thought there could be another way. 8-) Jorge Godoy wrote: Johan Geldenhuys <[EMAIL PROTECTED]> writes: What is the syntax if I want to work out what percentage 42 is out of 250? If you want it as a factor to multiply / divide by som

[Tutor] Percentage

2005-11-07 Thread Johan Geldenhuys
Hi all, What is the syntax if I want to work out what percentage 42 is out of 250? TIA, ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Sorting a dictionary

2005-11-04 Thread Johan Geldenhuys
Thanks, Danny. You see, I didn't put all the keys and values in the dicionary manually. It was generated while parsing a file with some Python code, that's why the dict is not in order. I just want to do it to read easier and look something up. How will I then put my dict together again after

[Tutor] Sorting a dictionary

2005-11-04 Thread Johan Geldenhuys
Hi all, In my new project I needed a dictionary with TCP/UDP port numbers as keys and the service for that key as the value. I got the info from the services file in Linux and compiled a dictionary as I needed. The only thing that I want to do is to sort the dictionary from the smallest key num

Re: [Tutor] Exit from program early

2005-11-03 Thread Johan Geldenhuys
Try using 'sys.exit()' where you want the script to stop if you haven't supplied enough arguments. in you example, it looks like it will go on to the else anyway AND print the string at the end. HTH, Johan Roy Bleasdale wrote: >Hi > >In the example below I would like the program to stop if I

Re: [Tutor] printing statement

2005-11-03 Thread Johan Geldenhuys
t I was looking for. I saw the '%', but that is wahat I wanted to use. Johan Colin J. Williams wrote: bob wrote: At 11:31 AM 11/3/2005, Johan Geldenhuys wrote:   Hi all, Just a quick question; How do I code this output: ""

[Tutor] printing statement

2005-11-03 Thread Johan Geldenhuys
Hi all, Just a quick question; How do I code this output: """ files dirs == """ I want to print something a few space away from the left side or in the middle of the line. Thanks, Johan ___ Tutor maillist - Tutor@python.org http://m

Re: [Tutor] Capture command output

2005-11-03 Thread Johan Geldenhuys
The version of python that I have is 2.2.2 and I can't upgrade, sorry. As far as I know this only from version 2.4.2?? Johan Kent Johnson wrote: Johan Geldenhuys wrote: I've been musy with the os command on how to kill a process. That's been sorted out to an exte

[Tutor] Capture command output

2005-11-02 Thread Johan Geldenhuys
I've been musy with the os command on how to kill a process. That's been sorted out to an extend. Many thanks for your input. Now I have a question in the same direction: I use os.execpv(cmd, [cmd, args]). That executes the command that have output. This was the best way of getting the pid and

Re: [Tutor] os command

2005-11-02 Thread Johan Geldenhuys
ocess. > > Probably your best bet would be to use the subprocess module. It was > designed around the limitations of the previous methods. > > Take a look at what oyu can do with it at: > > http://www.python.org/doc/2.4.2/lib/module-subprocess.html > > For example, the pid

[Tutor] Tutorials on the web

2005-11-02 Thread Johan Geldenhuys
Here is a link to a range of tutorials: http://www.awaretek.com/tutorials.html Maybe this wil help some people to know where to find a good tutorial ona specific subject. Johan ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/list

[Tutor] Decoding decleration

2005-11-02 Thread Johan Geldenhuys
I receive this error when executing a file: "Non-ASCII character '\x8b' in file task.py on line 1, but no encoding declared". Can anybody tell me what the encoding is supposed to look like and is it standard on all files that is trying to use Non-ASCII characters? Thanks, Johan

Re: [Tutor] os command

2005-11-02 Thread Johan Geldenhuys
f > exec): > > pid = os.fork() > > if pid == 0: #child process > os.execvp("tcpdump", "tcpdump", "-n", "-i", "eth0") > > else: #parent > time.sleep(5) > os.kill(pid, os.SIGTERM) > os.waitpid(pid,

Re: [Tutor] Talking to UDPServer

2005-11-01 Thread Johan Geldenhuys
I've done some network programming mostly with TCP and I don't think that the way the client connects to the server is a lot different (if any), The only difference is when you must decide the protcol family. "socket.SOCK_DGRAM" will be for UDP and "socket.SOCK_STREAM" will be for TCP. After th

Re: [Tutor] Talking to UDPServer

2005-10-31 Thread Johan Geldenhuys
Maybe you could tel us if you already have the server listening on the socket that you expec connections on? If, yes, do you want an example of how a client connects to that socket? Johan Carroll, Barry wrote: Greetings:   I am writing a browser-based interface to a server

Re: [Tutor] compare

2005-10-31 Thread Johan Geldenhuys
In your code that line is not executed. And if it was at some stage, it will give you an error. max_item is a list and you cannot put a string and a list together: "TypeError: cannot concatenate 'str' and 'list' objects". What are trying to do with this line? 'maximum = 0' and so product will

Re: [Tutor] Random number generator (was: Can anyone help me?)

2005-10-28 Thread Johan Geldenhuys
After I tested the previous code, I noticed that the odds is 1:49 that a duplicate number can be found in the 6 digit range (and it happended) and that 0 can also be found. Here is the fix: import random def randnum():     c = []     for x in range(6):     s = random.randrange(0, 50)    

Re: [Tutor] Can anyone help me?

2005-10-28 Thread Johan Geldenhuys
>>> def randnum(): ...           c = [] ...   for x in range(6): ... s = random.randrange(50) ... c.append(s) ...   print 'Randoms: ',c ...   c = [] This works good !! Johan R. Alan Monroe wrote: Hey all, I am trying to create

Re: [Tutor] OT - Re: Can anyone help me?

2005-10-28 Thread Johan Geldenhuys
Any chance of winning  £25million is a good one. ;-) Ed Singleton wrote: You can actually increase your chance of winning in the English lottery. If two many tickets win a prize in one draw, the lowest prize (£10 for three numbers) is not paid out. Also the jackpot is shared between al

Re: [Tutor] os.system sending of break signals

2005-10-28 Thread Johan Geldenhuys
With what can I try and see what the PID is when using popen() or popen2() ? One thing that I noticed now is that when using popen() and the sys.exit(). The command is completed before my Python shell is terminated and if I use popen2(), sys.exit() works immediately but the ping command runs st

Re: [Tutor] os.system sending of break signals

2005-10-28 Thread Johan Geldenhuys
If I use popen2, I need to write to one of the tuple parts. >>> f = os.popen2('ping 192.168.8.85 -c 100 > cap1.txt') >>> f[0].write('\x03') Thank command works, but 'f[1]' is in read-only mode and I can't write to it. My command in the background is still not terminated. BTW I use Linux as OS.

Re: [Tutor] os.system sending of break signals

2005-10-28 Thread Johan Geldenhuys
So far: I tried >>> f = os.popen('ping 192.168.8.85 -c 100 > cap2.txt') You will see that I send the output from the command to a file, because I want to test how stop the command before it reaches 100 pings. If I don't write the output to the file 'cap2.txt' and succeeds in closing 'f', all th

[Tutor] os.system sending of break signals

2005-10-27 Thread Johan Geldenhuys
Hi all, I send a command to os.system(cmd) and want to send a break signal in the same way. Is this possible? The break signal is ctrl c (^c). I tried this, but it didn't work: os.system('\x03') I think Hex 03 is the signal for ctrl c. Thanks, ___ Tu

Re: [Tutor] os command

2005-10-26 Thread Johan Geldenhuys
So, for a newbie like me I might struggle with this one :-( I saw that the thread in comp.lang.python talks about a deamon flag for a thread. This sounds like a idea that could work. I don't know how to use that, but will use the example given there. Thanks. Kent Johnson wrote:

[Tutor] os command

2005-10-26 Thread Johan Geldenhuys
I have script that calls a system command that I want to run for 5 minutes. """ import os cmd = 'tcpdump -n -i eth0' os.system(cmd) """ I can start a timer after the cmd is issued, but I don't know how to send a control signal to stop the command after I issued it. This is normally from the shel

Re: [Tutor] new user question about while loops

2005-10-26 Thread Johan Geldenhuys
I am confused. It looks to me as if the while loop will never work, because it stays inside while <100 and further down in the loop, if it is < 100, it should go out of the loop. How can it stay running while <100 and yet go out if  < 100? Johan   Nick Eberle wrote: print "This is a

Re: [Tutor] "Decompile" pyc file

2005-10-20 Thread Johan Geldenhuys
When I want to download the zip file from the source, I get the error that the page does not exist. Where can I get it? Thanx. Bernard Lebel wrote: Sorry for the late reply. Thanks a lot Kent, that was really helpful. Bernard On 10/14/05, Kent Johnson <[EMAIL PROTECTED]> wrote:

Re: [Tutor] guidance for web site development

2005-10-14 Thread Johan Geldenhuys
I am also looking for a good tutorial on this subject. Have you tried http://www.modpython.org/ ? I think that the mod_python mailing list will be a better place to ask. I'm going to. Johan nitin chandra wrote: > Hi!... >i am new to Python and i want to develop a website with forms; data

[Tutor] PLC programming with Python?

2005-10-12 Thread Johan Geldenhuys
Hi all, Can Python be used to do PLC (programmable logic controller) programming? I'm not sure because Python needs some platform to run on? Thanks, Johan ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Stopping function after given time

2005-10-10 Thread Johan Geldenhuys
You can use the Timer in threading. Look at what is done in the attached script. You can basically use three functions to start the timer, stop the timer and do what ever it is to be done upon expiring. There maybe easier ways, but this will work. You can call the start_timer with a time in se

Re: [Tutor] Console output

2005-10-05 Thread Johan Geldenhuys
This might help. Never used it though. Johan Christian Wyglendowski wrote: > -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Oliver Maunder Sent: Wednesday, October 05, 2005 1:13 PM To: tutor@python.org Subject: [Tutor] Console output Does anyon

Re: [Tutor] Python Editors (particualrly Vim)

2005-09-22 Thread Johan Geldenhuys
jedit is also good. I use that. The only thing is that you can't execute the script from there. It is great for collapsing at indentions. www.jedit.org Johan On Thu, 2005-09-22 at 13:54 +0100, Ed Singleton wrote: Okay, I've also found this: http://cream.sourceforge.net/features.html Which i

  1   2   >