# -*- coding: utf-8 -*-
"""
<DefineSource>
@Date : Fri Nov 14 13:20:38 2014 \n
@Author : Erwan Ledoux \n\n
</DefineSource>
The Deployer
"""
#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Standards.Interfacers.Capturer"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>
#<ImportSpecificModules>
import os
import ftplib
#</ImportSpecificModules>
#<DefineClass>
@DecorationClass()
class DeployerClass(BaseClass):
#Definition
RepresentingKeyStrsList=[
'DeployingUrlStr',
'DeployingLoginStr',
'DeployingPwdStr',
'DeployingClientFilePathStrToServerFilePathStrOrderedDict',
'DeployedFtplibVariable',
'DeployedDirKeyStrsList'
]
def default_init(self,
_DeployingUrlStr="ftp.ouvaton.coop",
_DeployingLoginStr="shareyoursystemhz",
_DeployingPwdStr="share",
_DeployingClientFilePathStrToServerFilePathStrOrderedDict=None,
_DeployedFtplibVariable=None,
_DeployedDirKeyStrsList=None,
**_KwargVariablesDict
):
#Call the parent __init__ method
BaseClass.__init__(self,**_KwargVariablesDict)
def do_deploy(self):
#open and login
self.DeployedFtplibVariable = ftplib.FTP(self.DeployingUrlStr);
self.DeployedFtplibVariable.login(
user=self.DeployingLoginStr,
passwd=self.DeployingPwdStr
);
"""
#delete all the files in the root folder
self.DeployedFtplibVariable.cwd(self.DeployingServerFolderPathStr);
for __ListedVariable in self.DeployedFtplibVariable.nlst():
try:
self.DeployedFtplibVariable.delete(__ListedVariable);
except Exception:
self.DeployedFtplibVariable.rmd(__ListedVariable);
#delete the dir and create a new one
try:
self.DeployedFtplibVariable.rmd(self.DeployingServerFolderPathStr);
except Exception:
pass;
self.DeployedFtplibVariable.mkd(self.DeployingServerFolderPathStr);
"""
#debug
self.debug(('self.',self,[
'DeployingClientFilePathStrToServerFilePathStrOrderedDict'
]))
#store
map(
lambda __DeployingClientFilePathStrToServerFilePathStrItemTuple:
self.DeployedFtplibVariable.storbinary(
'STOR '+__DeployingClientFilePathStrToServerFilePathStrItemTuple[1],
open(
__DeployingClientFilePathStrToServerFilePathStrItemTuple[0],
'rb'
)
),
self.DeployingClientFilePathStrToServerFilePathStrOrderedDict.items()
)
#ls
self.DeployedDirKeyStrsList=map(
lambda __DeployingClientFilePathStrToServerFilePathStrItemTuple:
self.DeployedFtplibVariable.nlst(
__DeployingClientFilePathStrToServerFilePathStrItemTuple[1]
),
self.DeployingClientFilePathStrToServerFilePathStrOrderedDict.items()
)
#quit
self.DeployedFtplibVariable.quit();
#</DefineClass>
View the Deployer sources on Github
#ImportModules
import ShareYourSystem as SYS
from ShareYourSystem.Standards.Interfacers import Folderer,Deployer
#Definition a Deployer
try:
MyDeployer=Deployer.DeployerClass().deploy()
except:
MyDeployer=Deployer.DeployerClass()
#Definition the AttestedStr
SYS._attest(
[
'MyDeployer is '+SYS._str(
MyDeployer,
**{
'RepresentingBaseKeyStrsListBool':False,
'RepresentingAlineaIsBool':False
}
)
]
)
#Print
>>>
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
////////////////////////////////
Deployer/__init__.py do_deploy
From Deployer/__init__.py do_deploy | site-packages/six.py exec_ | Celler/__init__.py do_cell | Notebooker/__init__.py do_notebook | Documenter/__init__.py do_inform | inform.py <module>
////////////////////////////////
l.82 :
*****
I am with []
*****
self.DeployingClientFilePathStrToServerFilePathStrOrderedDict is
/{
/}
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
*****Start of the Attest *****
MyDeployer is < (DeployerClass), 4540433488>
/{
/ '<New><Instance>IdInt' : 4540433488
/ '<Spe><Class>DeployingLoginStr' : shareyoursystemhz
/ '<Spe><Class>DeployingPwdStr' : share
/ '<Spe><Class>DeployingUrlStr' : ftp.ouvaton.coop
/ '<Spe><Instance>DeployedDirKeyStrsList' : []
/ '<Spe><Instance>DeployedFtplibVariable' : <ftplib.FTP instance at 0x10e9e94d0>
/ '<Spe><Instance>DeployingClientFilePathStrToServerFilePathStrOrderedDict' :
/ /{
/ /}
/}
*****End of the Attest *****