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


Python Emulator.gather_data方法代码示例

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


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

示例1: scan

# 需要导入模块: from emulator import Emulator [as 别名]
# 或者: from emulator.Emulator import gather_data [as 别名]
def scan(images=True):
    """ scanning method that will scan all images or containers """

    # FIXME using default 'unix://var/run/docker.sock'
    client = docker.Client(base_url='unix://var/run/docker.sock')
    emu = Emulator()

    objs = client.images(quiet=True) 
    driver = client.info()['Driver']

    # If there are no images/containers on the machine, objs will be ['']
    if objs == ['']:
        return

    # does actual work here!
    for im in objs:
        try:

            emu.create_dirs()
            cid = mount_obj(emu.tmp_image_dir, im, driver)

            if emu.is_applicable():
                print "scanning " + im[:12]
                emu.intial_setup()
                emu.chroot_and_run()
                emu.unmount()
            else:
                print im[:12] + " is not RHEL based"

            unmount_obj(emu.tmp_image_dir, cid, driver)
            emu.remove_dirs()


        except MountError as dme:
            force_clean(cid, client, emu)
            print "Red Hat Insights was unable to complete " \
                  "due to the below error. All mounts and devices " \
                  "have been removed."
            raise ValueError(str(dme))
        except EmulatorError as eme:
            force_clean(cid, client, emu)
            print "Red Hat Insights was unable to complete " \
                  "due to the below error. All mounts and devices " \
                  "have been removed."
            raise ValueError(str(eme))

    emu.gather_data()
开发者ID:ajcollins0,项目名称:insights-container,代码行数:49,代码来源:__init__.py

示例2: scan

# 需要导入模块: from emulator import Emulator [as 别名]
# 或者: from emulator.Emulator import gather_data [as 别名]
def scan(images=True):
    """ scanning method that will scan all images or containers """

    client = DockerClient()
    emu = Emulator()

    objs = client.images() if images is True else client.containers()

    # If there are no images/containers on the machine, objs will be ['']
    if objs == ['']:
        return

    # does actual work here!
    for im in objs:
        try:
            emu.create_dirs()
            mount_obj(emu.tmp_image_dir, im, client.info()['Storage Driver'])

            if emu.is_applicable():

                print "scanning " + im[:12]
                emu.intial_setup()

                emu.chroot_and_run()

                emu.unmount()
            else:
                print im[:12] + " is not RHEL based"

            unmount_obj(emu.tmp_image_dir, client.info()['Storage Driver'])
            emu.remove_dirs()

        except MountError as dme:
            raise ValueError(str(dme))

    emu.gather_data(images)
开发者ID:lphiri,项目名称:insights-docker,代码行数:38,代码来源:__init__.py


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