本文整理汇总了Python中useless.base.util.makepaths函数的典型用法代码示例。如果您正苦于以下问题:Python makepaths函数的具体用法?Python makepaths怎么用?Python makepaths使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了makepaths函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: export_trait
def export_trait(self, suite_path):
#print "----Begin export trait", self.current_trait
#print "start xml", self.current_trait
#xmldata = TraitElement(self.conn, self.suite)
xmldata = self._xmldata
#print 'set xml data'
xmldata.set(self.current_trait)
#print 'xml data set'
bkup_path = os.path.join(suite_path, self.current_trait)
makepaths(bkup_path)
#print 'render xml'
xmlfile = file(os.path.join(bkup_path, 'trait.xml'), 'w')
xmlfile.write(xmldata.toprettyxml())
xmlfile.close()
#print 'xml rendered'
#print "end xml", self.current_trait
row = self._traits.select_row(clause=Eq('trait', self.current_trait))
if row['description'] is not None:
print 'export description', self.current_trait
descfile = file(os.path.join(bkup_path, 'description.txt'), 'w')
descfile.write(row['description'])
descfile.close()
#print "start templates,scripts", self.current_trait
self._templates.export_templates(bkup_path)
self._scripts.export_scripts(bkup_path)
#print "end templates,scripts", self.current_trait
#print 'all exported', os.listdir(bkup_path)
print 'trait', self.current_trait, 'exported in suite', self.suite
示例2: ready_base_for_install
def ready_base_for_install(self):
self._check_bootstrap()
self._check_installer()
fstab = self.machine.make_fstab()
ready_base_for_install(self.target, self.cfg, self.suite, fstab)
if self.cfg.is_it_true('installer', 'use_devices_tarball'):
runlog('echo extracting devices tarball')
self._extract_devices_tarball()
else:
runlog('echo using MAKEDEV to make devices')
self.make_generic_devices()
self.make_disk_devices()
if self._raid_setup:
mdpath = join(self.target, 'etc/mdadm')
makepaths(mdpath)
mdconfname = join(mdpath, 'mdadm.conf')
mdconf = file(mdconfname, 'w')
for diskname in self._raid_drives:
devices = ['%s*' % d for d in self._raid_drives[diskname]]
line = 'DEVICE %s' % ' '.join(devices)
mdconf.write(line + '\n')
mdconf.close()
mdconf = file(mdconfname, 'a')
arrdata = commands.getoutput('mdadm -E --config=%s -s' % mdconfname)
mdconf.write(arrdata + '\n')
mdconf.write('\n')
mdconf.close()
self._mount_target_proc()
示例3: _make_template_common
def _make_template_common(self, template, tmpl):
sub = self.traittemplate.template.sub()
newpath = join(self.target, template.template)
bkuppath = join(self.target, self.paelladir, 'original_files', template.template)
makepaths(dirname(newpath), dirname(bkuppath))
self.log.info('target template %s' % newpath)
if tmpl != sub:
self.log.info('%s %s subbed' % (template.package, template.template))
if isfile(newpath):
if not isfile(bkuppath):
os.system('mv %s %s' % (newpath, dirname(bkuppath)))
self.log.info('%s backed up' % template.template)
else:
self.log.info('overwriting previously installed template %s' % template.template)
else:
self.log.info('installing new template %s' % template.template)
newfile = file(newpath, 'w')
newfile.write(sub)
newfile.close()
mode = template.mode
if mode[0] == '0' and len(mode) <= 7 and mode.isdigit():
mode = eval(mode)
os.chmod(newpath, mode)
own = ':'.join([template.owner, template.grp_owner])
os.system(self.command('chown', "%s '%s'" %(own, join('/', template.template))))
示例4: export
def export(self, mtypepath):
mtype = self.getAttribute("name")
path = join(mtypepath, mtype)
makepaths(path)
xfile = file(join(path, "machine_type.xml"), "w")
xfile.write(self.toprettyxml())
xfile.close()
示例5: _make_template_common
def _make_template_common(self, template, tmpl):
sub = self.traittemplate.template.sub()
newpath = join(self.target, template.template)
bkuppath = join(self.target, self.paelladir, 'original_files', template.template)
makepaths(dirname(newpath), dirname(bkuppath))
self.log.info('target template %s' % newpath)
if tmpl != sub:
self.log.info('%s %s subbed' % (template.package, template.template))
if isfile(newpath):
if not isfile(bkuppath):
os.system('mv %s %s' % (newpath, dirname(bkuppath)))
self.log.info('%s backed up' % template.template)
else:
self.log.info('overwriting previously installed template %s' % template.template)
else:
self.log.info('installing new template %s' % template.template)
newfile = file(newpath, 'w')
newfile.write(sub)
newfile.close()
mode = template.mode
# a simple attempt to insure mode is a valid octal string
# this is one of the very rare places eval is used
# there are a few strings with 8's and 9's that will pass
# the if statement, but the eval will raise SyntaxError then.
# If the mode is unusable the install will fail at this point.
if mode[0] == '0' and len(mode) <= 7 and mode.isdigit():
mode = eval(mode)
os.chmod(newpath, mode)
else:
raise InstallError, 'bad mode %s, please use octal prefixed by 0' % mode
own = ':'.join([template.owner, template.grp_owner])
os.system(self.command('chown', "%s '%s'" %(own, join('/', template.template))))
示例6: make_sources_list
def make_sources_list(cfg, target, suite):
section = 'debrepos'
aptdir = os.path.join(target, 'etc', 'apt')
makepaths(aptdir)
sources_list = file(os.path.join(aptdir, 'sources.list'), 'w')
source = RepositorySource()
source.uri = cfg.get(section, 'http_mirror')
source.suite = suite
source.set_path()
sources_list.write(str(source) +'\n')
source.type = 'deb-src'
sources_list.write(str(source) +'\n')
source.type = 'deb'
if suite == 'woody' or cfg.has_option(section, '%s_nonus' % suite):
source.suite += '/non-US'
sources_list.write(str(source) +'\n')
source.type = 'deb-src'
sources_list.write(str(source) +'\n')
loption = suite + '_local'
if cfg.has_option(section, loption) and cfg[loption] == 'true':
sources_list.write('deb %s/local %s/\n' % (source.uri, suite))
sources_list.write('deb-src %s/local %s/\n' % (source.uri, suite))
coption = suite + '_common'
if cfg.has_option(section, coption) and cfg[coption] == 'true':
sources_list.write('deb %s/local common/\n' % source.uri)
sources_list.write('deb-src %s/local common/\n' % source.uri)
sources_list.write('\n')
sources_list.close()
示例7: install_template
def install_template(self, template, text):
target_filename = self.target / template.template
makepaths(target_filename.dirname())
if target_filename.isfile():
backup_filename = self.target / path('root/paella') / template.template
if not backup_filename.isfile():
makepaths(backup_filename.dirname())
target_filename.copy(backup_filename)
target_filename.write_bytes(text)
mode = template.mode
# a simple attempt to insure mode is a valid octal string
# this is one of the very rare places eval is used
# there are a few strings with 8's and 9's that will pass
# the if statement, but the eval will raise SyntaxError then.
# If the mode is unusable the install will fail at this point.
if mode[0] == '0' and len(mode) <= 7 and mode.isdigit():
mode = eval(mode)
target_filename.chmod(mode)
else:
raise InstallError, 'bad mode %s, please use octal prefixed by 0' % mode
own = ':'.join([template.owner, template.grp_owner])
# This command is run in a chroot to make the correct uid, gid
os.system(self.command('chown', "%s '%s'" %(own, join('/', template.template))))
示例8: ready_target
def ready_target(self):
self._check_target()
makepaths(self.target)
device = self.machine.array_hack(self.machine.current.machine_type)
clause = Eq('filesystem', self.machine.current.filesystem)
clause &= Gt('partition', '0')
table = 'filesystem_mounts natural join mounts'
mounts = self.cursor.select(table=table, clause=clause, order='mnt_point')
if mounts[0].mnt_point != '/':
raise Error, 'bad set of mounts', mounts
mddev = False
mdnum = 0
if device == '/dev/md':
mddev = True
pdev = '/dev/md0'
mdnum += 1
else:
pdev = self._pdev(device, mounts[0].partition)
print 'mounting target', pdev, self.target
clause &= Neq('mnt_point', '/')
mounts = self.cursor.select(table=table, clause=clause, order='ord')
runlog('mount %s %s' % (pdev, self.target))
for mnt in mounts:
tpath = os.path.join(self.target, mnt.mnt_point[1:])
makepaths(tpath)
if mddev:
pdev = '/dev/md%d' % mdnum
else:
pdev = self._pdev(device, mnt.partition)
mdnum += 1
runlog('mount %s %s' % (pdev, tpath))
self._mounted = True
示例9: make_sources_list
def make_sources_list(cfg, target, suite):
section = 'debrepos'
aptdir = os.path.join(target, 'etc', 'apt')
makepaths(aptdir)
sources_list = file(os.path.join(aptdir, 'sources.list'), 'w')
source = RepositorySource()
source.uri = cfg.get('installer', 'http_mirror')
source.suite = suite
source.set_path()
sources_list.write(str(source) +'\n')
source.type = 'deb-src'
sources_list.write(str(source) +'\n')
source.type = 'deb'
if suite == 'woody' or cfg.has_option(section, '%s_nonus' % suite):
source.suite += '/non-US'
sources_list.write(str(source) +'\n')
source.type = 'deb-src'
sources_list.write(str(source) +'\n')
loption = suite + '_local'
if _is_option_true(cfg, section, loption):
sources_list.write('deb %s/local %s/\n' % (source.uri, suite))
sources_list.write('deb-src %s/local %s/\n' % (source.uri, suite))
coption = suite + '_common'
if _is_option_true(cfg, section, coption):
sources_list.write('deb %s/local common/\n' % source.uri)
sources_list.write('deb-src %s/local common/\n' % source.uri)
secopt = suite + '_updates'
if _is_option_true(cfg, section, secopt):
sline = ['deb', source.uri, '%s/updates' % suite, 'main contrib non-free']
sources_list.write(' '.join(sline) + '\n')
sline[0] = 'deb-src'
sources_list.write(' '.join(sline) + '\n')
sources_list.write('\n')
sources_list.close()
示例10: mount_target
def mount_target(target, mounts, device):
mounts = [m for m in mounts if int(m.partition)]
if mounts[0].mnt_point != '/':
raise RuntimeError, 'bad set of mounts', mounts
mddev = False
mdnum = 0
if device == '/dev/md':
mddev = True
pdev = '/dev/md0'
mdnum += 1
else:
pdev = '%s%d' % (device, mounts[0].partition)
runlog('echo mounting target %s to %s' % (pdev, target))
runlog('mount %s %s' % (pdev, target))
mounts = mounts[1:]
mountable = [m for m in mounts if m.fstype != 'swap']
for mnt in mountable:
tpath = os.path.join(target, mnt.mnt_point[1:])
makepaths(tpath)
if mddev:
pdev = '/dev/md%d' % mdnum
else:
pdev = '%s%d' % (device, mnt.partition)
mdnum += 1
runlog('echo mounting target %s to %s' % (pdev, tpath))
runlog('mount %s %s' % (pdev, tpath))
示例11: export_all_diskconfigs
def export_all_diskconfigs(self, dirname=None):
if dirname is None:
dirname = self.db_export_path / 'diskconfig'
makepaths(dirname)
for row in self.diskconfig.cursor.select():
filename = row.name
diskconfig = dirname / filename
diskconfig.write_text(row.content)
示例12: mount_target
def mount_target(self):
"this is a default process"
self._check_target()
makepaths(self.target)
device = self.machine.array_hack()
#mounts = self.machine.get_ordered_fsmounts()
mounts = self.machine.get_installable_fsmounts()
mount_target(self.target, mounts, device)
self._mounted = True
示例13: install
def install(self, machine, target):
self.set_machine(machine)
self.setup_installer()
self.set_target(target)
makepaths(target)
self.log.info('Installer set to install %s to %s' % (machine, target))
self.helper = MachineInstallerHelper(self)
self.helper.curenv = self.curenv
self.process()
示例14: setup_initial_paellainfo_files
def setup_initial_paellainfo_files(self, traits):
makepaths(self.paelladir)
traitlist = file(join(self.paelladir, 'traitlist'), 'w')
for trait in traits:
traitlist.write('%s\n' % trait)
traitlist.close()
itraits = file(join(self.paelladir, 'installed_traits'), 'w')
itraits.write('Installed Traits:\n')
itraits.close()
示例15: export_aptkey
def export_aptkey(self, name=None, dirname=None, row=None):
dirname = path(dirname)
makepaths(dirname)
if name is None and row is None:
raise RuntimeError, "need to set either row or name"
if row is None:
row = self.aptkeys.get_row(name)
basename = '%s.gpg' % row.name
filename = dirname / basename
filename.write_text(row.data)