How to detect the presence of a html file

2005-12-09 Thread Phoe6
Operating System: Windows Python version: 2.4 I have bookmarks.html and wumpus.c under my c: When I tried to check the presence of the bookmarks.html, I fail. >>> os.path.isfile('c:\bookmarks.html') False >>> os.path.isfile('c:\wumpus.c') True >>> os.path.exists('c:\wumpus.c') True >>> os.path.

Re: How to detect the presence of a html file

2005-12-09 Thread Phoe6
Kent Johnson wrote: > The problem is that \ is special in string literals. \b is a backspace > character, not the two-character sequence you expect. \w has no special > meaning so it *is* the two-character sequence you expect. > The simplest fix is to use raw strings for all your Windows path need

Howto Determine mimetype without the file name extension?

2006-07-18 Thread Phoe6
== '__main__': main() but the problem with using file was it recognized both .xls (MS Excel) and .doc ( MS Doc) as Microsoft Word Document only. I need to separate the .xls and .doc files, I dont know if file will be helpful here. -- If the first approach of mime

Re: Howto Determine mimetype without the file name extension?

2006-07-18 Thread Phoe6
Justin Azoff wrote: > Additionally, I would re-organize your program a bit. something like: > Thanks Justin, that was a helpful one. Helping me in learning python programming. Thanks, Senthil -- http://mail.python.org/mailman/listinfo/python-list

Comment on this script. Possible error in communication with list arg between functions

2006-07-24 Thread Phoe6
Hi all, Part of my script is to check for pre-requisite rpms to be installed. If its installed, I just display the rpm version as in rpm database, otherwise I output a message saying: ' rpm is not installed' and collect the rpm name in a list (notInstalled). At the end if the len(notInstal

Re: Comment on this script. Possible error in communication with list arg between functions

2006-07-24 Thread Phoe6
Juho Schultz wrote: > I think return values should be used for communication between > functions. Maybe something like this could work for you (not tested). > > def checkForRpm(rpmname): > # > # Strings with 0 lenght are False > if output: > print output > else: > p

import a user created python file as module

2006-07-30 Thread Phoe6
Hi, I have the following directory structure in my project. Base: file1.py file2.py Directory1: file1-dir1.py I am able to import file1 into file2.py What I need to do is, import file1 in the file file1-dir1.py. I did not create the entire dir

strings in the global section

2006-10-12 Thread Phoe6
I write a script: #!/usr/bin/python astring = "This is a String" def fun1(): astring = "I modify it in fun1" def fun2(): astring = "I modify it in fun2" def main(): print astring fun1() print astring fun2() print astring if __name__ == '__mai

Re: strings in the global section

2006-10-12 Thread Phoe6
Bjoern Schliessmann wrote: > If you assign "astring" inside the function body, it's a local name. > > > - What should I do to overwrite the string variable in the global > > section within functions? > > Put a "global astring" in the function to access the global name > instead. #!/usr/bin/python

httplib.InvalidURL: nonnumeric port: For characters in the proxy password in URL

2006-11-13 Thread Phoe6
Hi, The following piece of code works properly when my proxy password contains characters[a-zA-Z0-9] etc. But when my proxy password contained something like '|\/|' , the httplib incorrectly indentified it as separator. How do I resolve this issue. # Proxy Address PROXY_IP = "1.1.9.8:80" #

Re: httplib.InvalidURL: nonnumeric port: For characters in the proxy password in URL

2006-11-13 Thread Phoe6
Fredrik Lundh wrote: > Phoe6 wrote: > > Hi, > > The following piece of code works properly when my proxy password > > contains characters[a-zA-Z0-9] etc. But when my proxy password > > contained something like '|\/|' , the httplib incorrectly indentified

Re: httplib.InvalidURL: nonnumeric port: For characters in the proxypassword in URL

2006-11-13 Thread Phoe6
Fredrik Lundh wrote: Hi Fredrik, I apologize if I offended you or have shown any impatience. I shall try again: > oh, please. urllib.quote is a *function*; there's no way that calling that > function > from code written for urllib2 will affect anything. > > but you can access url

Re: httplib.InvalidURL: nonnumeric port: For characters in theproxypassword in URL

2006-11-13 Thread Phoe6
Fredrik Lundh wrote: > "Phoe6" wrote: > > > - use urllib.quote() to covert the proxy url to a quoted one. > > you should use quote to convert the *password* to quoted form, not use it on > the entire URL. > Am sorry Fred. The same problem: File "C:

Re: httplib.InvalidURL: nonnumeric port: For characters intheproxypassword in URL

2006-11-13 Thread Phoe6
Fredrik Lundh wrote: > > can you post the code you're using to build the URI ? > Okay. This piece of code fetches a page from a particular site. As I am behind a firewall, I have to communicate through a proxy. # Set the Proxy Address PROXY_IP = "10.1.9.4:80" # Trying with linear way proxy_user

Re: httplib.InvalidURL: nonnumeric port: For charactersintheproxypassword in URL

2006-11-13 Thread Phoe6
Fredrik Lundh wrote: > "Phoe6" wrote: > > > proxy_password = urllib.quote(proxy_password_orig) > > make that: > > proxy_password = urllib.quote(proxy_password_orig, "") > Oh yeah. Wonderful!! That worked. Thanks a lot Fredrik!. :-) (<^> p

timeit module for comparing the performance of two scripts

2006-07-11 Thread Phoe6
Hi, Following are my files. In the format: Filename content config1.txt #DataBase Repository file dbRepository = omsa_disney.xml config2.txt # Configfile for sendmail [Sendmail] userprefix = testuser pyConfig.py import re def pyConfig(): fhandle =

Re: timeit module for comparing the performance of two scripts

2006-07-11 Thread Phoe6
Fredrik Lundh wrote: > > $ python -m timeit -s "import pyConfig" "pyConfig.pyConfig()" > $ python -m timeit -s "import pyConparse" "pyConparse.pyConParse()" > note that timeit runs the benchmarked function multiple times, so you may want > to remove the print statements. Thanks a lot Fredrik!. I

Accessing Add/Remove Programs Details

2006-09-07 Thread Phoe6
Hi all, I have to uninstall an application and I don't find the uninstaller, the option available to me is to access Add/Remove Programs, select the application and remove from there. I am trying to automate this task using Python: 1) Get the Application Name 2) Access the Add/Remove Program det

Re: Accessing Add/Remove Programs Details

2006-09-08 Thread Phoe6
Tim Golden wrote: > [Phoe6] > and perhaps you need something like > this (altho' obviously more sophisticated): > > import wmi > > appname = "Python 2.4.3" > c = wmi.WMI () > for product in c.Win32_Product (Caption=appname): > print product.Captio

Trying to understand rfc822.Message() behaviour

2006-11-30 Thread Phoe6
Hi all, Have a look at this snippet, I have a file direct.txt and I want to read it as rfc8222.Message() so that I get the Subject: and Mood: as Dict Keys and content separately, but I am unable to get the Content Properly. >>> fhandle = open('direct.txt','r') >>> print fhandle.read() Subject: te

Re: Trying to understand rfc822.Message() behaviour

2006-11-30 Thread Phoe6
Fredrik Lundh wrote: > Phoe6 wrote: > > > Have a look at this snippet, I have a file direct.txt and I want to > > read it as rfc8222.Message() so that I get the Subject: and Mood: as > > Dict Keys and content separately, but I am unable to get the Content > > Pr

problem occurs with replaced values using fileinput

2006-12-02 Thread Phoe6
Hi All, I am able to use urlib2 through proxy. I give proxy credentials and use # Set the Proxy Address proxy_ip = "10.0.1.1:80" proxy_user = 'senthil_or' proxy_password_orig='password' proxy_password = urllib.quote(proxy_password_orig,"") # Setup the Proxy with urllib2 proxy_url = 'http://'

Annoucement- pyljvim-0.0.3 Released.

2006-12-04 Thread Phoe6
pyljvim is a a Livejournal Plugin for Vim. One can post to the Livejournal directly from vim! :) It is available at: http://www.vim.org/scripts/script.php?script_id=1724 Installation is pretty easy and so is the usage. Thanks, Senthil http://phoe6.livejournal.com Contemptuous lights flashed

Reading multiline values using ConfigParser

2007-06-20 Thread Phoe6
Hi, I have a configfile, in fact, I am providing a configfile in the format: [Information] Name: Foo Author: Bar Testcases: tct123 tct124 tct101 The last values is a multi-line. ConfigParser is unable to recognize a multi-line value and splits out error. C:\ATF-Tasks>python CreateTask.py Trace

Re: Reading multiline values using ConfigParser

2007-06-20 Thread Phoe6
On Jun 20, 10:35 pm, "John Krukoff" <[EMAIL PROTECTED]> wrote: > > Is there anyway, I can include multi-line value in the configfile? I > > Following the link to RFC 822 (http://www.faqs.org/rfcs/rfc822.html) > indicates that you can spread values out over multiple lines as long as > there is a s

Re: Reading multiline values using ConfigParser

2007-06-25 Thread Phoe6
On Jun 21, 7:34 pm, "John Krukoff" <[EMAIL PROTECTED]> wrote: > > > > Is there anyway, I can include multi-line value in the configfile? I > > > > Following the link to RFC 822 (http://www.faqs.org/rfcs/rfc822.html) > > > indicates that you can spread values out over multiple lines as long as > > >

New Thread- Supporting Multiline values in ConfigParser

2007-06-25 Thread Phoe6
Hi, Am starting a new thread as I fear the old thread which more than a week old can go unnoticed. Sorry for the multiple mails. I took the approach of Subclassing ConfigParser to support multiline values without leading white-spaces, but am struct at which position in _read I should modify to acc

using subprocess for non-terminating command

2007-07-04 Thread Phoe6
Hi all, Consider this scenario, where in I need to use subprocess to execute a command like 'ping 127.0.0.1' which will have a continuous non- terminating output in Linux. # code >>>import subprocess >>>process = subprocess.Popen('ping 127.0.0.1', shell=True, >>>stdin=subprocess.PIPE, stdout=subp

RFC - n-puzzle.py

2007-05-18 Thread Phoe6
Hi All, I would like to request a code and design review of one of my program. n-puzzle.py http://sarovar.org/snippet/detail.php?type=snippet&id=83 Its a N-puzzle problem solver ( Wikipedia page and http://norvig.com/ltd/test/n-puzzle.lisp ) I have used OO Python for the above program and would l

Re: RFC - n-puzzle.py

2007-05-19 Thread Phoe6
On May 19, 2:23 pm, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > On May 18, 4:15 pm, Phoe6 <[EMAIL PROTECTED]> wrote: > > I would like to request a code and design review of one of my program. > > n-puzzle.pyhttp://sarovar.org/snippet/detail.php?type=snippet&id=83

Re: Lists vs tuples (newbie)

2007-05-21 Thread Phoe6
On May 21, 4:48 pm, Szabolcs <[EMAIL PROTECTED]> wrote: > In what circumstances is it advantageous to use tuples instead of lists? > Is there a difference in performance? > As you should not, tuples are immutable while lists are mutable. You can think of all the scenarios where immutable datatype

Comparing RFC1123 based Dates

2007-08-04 Thread Phoe6
I would like to parse RFC 1123 date format and compare two dates. I find that datetime module does not specifically confirms to any RFC. Any suggestions as how I can handle the RFC 1123 date format using standard libraries before I go to re based parsing? Thanks, Senthil -- http://mail.python.or

Re: Comparing RFC1123 based Dates

2007-08-04 Thread Phoe6
Phoe6 wrote: > I would like to parse RFC 1123 date format and compare two dates. I > find that > datetime module does not specifically confirms to any RFC. Any > suggestions as how I can handle the RFC 1123 date format using > standard libraries before I go to re based parsing? W

print and softspace in python

2007-03-14 Thread Phoe6
print and softspace in python In python, whenever you use >>>print statement it will append a newline by default. If you don't want newline to be appended, you got use a comma at the end (>>>print 10,) When, you have a list of characters and want them to be printed together a string using a for loo

package import question

2007-10-22 Thread Phoe6
Hi all, I have the following directory structure: wallpaper/ -main.py -ng/ -- __init__.py -- setdesktop.py -yb/ -- __init__.py -- setdesktop.py >From main.py, I would like to do: import n

Re: package import question

2007-10-22 Thread Phoe6
On Oct 22, 1:24 pm, Peter Otten <[EMAIL PROTECTED]> wrote: > Phoe6 wrote: > > Hi all, > > I have the following directory structure: > > > wallpaper/ > > -main.py > > -ng/ > > -- __init__.py > >

How can I disable a device in windows using python

2007-02-26 Thread Phoe6
Hi all, I am trying to disable the NIC card (and other cards) enabled in my machine to test diagnostics on that card. I am trying to disable it programmatic using python. I checked python wmi and i could not find ways to disable/enable, (listing is however, possible). Where should I look for to en

Re: How can I disable a device in windows using python

2007-02-28 Thread Phoe6
On Feb 27, 2:21 pm, Duncan Booth <[EMAIL PROTECTED]> wrote: > > Hi all, > > I am trying to disable it programmatic using python. I checked python > > wmi and i could not find ways to disable/enable, (listing is however, > > possible). > > > Where should I look for to enable/disable devices in pyth

using telnetlib

2007-02-28 Thread Phoe6
Hi All, I am trying to use the telnetlib module. Manually when I do telnet 172.31.128.244 I get: Login: (I type root) Password: ( I type Password) And it enters to the Telnet Session: [root]# Now, I am trying to use telnetlib module >>> import telnetlib >>> tn = telnetlib.Telnet("172.31.128.244"

Re: using telnetlib

2007-02-28 Thread Phoe6
On Feb 28, 4:15 pm, Bjoern Schliessmann wrote: > Phoe6 wrote: > >>>> import telnetlib > >>>> tn = telnetlib.Telnet("172.31.128.244") > >>>> tn.read_until("Login: ") > > '\r\nLogin: ' > >>>> tn.wri

Re: How do I use Code Context under Options in IDLE?

2006-04-17 Thread Phoe6
[EMAIL PROTECTED] wrote: > --- > Code Context -- Open a pane at the top of the edit window which > shows the block context of the section of code > which is scrolling off the top or the window. > > But what does that actually mean? > > Take this code fragment example (with line numbers added > for

Previous PyCon Videos, anyone?

2009-01-15 Thread Phoe6
Hello All, Youtube channel of pycon09 has some videos ( http://www.youtube.com/user/pycon08), but most of them don't have a sufficiently good audio quality. Is there anyone who has better recording of an earlier PyCon talk? If yes, can you please point me to the location? Thanks, Senthil -- htt

CVS Folders/Contents to Automatic Website - Program suggestions

2008-12-06 Thread Phoe6
Hello all, I use cvs to maintain all my python snippets, notes, c, c++ code. As the hosting provider provides a public webserver also, I was thinking that I should convert the cvs folders automatically to website. 1) cvs2web is not what i mean. 2) doxygen may not be suitable. I tried with rest2w

Python and Windows Services Question

2009-03-04 Thread Phoe6
Hello, This is a windows services question. The following script which is a windows service was supposed to something ( download wallpaper and set the desktopwallpaper) at 16:45 my time here. The service is running, but the supposed action did not take place. Does anyone who is aware of win32 apis

CGIXMLRPCRequestHandler example

2009-03-29 Thread Phoe6
I have the following CGIXMLRPCRequestHandler usage example. I have both the server and the client in the same directory. I based this following this example: http://mail.python.org/pipermail/python-list/2005-May/320696.html Server Code: Foo.py import os import SimpleXMLRPCServer class Foo:

caseless dict - questions

2008-07-04 Thread Phoe6
I have a requirement for using caseless dict. I searched the web for many different implementations and found one snippet which was implemented in minimal and useful way. # import UserDict class CaseInsensitiveDict(dict, UserDict.DictMixin): def __init__(self, *args, **kwargs):

New python.org website

2006-03-06 Thread Phoe6
esign team. Senthil http://phoe6.livejournal.com -- http://mail.python.org/mailman/listinfo/python-list

read a file line by line using readline()

2006-03-22 Thread Phoe6
le.readline() As mentioned in the docs, the EOF returns an empty string. I am unable to catch or match against the EOF. Please help me in pointing out as where I am making the mistake. -- Senthil http://phoe6.livejournal.com -- http://mail.python.org/mailman/listinfo/python-list

Re: read a file line by line using readline()

2006-03-22 Thread Phoe6
Thomas Girod wrote: > > while line != "": > > and it works very well. Thanks Thomas, I stand corrected now. my mistake, I was checking against a single space ' ' instead of empty string ''. :( -- Senthil -- http://mail.python.org/mailman/listinfo/python-list

Re: Menu For The Command Line?

2006-03-27 Thread Phoe6
Michael Sperlle wrote: > When I bring up the command line interface, it looks like: [EMAIL PROTECTED] > > Then I type in some command, and it works! > > But there are lots of commands to type in, and I find it more and more > difficult to remember them. This question is not for comp.lang.python. H

dir_util.copy_tree call

2006-03-28 Thread Phoe6
Hi all. I am using IDLE when I am on the python shell, I do: >>>import os >>>os.mkdir('newdir') >>>from dirutils import dir_util >>>#copy a big directory tree >>>dir_util.copy_tree('big_directory','newdir') This works properly, but I find a huge Resource Comsumption of my PC. 100% of CPU and Memo

How do I use Code Context under Options in IDLE?

2006-04-17 Thread Phoe6
Hi all, I have this Code Context feature under Options in the IDLE. How should I use it? Are there folks here who use it regularly and find it useful. Please guide me. Thanks! Senthil -- http://mail.python.org/mailman/listinfo/python-list

problems while using pexpect: pexcept.TIMEOUT always

2009-06-08 Thread Phoe6
I have been trying to use pexpect and I am failing with pexpect.TIMEOUT for all my attempts. In order to troubleshoot, I decided to go with simplest possible one. Here is my ssh to localhost: [21:29:14 senthil]$ssh localhost -l senthil sent...@localhost's password: sent...@ubuntu:~$ And here is