• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python path.path函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中useless.base.path.path函数的典型用法代码示例。如果您正苦于以下问题:Python path函数的具体用法?Python path怎么用?Python path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了path函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: install_kernel_package

def install_kernel_package(package, toolkit=None, target=None, loginfo=loginfo,
                           logerror=logerror):
    if toolkit is not None:
        target = toolkit.target
    if target is None:
        raise RuntimeError , "No target specified."
    target = path(target)
    chroot_precommand = ['chroot', str(target)]
    aptinstall = ['aptitude', '--assume-yes', 'install']
    cmd = chroot_precommand + aptinstall + [package]
    loginfo('install command is: %s' % ' '.join(cmd))
    kimgconf = target / 'etc' / 'kernel-img.conf'
    kimgconf_old = path('%s.paella-orig' % kimgconf)
    kimgconflines = ['do_bootloader = No',
                     'do_initrd = Yes',
                     'warn_initrd = No'
                     ]
    if kimgconf.exists():
        loginfo('/etc/kernel-img.conf already exists')
        k = '/etc/kernel-img.conf'
        msg ='renaming %s to %s.paella-orig' % (k, k)
        loginfo(msg)
        if kimgconf_old.exists():
            msg = '%s already exists, aborting install.' % kimgconf_old
            logerror(msg)
            raise RuntimeError , msg
        os.rename(kimgconf, kimgconf_old)
    kimgconf.write_lines(kimgconflines)
    subprocess.check_call(cmd)
    loginfo('Kernel installation is complete.')
    if kimgconf_old.exists():
        loginfo('Restoring /etc/kernel-img.conf')
        os.remove(kimgconf)
        os.rename(kimgconf_old, kimgconf)
开发者ID:joelsefus,项目名称:paella,代码行数:34,代码来源:postinst.py


示例2: _filename

 def _filename(self, sequence, filename=None):
     if filename is None:
         filename = self.orig_filename
     else:
         filename = path(filename)
     seqname = "%s.%d" % (filename, sequence)
     return path(seqname)
开发者ID:BackupTheBerlios,项目名称:useless-svn,代码行数:7,代码来源:logrotate.py


示例3: _setup_standard_directories

 def _setup_standard_directories(self):
     self._std_dirs = KStandardDirs()
     self.tmpdir_parent = path(str(self._std_dirs.findResourceDir('tmp', '/')))
     self.datadir_parent = path(str(self._std_dirs.findResourceDir('data', '/')))
     self.tmpdir = self.tmpdir_parent / 'utguests'
     self.datadir = self.datadir_parent / 'utguests'
     # we need this in dosbox object (for now)
     self.main_config_dir = self.datadir
     if not os.path.exists(self.datadir):
         os.mkdir(self.datadir)
开发者ID:BackupTheBerlios,项目名称:useless-svn,代码行数:10,代码来源:utapp.py


示例4: export_profile

 def export_profile(self, profile, dirname=None):
     if dirname is None:
         dirname = path('.')
     dirname = path(dirname)
     makepaths(dirname)
     # this env object should be handled
     # inside the profile object instead
     # of being handled here.
     env = self.profile.make_environment_object()
     env.set_profile(profile)
     self.profile.export_profile(dirname, profile=profile, env=env)
开发者ID:joelsefus,项目名称:paella,代码行数:11,代码来源:main.py


示例5: extract_base_tarball

 def extract_base_tarball(self):
     suite = self.suitecursor.get_base_suite(self._suite)
     fstype = self.cfg.get('umlmachines', 'backup_filesystem')
     if fstype == 'hostfs':
         #backup_path = path(self.cfg.get('umlmachines', 'hostfs_backup_path')).expand()
         backup_path = path(self.options['hostfs_backup_path'].value)
     else:
         backup_path = path('/mnt')
     basetarball = backup_path / path('%s.base.tar.gz' % suite)
     if not basetarball.isfile():
         basetarball = backup_path / path('%s.base.tar' % suite)
     if basetarball.isfile():
         extract_tarball(self.target, basetarball)
     else:
         raise RuntimeError, 'No base tarball found for suite %s' % suite
