aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Matthijs <axxo@gentoo.org>2005-07-02 12:41:52 +0000
committerThomas Matthijs <axxo@gentoo.org>2005-07-02 12:41:52 +0000
commitd341c0a5f8089596c72aeba4afafdd3e82a40b96 (patch)
tree238c6f36ca7f95773e5b6b1a00f7f23c74460d68
parentmake sure line is stripped, and change the loop a bit (diff)
downloadjava-config-d341c0a5f8089596c72aeba4afafdd3e82a40b96.tar.gz
java-config-d341c0a5f8089596c72aeba4afafdd3e82a40b96.tar.bz2
java-config-d341c0a5f8089596c72aeba4afafdd3e82a40b96.zip
catch some exceptions for when the active vm can't be found
svn path=/java-config-ng/branches/axxo/; revision=295
-rwxr-xr-xsrc/java-config25
-rw-r--r--src/java_config/EnvironmentManager.py2
2 files changed, 23 insertions, 4 deletions
diff --git a/src/java-config b/src/java-config
index 9ee1690..3fed775 100755
--- a/src/java-config
+++ b/src/java-config
@@ -30,49 +30,63 @@ def java(option, opt, value, parser):
printer._print(manager.get_active_vm().find_exec('java'))
except PermissionError:
printer._printError("The java executable was not found in the Java path")
+ except InvalidVMError:
+ printer._printError("The active vm could not be found")
def javac(option, opt, value, parser):
try:
printer._print(manager.get_active_vm().find_exec('javac'))
except PermissionError:
printer._printError("The javac executable was not found in the Java path")
+ except InvalidVMError:
+ printer._printError("The active vm could not be found")
def jar(option, opt, value, parser):
try:
printer._print(manager.get_active_vm().find_exec('jar'))
except PermissionError:
printer._printError("The jar executable was not found in the Java path")
+ except InvalidVMError:
+ printer._printError("The active vm could not be found")
def jdk_home(option, opt, value, parser):
try:
printer._print(manager.get_active_vm().query('JDK_HOME'))
except EnvironmentUndefinedError:
print
+ except InvalidVMError:
+ printer._printError("The active vm could not be found")
def jre_home(option, opt, value, parser):
try:
printer._print(manager.get_active_vm().query('JRE_HOME'))
except EnvironmentUndefinedError:
print
+ except InvalidVMError:
+ printer._printError("The active vm could not be found")
def runtime(option, opt, value, parser):
try:
printer._print(manager.get_active_vm().query('BOOTCLASSPATH'))
except EnvironmentUndefinedError:
print
+ except InvalidVMError:
+ printer._printError("The active vm could not be found")
def show_active_vm(option, opt, value, parser):
try:
printer._print(manager.get_active_vm().name())
- except RuntimeError, (ex):
- printer._printError(str(ex))
+ except InvalidVMError:
+ printer._printError("The active vm could not be found")
def java_version(option, opt, value, parser):
try:
printer._print(getoutput('%s -version' % manager.get_active_vm().find_exec('java')))
except PermissionError:
printer._printError("The java executable was not found in the Java path")
+ except InvalidVMError:
+ printer._printError("The active vm could not be found")
def classpath(option, opt, value, parser):
packages = value.split(',')
@@ -89,6 +103,8 @@ def get_env(option, opt, value, parser):
printer._print(manager.get_active_vm().query(env))
except EnvironmentUndefinedError:
print
+ except InvalidVMError:
+ printer._printError("The active vm could not be found")
def exec_cmd(option, opt, value, parser):
for cmd in iter(value.split(',')):
@@ -100,7 +116,10 @@ def list_available_packages(option, opt, value, parser):
def list_available_vms(option, opt, value, parser):
vm_list = manager.get_virtual_machines()
- active = manager.get_active_vm()
+ try:
+ active = manager.get_active_vm()
+ except InvalidVMError:
+ active = None
for i, vm in vm_list.iteritems():
if vm is active:
diff --git a/src/java_config/EnvironmentManager.py b/src/java_config/EnvironmentManager.py
index c3557fc..377fcca 100644
--- a/src/java_config/EnvironmentManager.py
+++ b/src/java_config/EnvironmentManager.py
@@ -85,7 +85,7 @@ class EnvironmentManager:
self.active = vm
return vm
- raise RuntimeError, "No java vm could be found."
+ raise InvalidVMError
def get_active_vm(self):
if self.active is None: