本文整理匯總了Python中rules.Rules.getContent方法的典型用法代碼示例。如果您正苦於以下問題:Python Rules.getContent方法的具體用法?Python Rules.getContent怎麽用?Python Rules.getContent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rules.Rules
的用法示例。
在下文中一共展示了Rules.getContent方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: run
# 需要導入模塊: from rules import Rules [as 別名]
# 或者: from rules.Rules import getContent [as 別名]
def run (self):
"""
"""
#Create folders and copy sources files
DEBIAN_DIR = os.path.join(self.build_dir,'debian')
DATA_DIR = os.path.join(self.build_dir,self.debian_package)
mkpath(DEBIAN_DIR)
mkpath(self.dist_dir)
#mkpath(os.path.join(DATA_DIR,'usr','bin'))
self.bdist_dir = DATA_DIR
install = self.reinitialize_command('install', reinit_subcommands=1)
install.root = self.bdist_dir
if self.install_purelib is not None:
install.install_purelib = self.install_purelib
install.skip_build = 0
install.warn_dir = 1
self.run_command('install')
#Create the debian rules
rules = Rules(self.debian_package,DATA_DIR)
dirs = rules.dirs
open(os.path.join(DEBIAN_DIR,"rules"),"w").write(unicode(rules.getContent()).encode('utf-8'))
os.chmod(os.path.join(DEBIAN_DIR,"rules"),0755)
#Create the debian compat
open(os.path.join(DEBIAN_DIR,"compat"),"w").write("5\n")
#Create the debian dirs
open(os.path.join(DEBIAN_DIR,"dirs"),"w").write("\n".join(dirs))
#Create the debian changelog
d=datetime.now()
self.buildDate=d.strftime("%a, %d %b %Y %H:%M:%S +0000")
clog = Changelog(self.debian_package,self.version,self.buildversion,self.changelog,self.distribution.get_maintainer(),self.distribution.get_maintainer_email(),self.buildDate)
open(os.path.join(DEBIAN_DIR,"changelog"),"w").write(unicode(clog.getContent()).encode('utf-8'))
#Create the pre/post inst/rm Script
if self.preinst is not None:
self.mkscript(self.preinst ,os.path.join(DEBIAN_DIR,"preinst"))
if self.postinst is not None:
self.mkscript(self.postinst,os.path.join(DEBIAN_DIR,"postinst"))
if self.prere is not None:
self.mkscript(self.prere ,os.path.join(DEBIAN_DIR,"prerm"))
if self.postre is not None:
self.mkscript(self.postre ,os.path.join(DEBIAN_DIR,"postrm"))
#Create the control file
control = Control(self.debian_package,
self.section,
self.distribution.get_maintainer(),
self.distribution.get_maintainer_email(),
self.architecture,
self.depends,
self.suggests,
self.description,
self.long_description,
self.conflicts,
self.replaces,
optionnal = {
'XB-Maemo-Display-Name':self.Maemo_Display_Name,
'XB-Maemo-Upgrade-Description':self.Maemo_Upgrade_Description,
'XSBC-Bugtracker':self.Maemo_Bugtracker,
'XB-Maemo-Icon-26':self.getIconContent(self.Maemo_Icon_26),
'XB-Maemo-Flags':self.Maemo_Flags,
'XB-Meego-Desktop-Entry-Filename':self.MeeGo_Desktop_Entry_Filename
}
)
open(os.path.join(DEBIAN_DIR,"control"),"w").write(unicode(control.getContent()).encode('utf-8'))
#Create the debian licence file
licence = Licence(self.copyright,
self.distribution.get_maintainer(),
self.distribution.get_maintainer_email(),
self.buildDate,
str(datetime.now().year))
open(os.path.join(DEBIAN_DIR,"copyright"),"w").write(unicode(licence.getContent()).encode('utf-8'))
#Delete tar if already exist as it will made add to the same tar
tarpath = os.path.join(self.dist_dir,self.debian_package+'_'+self.version+'-'+self.buildversion+'.tar.gz')
if os.path.exists(tarpath):
os.remove(tarpath)
#Now create the tar.gz
import tarfile
def reset(tarinfo):
tarinfo.uid = tarinfo.gid = 0
tarinfo.uname = tarinfo.gname = "root"
return tarinfo
tar = tarfile.open(tarpath, 'w:gz')
#tar.add(self.dist_dir,'.')
tar.add(self.build_dir,'.')
tar.close()
#Clean the build dir
remove_tree(DEBIAN_DIR)
#.........這裏部分代碼省略.........