Ejemplo n.º 1
0
def deploy(source, destination, systemName=None, machineName=None):
    '''
    Deploys the tool found at the source directory to the destination directory.

    @param source: src
        The directory from which to deploy the tool
    @param destination: src
        The path where to deploy the tool
    @param systemName: src
        The name of the system for which to deploy (e.g. Darwin, Windows, Ubuntu)
    @param machineName: src
        The machine name (e.g.: x86, x86_64)
    @return: tuple
        Tuple containing the system information (name, release, version) and True
        if the tool was deployed, False if it wasn't
    '''
    # TODO: This should not be placed here a separate plugin needs to be created.
    assert isinstance(source, str), 'Invalid source path %s' % source
    assert isinstance(destination,
                      str), 'Invalid destination path %s' % destination
    assert not systemName or isinstance(
        systemName, str), 'Invalid system name %s' % systemName
    assert not machineName or isinstance(
        machineName, str), 'Invalid machine name %s' % machineName

    if not systemName: systemName, rel, ver = systemInfo()
    machineName = machineName if machineName else machine()

    systems = (SYSTEM_ALL) if systemName == SYSTEM_ALL else (systemName,
                                                             SYSTEM_ALL)
    machines = (MACHINE_ALL) if machineName == MACHINE_ALL else (machineName,
                                                                 MACHINE_ALL)

    deployed = False
    for systemName in systems:
        for machineName in machines:
            srcDir = join(source, systemName, machineName)
            if not isdir(srcDir):
                try:
                    zipPath, inPath = getZipFilePath(srcDir)
                    validateInZipPath(ZipFile(zipPath), inPath + ZIPSEP)
                except (IOError, KeyError):
                    continue
            synchronizeURIToDir(srcDir, destination)
            deployed = True

    return (systemName, rel, ver, deployed)
Ejemplo n.º 2
0
    def _publishFromFile(self, path, filePath):
        assert isinstance(path, str) and len(path) > 0, 'Invalid content path %s' % path
        assert isinstance(filePath, str), 'Invalid file path value %s' % filePath
        dstDir = dirname(self._getItemPath(path))
        if not isdir(dstDir):
            os.makedirs(dstDir)
        if isfile(filePath) or isdir(filePath):
            filePath = normpath(filePath)
            assert os.access(filePath, os.R_OK), 'Unable to read file path %s' % filePath
            self._createLinkToFileOrDir(path, filePath)
            return

        # not a file, see if it's a entry in a zip file
        zipFilePath, inFilePath = getZipFilePath(filePath, self.delivery.getRepositoryPath())
        assert isfile(zipFilePath) and os.access(zipFilePath, os.R_OK), \
            'Unable to read file path %s' % filePath
        zipFile = ZipFile(zipFilePath)
        validateInZipPath(zipFile, inFilePath)
        self._createLinkToZipFile(path, zipFilePath, inFilePath)
Ejemplo n.º 3
0
    def _publishFromFile(self, path, filePath):
        assert isinstance(path, str) and len(path) > 0, 'Invalid content path %s' % path
        assert isinstance(filePath, str), 'Invalid file path value %s' % filePath
        dstDir = dirname(self._getItemPath(path))
        if not isdir(dstDir):
            os.makedirs(dstDir)
        if isfile(filePath) or isdir(filePath):
            filePath = normpath(filePath)
            assert os.access(filePath, os.R_OK), 'Unable to read file path %s' % filePath
            self._createLinkToFileOrDir(path, filePath)
            return

        # not a file, see if it's a entry in a zip file
        zipFilePath, inFilePath = getZipFilePath(filePath, self.delivery.getRepositoryPath())
        assert isfile(zipFilePath) and os.access(zipFilePath, os.R_OK), \
            'Unable to read file path %s' % filePath
        zipFile = ZipFile(zipFilePath)
        validateInZipPath(zipFile, inFilePath)
        self._createLinkToZipFile(path, zipFilePath, inFilePath)
Ejemplo n.º 4
0
def deploy(source, destination, systemName=None, machineName=None):
    '''
    Deploys the tool found at the source directory to the destination directory.

    @param source: src
        The directory from which to deploy the tool
    @param destination: src
        The path where to deploy the tool
    @param systemName: src
        The name of the system for which to deploy (e.g. Darwin, Windows, Ubuntu)
    @param machineName: src
        The machine name (e.g.: x86, x86_64)
    @return: tuple
        Tuple containing the system information (name, release, version) and True
        if the tool was deployed, False if it wasn't
    '''
    # TODO: This should not be placed here a separate plugin needs to be created.
    assert isinstance(source, str), 'Invalid source path %s' % source
    assert isinstance(destination, str), 'Invalid destination path %s' % destination
    assert not systemName or isinstance(systemName, str), 'Invalid system name %s' % systemName
    assert not machineName or isinstance(machineName, str), 'Invalid machine name %s' % machineName

    if not systemName: systemName, rel, ver = systemInfo()
    machineName = machineName if machineName else machine()

    systems = (SYSTEM_ALL) if systemName == SYSTEM_ALL else (systemName, SYSTEM_ALL)
    machines = (MACHINE_ALL) if machineName == MACHINE_ALL else (machineName, MACHINE_ALL)

    deployed = False
    for systemName in systems:
        for machineName in machines:
            srcDir = join(source, systemName, machineName)
            if not isdir(srcDir):
                try:
                    zipPath, inPath = getZipFilePath(srcDir)
                    validateInZipPath(ZipFile(zipPath), inPath + ZIPSEP)
                except (IOError, KeyError): continue
            synchronizeURIToDir(srcDir, destination)
            deployed = True

    return (systemName, rel, ver, deployed)