Re: How do I pass a variable to os.popen?

2011-10-31 Thread Dan M
On Mon, 31 Oct 2011 13:16:25 -0700, extraspecialbitter wrote: > cmd = 'ethtool %interface' Do you perhaps mean: cmd = 'ethtool %s' % (interface, ) -- http://mail.python.org/mailman/listinfo/python-list

Re: mystery string code - help!

2011-04-20 Thread Dan M
> As a newbie Pythoner, I understand [] -1] but would some tell me how > '::' does its magic? > > Uncle Ben The -1 is the "stride" or "step" argument. It's described at http://docs.python.org/release/2.3.5/whatsnew/section-slices.html Dan -- http://mail.python.org/mailman/listinfo/python-list

Re: find in smartpdf files

2011-01-06 Thread Dan M
On Thu, 06 Jan 2011 08:11:34 -0800, Wanderer wrote: > We generate PCB assembly files in pdf format using SmartPDF. This allows > us to search for a component in the assembly using the find feature. We > would like to be able to generate a list of components sorted by part > type and then use that

Re: list from FTP server to a text file

2011-01-06 Thread Dan M
On Thu, 06 Jan 2011 10:51:42 -0500, Ahmed, Shakir wrote: > Hi, > > I am trying to create a list in a txt file from an ftp server. The > following code is retrieving the list of the files but could not able to > write in a text file. Any help is highly appreciated. > > Thanks > > > > *

Re: Trying to decide between PHP and Python

2011-01-04 Thread Dan M
On Tue, 04 Jan 2011 12:32:28 -0800, Google Poster wrote: > Not to mention that it took me 9 minutes to get a reply from you... > Quite speedy community support. > > That is a very important parameter in my technology decisions these > days. > > Thanks! > > -Ramon This Usenet group is a truly a

Re: Trying to decide between PHP and Python

2011-01-04 Thread Dan M
On Tue, 04 Jan 2011 12:20:42 -0800, Google Poster wrote: > About once a year, I have to learn yet another programming language. > Given all the recommendations (an outstanding accolade from Bruce Eckel, > author of "Thinking in Java") I have set my aim to Python. Sounds kinda > cool. > > The inde

Re: Hosting a Python based TCP server

2010-12-23 Thread Dan M
On Thu, 23 Dec 2010 04:01:03 -0800, Oltmans wrote: > Hi all, > > I'm writing a very small TCP server(written in Python) and now I want to > host it on some ISP so that it can be accessed anywhere from the > Internet. I've never done that before so I thought I should ask for some > advice. Do you

Re: Newbie needs regex help

2010-12-06 Thread Dan M
On Mon, 06 Dec 2010 18:12:33 +0100, Peter Otten wrote: > By the way: > print quopri.decodestring("=E4=F6=FC").decode("iso-8859-1") > äöü print r"\xe4\xf6\xfc".decode("string-escape").decode("iso-8859-1") > äöü Ah - better than a regex. Thanks! -- http://mail.python.org/mailman/listin

Re: Newbie needs regex help

2010-12-06 Thread Dan M
On Mon, 06 Dec 2010 09:44:39 -0600, Dan M wrote: > That's what I had initially assumed was the case, but looking at the > data files with a hex editor showed me that I do indeed have > four-character sequences. That's what makes this such as interesting > task! Sorry, I m

Re: Newbie needs regex help

2010-12-06 Thread Dan M
On Mon, 06 Dec 2010 16:34:56 +0100, Alain Ketterlin wrote: > Dan M writes: > >> I took at look at http://docs.python.org/howto/regex.html, especially >> the section titled "The Backslash Plague". I started out trying : > >>>>> import re >>&

Re: Newbie needs regex help

