~ubuntu-branches/ubuntu/trusty/jcc/trusty-proposed

« back to all changes in this revision

Viewing changes to helpers/windows.py

  • Committer: Bazaar Package Importer
  • Author(s): Ludovico Cavedon
  • Date: 2010-07-18 11:16:04 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20100718111604-pmncb3js701dk0qp
Tags: 2.6-1
* New upstream release.
* Fix typo in README.Debian.
* Refresh avoid-ftbfs-unknown-archs.patch.
* Update Standards-Version to 3.9.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#   Licensed under the Apache License, Version 2.0 (the "License");
 
2
#   you may not use this file except in compliance with the License.
 
3
#   You may obtain a copy of the License at
 
4
#
 
5
#       http://www.apache.org/licenses/LICENSE-2.0
 
6
#
 
7
#   Unless required by applicable law or agreed to in writing, software
 
8
#   distributed under the License is distributed on an "AS IS" BASIS,
 
9
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
10
#   See the License for the specific language governing permissions and
 
11
#   limitations under the License.
 
12
 
 
13
import sys
 
14
 
 
15
global JAVAHOME
 
16
JAVAHOME = None
 
17
 
 
18
if sys.platform == "win32":
 
19
    # figure out where the JDK lives
 
20
 
 
21
    try:
 
22
        import _winreg as wreg
 
23
 
 
24
        class WindowsRegistry:
 
25
            # see the Python Cookbook, #146305, Dirk Holtwick
 
26
 
 
27
            def __init__(self, keyname):
 
28
                " handle registry access "
 
29
                self.reg = wreg.ConnectRegistry(None, wreg.HKEY_LOCAL_MACHINE)
 
30
                self.key = wreg.OpenKey(self.reg, keyname)
 
31
 
 
32
            def get(self, name):
 
33
                " get value out of registry "
 
34
                v, t = wreg.QueryValueEx(self.key, name)
 
35
                return v, t
 
36
 
 
37
            def close(self):
 
38
                " close the key finally "
 
39
                self.key.Close()
 
40
                self.reg.Close()
 
41
 
 
42
            def __del__(self):
 
43
                self.close()
 
44
 
 
45
        def get_registry_value(vname, subname):
 
46
            r = WindowsRegistry(vname)
 
47
            v, t = r.get(subname)
 
48
            return v
 
49
 
 
50
        javaversion = get_registry_value(r"SOFTWARE\JavaSoft\Java Development Kit", "CurrentVersion")
 
51
        JAVAHOME = get_registry_value(r"SOFTWARE\JavaSoft\Java Development Kit\%s" % javaversion, "JavaHome")
 
52
 
 
53
    except:
 
54
        JAVAHOME = 'c:/Program Files/Java/jdk1.6.0_18'