开发者ID:BackupTheBerlios,项目名称:paella-svn,代码行数:15,代码来源:installer.py


示例6: import_all_aptkeys

 def import_all_aptkeys(self, dirname=None):
     if dirname is None:
         dirname = self.main_path / 'aptkeys'
     dirname = path(dirname)
     files = [f for f in dirname.listdir() if f.isfile() and f.endswith('.gpg')]
     for filename in files:
         self.import_aptkey(filename)
开发者ID:joelsefus,项目名称:paella,代码行数:7,代码来源:main.py


示例7: __init__

    def __init__(self):
        object.__init__(self)
        self.cfg = PaellaConfig()
        self.conn = InstallerConnection()
        self.profile = os.environ['PAELLA_PROFILE']
        self.target = path(os.environ['PAELLA_TARGET'])
        self.machine = None
        self.trait = None
        self.suite = get_suite(self.conn, self.profile)

        self.db = ToolkitDatabase(self.conn)
        self.db.set_profile(self.profile)
        self.traits = self.db.profile.make_traitlist()
        profile_families = self.db.profile.get_families()
        self.families = list(self.db.family.get_related_families(profile_families))
        self.default = DefaultEnvironment(self.conn)
        

        if os.environ.has_key('PAELLA_MACHINE'):
            self.machine = os.environ['PAELLA_MACHINE']
            self.db.set_machine(self.machine)
            
        # we need to make an installer to do
        # some of the installer functions.
        self.installer = None

        if os.environ.has_key('PAELLA_TRAIT'):
            self.set_trait(os.environ['PAELLA_TRAIT'])
开发者ID:BackupTheBerlios,项目名称:paella-svn,代码行数:28,代码来源:toolkit.py


示例8: install_kernel_package

 def install_kernel_package(self):
     self.log.info('called install_kernel_package')
     extra_modules = self.determine_extra_modules_from_diskconfig()
     if extra_modules:
         self.log.info('Checking if extra packages are required before kernel install.')
         self.install_packages_for_extra_modules(extra_modules)
     kernel = self.machine.get_kernel()
     cmd = self.chroot_precommand + self.aptinstall + [kernel]
     self.log.info('install cmd is: %s' % ' '.join(cmd))
     kimgconf = self.target / 'etc' / 'kernel-img.conf'
     kimgconf_old = path('%s.paella-orig' % kimgconf)
     kimgconflines = ['do_bootloader = No',
                      'do_initrd = Yes',
                      'warn_initrd = No'
                      ]
     if kimgconf.exists():
         self.log.info('/etc/kernel-img.conf already exists')
         k = '/etc/kernel-img.conf'
         msg ='renaming %s to %s.paella-orig' % (k, k)
         self.log.info(msg)
         if kimgconf_old.exists():
             raise RuntimeError , '%s already exists, aborting install.' % kimgconf_old
         os.rename(kimgconf, kimgconf_old)
     kimgconf.write_lines(kimgconflines)
     runlog(cmd)
     self.log.info('Kernel installation is complete.')
     if kimgconf_old.exists():
         self.log.info('Restoring /etc/kernel-img.conf')
         os.remove(kimgconf)
         os.rename(kimgconf_old, kimgconf)
开发者ID:BackupTheBerlios,项目名称:paella-svn,代码行数:30,代码来源:machinehelper.py


示例9: __init__

    def __init__(self, conn, suite, target):
        # target should already be a path object
        self.target = path(target)
        self.trait = None

        # setup relation objects
        self.traitpackage = TraitPackage(conn, suite)
        self.traittemplate = TraitTemplate(conn, suite)
        self.traitscripts = TraitScript(conn, suite)

        # setup empty variable containers
        self.profiledata = {}
        self.machine_data = {}
        self.familydata = {}

        # It's odd, but running the same
        # code for setting debconf selections
        # returns a 1 on the preseed process, yet
        # returns a 0 when it's done during
        # the templates process.
        # -- I found the problem, debconf reports
        #    an error if the question doesn't exist
        #    yet.
        # This attribute helps keep track of the
        # problem, and will run the debconf
        # selections during the templates
        # process, if the value is True.
        # I don't really like this, but it seems
        # to work for now, so I'm going to leave
        # it as is, and come up with a better
        # solution later.
        self.debconf_problem = False
开发者ID:joelsefus,项目名称:paella,代码行数:32,代码来源:trait.py


示例10: export_db_element

 def export_db_element(self, dirname=None, filename="database.xml"):
     if dirname is None:
         dirname = self.db_export_path
     filename = path(dirname) / filename
     dbfile = filename.open("w")
     self.dbelement.writexml(dbfile, indent="\t", newl="\n", addindent="\t")
     dbfile.close()
开发者ID:BackupTheBerlios,项目名称:paella-svn,代码行数:7,代码来源:main.py


示例11: _bootstrap_with_tarball

 def _bootstrap_with_tarball(self, suite):
     self.check_target_exists()
     suite_path = path(self.defenv.get('installer', 'suite_storage'))
     arch = get_architecture()
     filename = '%s-%s.tar.gz' % (suite, arch)
     basefile = suite_path / filename
     taropts = '-xzf'
     # we normally expect a tar.gz
     # but we'll check for a plain tar also
     if not basefile.exists():
         filename = '%s-%s.tar' % (suite, arch)
         basefile = suite_path / filename
         taropts = '-xf'
     if not basefile.exists():
         # We don't really want to ruin an install
         # by not having a tarball, so we log a warning
         # and proceed with a debootstrap.
         msg = "base tarball not found, reverting to debootstrap"
         self.log.warn(msg)
         self._bootstrap_with_debootstrap(suite)
     else:
         #cmd = 'tar -C %s %s %s' % (self.target, taropts, basefile)
         cmd = ['tar', '-C', str(self.target), taropts, str(basefile)]
         # if cmd returns nonzero, runlog will raise an error
         runlog(cmd)
开发者ID:joelsefus,项目名称:paella,代码行数:25,代码来源:chroot.py


示例12: __init__

 def __init__(self, conn=None, cfg=None):
     self.conn = conn
     UmlChroot.__init__(self, cfg=cfg)
     self.options['paella_action'] = 'install'
     paellarc = path(self.cfg['paellarc']).expand()
     self.paellarc = PaellaConfig(files=[paellarc])
     self.options['paellarc'] = paellarc
开发者ID:BackupTheBerlios,项目名称:paella-svn,代码行数:7,代码来源:installer.py


示例13: export_db_element

 def export_db_element(self, dirname=None, filename='database.xml'):
     if dirname is None:
         dirname = self.db_export_path
     filename = path(dirname) / filename
     dbfile = filename.open('w')
     self.dbelement.writexml(dbfile, indent='\t', newl='\n', addindent='\t')                                
     dbfile.close()
开发者ID:BackupTheBerlios,项目名称:paella-svn,代码行数:7,代码来源:main.py


示例14: import_machines

 def import_machines(self, machines, dirname):
     dirname = path(dirname)
     current_machine = self.current_machine
     # make a queue for the machines
     machine_queue = [machine for machine in machines]
     # I hope this is correct.  This is an
     # attempt to keep this function from
     # running in an infinite loop.
     num_machines = len(machine_queue)
     max_loops = (num_machines * (num_machines +1) ) / 2
     count = 0
     while machine_queue:
         machine = machine_queue.pop(0)
         machine_dir = dirname / machine
         try:
             self.import_machine(machine_dir)
         except UnbornError:
             print "The parent of machine %s hasn't been imported yet." % machine
             machine_queue.append(machine)
         count +=1
         if count > max_loops:
             msg = "We appear to be in an infinite loop.\n"
             msg += "It's likely that there are unmet dependencies"
             msg += " in your list of machines."
             raise RuntimeError , msg
     if current_machine is not None:
         self.set_machine(current_machine)
开发者ID:joelsefus,项目名称:paella,代码行数:27,代码来源:main.py


