Today's Messages (OFF)  | Unanswered Messages (ON)

Forum: Python
 Topic: a good website for softwares,movies and music etc.
a good website for softwares,movies and music etc. [message #17454] Sun, 07 October 2007 22:57
panguohua  is currently offline panguohua
Messages: 11
Registered: September 2007
Junior Member
www.space666.com


support!!!!!!!!!!!!!!!!
 Topic: Re: Problem using subprocess.Popen on windows
Re: Problem using subprocess.Popen on windows [message #17451] Sun, 07 October 2007 20:43
Nicholas Bastin  is currently offline Nicholas Bastin
Messages: 7
Registered: October 2007
Junior Member
On 10/7/07, jorma kala <jjkk73@gmail.com> wrote:
> from subprocess import *
>
> p1 = Popen(["dir"], stdout=PIPE)
> output = p1.communicate()[0]
>
>
> But I get a WindowsError : [Error 2] File Not Found

Tim answered your actual question, but why are you doing this in the
first place? The Python standard library provides all the
functionality that dir will provide and you don't have to parse the
output...

Look into <http://www.python.org/doc/lib/os-file-dir.html>, and
specifically, os.listdir(path).

--
Nick
 Topic: finding out the call (and not only the caller)
finding out the call (and not only the caller) [message #17440] Sun, 07 October 2007 17:47
Francesco Guerrieri  is currently offline Francesco Guerrieri
Messages: 16
Registered: August 2007
Junior Member
Hi,

Today I've been thinking a bit about the "python internals". Inspired
by this recipe:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/6606 2
I found out a little problem which haven't been able to solve.
In short, is there a way to find out how a given name lookup was started?
It is not enough to know the name of the caller as given by the recipe.

a little example:
import inspect

class test(object):
def __init__(self, a_list):
self.my_list = a_list
def info(self):
for counter, item in
enumerate(inspect.getouterframes(inspect.currentframe())):
print counter, item
return self.my_list
data = property(info)

if __name__ == '__main__':
a = test([1111,2222])
def g(a_seq):
for item in a_seq:
print item, '\n'
g(a.data)

This prints
0 (<frame object at 0x00B58B08>, 'myfile.py', 10, 'info', ['
for counter, item in
enumerate(inspect.getouterframes(inspect.currentframe())):\n '], 0)
1 (<frame object at 0x00A5B000>, 'myfile.py', 38, '<module>', ['
g(a.data)\n'], 0)
1111
2222

What I would like is a reference to g itself, and not only to
'<module>' which is the caller according to f_code.co_name.
I thought of manually parsing the string ' g(a.data)\n' to extract
the name but I'm sure that it would be a rather fragile approach, and
so I decided that it was time to ask for help :-)
To 'get a feeling', I tried to disassemble the code:

code = compile('g(a.data)', 'test', 'single')
dis.dis(code)

and this is the result

0 LOAD_NAME 0 (g)
3 LOAD_NAME 1 (a)
6 LOAD_ATTR 2 (data)
9 CALL_FUNCTION 1
12 PRINT_EXPR
13 LOAD_CONST 0 (None)
16 RETURN_VALUE

So ... I'm looking for the first name loaded. Is there a reference to
it, somewhere?

Francesco
 Topic: Re: Top Programming Languages of 2013
Re: Top Programming Languages of 2013 [message #15655] Sun, 07 October 2007 08:09
jcd  is currently offline jcd
Messages: 43
Registered: August 2007
Member
James Matthews wrote:
> What are these stats based on?
>
This survey here:

http://app.sgizmo.com/reports/4762/6895/QJK8UD9C9371P37EOQ7V 8OIC1RP39O/

Now how was this survey advertised? Who was asked to participate?
Dunno. Clearly not MacFans, given the high number of 1 scores given to
Objective C + cocoa.

Interestingly, python got the most votes (619--the next highest were 518
(Java) and 505 (Ruby)), the highest average score (8.5 out of 10,
followed by HTML/CSS with 7.6 and Javascript with 7.3), *and* the
highest percentage of 10 scores, (49.3%, with HTML/CSS second with 28.6%).

Cheers,
Cliff
 Topic: Re: [Tutor] Top Programming Languages of 2013
Re: [Tutor] Top Programming Languages of 2013 [message #15643] Sun, 07 October 2007 07:53
ricaraoz  is currently offline ricaraoz
Messages: 60
Registered: July 2007
Member
Alan Gauld wrote:
> "Dick Moores" <rdm@rcblue.com> wrote
>
>> <http://www.redcanary.ca/view/top-programming>
>>
>
> Interesting, but I'm not sure what the criteria for "top" is.
> Is it a measure of power, popularity, usage?
>
> Scary that HTML/CSS should be so high though
> given its not a programming language at all!
>
> Alan G.
>

Besides all that, we are programmers not fashion models. Who cares which
is the "top" language, leave that for the "top models" and such. Our
trade is code, not fashion.
 Topic: Re: Problem using subprocess.Popen on windows
Re: Problem using subprocess.Popen on windows [message #15641] Sun, 07 October 2007 07:47
Tim Golden  is currently offline Tim Golden
Messages: 51
Registered: August 2007
Member
jorma kala wrote:
> I get an error that I don't understand when using the subprocess module
> on Windows.
> I guess I'm missing out something very basic.
> For instance, to execute and capture the output of the ms-dos dir
> command, I tried the following:
>
> from subprocess import *
>
> p1 = Popen(["dir"], stdout=PIPE)
> output = p1.communicate()[0]
>
> But I get a WindowsError : [Error 2] File Not Found

That's because "dir" isn't an executable file in its
own right, merely a subcommand of the command shell.
Do this:

<code>
from subprocess import *

p1 = Popen ("dir", shell=True, stdout=PIPE)
print p1.communicate ()[0]

</code>

TJG
 Topic: a good website for softwares,movies and music etc.
a good website for softwares,movies and music etc. [message #15636] Sun, 07 October 2007 07:22
panguohua  is currently offline panguohua
Messages: 11
Registered: September 2007
Junior Member
www.space666.com



support!!!!!!!
 Topic: ANN: pyparsing 1.4.8 released
ANN: pyparsing 1.4.8 released [message #15614] Sun, 07 October 2007 03:31
Paul McGuire  is currently offline Paul McGuire
Messages: 59
Registered: August 2007
Member
I'm happy to announce that I have just uploaded the latest release
(v1.4.8) of pyparsing. This release has a few new features and
corresponding demonstration examples. There are also a few minor
bug-fixes, and a performance speedup in the operatorPrecedence method.

Here are the notes:

- Added new helper method nestedExpr to easily create expressions
that parse lists of data in nested parentheses, braces, brackets,
etc.

- Added withAttribute parse action helper, to simplify creating
filtering parse actions to attach to expressions returned by
makeHTMLTags and makeXMLTags. Use withAttribute to qualify a
starting tag with one or more required attribute values, to avoid
false matches on common tags such as <TD> or <DIV>.

- Added new examples nested.py and withAttribute.py to demonstrate
the new features.

- Added performance speedup to grammars using operatorPrecedence,
instigated by Stefan Reichör - thanks for the feedback, Stefan!

- Fixed bug/typo when deleting an element from a ParseResults by
using the element's results name.

- Fixed whitespace-skipping bug in wrapper classes (such as Group,
Suppress, Combine, etc.) and when using setDebug(), reported by
new pyparsing user dazzawazza on SourceForge, nice job!

- Added restriction to prevent defining Word or CharsNotIn expressions
with minimum length of 0 (should use Optional if this is desired),
and enhanced docstrings to reflect this limitation. Issue was
raised by Joey Tallieu, who submitted a patch with a slightly
different solution. Thanks for taking the initiative, Joey, and
please keep submitting your ideas!

- Fixed bug in makeHTMLTags that did not detect HTML tag attributes
with no '= value' portion (such as "<td nowrap>"), reported by
hamidh on the pyparsing wiki - thanks!

- Fixed minor bug in makeHTMLTags and makeXMLTags, which did not
accept whitespace in closing tags.

Download pyparsing 1.4.8 at http://sourceforge.net/projects/pyparsing/.
The pyparsing Wiki is at http://pyparsing.wikispaces.com

-- Paul

========================================
Pyparsing is a pure-Python class library for quickly developing
recursive-descent parsers. Parser grammars are assembled directly in
the calling Python code, using classes such as Literal, Word,
OneOrMore, Optional, etc., combined with operators '+', '|', and '^'
for And, MatchFirst, and Or. No separate code-generation or external
files are required. Pyparsing can be used in many cases in place of
regular expressions, with shorter learning curve and greater
readability and maintainability. Pyparsing comes with a number of
parsing examples, including:
- "Hello, World!" (English, Korean, Greek, and Spanish(new))
- chemical formulas
- configuration file parser
- web page URL extractor
- 5-function arithmetic expression parser
- subset of CORBA IDL
- chess portable game notation
- simple SQL parser
- Mozilla calendar file parser
- EBNF parser/compiler
- Python value string parser (lists, dicts, tuples, with nesting)
(safe alternative to eval)
- HTML tag stripper
- S-expression parser
- macro substitution preprocessor
 Topic: Re: Need help to understand garbage collection
Re: Need help to understand garbage collection [message #15612] Sun, 07 October 2007 03:25
David Tremouilles  is currently offline David Tremouilles
Messages: 3
Registered: October 2007
Junior Member
Thanks Gabriel!
I get it now. With your help I was able to focus on the real problem.
Here is the correctly working example for the record:


import gc

class Test(object):
def __init__(self):
pass

gc.collect()
original_objects_id = [id(x) for x in gc.get_objects()]
#create object a
a = Test()
gc.collect()
new_objects = [x for x in gc.get_objects()
if id(x) not in original_objects_id]
print "-" * 40
print "Added object:", len(new_objects)
for obj in new_objects:
print "*" * 10
print str(id(obj)) + ":" + str(obj)
print gc.get_referents(obj)
print "*" * 3
print "-" * 20
del new_objects
del obj

gc.collect()
original_objects_id = [id(x) for x in gc.get_objects()]
#remove object a
del a
gc.collect()
after_rm_objects_id = [id(x) for x in gc.get_objects()]
removed_objects_id = [idx for idx in original_objects_id
if idx not in after_rm_objects_id]
print "-" * 40
print "Removed objects:", len(removed_objects_id)
print removed_objects_id
print "-" * 20
 Topic: Re: Need help to understand garbage collection
Re: Need help to understand garbage collection [message #15593] Sat, 06 October 2007 23:36
Gabriel Genellina  is currently offline Gabriel Genellina
Messages: 205
Registered: July 2007
Senior Member
En Sat, 06 Oct 2007 14:16:36 -0300, David Tremouilles
<david.trem@gmail.com> escribi�:

> I would need help to understand how garbage collection work and how to
> "trace" objects...
> In the example below an object is created and deleted.

Not exactly: an object is created and bound to the name "a". Some code is
executed... Later, the name "a" is removed; the object's reference count
is decremented, but the object itself can only be removed when the r.c.
goes to zero.

> Why in the second part of the example I do not see any object removed:

Because you still hold a reference to the object.

--
Gabriel Genellina
 Topic: esvect and reflectbox
esvect and reflectbox [message #15585] Sat, 06 October 2007 21:20
Tom Jones  is currently offline Tom Jones
Messages: 1
Registered: October 2007
Junior Member
Hi,

I am trying to create a leftarrow of \vv{}. I thought I could just
reflect the vector, but the solution has escaped me. Could someone help
me out?

\def\traitfill@#1#2#3#4{%
$\m@th\mkern2mu\relax#4#1\mkern-1.5mu%
\cleaders\hbox{$#4\mkern0mu#2\mkern0mu$}\hfill%
\mkern-1.5mu#3$%
}

was replaced with

\def\traitfill@#1#2#3#4{%
\reflectbox{$\m@th\mkern2mu\relax#4#1\mkern-1.5mu%
\cleaders\hbox{$#4\mkern0mu#2\mkern0mu$}\hfill%
\mkern-1.5mu#3$}%
}

But the result is incorrect (the vector does not fill properly).

Thanks.
 Topic: Re: Howto Launch a windows application ?
Re: Howto Launch a windows application ? [message #15580] Sat, 06 October 2007 18:23
stef mientki[2]  is currently offline stef mientki[2]
Messages: 20
Registered: August 2007
Junior Member
I finally found out what was wrong:

stef mientki wrote:
> hello,
>
> I'm trying to launch a windows application,
> but as many others on this list, I've some trouble.
> I read some other threads about this topic,
> but sorry, I still don't understand all this (never heard of pipes).
>
> When I use a batch file, I can launch the bat-file from python,
> and the windows application launched from the batchfile is run perfectly.
>
> Now when I try to run the same windows application from Popen or call,
> nothing happens (or at least it's very fast and produces not the
> expected output).
>
> Please enlighten me, preferable in "windows-terminology" ;-)
>
> thanks,
> Stef Mientki
>
> from subprocess import *
>
> cmd =[]
> cmd.append ( 'D:\\PIC-tools\\JALxxx\\jalv2_3.exe' )
> cmd.append ( '-long-start' )
> cmd.append ( '-d')
> cmd.append ( '-clear' )
> cmd.append ( '-sD:\\PIC-tools\\JAL\\libs2' )
> cmd.append (
> 'd:\\pic-tools\\jal\\programs\\test_rs232\\test_rs232_hw.jal ' )
> cmd.append ( '>d:\\data_actueel\\d7_test_browser\\temp.log' )
>
> # DOESN'T WORK
> result = call ( cmd )
>
> # Both Popen and call work
> cmd = [ 'd:\\data_actueel\\d7_test_browser\\JALcc.bat' ]
> #output = Popen ( cmd )
> result = call ( cmd )
> print result
>
subprocess performs double quoting (necessary for paths with spaces)
automatically.
Therefor both the following lines:
cmd.append ( '-sD:\\PIC-tools\\JAL\\libs2' )
cmd.append ( '>d:\\data_actueel\\d7_test_browser\\temp.log' )
should become
cmd.append ( '-s' )
cmd.append ( ' D:\\PIC-tools\\JAL\\libs2' )
cmd.append ( '>' )
cmd.append ( 'd:\\data_actueel\\d7_test_browser\\temp.log' )
then everything works perfect, also with the convenience call "call"
and the redirection.

thank you all for the hints,
cheers,
Stef Mientki
 Topic: setuptools on mac
setuptools on mac [message #15570] Sat, 06 October 2007 13:35
Calvin Spealman  is currently offline Calvin Spealman
Messages: 5
Registered: August 2007
Junior Member
I am trying to install the newest setuptools on my macbook. 2.3 was
installed by default, and 2.4 is installed and is my default version
now. However, when I try to import setuptools, which is required to
_install_ setuptools, I get this error:

macbkpro1:~/Desktop/setuptools-0.6c7 ironfroggy$ python setup.py install
Traceback (most recent call last):
File "setup.py", line 7, in ?
execfile(convert_path('setuptools/command/__init__.py'), d)
File "setuptools/command/__init__.py", line 13, in ?
from distutils.command.bdist import bdist
File " /Library/Frameworks/Python.framework/Versions/2.4//lib/pytho n2.4/distutils/command/bdist.py ",
line 29, in ?
class bdist (Command):
File " /Library/Frameworks/Python.framework/Versions/2.4//lib/pytho n2.4/distutils/command/bdist.py ",
line 33, in bdist
user_options = [('bdist-base=', 'b',
File " /Library/Frameworks/Python.framework/Versions/2.4//lib/pytho n2.4/distutils/util.py ",
line 78, in get_platform
cfgvars = get_config_vars()
File " /Library/Frameworks/Python.framework/Versions/2.4//lib/pytho n2.4/distutils/sysconfig.py ",
line 488, in get_config_vars
func()
File " /Library/Frameworks/Python.framework/Versions/2.4//lib/pytho n2.4/distutils/sysconfig.py ",
line 373, in _init_posix
raise DistutilsPlatformError(my_msg)
distutils.errors.DistutilsPlatformError: $MACOSX_DEPLOYMENT_TARGET
mismatch: now "10.4" but "10.3" during configure
macbkpro1:~/Desktop/setuptools-0.6c7 ironfroggy$

--
Read my blog! I depend on your acceptance of my opinion! I am interesting!
http://ironfroggy-code.blogspot.com/
 Topic: Need help to understand garbage collection
Need help to understand garbage collection [message #15566] Sat, 06 October 2007 13:16
David Tremouilles  is currently offline David Tremouilles
Messages: 3
Registered: October 2007
Junior Member
I would need help to understand how garbage collection work and how to
"trace" objects...
In the example below an object is created and deleted.
Why in the second part of the example I do not see any object removed:

import gc
class Test(object):
def __init__(self):
pass


gc.collect()
original_objects_id = [id(x) for x in gc.get_objects()]
#create object a
a = Test()
gc.collect()
new_objects = [x for x in gc.get_objects()
if id(x) not in original_objects_id]
print "-" * 40
print "Added object:", len(new_objects)
for obj in new_objects:
print "*" * 10
print str(id(obj)) + ":" + str(obj)
print gc.get_referents(obj)
print "*" * 3
print "-" * 20

gc.collect()
original_objects_id = [id(x) for x in gc.get_objects()]
#remove object a
del a
gc.collect()
after_rm_objects_id = [id(x) for x in gc.get_objects()]
removed_objects_id = [x for x in original_objects_id
if x not in after_rm_objects_id]
print "-" * 40
print "Removed objects:", len(removed_objects_id)
print removed_objects_id
print "-" * 20

Which give:

----------------------------------------
Added object: 2
**********
400600:[[...], <__main__.Test object at 0x62bd0>]
[<__main__.Test object at 0x62bd0>, [[...], <__main__.Test object at 0x62bd0>]]
***
**********
404432:<__main__.Test object at 0x62bd0>
[<class '__main__.Test'>]
***
--------------------
----------------------------------------
Removed objects: 0
[]
--------------------
 Topic: help on understanding garbage collection
help on understanding garbage collection [message #15564] Sat, 06 October 2007 13:09
David Tremouilles  is currently offline David Tremouilles
Messages: 3
Registered: October 2007
Junior Member
Hello,

I would need help to understand how garbage collection work and how
to "trace" objects...
An example is joined where and object is created and deleted.
Why in the second part of the example I do not see any object removed:
"
----------------------------------------
Removed objects: 0
[]
--------------------
"

Thanks for your help,

David
 Topic: Re: Please Help me
Re: Please Help me [message #15500] Sat, 06 October 2007 02:47
Hendrik van Rooyen  is currently offline Hendrik van Rooyen
Messages: 47
Registered: August 2007
Member
Jean-Francois Canac wrote:

8< -------------- duplicate request -------------------

see other answer.

- Hendrik
 Topic: Paid Surveys - Make Money Online From Free Paid Surveys
Paid Surveys - Make Money Online From Free Paid Surveys [message #15495] Sat, 06 October 2007 02:15
harina  is currently offline harina
Messages: 2
Registered: October 2007
Junior Member
Paid Surveys - Make Money Online From Free Paid Surveys

Welcome to Internet Paid Surveys. Here we review the best online paid
survey sites that pay you for your opinions. We feature only tried and
tested paid survey companies that are really worth joining and have
good reputation. Our database is frequently updated and is absolutely
FREE. You never have to pay firms like surveyscout to join survey
sites. Anyone who asks money in return for a database of paid survey
companies are only cheating you. Go through our list of free paid
surveys and join them without spending a cent.

Paid surveys are a great work from home opportunity to make some extra
money in your spare time. Internet surveys are fun. At the same time,
you help in the development of new products. Market research companies
are interested in knowing your opinion on various matters on behalf of
their clients. They are willing to pay you for the time you spend for
them. Most of the reputed paid survey sites are online divisions of
market research companies. They are all free to join and give rewards
ranging from $1 to $100 or more per survey completed. Some paid survey
sites enter you into sweepstakes where you can earn more money. Others
may reward you with points which can be later redeemed for cash.

http://surveyss.blogspot.com/
 Topic: pypar error
pypar error [message #15486] Fri, 05 October 2007 22:40
smalltalk  is currently offline smalltalk
Messages: 4
Registered: August 2007
Junior Member
I want to install pypar,but it always show following errors:
D:\pypar_1.9.3>python setup.py build -c mingw32

running build
running build_py
running build_ext
building 'pypar.mpiext' extension
D:\MinGWStudio\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -I
$MPICH_DIR\SDK.gcc
\include -ID:\Python25\include -ID:\Python25\PC -c mpiext.c -o build
\temp.win32-
2.5\Release\mpiext.o
gcc: mpiext.c: No such file or directory
gcc: no input files
error: command 'gcc' failed with exit status 1

can you give me a help ?
 Topic: Need a minimal, easily-modifiable HTTP proxy
Need a minimal, easily-modifiable HTTP proxy [message #15481] Fri, 05 October 2007 21:54
__BMR__  is currently offline __BMR__
Messages: 1
Registered: October 2007
Junior Member
I'm looking for a simple HTTP proxy that I can modify to fix the
"brokenness" of a website that I use often. One aspect of the
"brokenness" is that if I visit the site from two different tabs in my
browser, what I do in one tab will interfere with what happens in the
other. There are a few other minor issues I want to tweak to my liking.
I thought a simple local proxy would give me maximum flexibility when it
comes to the tweaking part.

http://www.xhaus.com/alan/python/proxies.html contains a list of
potential candidates but it's difficult to get a feel of the ease of
modification.

I'd like to hear your experience/recommendation if you have solved a
similar problem before.

Thanks.
 Topic: Re: Python Magazine: Issue 1 Free!
Re: Python Magazine: Issue 1 Free! [message #15476] Fri, 05 October 2007 19:54
Terry Reedy  is currently offline Terry Reedy
Messages: 55
Registered: August 2007
Member
"Steve Holden" <steve@holdenweb.com> wrote in message
news:fe583c$4kj$1@sea.gmane.org...
| I've just been told by the editors at Python Magazine that the first
| issue is out. It's all-electronic so anyone can download and read it.
| Let them know what you think:
|
| http://www.pythonmagazine.com/c/issue/2007/10

OK. Given that my (widescreen) monitor, like most current monitors, does
not rotate into the portrait mode that would display a whole page, double
column pdf files are painful to read on a screen. Up and down, up and
down. And the color pages cannot be sensibly printed on a b/w printer,
even if I wanted to go to paper (which is what pdf was meant for), which I
do not. Mismatching electronic documents to the screens they are most
commonly read on is to me at least shortsighted. So I suggest that you
also produce a readable html version.
 Topic: Re: howto kill a windows process by name ?
Re: howto kill a windows process by name ? [message #15473] Fri, 05 October 2007 19:30
stef mientki[2]  is currently offline stef mientki[2]
Messages: 20
Registered: August 2007
Junior Member
Adam Pletcher wrote:
> Take a look at "killProcName.py", in the win32 extension package.
>
> - Adam
>
>
>> -----Original Message-----
>> From: python-list-bounces+adam=volition-inc.com@python.org
>> [mailto:python-list-bounces+adam=volition-inc.com@python.org] On
>>
> Behalf
>
>> Of stef mientki
>> Sent: Friday, October 05, 2007 4:40 PM
>> To: python-list@python.org
>> Subject: howto kill a windows process by name ?
>>
>> hello,
>>
>> is there a library to kill a windows process by name ?
>>
>> thanks,
>> Stef Mientki
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>>
thanks Adam,
that indeed it works,
but googling for killProcName.py I found messages about it being slow,
and indeed it's slow,
and that same google search turned up a faster method, see below.

thanks again,
Stef Mientki



import time
import win32api, win32pdhutil, win32con
import win32pdh, string


# ************************************************************ ***********
# ************************************************************ ***********
def GetAllProcesses():
object = "Process"
items, instances = win32pdh.EnumObjectItems(None,None,object,
win32pdh.PERF_DETAIL_WIZARD)
return instances
# ************************************************************ ***********


# ************************************************************ ***********
# ************************************************************ ***********
def GetProcessID ( name ) :
object = "Process"
items, instances = win32pdh.EnumObjectItems(None,None,object,
win32pdh.PERF_DETAIL_WIZARD)

val = None
if name in instances :
hq = win32pdh.OpenQuery()
hcs = []
item = "ID Process"
path = win32pdh.MakeCounterPath( (None,object,name, None, 0, item) )
hcs.append(win32pdh.AddCounter(hq, path))
win32pdh.CollectQueryData(hq)
time.sleep(0.01)
win32pdh.CollectQueryData(hq)

for hc in hcs:
type, val = win32pdh.GetFormattedCounterValue(hc,
win32pdh.PDH_FMT_LONG)
win32pdh.RemoveCounter(hc)
win32pdh.CloseQuery(hq)
return val
# ************************************************************ ***********


"""
THIS IS SLOW !!
def Kill_Process ( process ) :
#get process id's for the given process name
pids = win32pdhutil.FindPerformanceAttributesByName ( process )
for p in pids:
handle = win32api.OpenProcess(win32con.PROCESS_TERMINATE, 0, p) #get
process handle
win32api.TerminateProcess(handle,0) #kill by handle
win32api.CloseHandle(handle) #close api
"""

# ************************************************************ ***********
# ************************************************************ ***********
def Kill_Process_pid ( pid ) :
handle = win32api.OpenProcess(win32con.PROCESS_TERMINATE, 0, pid) #get
process handle
win32api.TerminateProcess(handle,0) #kill by handle
win32api.CloseHandle(handle) #close api
# ************************************************************ ***********


# ************************************************************ ***********
# ************************************************************ ***********
def Kill_Process ( name ) :
pid = GetProcessID ( name)
if pid:
Kill_Process_pid ( pid )
# ************************************************************ ***********


# ************************************************************ ***********
# ************************************************************ ***********
if __name__ == "__main__":
a = GetAllProcesses()
print a

process = 'UPD'
Kill_Process ( process )

# ************************************************************ ***********
 Topic: RE: howto kill a windows process by name ?
RE: howto kill a windows process by name ? [message #15460] Fri, 05 October 2007 18:12
Adam Pletcher  is currently offline Adam Pletcher
Messages: 1
Registered: October 2007
Junior Member
Take a look at "killProcName.py", in the win32 extension package.

- Adam

> -----Original Message-----
> From: python-list-bounces+adam=volition-inc.com@python.org
> [mailto:python-list-bounces+adam=volition-inc.com@python.org] On
Behalf
> Of stef mientki
> Sent: Friday, October 05, 2007 4:40 PM
> To: python-list@python.org
> Subject: howto kill a windows process by name ?
>
> hello,
>
> is there a library to kill a windows process by name ?
>
> thanks,
> Stef Mientki
> --
> http://mail.python.org/mailman/listinfo/python-list
 Topic: howto kill a windows process by name ?
howto kill a windows process by name ? [message #15451] Fri, 05 October 2007 17:40
stef mientki[2]  is currently offline stef mientki[2]
Messages: 20
Registered: August 2007
Junior Member
hello,

is there a library to kill a windows process by name ?

thanks,
Stef Mientki
 Topic: Re: Howto Launch a windows application ?
Re: Howto Launch a windows application ? [message #15419] Fri, 05 October 2007 14:51
stef mientki[2]  is currently offline stef mientki[2]
Messages: 20
Registered: August 2007
Junior Member
Nicholas Bastin wrote:
> On 10/3/07, stef mientki <stef.mientki@gmail.com> wrote:
>
>> hello,
>>
>> I'm trying to launch a windows application,
>> but as many others on this list, I've some trouble.
>> I read some other threads about this topic,
>> but sorry, I still don't understand all this (never heard of pipes).
>>
>> When I use a batch file, I can launch the bat-file from python,
>> and the windows application launched from the batchfile is run perfectly.
>>
>> Now when I try to run the same windows application from Popen or call,
>> nothing happens (or at least it's very fast and produces not the
>> expected output).
>>
>> Please enlighten me, preferable in "windows-terminology" ;-)
>>
>> thanks,
>> Stef Mientki
>>
>> from subprocess import *
>>
>> cmd =[]
>> cmd.append ( 'D:\\PIC-tools\\JALxxx\\jalv2_3.exe' )
>> cmd.append ( '-long-start' )
>> cmd.append ( '-d')
>> cmd.append ( '-clear' )
>> cmd.append ( '-sD:\\PIC-tools\\JAL\\libs2' )
>> cmd.append ( 'd:\\pic-tools\\jal\\programs\\test_rs232\\test_rs232_hw.jal ' )
>> cmd.append ( '>d:\\data_actueel\\d7_test_browser\\temp.log' )
>>
>> # DOESN'T WORK
>> result = call ( cmd )
>>
>> # Both Popen and call work
>> cmd = [ 'd:\\data_actueel\\d7_test_browser\\JALcc.bat' ]
>> #output = Popen ( cmd )
>> result = call ( cmd )
>> print result
>>
>
> First, call is a convenience function, but in your case, it's probably
> not that convenient. Use the actual Popen constructor so you can get
> at the output directly. Also, ditch the output redirector and use a
> pipe:
>
> p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
> (out, err) = p.stdout, p.stderr
> rcode = p.wait()
> print out, err, rcode
>
> Try that and see what happens. When it doesn't work, look carefully
> in out and err and see if anything interesting is in there. I was
> able to open notepad.exe in this way with no problems so my guess is
> you're having some other problem, but avoiding the use of the
> convenience function will give you stdout and stderr to look at.
>
>
Thanks Nick,

replacing
#print out, err, rcode
with
for line in out:
print line
for line in err:
print line
points me to the problem issue, which is the "-s" option,
although I don't understand it yet

> --
> Nick
>
>
 Topic: Re: Where's the Starship's crew?
Re: Where's the Starship's crew? [message #15320] Fri, 05 October 2007 08:21
Dick Moores  is currently offline Dick Moores
Messages: 20
Registered: August 2007
Junior Member
At 04:54 AM 10/5/2007, Thomas Heller wrote:
>Dick Moores schrieb:
> > <http://starship.python.net/crew/index.html>
> >
> > I didn't check on all of them, but the only one I found was Mark
> > Hammond <http://starship.python.net/crew/mhammond/>.
> >
> > Dick Moores
> >
>
>There are more. Think of it as a game you have to solve.

Yeah, a mind numbing game!

http://starship.python.net/crew/ewalstad/ Eric Walstad
http://starship.python.net/crew/piers/ Piers Lauder
http://starship.python.net/crew/jae/ --> http://zhar.net/ John Eikenberry
http://starship.python.net/crew/mwh/
http://starship.python.net/crew/manus/ Manus Hand
http://starship.python.net/crew/bhoel/ Berthold Höllmann
http://starship.python.net/crew/marduk/ ("Server Error")
http://starship.python.net/crew/schorsch/
http://starship.python.net/crew/dni/ David Niergarth
http://starship.python.net/crew/jcooley/ James Cooley
http://starship.python.net/crew/sdrees/ Stefan Drees
http://starship.python.net/crew/jwt/ Jim Tittsler
http://starship.python.net/crew/theller/ Thomas Heller
http://starship.python.net/crew/gherman/ Dinu Gherman
http://starship.python.net/crew/mhammond/ Mark Hammond
http://starship.python.net/crew/atuining/
http://starship.python.net/crew/hooft/ Rob W.W. Hooft
http://starship.python.net/crew/lemburg/ --> http://www.egenix.com/
http://starship.python.net/crew/goodger/ David Goodger
http://starship.python.net/crew/mmuller/ Mike Muller
http://starship.python.net/crew/skippy/ same as
http://starship.python.net/crew/mhammond/ Mark Hammond

BTW How could I have done this with Python script?

Dick Moores
 Topic: Re: Where's the Starship's crew?
Re: Where's the Starship's crew? [message #15307] Fri, 05 October 2007 07:54
Thomas Heller  is currently offline Thomas Heller
Messages: 9
Registered: August 2007
Junior Member
Dick Moores schrieb:
> <http://starship.python.net/crew/index.html>
>
> I didn't check on all of them, but the only one I found was Mark
> Hammond <http://starship.python.net/crew/mhammond/>.
>
> Dick Moores
>

There are more. Think of it as a game you have to solve.
 Topic: Re: novice list
Re: novice list [message #15295] Fri, 05 October 2007 07:23
Steve Holden  is currently offline Steve Holden
Messages: 353
Registered: July 2007
Senior Member
István wrote:
> Could somebody suggest me a novice Python list, please?
> Thanks, Istvan
>
tutor@python.org is known to be noob-friendly. See

http://mail.python.org/mailman/listinfo/tutor

for more details.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden

Sorry, the dog ate my .sigline so I couldn't cat it
 Topic: Version 0.3.7 of the config module has been released
Version 0.3.7 of the config module has been released [message #15354] Fri, 05 October 2007 07:15
Vinay Sajip  is currently offline Vinay Sajip
Messages: 8
Registered: August 2007
Junior Member
Version 0.3.7 of the Python config module has been released.

What Does It Do?
================
The config module allows you to implement a hierarchical configuration
scheme with support for mappings and sequences, cross-references
between one part of the configuration and another, the ability to
flexibly access real Python objects, facilities for configurations to
include and cross-reference one another, simple expression evaluation
and the ability to change, save, cascade and merge configurations. You
can easily integrate with command line options using optparse.

This module has been developed on python 2.3 but should work on
version 2.2 or greater. A test suite using unittest is included in the
distribution.

A very simple configuration file (simple.cfg):

# starts here
message: Hello, world!
#ends here

a very simple program to use it:

from config import Config

cfg = Config(file('simple.cfg'))
print cfg.message

results in:

Hello, world!

Configuration files are key-value pairs, but the values can be
containers that contain further values.

A simple example - with the example configuration file:

messages:
[
{
stream : `sys.stderr`
message: 'Welcome'
name: 'Harry'
}
{
stream : `sys.stdout`
message: 'Welkom'
name: 'Ruud'
}
{
stream : $messages[0].stream
message: 'Bienvenue'
name: Yves
}
]

a program to read the configuration would be:

from config import Config

f = file('simple.cfg')
cfg = Config(f)
for m in cfg.messages:
s = '%s, %s' % (m.message, m.name)
try:
print >> m.stream, s
except IOError, e:
print e

which, when run, would yield the console output:

Welcome, Harry
Welkom, Ruud
Bienvenue, Yves

The above example just scratches the surface. There's more information
about this module available at

http://www.red-dove.com/python_config.html

Comprehensive API documentation is available at

http://www.red-dove.com/config/index.html

As always, your feedback is most welcome (especially bug reports,
patches and suggestions for improvement). Enjoy!

Cheers

Vinay Sajip
Red Dove Consultants Ltd.

Changes since the last release posted on comp.lang.python[.announce]:
=====================================================
Added Mapping.__delitem__ (patch by John Drummond).
Mapping.__getattribute__ no longer returns "" when asked
for "__class__" - doing so causes pickle to crash
(reported by Jamila Gunawardena).
Allow negative numbers (reported by Gary Schoep; had
already been fixed but not yet released).
 Topic: a good website for making money online
a good website for making money online [message #15226] Fri, 05 October 2007 03:34
panguohua  is currently offline panguohua
Messages: 11
Registered: September 2007
Junior Member
www.space666.com



more information for making money
 Topic: Re: Program with wx in Linux and Windows
Re: Program with wx in Linux and Windows [message #15230] Fri, 05 October 2007 02:23
Hendrik van Rooyen  is currently offline Hendrik van Rooyen
Messages: 47
Registered: August 2007
Member
"marcpp" <ma...mail.com> wrote:


> Hi I've developed a program (WXpython GUI). In Linux the GUI is correct
> (various distributions), but in Windows all appears disordered.
> Any recomendations?

You are not going to like this recommendation.

Use Tkinter instead - seems to work nicely cross platform for me.

- Hendrik
 Topic: Re: Howto Launch a windows application ?
Re: Howto Launch a windows application ? [message #15190] Fri, 05 October 2007 00:24
Nicholas Bastin  is currently offline Nicholas Bastin
Messages: 7
Registered: October 2007
Junior Member
On 10/3/07, stef mientki <stef.mientki@gmail.com> wrote:
> hello,
>
> I'm trying to launch a windows application,
> but as many others on this list, I've some trouble.
> I read some other threads about this topic,
> but sorry, I still don't understand all this (never heard of pipes).
>
> When I use a batch file, I can launch the bat-file from python,
> and the windows application launched from the batchfile is run perfectly.
>
> Now when I try to run the same windows application from Popen or call,
> nothing happens (or at least it's very fast and produces not the
> expected output).
>
> Please enlighten me, preferable in "windows-terminology" ;-)
>
> thanks,
> Stef Mientki
>
> from subprocess import *
>
> cmd =[]
> cmd.append ( 'D:\\PIC-tools\\JALxxx\\jalv2_3.exe' )
> cmd.append ( '-long-start' )
> cmd.append ( '-d')
> cmd.append ( '-clear' )
> cmd.append ( '-sD:\\PIC-tools\\JAL\\libs2' )
> cmd.append ( 'd:\\pic-tools\\jal\\programs\\test_rs232\\test_rs232_hw.jal ' )
> cmd.append ( '>d:\\data_actueel\\d7_test_browser\\temp.log' )
>
> # DOESN'T WORK
> result = call ( cmd )
>
> # Both Popen and call work
> cmd = [ 'd:\\data_actueel\\d7_test_browser\\JALcc.bat' ]
> #output = Popen ( cmd )
> result = call ( cmd )
> print result

First, call is a convenience function, but in your case, it's probably
not that convenient. Use the actual Popen constructor so you can get
at the output directly. Also, ditch the output redirector and use a
pipe:

p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(out, err) = p.stdout, p.stderr
rcode = p.wait()
print out, err, rcode

Try that and see what happens. When it doesn't work, look carefully
in out and err and see if anything interesting is in there. I was
able to open notepad.exe in this way with no problems so my guess is
you're having some other problem, but avoiding the use of the
convenience function will give you stdout and stderr to look at.

--
Nick
 Topic: ANN: Chandler Preview (0.7.0.1)
ANN: Chandler Preview (0.7.0.1) [message #15186] Fri, 05 October 2007 00:19
Heikki Toivonen  is currently offline Heikki Toivonen
Messages: 8
Registered: August 2007
Junior Member
Open Source Applications Foundation (OSAF) released Chandler Preview
(0.7.0.1) on September 10, 2007.

Chandler is a Personal Information Management (PIM) client application
with innovative design and ambitious plans for sharing, extensibility
and cross-platform support. Chandler is written mainly in Python.

We now have public-beta quality releases of our products; we believe
them to be full featured enough and stable enough for daily use. Check
out a full overview of features (including screenshots and screencasts).
Download Chandler Desktop, create an account on Chandler Hub. Check out
the source. Get involved in the project, help us build a really great
1.0 release.

Chandler desktop adds a central dashboard for managing tasks, notes,
events, and messages to the basic calendar functionality found in the
0.6 release. You can share calendars, task lists, messages and notes in
collections that can hold whatever you choose to put in them, regardless
of data type. The performance has improved greatly, the application has
basic search functionality, and now there’s a way to to manage and
resolve conflicts on shared data. You can collaborate on individual
items via email with the ability to edit and update messages you’ve
already received or sent. Although Chandler Preview is not meant to
replace your email application, you can configure your IMAP account so
that Chandler can see some messages from your regular mail client.

Get it from http://chandlerproject.org/

--
Heikki Toivonen
 Topic: Re: Python 3.0 migration plans?
Re: Python 3.0 migration plans? [message #15188] Fri, 05 October 2007 00:12
Nicholas Bastin  is currently offline Nicholas Bastin
Messages: 7
Registered: October 2007
Junior Member
On 9/27/07, Steve Holden <steve@holdenweb.com> wrote:
> I wondered if a straw poll could get some idea of readers' thoughts
> about when they will be migrating to 3.0 on, so I used the new widget on
> Blogger to add a poll for that.
>
> I'd appreciate if if you would go to
>
> http://holdenweb.blogspot.com/
>
> and register your vote on your intended migration timescale.

The options should have all been relative to the release date.
Options one and two might very well be the same (yes, I know, but shit
happens). Also, you're relying on people knowing the current
timeframe for 3.0.

--
Nick
 Topic: RE: Python 3.0 migration plans?
RE: Python 3.0 migration plans? [message #15182] Thu, 04 October 2007 23:49
tdelaney  is currently offline tdelaney
Messages: 14
Registered: August 2007
Junior Member
TheFlyingDutchman wrote:

> On Sep 28, 1:09 pm, Steve Holden <st...@holdenweb.com> wrote:
>
>> That's because the tutor list doesn't offer a newsgroup. He was
>> probably just trying to get rid of you.
>>
>> Now at 98.75% ...
>
> Not sure if that's the reading on your trollmeter or on the meter that
> measures what percentage of your posts you get huffy.

I would imagine it's the SpamBayes score your posts are currently
getting on Steve's machine.

Tim Delaney
 Topic: Re: RegEx question
Re: RegEx question [message #15104] Thu, 04 October 2007 16:50
John K Masters  is currently offline John K Masters
Messages: 13
Registered: August 2007
Junior Member
On 15:25 Thu 04 Oct , Robert Dailey wrote:
> I am not a regex expert, I simply assumed regex was standardized to follow
> specific guidelines.

There are as many different regex flavours as there are Linux distros.
Each follows the basic rules but implements them slightly differently
and adds their own 'extensions'.

> I also made the assumption that this was a good place
> to pose the question since regular expressions are a feature of Python.

The best place to pose a regex question is in the sphere of usage, i.e.
Perl regexes differ hugely in implementation from OO langs like Python
or Java, while shells like bash or zsh use regexes slightly differently,
as do shell scripting languages like awk or sed.

> The question concerned regular expressions in general, not really the
> application. However, now that I know that regex can be different, I'll try
> to contact the author directly to find out the dialect and then find the
> appropriate location for my question from there. I do appreciate everyone's
> help. I've tried the various suggestions offered here, however none of them
> work. I can only assume at this point that this regex is drastically
> different or the application reading the regex is just broken.

If you care to PM me with details of the language/context I will try to
help but I am no expert.

Regards, John
 Topic: Re: RegEx question
Re: RegEx question [message #15078] Thu, 04 October 2007 16:08
Tim Chase  is currently offline Tim Chase
Messages: 21
Registered: September 2007
Junior Member
[sigh...replying to my own post]
> However, things to try:
>
> - sometimes the grouping parens need to be escaped with "\"
>
> - sometimes "\w" isn't a valid character class, so use the
> long-hand variant of something like "[a-zA-Z0-9_]]
>
> - sometimes the "+" is escaped with a "\"
>
> - if you don't use raw strings, you'll need to escape your "\"
> characters, making each instance "\\"

just to be clear...these are some variants you may find in
non-python regexps (or in python regexps if you're not using raw
strings)

-tkc
 Topic: Re: RegEx question
Re: RegEx question [message #15076] Thu, 04 October 2007 16:05
Tim Chase  is currently offline Tim Chase
Messages: 21
Registered: September 2007
Junior Member
>>> try @param\[(in|out)\] \w+
>>>
>> This didn't work either :(
>>
>> The tool using this regular expression (Comment Reflower for VS2005) May be
>> broken...
>
> How about @param\[[i|o][n|u]t*\]\w+ ?

....if you want to accept patterns like

@param[iutttttt]xxxxxxx

....

The regexp at the top (Adam's original reply) would be the valid
regexp in python and matches all the tests thrown at it, assuming
it's placed in a raw string:

r = re.compile(r"@param\[(in|out)\] \w+")

If it's not a python regexp, this isn't really the list for the
question, is it? ;)

However, things to try:

- sometimes the grouping parens need to be escaped with "\"

- sometimes "\w" isn't a valid character class, so use the
long-hand variant of something like "[a-zA-Z0-9_]]

- sometimes the "+" is escaped with a "\"

- if you don't use raw strings, you'll need to escape your "\"
characters, making each instance "\\"

HTH,

-tkc
 Topic: Re: RegEx question
Re: RegEx question [message #15072] Thu, 04 October 2007 15:48
Manu Hack  is currently offline Manu Hack
Messages: 1
Registered: October 2007
Junior Member
On 10/4/07, Robert Dailey <rcdailey@gmail.com> wrote:
> On 10/4/07, Adam Lanier <adam@krusty.madoff.com> wrote:
> >
> > try @param\[(in|out)\] \w+
> >
>
> This didn't work either :(
>
> The tool using this regular expression (Comment Reflower for VS2005) May be
> broken...
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>

How about @param\[[i|o][n|u]t*\]\w+ ?
 Topic: Re: RegEx question
Re: RegEx question [message #15064] Thu, 04 October 2007 15:30
Jerry Hill  is currently offline Jerry Hill
Messages: 5
Registered: July 2007
Junior Member
> As far as the dialect, I can't be sure. I am unable to find documentation
> for Comment Reflower and thus cannot figure out what type of regex it is
> using. What exactly do you mean by your question, "are you using raw
> strings?". Thanks for your response and I apologize for the lack of detail.

Comment Reflower appears to be a plugin for Visual Studio written in
C#. As far as I can tell, it has nothing to do with Python at all.

A quick look at their sourceforge page
(http://sourceforge.net/projects/commentreflower/) doesn't show any
mailing lists or discussion groups. Maybe try emailing the author
directly, or asking a C# language group about whatever the standard C#
regular expression library is.

--
Jerry
 Topic: Re: RegEx question
Re: RegEx question [message #15012] Thu, 04 October 2007 13:09
jcd  is currently offline jcd
Messages: 43
Registered: August 2007
Member
You *are* talking about python regular expressions, right? There are a number of different dialects. Also, there could be issues with the quoting method (are you using raw strings?)

The more specific you can get, the more we can help you.

Cheers,
Cliff
On Thu, Oct 04, 2007 at 11:54:32AM -0500, Robert Dailey wrote regarding Re: RegEx question:
>
> On 10/4/07, Adam Lanier <[1]adam@krusty.madoff.com> wrote:
>
> try @param\[(in|out)\] \w+
>
> This didn't work either :(
> The tool using this regular expression (Comment Reflower for VS2005)
> May be broken...
>
> References
>
> 1. mailto:adam@krusty.madoff.com

> --
> http://mail.python.org/mailman/listinfo/python-list
Pages (32): [1  2  3  4  5  6  7  8  9  10