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

Python utils.ensure_dir函数代码示例

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

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



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

示例1: __init__

    def __init__(
        self,
        conf,
        uuid,
        namespace=None,
        service=None,
        pids_path=None,
        default_cmd_callback=None,
        cmd_addl_env=None,
        pid_file=None,
        run_as_root=False,
    ):

        self.conf = conf
        self.uuid = uuid
        self.namespace = namespace
        self.default_cmd_callback = default_cmd_callback
        self.cmd_addl_env = cmd_addl_env
        self.pids_path = pids_path or self.conf.external_pids
        self.pid_file = pid_file
        self.run_as_root = run_as_root

        if service:
            self.service_pid_fname = "pid." + service
            self.service = service
        else:
            self.service_pid_fname = "pid"
            self.service = "default-service"

        common_utils.ensure_dir(os.path.dirname(self.get_pid_file_name()))
开发者ID:punithks,项目名称:neutron,代码行数:30,代码来源:external_process.py


示例2: initialize_map

 def initialize_map(self):
     # Create a default table if one is not already found
     self.etc.create()
     utils.ensure_dir(os.path.dirname(self._rt_tables_filename))
     if not os.path.exists(self._rt_tables_filename):
         self._write_map(self.DEFAULT_TABLES)
     self._keep = set()
开发者ID:TonyChengTW,项目名称:OpenStack_Liberty_Control,代码行数:7,代码来源:rt_tables.py


示例3: _check_bootstrap_new_branch

def _check_bootstrap_new_branch(branch, version_path, addn_kwargs):
    addn_kwargs['version_path'] = version_path
    addn_kwargs['head'] = _get_branch_head(branch)
    if not os.path.exists(version_path):
        # Bootstrap initial directory structure
        utils.ensure_dir(version_path)
        addn_kwargs['branch_label'] = branch
开发者ID:swdream,项目名称:neutron,代码行数:7,代码来源:cli.py


示例4: __init__

 def __init__(self, conf, network, process_monitor, version=None,
              plugin=None):
     super(DhcpLocalProcess, self).__init__(conf, network, process_monitor,
                                            version, plugin)
     self.confs_dir = self.get_confs_dir(conf)
     self.network_conf_dir = os.path.join(self.confs_dir, network.id)
     commonutils.ensure_dir(self.network_conf_dir)
开发者ID:glove747,项目名称:liberty-neutron,代码行数:7,代码来源:dhcp.py


示例5: do_revision

def do_revision(config, cmd):
    '''Generate new revision files, one per branch.'''
    addn_kwargs = {
        'message': CONF.command.message,
        'autogenerate': CONF.command.autogenerate,
        'sql': CONF.command.sql,
    }

    if _use_separate_migration_branches(config):
        for branch in MIGRATION_BRANCHES:
            version_path = _get_version_branch_path(config, branch)
            addn_kwargs['version_path'] = version_path

            if not os.path.exists(version_path):
                # Bootstrap initial directory structure
                utils.ensure_dir(version_path)
                # Each new release stream of migrations is detached from
                # previous migration chains
                addn_kwargs['head'] = 'base'
                # Mark the very first revision in the new branch with its label
                addn_kwargs['branch_label'] = _get_branch_label(branch)
                # TODO(ihrachyshka): ideally, we would also add depends_on here
                # to refer to the head of the previous release stream. But
                # alembic API does not support it yet.
            else:
                addn_kwargs['head'] = _get_branch_head(branch)

            do_alembic_command(config, cmd, **addn_kwargs)
    else:
        do_alembic_command(config, cmd, **addn_kwargs)
    update_heads_file(config)
开发者ID:Japje,项目名称:neutron,代码行数:31,代码来源:cli.py


示例6: _get_state_file_path

 def _get_state_file_path(self, loadbalancer_id, kind, ensure_state_dir=True):
     """Returns the file name for a given kind of config file."""
     confs_dir = os.path.abspath(os.path.normpath(self.state_path))
     conf_dir = os.path.join(confs_dir, loadbalancer_id)
     if ensure_state_dir:
         n_utils.ensure_dir(conf_dir)
     return os.path.join(conf_dir, kind)
开发者ID:bdrich,项目名称:neutron-lbaas,代码行数:7,代码来源:namespace_driver.py


示例7: _get_conf_base

def _get_conf_base(cfg_root, uuid, ensure_conf_dir):
    #TODO(mangelajo): separate responsibilities here, ensure_conf_dir
    #                 should be a separate function
    conf_dir = os.path.abspath(os.path.normpath(cfg_root))
    conf_base = os.path.join(conf_dir, uuid)
    if ensure_conf_dir:
        utils.ensure_dir(conf_dir)
    return conf_base