2010-12-06 Thread Dan M
On Mon, 06 Dec 2010 10:29:41 -0500, Mel wrote: > What you're missing is that string `a` doesn't actually contain four- > character sequences like '\', 'x', 'a', 'a' . It contains single > characters that you encode in string literals as '\xaa' and so on. You > might do better with > > p1 = r'([

Newbie needs regex help

2010-12-06 Thread Dan M
I'm getting bogged down with backslash escaping. I have some text files containing characters with the 8th bit set. These characters are encoded one of two ways: either "=hh" or "\xhh", where "h" represents a hex digit, and "\x" is a literal backslash followed by a lower-case x. Catching the f

Re: [Q] get device major/minor number

2010-11-30 Thread Dan M
On Tue, 30 Nov 2010 21:35:43 +0100, Thomas Portmann wrote: > Thank you very much Dan, this is exactly what I was looking for. > > > Tom You're very welcome. -- http://mail.python.org/mailman/listinfo/python-list

Re: [Q] get device major/minor number

2010-11-30 Thread Dan M
On Tue, 30 Nov 2010 21:09:14 +0100, Thomas Portmann wrote: > Hello all, > > In a script I would like to extract all device infos from block or > character device. The "stat" function gives me most of the infos (mode, > timestamp, user and group id, ...), however I did not find how to get > the de

Re: SQLite3 and lastrowid

2010-11-16 Thread Dan M
On Tue, 16 Nov 2010 13:08:15 -0800, fuglyducky wrote: > On Nov 16, 12:54 pm, Ian wrote: >> On Nov 16, 1:00 pm, fuglyducky wrote: >> >> > Before I added the second table I could simply run >> > 'print(cursor.lastrowid)' and it would give me the id number. >> > However, with two tables I am unable

Re: What people are using to access this mailing list

2010-11-03 Thread Dan M
On Wed, 03 Nov 2010 08:02:29 +, John Bond wrote: > Hope this isn't too O/T - I was just wondering how people read/send to > this mailing list, eg. normal email client, gmane, some other software > or online service? > > My normal inbox is getting unmanageable, and I think I need to find a > n

Re: python script to read google spreadsheet

2010-11-01 Thread Dan M
On Mon, 01 Nov 2010 01:14:09 -0700, charu gangal wrote: > This is the page i am getting on localhost 8080. The code is showing me > thr result only in Eclipse but not through google app engine launcher. > > Traceback (most recent call last): > File "C:\Program Files (x86)\Google\google_appengin

Re: Newbie question - parsing MIME(?) strings

2010-10-28 Thread Dan M
On Thu, 28 Oct 2010 15:05:56 -0500, Dan M wrote: Ok, I didn't research enough before I posted this. I see now that this *is* indeed a MIME message, and the '?Q' bit says that the next piece is quoted-printable, and that the encoding is defined in RFC2047. So the question the

Newbie question - parsing MIME(?) strings

2010-10-28 Thread Dan M
I'm working on a script that grabs messages from a Usenet server and does some work with them. All works nicely except for a few issues with the data I retrieve. For example, in one newsgroup I find occasional lines containing bits like: "Re: Mlle. =?ISO-8859-1?Q?Ana=EFs_introdooses_her_ownself

os.link makes a copy, not a link

2006-06-09 Thread Dan M
I'm a little bit confused. According to the sources I've looked at on the net, os.link('file1', 'file2') should make a hard link from file1 to file2. But what I'm finding is that it's actually making a copy. Am I forgetting a step or something? Python 2.3.4 running on CentOS 4.3 -- http://m

Re: TSV to HTML

2006-05-31 Thread Dan M
> 1) in the code define a css > 2) use a regex to extract the info between tabs In place of this, you might want to look at http://effbot.org/librarybook/csv.htm Around the middle of that page you'll see how to use a delimiter other than a comma > 3) wrap the values in the appropriate tags and in

Re: I'm just not cut out for web programming, I guess :)

2006-05-17 Thread Dan M
On Wed, 17 May 2006 20:51:07 +, John Salerno wrote: > Ok, I've tinkered with this thing for a while, and I keep fixing little > problems, but I always get a 500 Internal Server error when I go to this > site: > > I don't necessarily even want help just yet, I'd like to figure it out > myse

Re: Code Feedback

