예제 #1
0
    def determine_vim_server_msi_path(self, version=None, testcase=None):
        """ Determine the path to the ViM server MSI file.
        INPUT
            testcase: a testcase object supplied when executing function as part of a testcase step.
        OUPUT
            successful: whether the function executed successfully or not.
            path: the path to the MSI file.
            build: the build number of the MSI file.
        """

        self.log.debug("Determining file path of ViM Server MSI ...")
        result = {'successful': False, 'path': None, 'build': None}

        try:
            # determine file path
            currentDirectory = getcwdu()
            if version is None:
                # use default testing artifact (from compiled development build)
                filePath = move_up_windows_path(currentDirectory,2)['path']+"\\artifacts\\"
            else:
                # use specified version in test resources folder
                filePath = "C:\\Program Files (x86)\\ViM\\test resources\\ViM Releases\\Server\\"
                # determine name of server MSI file
            fileName = None
            self.log.trace("Determining file name of ViM Server MSI ...")
            files = listdir(filePath)
            self.log.trace("Files found:\t%s"%str(files))
            if files is not None and files != []:
                for f in files:
                    # if looking for only ViM server MSI in artifacts folder
                    if version is None and "VIMServer" in str(f): fileName = f
                    # if looking for specified version MSI in test resources folder
                    if version is not None and str(version) in str(f): fileName = f
                self.log.trace("MSI File Path:\t%s%s"%(filePath,fileName))
            else:
                self.log.trace("VIM Server MSI file not found.")
                return {'path':None,'build':None}
            # parse file name to determine version/build number (split along '-' character in file name)
            if version is None:
                # return build only if using default testing artifact (to update test line number)
                try:
                    build = fileName.split('-')[1]
                    self.log.trace("Build:\t%s"%build)
                except BaseException, e:
                    self.log.trace("Failed to determine build number from MSI file.")
                    build = None
            else: build = None
            # return file path
            if filePath is not None and fileName is not None:
                result['path'] = "%s%s"%(filePath,fileName)
                result['build'] = build
            else:
                self.log.warn("VIM Server MSI file not found.")

            self.log.trace("Determined file path of ViM server MSI.")
            result['successful'] = True
예제 #2
0
    def uninstall_vim_server(self, testcase=None):
        """ Uninstall the ViM server.
        INPUT
            testcase: a testcase object supplied when executing function as part of a testcase step.
        OUPUT
            successful: whether the function executed successfully or not.
            verified: whether the operation was verified or not.
        """

        self.log.debug("Uninstalling ViM Server ...")
        result = {'successful': False, 'verified': False}

        try:
            # stop server
            self.stop_vim_server()

            # uninstall server (through wmi)
            c = WMI()
            productName = "ViM Server"
            self.log.trace("Searching for installed copies of ViM Server ...")
            for product in c.Win32_Product(Name = productName):
                self.log.trace("ViM Server installation found. Uninstalling ...")
                product.Uninstall()
            # verify ViM was uninstalled
            result['verified'] = self.verify_vim_uninstalled()['verified']

            # if failed to uninstall, try doing it using build number in expected location
            if not result['verified']:
                try:
                    self.log.warn("Failed to uninstall ViM server. "
                                  "Re-attempting using server package.")
                    path = move_up_windows_path(getcwdu(),2)['path']+"\\artifacts\\"
                    path += "VIMServer.msi"
                    system('C:\Windows\System32\MSIEXEC.exe /x "%s" /QN /norestart'%path)
                    # verify ViM was uninstalled
                    result['verified'] = self.verify_vim_uninstalled()['verified']
                except BaseException, e:
                    self.log.error(e)
                    self.start_vim_server()

            # clean up files
            self.cleanup_installed_files()

            if result['verified']: self.log.trace("Uninstalled ViM server.")
            result['successful'] = True