开发者ID:davidcusatis,项目名称:neutron,代码行数:8,代码来源:utils.py


示例8: setup_test_logging

def setup_test_logging(config_opts, log_dir, log_file_path_template):
    # Have each test log into its own log file
    config_opts.set_override('debug', True)
    utils.ensure_dir(log_dir)
    log_file = sanitize_log_path(
        os.path.join(log_dir, log_file_path_template))
    config_opts.set_override('log_file', log_file)
    config_opts.set_override('use_stderr', False)
    config.setup_logging()
开发者ID:Jackwwg,项目名称:neutron,代码行数:9,代码来源:base.py


示例9: enable

 def enable(self):
     """Enables DHCP for this network by spawning a local process."""
     if self.active:
         self.restart()
     elif self._enable_dhcp():
         commonutils.ensure_dir(self.network_conf_dir)
         interface_name = self.device_manager.setup(self.network)
         self.interface_name = interface_name
         self.spawn_process()
开发者ID:glove747,项目名称:liberty-neutron,代码行数:9,代码来源:dhcp.py


示例10: start

    def start(self):
        fmt = self.process_name + "--%Y-%m-%d--%H%M%S.log"
        log_dir = os.path.join(DEFAULT_LOG_DIR, self.test_name)
        common_utils.ensure_dir(log_dir)

        cmd = [spawn.find_executable(self.exec_name), "--log-dir", log_dir, "--log-file", timeutils.strtime(fmt=fmt)]
        for filename in self.config_filenames:
            cmd += ["--config-file", filename]
        self.process = async_process.AsyncProcess(cmd)
        self.process.start(block=True)
开发者ID:Raghunanda,项目名称:neutron,代码行数:10,代码来源:fullstack_fixtures.py


示例11: _get_allocations

    def _get_allocations(self):
        utils.ensure_dir(TMP_DIR)

        try:
            with open(self._state_file_path, 'r') as allocations_file:
                contents = allocations_file.read()
        except IOError:
            contents = None

        # If the file was empty, we want to return an empty set, not {''}
        return set(contents.split(',')) if contents else set()
开发者ID:dlevy-ibm,项目名称:neutron,代码行数:11,代码来源:resource_allocator.py


示例12: ensure_directory_exists_without_file

def ensure_directory_exists_without_file(path):
    dirname = os.path.dirname(path)
    if os.path.isdir(dirname):
        try:
            os.unlink(path)
        except OSError:
            with excutils.save_and_reraise_exception() as ctxt:
                if not os.path.exists(path):
                    ctxt.reraise = False
    else:
        utils.ensure_dir(dirname)
开发者ID:davidcusatis,项目名称:neutron,代码行数:11,代码来源:utils.py


示例13: start

    def start(self):
        log_dir = os.path.join(DEFAULT_LOG_DIR, self.test_name)
        common_utils.ensure_dir(log_dir)

        timestamp = datetime.datetime.now().strftime("%Y-%m-%d--%H-%M-%S-%f")
        log_file = "%s--%s.log" % (self.process_name, timestamp)
        cmd = [spawn.find_executable(self.exec_name),
               '--log-dir', log_dir,
               '--log-file', log_file]
        for filename in self.config_filenames:
            cmd += ['--config-file', filename]
        self.process = async_process.AsyncProcess(cmd)
        self.process.start(block=True)
开发者ID:neoareslinux,项目名称:neutron,代码行数:13,代码来源:process.py


示例14: __init__

 def __init__(self, host=None, conf=None):
     super(DhcpAgent, self).__init__(host=host)
     self.needs_resync_reasons = collections.defaultdict(list)
     self.conf = conf or cfg.CONF
     self.cache = NetworkCache()
     self.dhcp_driver_cls = importutils.import_class(self.conf.dhcp_driver)
     ctx = context.get_admin_context_without_session()
     self.plugin_rpc = DhcpPluginApi(topics.PLUGIN, ctx, self.conf.host)
     # create dhcp dir to store dhcp info
     dhcp_dir = os.path.dirname("/%s/dhcp/" % self.conf.state_path)
     utils.ensure_dir(dhcp_dir)
     self.dhcp_version = self.dhcp_driver_cls.check_version()
     self._populate_networks_cache()
     self._process_monitor = external_process.ProcessMonitor(
         config=self.conf,
         resource_type='dhcp')
开发者ID:davidcusatis,项目名称:neutron,代码行数:16,代码来源:agent.py


