Esempio n. 1
0
def main():

    # Define Variables
    jdk_Directory = '/Library/Java/JavaVirtualMachines'
    installed_JDKs = []
    installed_JDK_Versions = []

    # Verify if the path exists.
    if os.path.exists(jdk_Directory):
        installed_JDKs = os.listdir(jdk_Directory)

        # Verify at least one JDK is present.
        if len(installed_JDKs) > 0:

            # Loop through each JDK.
            for jdk in installed_JDKs:
                # print('Testing JDK:  {}'.format(jdk))

                # Get the contents of the plist file.
                try:
                    # print('Location:  {}/{}/Contents/Info.plist'.format(jdk_Directory, jdk))
                    plist_contents = plist_Reader(
                        '{}/{}/Contents/Info.plist'.format(jdk_Directory, jdk))
                except Exception:
                    print('Unable to locate the specified plist file.')
                    sys.exit('<result>Error</result>')

                # Get the JVM Version for this JDK.
                jvm_version = plist_contents.get('JavaVM').get('JVMVersion')
                installed_JDK_Versions.append(jvm_version)

            # Get the latest version.
            newest_JDK = sorted(installed_JDK_Versions)[-1]

            if newest_JDK:
                print("<result>{}</result>".format(newest_JDK))
            else:
                print("<result>Unknown</result>")

        else:
            print("<result>Not installed</result>")

    else:
        print("<result>Not installed</result>")
Esempio n. 2
0
    def main(self):

        # Define the plist file.
        plist = self.env.get("plist")

        try:
            plist_contents = plist_Reader(plist)
        except Exception:
            raise ProcessorError('Unable to locate the specified plist file.')

        # Get the latest version.
        jvm_version = plist_contents.get('JavaVM').get('JVMVersion')

        if jvm_version:
            self.env["jvm_version"] = jvm_version
            self.output("jvm_version: {}".format(self.env["jvm_version"]))
        else:
            raise ProcessorError(
                "Unable to determine the Java Virtual Machine version.")
    def main(self):
        def runUtility(command):
            """A helper function for subprocess.
            Args:
                command:  List containing command and arguments in a list
            Returns:
                stdout:  output of the command
            """
            try:
                process = subprocess.Popen(command)
            except subprocess.CalledProcessError as error:
                print(('return code = ', error.returncode))
                print(('result = ', error))

            return process

        # Define some variables.
        bootstrapperLocation = self.env.get("bootstrapperLocation")
        moveTo = self.env.get("moveTo")

        # Run the binary to build the final .app.
        bootstrapper = [
            '{}/Contents/MacOS/SolsticeClientInstallerMac'.format(
                bootstrapperLocation)
        ]
        build = runUtility(bootstrapper)

        # Give it five seconds to build the app, and then kill the process -- we don't want the app launching.
        time.sleep(5)
        build.kill()

        # The final .app is saved to the logged in users home directory, so we get that.
        username = (SCDynamicStoreCopyConsoleUser(None, None, None)
                    or [None])[0]
        username = [username, ""][username in [u"loginwindow", None, u""]]

        if os.path.exists(
                "/Users/{}/Desktop/Mersive Solstice.app".format(username)):
            # Move the file from the home directory, back into the Autopkg Cache directory.
            shutil.move(
                "/Users/{}/Desktop/Mersive Solstice.app".format(username),
                "{}/Mersive Solstice.app".format(moveTo))
        else:
            raise ProcessorError(
                "The Mersive Solstice.app wasn't at the expected location.")

        # Define the plist file.
        plist = "{}/Mersive Solstice.app/Contents/Info.plist".format(moveTo)

        # Get the contents of the plist file.
        try:
            with open(plist, 'rb') as file:
                plist_contents = plist_Reader(file)
        except Exception:
            raise ProcessorError('Unable to locate the specified plist file.')

        # Get the version and bundle id
        version = plist_contents.get('CFBundleShortVersionString')
        bundle_id = plist_contents.get('CFBundleIdentifier')

        # Output
        self.env["version"] = version
        self.output("Version: {}".format(self.env["version"]))
        self.env["bundle_id"] = bundle_id
        self.output("Bundle Identifier: {}".format(self.env["bundle_id"]))