Changeset 4574

Show
Ignore:
Timestamp:
07/09/09 12:51:05 (14 months ago)
Author:
jmoore
Message:

ticket:1402 - check_java added to java.py

This should actually be taken care of by unifying all our
uses of subprocess into a single module which catches the
exception on subprocess.Popen() and displays the actual
command-line which was used.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/components/tools/OmeroPy/src/omero/java.py

    r4090 r4574  
    99import platform 
    1010import subprocess 
     11import exceptions 
     12import logging 
     13 
    1114 
    1215DEFAULT_DEBUG = "-Xrunjdwp:server=y,transport=dt_socket,address=8787,suspend=n" 
     16 
     17def check_java(command): 
     18    try: 
     19        p = subprocess.Popen([command[0],"-version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) 
     20        std = p.communicate() 
     21        rc = p.wait() 
     22        if rc == 0: 
     23            return 
     24    except: 
     25        pass # Falls through to raise 
     26 
     27    raise exceptions.Exception("Java could not be found. (Executable=%s)" % command[0]) 
    1328 
    1429def makeVar(key, env): 
     
    8196    """ 
    8297    command = cmd(args, java, xargs, chdir, debug, debug_string) 
     98    check_java(command) 
    8399    if use_exec: 
    84100        env = os.environ 
     
    108124    """ 
    109125    command = cmd(args, java, xargs, chdir, debug, debug_string) 
     126    check_java(command) 
    110127    if not chdir: 
    111128        chdir = os.getcwd() 

1.2.1-PRO © 2008-2009 agile42 all rights reserved (this page was served in: 0.64623 sec.)