2006-02-06 Thread Dan M
> 2) Anybody know how to alter the "while 1: pass" section to make the > app stoppable? That one I think I can help with! See below. > while 1: pass try: while 1: pass except KeyboardInterrupt: break -- http://mail.python.org/mailman/listinf

Re: script to read emails and extract attachments from cron

2006-02-06 Thread Dan M
On Mon, 06 Feb 2006 10:57:23 -0800, [EMAIL PROTECTED] wrote: > Hi: > > I am looking for advice on the best way to set up a process to read > incoming emails (from a normal unix mailbox on the same host) > containing a gzipped telemetry attachment. I'd like the script to > extract the attachment i

Re: Redirecting stdin/stdout to self

2006-01-23 Thread Dan M
>>> And if I'm reading it correctly, the Perl >>> script's process starts tcpdump, but redirects its output to its own >>> input, and reads it line by line. And to clarify, what the Perl script is doing is redirecting the standard error to standard out. STDIN is file handle 0, STDOUT is file handl

Re: copying a file from windows file system to ext2 and ext3

2006-01-10 Thread Dan M
On Tue, 10 Jan 2006 15:59:01 -0800, muttu2244 wrote: > hi all > > could anybody please tell me how can i copy a file from windows file > systems like FAT12, FAT16,FAT32 and NTFS to EXT2, and EXT3. > Is their any function in python that we can do the above > > Thanks in advance > Yogi I'm sure m

Re: urlretrieve() questions

2005-12-23 Thread Dan M
> Pretty straight forward...but what I'm finding is if the > url is pointing to a file that is not there, the server > returns a file that's a web page displaying a 404 error. > > Anyone have any recommendations for handling this? You're right, that is NOT documented in a way that's easy to find

Re: doubt on csv file

2005-12-15 Thread Dan M
On Thu, 15 Dec 2005 16:09:51 -0800, muttu2244 wrote: > hey thanks a lot for that it worked . Excellent! Glad to be of assistance :) -- http://mail.python.org/mailman/listinfo/python-list

Re: doubt on csv file

2005-12-15 Thread Dan M
> here is what am trying to do, first am trying to open it in a read > mode, and checking each row by row , if it is not found till my last > row, i want to append it to the last row , so how should i do that. > > file = open ('C:\some.csv','r') > reader = csv.reader(file) > for row in reader: >

Re: Newbie question - deleting records from anydbm database

2005-12-15 Thread Dan M
>> Now how can I go about deleting that record when it's too old? >> > (untested) > > try > > del db[ipAddress] Yep, that did it. Thanks! -- http://mail.python.org/mailman/listinfo/python-list

Newbie question - deleting records from anydbm database

2005-12-14 Thread Dan M
I've been Googling like a mad fiend and flipping through my hard-copy Python books, but still haven't located the one little bit of info I need. I've put together a simple SMTP-after-IMAP script that gets the authorized IP info from the mail log (I know, it's not elegant but it works). All works f

Re: how to get select label?

2005-12-14 Thread Dan M
On Wed, 14 Dec 2005 13:56:24 -0800, lli wrote: > I build web application. So I use CGI. I need to show select text in > the html page. Now I can only display select value such as '001'. But I > need to display its text 'AAA'. > > LLI I'm a Python newbie, so by all means verify this answer with m

Re: Simple (?) question about print statement

2005-12-14 Thread Dan M
On Wed, 14 Dec 2005 15:27:58 -0800, TY wrote: > So I guess then my next question is why does adding comma to print > statement cause buffering, but not when you don't have comma? Because of the line buffering. If you don't have a comma at the end, the print statement prints the numeric value and

Re: Newbie: executing a system command from my Python app

2005-12-13 Thread Dan M
> Few points points: > > 1. Generally: I would try to minimize system calls. They make your code less > portable. Excellent point. In this case the app will never live anywhere other than one specific FreeBSD machine, but I do appreciate the value of the advice anyway. Therefore... > 2. Look

Re: Newbie: executing a system command from my Python app

