def eggify(self): '''Let's wrap a nice Python module into an ugly egg.''' j = os.path.join # First, clean the Python module cleanFolder(self.pythonModule, verbose=False) # Create the egg folder eggFullName = j(self.eggFolder, self.eggName) if os.path.exists(eggFullName): os.remove(eggFullName) print('Existing "%s" was removed.' % eggFullName) # Create a temp folder where to store the egg eggTempFolder = os.path.splitext(eggFullName)[0] if os.path.exists(eggTempFolder): FolderDeleter.delete(eggTempFolder) print('Removed "%s" that was in my way.' % eggTempFolder) os.mkdir(eggTempFolder) # Create the "Products" sub-folder if we must wrap the package in this # namespace eggModulePath = j(j(eggTempFolder, self.moduleName.replace('.', '/'))) # Copy the Python module into the egg. os.makedirs(eggModulePath) copyFolder(self.pythonModule, eggModulePath) # Create setup files in the root egg folder self.createSetupFile(eggTempFolder) self.createInitFile(eggTempFolder) self.zipResult(eggFullName, eggTempFolder)
def eggify(self): '''Let's wrap a nice Python module into an ugly egg.''' j = os.path.join # First, clean the Python module cleanFolder(self.pythonModule, verbose=False) # Create the egg folder eggFullName = j(self.eggFolder, self.eggName) if os.path.exists(eggFullName): os.remove(eggFullName) print 'Existing "%s" was removed.' % eggFullName # Create a temp folder where to store the egg eggTempFolder = os.path.splitext(eggFullName)[0] if os.path.exists(eggTempFolder): FolderDeleter.delete(eggTempFolder) print 'Removed "%s" that was in my way.' % eggTempFolder os.mkdir(eggTempFolder) # Create the "Products" sub-folder if we must wrap the package in this # namespace eggModulePath = j(j(eggTempFolder, self.moduleName.replace('.', '/'))) # Copy the Python module into the egg. os.makedirs(eggModulePath) copyFolder(self.pythonModule, eggModulePath) # Create setup files in the root egg folder self.createSetupFile(eggTempFolder) self.createInitFile(eggTempFolder) self.zipResult(eggFullName, eggTempFolder)
def copyEggs(self): '''Copy content of eggs into the Zope instance. This method also retrieves every egg version and returns a dict {s_egg:s_version}.''' j = os.path.join eggsFolder = j(self.plonePath, 'buildout-cache/eggs') res = {} for name in os.listdir(eggsFolder): if name == 'EGG-INFO': continue splittedName = name.split('-') res[splittedName[0]] = splittedName[1] if splittedName[0].startswith('Products.'): res[splittedName[0][9:]] = splittedName[1] absName = j(eggsFolder, name) # Copy every file or sub-folder into self.libFolder or # self.productsFolder. for fileName in os.listdir(absName): absFileName = j(absName, fileName) if fileName == 'Products' and not name.startswith('Zope2-'): # Copy every sub-folder into self.productsFolder for folderName in os.listdir(absFileName): absFolder = j(absFileName, folderName) if not os.path.isdir(absFolder): continue copyFolder(absFolder, j(self.productsFolder,folderName)) elif os.path.isdir(absFileName): copyFolder(absFileName, j(self.libFolder, fileName)) else: shutil.copy(absFileName, self.libFolder) return res
def installPlone25or30Stuff(self, linksForProducts): '''Here, we will copy all Plone2-related stuff in the Zope instance we've created, to get a full Plone-ready Zope instance. If p_linksForProducts is True, we do not perform a real copy: we will create symlinks to products lying within Plone installer files.''' j = os.path.join if self.ploneVersion == 'plone25': sourceFolders = ('zeocluster/Products',) else: sourceFolders = ('zinstance/Products', 'zinstance/lib/python') for sourceFolder in sourceFolders: sourceBase = j(self.plonePath, sourceFolder) destBase = j(self.instancePath, sourceFolder[sourceFolder.find('/')+1:]) for name in os.listdir(sourceBase): folderName = j(sourceBase, name) if os.path.isdir(folderName): destFolder = j(destBase, name) # This is a Plone product. Copy it to the instance. if linksForProducts: # Create a symlink to this product in the instance executeCommand(['ln', '-s', folderName, destFolder]) else: # Copy thre product into the instance copyFolder(folderName, destFolder)
def installPlone25or30Stuff(self, linksForProducts): '''Here, we will copy all Plone2-related stuff in the Zope instance we've created, to get a full Plone-ready Zope instance. If p_linksForProducts is True, we do not perform a real copy: we will create symlinks to products lying within Plone installer files.''' j = os.path.join if self.ploneVersion == 'plone25': sourceFolders = ('zeocluster/Products',) else: sourceFolders = ('zinstance/Products', 'zinstance/lib/python') for sourceFolder in sourceFolders: sourceBase = j(self.plonePath, sourceFolder) destBase = j(self.instancePath, sourceFolder[sourceFolder.find('/')+1:]) for name in os.listdir(sourceBase): folderName = j(sourceBase, name) if os.path.isdir(folderName): destFolder = j(destBase, name) # This is a Plone product. Copy it to the instance. if linksForProducts: # Create a symlink to this product in the instance cmd = 'ln -s %s %s' % (folderName, destFolder) os.system(cmd) else: # Copy thre product into the instance copyFolder(folderName, destFolder)
def copyEggs(self): '''Copy content of eggs into the Zope instance.''' j = os.path.join eggsFolder = j(self.plonePath, 'buildout-cache/eggs') self.ploneThemes = [] for name in os.listdir(eggsFolder): if name == 'EGG-INFO': continue absName = j(eggsFolder, name) # Copy every file or sub-folder into self.libFolder or # self.productsFolder. for fileName in os.listdir(absName): absFileName = j(absName, fileName) if fileName == 'Products' and not name.startswith('Zope2-'): # Copy every sub-folder into self.productsFolder for folderName in os.listdir(absFileName): absFolder = j(absFileName, folderName) if not os.path.isdir(absFolder): continue copyFolder(absFolder, j(self.productsFolder,folderName)) elif os.path.isdir(absFileName): copyFolder(absFileName, j(self.libFolder, fileName)) else: shutil.copy(absFileName, self.libFolder)