Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #5225

Re: Need Assistance on this program.

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <mail@timgolden.me.uk>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'skip:# 20': 0.03; 'python': 0.07; 'from:addr:timgolden.me.uk': 0.09; 'from:name:tim golden': 0.09; 'message-id:@timgolden.me.uk': 0.09; 'prevents': 0.09; 'subprocess': 0.09; 'def': 0.13; 'wrote:': 0.14; 'received:74.55.86': 0.16; 'received:74.55.86.74': 0.16; 'received:smtp.webfaction.com': 0.16; 'received:webfaction.com': 0.16; 'shell=true)': 0.16; 'shorthand': 0.16; 'threading': 0.16; 'true)': 0.16; 'shell': 0.19; 'command': 0.19; 'cc:no real name:2**0': 0.20; 'cc:2**0': 0.20; 'header:In-Reply-To:1': 0.22; 'cc:addr:python-list': 0.22; 'skip:" 30': 0.29; 'start,': 0.29; 'cc:addr:python.org': 0.31; 'skip:( 20': 0.31; 'tjg': 0.31; 'import': 0.32; 'received:192': 0.34; 'print': 0.35; 'header:User- Agent:1': 0.35; 'getting': 0.36; 'received:192.168': 0.37; 'but': 0.38; 'skip:" 20': 0.38; 'from:addr:mail': 0.60; 'subject:this': 0.79; 'messed': 0.84; 'to:none': 0.92
Date Thu, 12 May 2011 11:38:02 +0100
From Tim Golden <mail@timgolden.me.uk>
User-Agent Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2.17) Gecko/20110414 Lightning/1.0b2 Thunderbird/3.1.10
MIME-Version 1.0
CC python-list@python.org
Subject Re: Need Assistance on this program.
References <BANLkTi=HJ6Ve2t9=EP1sGfMbR6ZoLtgy7g@mail.gmail.com> <sa0hb901dor.fsf@gmail.com> <BANLkTi=PW6xCTQ9ReYFdtgO+rnU2tAW_Ww@mail.gmail.com> <4DCBB18B.5050309@timgolden.me.uk> <BANLkTimX-tDpveXUqdGy2vBCWuqQ0VPabA@mail.gmail.com>
In-Reply-To <BANLkTimX-tDpveXUqdGy2vBCWuqQ0VPabA@mail.gmail.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1459.1305196686.9059.python-list@python.org> (permalink)
Lines 43
NNTP-Posting-Host 82.94.164.166
X-Trace 1305196686 news.xs4all.nl 34849 [::ffff:82.94.164.166]:46217
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:5225

Show key headers only | View raw


On 12/05/2011 11:29, vijay swaminathan wrote:

<... snippet from code ...>
   print 'Invoking Command Promptt..............'
         #subprocess.call(["start", "/DC:\\PerfLocal_PAL", 
"scripts_to_execute.bat"], shell=True)
         subprocess.call(["start", "C:\\windows\\system32\\cmd.exe"], 
shell = True)
         self.status()
</snippet>

If you want to use start, use start /wait.

But you don't have to:

<code>
import threading
import time
import subprocess

def run_command (command):
   #
   # .call is shorthand for: start process and wait
   # CREATE_NEW_CONSOLE prevents it from getting messed
   #  up with the Python console
   #
   subprocess.call (
     [command],
     creationflags=subprocess.CREATE_NEW_CONSOLE
   )

t = threading.Thread (target=run_command, args=("cmd.exe",))
t.start ()

while t.is_alive ():
   print "alive"
   time.sleep (0.5)

print "Thread is dead"

</code>

TJG

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Need Assistance on this program. Tim Golden <mail@timgolden.me.uk> - 2011-05-12 11:38 +0100

csiph-web