当前位置: 首页>>代码示例>>Python>>正文


Python Project.clean_project_directory方法代码示例

本文整理汇总了Python中gns3server.modules.project.Project.clean_project_directory方法的典型用法代码示例。如果您正苦于以下问题:Python Project.clean_project_directory方法的具体用法?Python Project.clean_project_directory怎么用?Python Project.clean_project_directory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gns3server.modules.project.Project的用法示例。


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

示例1: main

# 需要导入模块: from gns3server.modules.project import Project [as 别名]
# 或者: from gns3server.modules.project.Project import clean_project_directory [as 别名]
def main():
    """
    Entry point for GNS3 server
    """

    level = logging.INFO
    args = parse_arguments(sys.argv[1:], Config.instance().get_section_config("Server"))
    if args.debug:
        level = logging.DEBUG

    user_log = init_logger(level, logfile=args.log, quiet=args.quiet)
    user_log.info("GNS3 server version {}".format(__version__))
    current_year = datetime.date.today().year
    user_log.info("Copyright (c) 2007-{} GNS3 Technologies Inc.".format(current_year))

    for config_file in Config.instance().get_config_files():
        user_log.info("Config file {} loaded".format(config_file))

    set_config(args)
    server_config = Config.instance().get_section_config("Server")
    if server_config.getboolean("local"):
        log.warning("Local mode is enabled. Beware, clients will have full control on your filesystem")

    # we only support Python 3 version >= 3.3
    if sys.version_info < (3, 3):
        raise RuntimeError("Python 3.3 or higher is required")

    user_log.info("Running with Python {major}.{minor}.{micro} and has PID {pid}".format(
                  major=sys.version_info[0], minor=sys.version_info[1],
                  micro=sys.version_info[2], pid=os.getpid()))

    # check for the correct locale (UNIX/Linux only)
    locale_check()

    try:
        os.getcwd()
    except FileNotFoundError:
        log.critical("The current working directory doesn't exist")
        return

    Project.clean_project_directory()

    CrashReport.instance()
    host = server_config["host"]
    port = int(server_config["port"])
    server = Server.instance(host, port)
    try:
        server.run()
    except OSError as e:
        # This is to ignore OSError: [WinError 0] The operation completed successfully exception on Windows.
        if not sys.platform.startswith("win") and not e.winerror == 0:
            raise
    except Exception as e:
        log.critical("Critical error while running the server: {}".format(e), exc_info=1)
        CrashReport.instance().capture_exception()
        return
开发者ID:AshokVardhn,项目名称:gns3-server,代码行数:58,代码来源:main.py

示例2: test_clean_project_directory

# 需要导入模块: from gns3server.modules.project import Project [as 别名]
# 或者: from gns3server.modules.project.Project import clean_project_directory [as 别名]
def test_clean_project_directory(tmpdir):

    # A non anonymous project with uuid.
    project1 = tmpdir / uuid4()
    project1.mkdir()

    # A non anonymous project.
    oldproject = tmpdir / uuid4()
    oldproject.mkdir()

    # an anonymous project
    project2 = tmpdir / uuid4()
    project2.mkdir()
    tmp = (project2 / ".gns3_temporary")
    with open(str(tmp), 'w+') as f:
        f.write("1")

    with patch("gns3server.config.Config.get_section_config", return_value={"project_directory": str(tmpdir)}):
        Project.clean_project_directory()

    assert os.path.exists(str(project1))
    assert os.path.exists(str(oldproject))
    assert not os.path.exists(str(project2))
开发者ID:AshokVardhn,项目名称:gns3-server,代码行数:25,代码来源:test_project.py


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