def disableModule(moduleName):
    """Disables optional module. Module files will be deleted.

    Keyword arguments:
    moduleName -- name of the optional module
    """

    if not os.path.exists("FrameworkInternals/EnabledModules/"+moduleName+".url"):
        print("Error, module "+moduleName+" seems not installed!")
        return False
    try:
        for file in glob("FrameworkInternals/EnabledModules/"+moduleName+".*"):
            os.remove(file)
    except Exception as ex:
        print("Failed to remove module file in FrameworkInternals/EnabledModules/ :", ex)
        return False

    print("Removed url file of "+moduleName+'. Now trying to store your decision in the VCS.')
    try:
        vci = version_control_interface.VersionControlInterface(os.getcwd() + os.path.sep)
        module_description_files = ['.url', '.tag', '.minVersion']
        for suffix in module_description_files:
            full_path = os.path.join(os.getcwd(), 'FrameworkInternals', 'EnabledModules', moduleName + suffix)
            if vci.is_versioned(full_path):
                vci.remove_from_vc(full_path)
        print('Your selection got remembered in the VCS. Dont forget to commit the changes.')
    except Exception as e:
        print('Unable to store your module selection because: '+str(e)+'. Note that module description files were removed in your working directory.')


    print("Remove module code if existing...")
    removeModule(moduleName)

    return True
def generateCommitID(generatedFile, project_root_dir):
    commitID = "No commit ID found"
    try:
        commitID = version_control_interface.VersionControlInterface(
            project_root_dir).get_latest_repo_commit()
    except Exception as e:
        print 'generateCommitID failed, exception: {}'.format(str(e))
    generatedFile.write('#define GEND_COMMIT_ID "{}"\n'.format(commitID))
示例#3
0
def mfCheckConsistency(param=None):
	"""Checks the consistency of the project, checking that all the files that must exist do exist, everything is in svn and the md5 keys are correct."""
	vci = version_control_interface.VersionControlInterface('.')
	global svnClient

	global ask
	if param == "--ask":
		ask = True
	directories = load_file('FrameworkInternals' + os.path.sep + 'files.txt', os.getcwd())
	problems=check_consistency(directories, os.getcwd(), vci)
	check_uncovered(directories,os.getcwd())
	if len(problems)>0:
		print "I've found this consistency problems (#problems="+str(len(problems))+")"
		for p in problems:
			print p 
	else:
		print "No problems found."
示例#4
0
            url = _getModuleUrl(moduleName, serverString="")
            urlFileName = "EnabledModules/" + moduleName + ".url"
            open(urlFileName, "w").write(url)
        # add tag
        if os.path.exists(tagFileName): os.remove(tagFileName)
        file = open(tagFileName, "w")
        file.write(tag)
    except Exception, ex:
        print "Failed to set up module files in FrameworkInternals/EnabledModules/ :", ex
        return False

    print(
        "Created module files. Adding them to your version control system to store the selection."
    )
    try:
        vci = version_control_interface.VersionControlInterface(baseDirectory +
                                                                os.path.sep)
        module_description_files = ['.url', '.tag', '.minVersion']
        for suffix in module_description_files:
            full_path = os.getcwd(
            ) + os.path.sep + 'FrameworkInternals' + os.path.sep + 'EnabledModules' + os.path.sep + moduleName + suffix
            if not vci.is_versioned(full_path):
                vci.add_to_vc(full_path)
        print(
            'Your selection got remembered in the VCS. Dont forget to commit the changes.'
        )
    except Exception as e:
        print(
            'Unable to store your module selection because: ' + str(e) +
            '. Note that module description files were created so you can add them to the VCS yourself'
        )
def enableModule(moduleName, tag="master", serverString=""):
    """Enables optional module. Module URL and required quasar version is downloaded from github.
       Module download is done later at cmake configure stage.

    Keyword arguments:
    moduleName   -- name of the optional module
    tag          -- tag/branch to checkout, if not specified, master branch is used
    serverString -- default git server is "https://github.com", specify custom if necessary, e.g. "ssh://[email protected]:7999"
    """
    print("Enabling module "+moduleName+", tag/branch "+tag)

    if not _getModuleInfo(serverString): return False

    print("Checking module to be compatible...")
    quasarVersion = None
    try:
        quasarVersion = open("Design/quasarVersion.txt").readline().rstrip()
    except Exception as ex:
        print(ex)
    if not quasarVersion:
        print("Error reading version info from Design/quasarVersion.txt")
        return False
    moduleMinVersion = moduleInfo[moduleName]["minVersion"]
    if parse_version(quasarVersion) >= parse_version(moduleMinVersion):
        print("Module {0} tag {1} required version {2} is compatible with installed quasar version {3}".format(moduleName, tag, moduleMinVersion, quasarVersion))
    else:
        print("Cannot enable module "+moduleName+". Minimum required version "+moduleMinVersion+" is newer than installed quasar version "+quasarVersion)
        return False

    # Check tag to be existing
    #
    if not _checkTagExists(moduleInfo[moduleName]["url"], tag): return

    baseDirectory = os.getcwd()
    fwInternalsDir = baseDirectory + os.path.sep + "FrameworkInternals"
    os.chdir(fwInternalsDir)

    # Check first if module is maybe already present with different version
    #
    tagFileName = "EnabledModules/"+moduleName+".tag"
    oldTag = ""
    if os.path.exists(tagFileName): oldTag = open(tagFileName).read()
    if oldTag and oldTag!=tag:
        print("Old version of "+moduleName+" exists ("+oldTag+"). Removing it first...")
        os.chdir(baseDirectory)
        if not removeModule(moduleName):
            print("Module not enabled, correct above errors first.")
            return
        os.chdir(fwInternalsDir)

    # actually enable
    #
    if not os.path.isdir("EnabledModules"): os.mkdir("EnabledModules")
    # FIXME: check if previous tag exists and possibly needs update
    try:
        for file in glob("quasar-modules/"+moduleName+".*"):
            copy(file, "EnabledModules/")
        # change URL if non-default server is specified
        if serverString:
            url = _getModuleUrl(moduleName, serverString="")
            urlFileName = "EnabledModules/"+moduleName+".url"
            open(urlFileName, "w").write(url)
        # add tag
        if os.path.exists(tagFileName): os.remove(tagFileName)
        file = open(tagFileName, "w")
        file.write(tag)
    except Exception as ex:
        print("Failed to set up module files in FrameworkInternals/EnabledModules/ :", ex)
        return False

    print("Created module files. Adding them to your version control system to store the selection.")
    try:
        vci = version_control_interface.VersionControlInterface(baseDirectory + os.path.sep)
        module_description_files = ['.url', '.tag', '.minVersion']
        for suffix in module_description_files:
            full_path = os.getcwd() + os.path.sep + 'FrameworkInternals' + os.path.sep + 'EnabledModules' + os.path.sep + moduleName + suffix
            if not vci.is_versioned(full_path):
                vci.add_to_vc(full_path)
        print('Your selection got remembered in the VCS. Dont forget to commit the changes.')
    except Exception as e:
        print('Unable to store your module selection because: '+str(e)+'. Note that module description files were created so you can add them to the VCS yourself')

    os.chdir(baseDirectory)


    return True