示例15: start

    def start(self):
        test_name = base.sanitize_log_path(self.test_name)

        log_dir = os.path.join(fullstack_base.DEFAULT_LOG_DIR, test_name)
        common_utils.ensure_dir(log_dir)

        timestamp = datetime.datetime.now().strftime("%Y-%m-%d--%H-%M-%S-%f")
        log_file = "%s--%s.log" % (self.process_name, timestamp)
        cmd = [spawn.find_executable(self.exec_name),
               '--log-dir', log_dir,
               '--log-file', log_file]
        for filename in self.config_filenames:
            cmd += ['--config-file', filename]
        run_as_root = bool(self.namespace)
        self.process = async_process.AsyncProcess(
            cmd, run_as_root=run_as_root, namespace=self.namespace
        )
        self.process.start(block=True)
开发者ID:openstack,项目名称:neutron-fwaas,代码行数:18,代码来源:process.py


示例16: __init__

 def __init__(self, host=None, conf=None):
     super(DhcpAgent, self).__init__(host=host)
     self.needs_resync_reasons = collections.defaultdict(list)
     self.dhcp_ready_ports = set()
     self.conf = conf or cfg.CONF
     self.cache = NetworkCache()
     self.dhcp_driver_cls = importutils.import_class(self.conf.dhcp_driver)
     self.plugin_rpc = DhcpPluginApi(topics.PLUGIN, self.conf.host)
     # create dhcp dir to store dhcp info
     dhcp_dir = os.path.dirname("/%s/dhcp/" % self.conf.state_path)
     utils.ensure_dir(dhcp_dir)
     self.dhcp_version = self.dhcp_driver_cls.check_version()
     self._populate_networks_cache()
     # keep track of mappings between networks and routers for
     # metadata processing
     self._metadata_routers = {}  # {network_id: router_id}
     self._process_monitor = external_process.ProcessMonitor(
         config=self.conf,
         resource_type='dhcp')
开发者ID:gotostack,项目名称:neutron,代码行数:19,代码来源:agent.py


示例17: setUp

    def setUp(self):
        super(BaseSudoTestCase, self).setUp()
        if not base.bool_from_env('OS_SUDO_TESTING'):
            self.skipTest('Testing with sudo is not enabled')

        # Have each test log into its own log file
        cfg.CONF.set_override('debug', True)
        common_utils.ensure_dir(DEFAULT_LOG_DIR)
        log_file = base.sanitize_log_path(
            os.path.join(DEFAULT_LOG_DIR, "%s.log" % self.id()))
        cfg.CONF.set_override('log_file', log_file)
        config.setup_logging()

        config.register_root_helper(cfg.CONF)
        self.config(group='AGENT',
                    root_helper=os.environ.get('OS_ROOTWRAP_CMD', SUDO_CMD))
        self.config(group='AGENT',
                    root_helper_daemon=os.environ.get(
                        'OS_ROOTWRAP_DAEMON_CMD'))
开发者ID:Blahhhhh,项目名称:neutron,代码行数:19,代码来源:base.py


示例18: do_revision

def do_revision(config, cmd):
    """Generate new revision files, one per branch."""
    addn_kwargs = {"message": CONF.command.message, "autogenerate": CONF.command.autogenerate, "sql": CONF.command.sql}

    if _use_separate_migration_branches(config):
        for branch in MIGRATION_BRANCHES:
            version_path = _get_version_branch_path(config, branch)
            addn_kwargs["version_path"] = version_path
            addn_kwargs["head"] = _get_branch_head(branch)

            if not os.path.exists(version_path):
                # Bootstrap initial directory structure
                utils.ensure_dir(version_path)
                # Mark the very first revision in the new branch with its label
                addn_kwargs["branch_label"] = branch

            do_alembic_command(config, cmd, **addn_kwargs)
    else:
        do_alembic_command(config, cmd, **addn_kwargs)
    update_heads_file(config)
开发者ID:neoareslinux,项目名称:neutron,代码行数:20,代码来源:cli.py


示例19: test_ensure_dir_calls_makedirs

 def test_ensure_dir_calls_makedirs(self, makedirs):
     utils.ensure_dir("/etc/create/directory")
     makedirs.assert_called_once_with("/etc/create/directory", 0o755)
开发者ID:cisco-openstack,项目名称:neutron,代码行数:3,代码来源:test_utils.py


示例20: test_ensure_dir_no_fail_if_exists

 def test_ensure_dir_no_fail_if_exists(self, makedirs):
     error = OSError()
     error.errno = errno.EEXIST
     makedirs.side_effect = error
     utils.ensure_dir("/etc/create/concurrently")
开发者ID:cisco-openstack,项目名称:neutron,代码行数:5,代码来源:test_utils.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python utils.fixed_ip_cidrs函数代码示例发布时间:2022-05-27
下一篇:
Python utils.diff_list_of_dict函数代码示例发布时间: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