Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Does this work?

def init_psse(self, vsn=32):
    """
    Inits PSSE to version of parent service.
    """
    # PSSE initialization routine.
    self.PSSE_VERSION == 33
    if self.PSSE_VERSION == 32:
        # this loops takes into account both the 32 and 64 bit registries, fixing an issue, where trying to run python code through certain IDEs wouldn't work.
        try:
            pssepath, regtype = _winreg.QueryValueEx(
                _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\PTI\\PSS\xaeE 32\\Product Paths", 0,
                                _winreg.KEY_READ), "PsseInstallPath")
        except WindowsError:
            pssepath, regtype = _winreg.QueryValueEx(
                _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\\Wow6432Node\\PTI\\PSS\xaeE 32\\Product Paths", 0,
                                _winreg.KEY_READ), "PsseInstallPath")
    elif self.PSSE_VERSION == 33:
        try:
            pssepath, regtype = _winreg.QueryValueEx(
                _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\PTI\\PSSE 33\\Product Paths", 0, _winreg.KEY_READ),
                "PsseInstallPath")
        except WindowsError:
            pssepath, regtype = _winreg.QueryValueEx(
                _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\\Wow6432Node\\PTI\\PSSE 33\\Product Paths", 0,
                                _winreg.KEY_READ), "PsseInstallPath")

    sys.path.append(os.path.join(pssepath, 'PSSBIN'))
    sys.path.append(os.path.join(pssepath, 'PSSLIB'))
    os.environ['PATH'] += ';' + os.path.join(pssepath, 'PSSBIN')
    os.environ['PATH'] += ';' + os.path.join(pssepath, 'PSSLIB')

    if "PTI\PSSE" not in pssepath:
        self.log("ERROR: Cannot find PSS(R)E Version %i." % self.PSSE_VERSION, 'error')
        sys.exit()

    import psspy
    import redirect