2005-12-12 Thread Dan M
On Mon, 12 Dec 2005 13:25:14 -0800, Dan M wrote: > I'm writing a Python replacement for a particularly ugly shell script. we > are running mimedefang on our mail server, moving spam and virus messages > to a quarantine directory. This little python script successfully chdir's

Newbie: executing a system command from my Python app

2005-12-12 Thread Dan M
I'm writing a Python replacement for a particularly ugly shell script. we are running mimedefang on our mail server, moving spam and virus messages to a quarantine directory. This little python script successfully chdir's to the quarantine directory, identifies all of the quarantine subdirectories

Re: Python web publishing framework like Cocoon?

2005-12-07 Thread Dan M
> Is there a Python web publishing framework like Cocoon? > > I found Maki but it was last updated in > 2003 and its author says that he doesn't want to make another release... How about: http://www.cherrypy.org/ http://www.turbogears.org/ http://www.djangoproject.

Re: how to handle two forms in cgi?

2005-11-30 Thread Dan M
> My question is: How let these two form works together? I try to use > two codes for these two forms, e.g. Login.py for login form and > search.py for search form. But when user input data in search form and > click its submit button, it just comes back to login form. Second form > doesn't work.

Timeout in urllib2

2005-11-23 Thread Dan M
I'm writing a system monitor script that needs to load web pages. I'm using urllib2.urlopen to get the pages, and I'm attempting to set the timeout value using socket.defaulttimeout. Specifically, I'm calling socket.defaultttimeout(10), then calling urllib2.urlopen to fetch a web page that never g

Re: Using Which Version of Linux

2005-11-05 Thread Dan M
On Sat, 05 Nov 2005 04:26:38 -0600, blahman wrote: > ok, i m going to use Linux for my Python Programs, mainly because i > need to see what will these fork() and exec() do. So, can anyone tell > me which flavour of linux i should use, some say that Debian is more > programmer friendly, or shold

Re: query a port

2005-10-30 Thread Dan M
On Sat, 29 Oct 2005 23:21:16 -0700, eight02645999 wrote: > thanks alot! > that's all there is to it..so it's just a simple connect. If all you want to do is check that the given port is open on the given host, that's it. I tried it on my local box. When connecting to port 25, it made the connecti

Re: query a port

2005-10-29 Thread Dan M
On Sat, 29 Oct 2005 20:21:20 -0700, eight02645999 wrote: > hi > in python, how do one query a port to see whether it's up or not? > thanks I'm an absolute beginner, but let's see if I can help. Assuming you want to check a port on another machine, import socket port=25 # Port we

Building 2.4.2 on OpenBSD 3.8

2005-10-29 Thread Dan M
I've been working with python 2.2.3 for the last couple of weeks, but would like to move up to 2.4. I grabbed the 2.4.2 tarball and attempted to install, but I get: gcc -pthread -c -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -I. -I./Include -DPy_BUILD_CORE -o Modules/python.o

Re: Python 2.3.4, Berkeley db 1.85, db file format not recognized

2005-10-26 Thread Dan M
On Wed, 26 Oct 2005 14:23:49 -0500, skip wrote: > > Dan> import bsddb > Dan> bsddb.hashopen("access.db") > > Dan> but I get: > Dan> bsddb._db.DBInvalidArgError: (22, 'Invalid argument -- access.db: > unexpected file type or format') > > Dan> Any suggestions on how to r

Python 2.3.4, Berkeley db 1.85, db file format not recognized

2005-10-26 Thread Dan M
I'm working on a script that will interface with sendmail on my FreeBSD box. I'm trying to read my access.db file (yes, it's for a quick and dirty SMTP-after-POP application). I'm trying: import bsddb bsddb.hashopen("access.db") but I get: bsddb._db.DBInvalidArgError: (22, 'Invalid argument -- ac

Re: Parsing XML - Newbie help

2005-05-22 Thread Dan M
Hi rh0dium wrote: > I am relatively new to python and certainly new to XML parsing. Me too. However there are plenty of good docs/tutorials available to help with both XML and using it in Python. For XML you may wish to look at http://www.w3schools.com/. It has a very accessible set of tutor