示例15: __init__

 def __init__(self, parent, logfile, name='LogBrowser'):
     BaseLogBrowser.__init__(self, parent, name=name)
     self.logfilename = path(logfile)
     if not self.logfilename.exists():
         file(self.logfilename, 'w').close()
     self.logfile_size = 0
     self.setVScrollBarMode(self.AlwaysOff)
开发者ID:BackupTheBerlios,项目名称:useless-svn,代码行数:7,代码来源:logbrowser.py


示例16: export_machine

 def export_machine(self, exportdir):
     self._check_machine_set()
     element = MachineElement(self.conn, self.current_machine)
     exportdir = path(exportdir)
     element.export(exportdir)
     subdir = element.export_directory(exportdir)
     self.relation.scripts.export_scripts(subdir)
开发者ID:joelsefus,项目名称:paella,代码行数:7,代码来源:main.py


示例17: export_kernels

 def export_kernels(self, exportdir):
     element = KernelsElement(self.conn)
     exportdir = path(exportdir)
     filename = exportdir / 'kernels.xml'
     xmlfile = file(filename, 'w')
     xmlfile.write(element.toprettyxml())
     xmlfile.close()
开发者ID:joelsefus,项目名称:paella,代码行数:7,代码来源:main.py


示例18: decode_base64_templates

def decode_base64_templates(toolkit, trait=None, suffix='.b64',
                            removefiles=True, verbose=False):
    it = toolkit
    current_trait = it.trait
    if trait is not None:
        if verbose:
            print "Setting trait to %s" % trait
        it.set_trait(trait)
    templates = it.db.trait.templates()
    b64_templates = [t for t in templates if t.endswith(suffix)]
    if verbose:
        print "base64 templates: %s" % b64_templates
    for template in b64_templates:
        if verbose:
            print "decoding %s" % template
        filename = it.target / template
        encoded_data = filename.bytes()
        decoded_data = base64.b64decode(encoded_data)
        truncate_position = - len(suffix)
        new_filename = path(filename[:truncate_position])
        new_filename.write_bytes(decoded_data)
        if verbose:
            print "Created %s" % new_filename
        if removefiles:
            if verbose:
                print "Removing %s" % filename
            filename.remove()
    # set the trait back
    it.set_trait(current_trait)
开发者ID:joelsefus,项目名称:paella,代码行数:29,代码来源:template-root-slash-site-slash-PaellaInstall-slash-General.py


示例19: 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))))
开发者ID:BackupTheBerlios,项目名称:paella-svn,代码行数:25,代码来源:trait.py


示例20: import_machine

 def import_machine(self, dirname):
     dirname = path(dirname)
     current_machine = self.current_machine
     parser = self._parse_machine_xml(dirname)
     machine = parser.machine
     imported_machines = self.get_machine_list()
     if machine.parent is not None:
         if machine.parent not in imported_machines:
             raise UnbornError, "%s not imported yet." % machine.parent
     self.make_a_machine(machine.name)
     self.set_machine(machine.name)
     # attributes - these will fail with foreign key
     # errors if they're not present in the database
     self.set_profile(machine.profile)
     self.set_kernel(machine.kernel)
     self.set_diskconfig(machine.diskconfig)
     if machine.parent is not None:
         self.set_parent(machine.parent)
     for family in machine.families:
         print "import family", family
         self.relation.family.append_family(family)
     for scriptname in machine.scripts:
         script_filename ='script-%s' % scriptname
         script_filename = dirname / script_filename
         print "import script", scriptname, script_filename
         self.relation.scripts.insert_script(scriptname, file(script_filename))
     for trait, name, value in machine.variables:
         print "import machine_variable -> %s" % str(tuple((trait, name, value)))
         self.relation.environment.append_variable(trait, name, value)
     # all done, set machine back to what it was,
     # unless it wasn't set in the first place, then
     # it remains set to what was just imported
     if current_machine is not None:
         self.set_machine(current_machine)
开发者ID:joelsefus,项目名称:paella,代码行数:34,代码来源:main.py



注:本文中的useless.base.path.path函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python util.makepaths函数代码示例发布时间:2022-05-27
下一篇:
Python util.get_string函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap