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


Python Service.delete方法代码示例

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


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

示例1: main

# 需要导入模块: from service import Service [as 别名]
# 或者: from service.Service import delete [as 别名]
def main(queue_results, queue_errors):
    log.info("Starting with process ID %d", os.getpid())

    # Check if the user is an Administrator.
    # If not, quit with an error message.
    if not shell.IsUserAnAdmin():
        log.error("The user is not an Administrator, aborting")
        queue_errors.put('NOT_AN_ADMIN')
        return

    # Generate configuration values.
    cfg = Config()

    # Check if this is a supported version of Windows and if so, obtain the
    # volatility profile name.
    cfg.get_profile_name()
    if not cfg.profile:
        log.error("Unsupported version of Windows, can't select a profile")
        queue_errors.put('UNSUPPORTED_WINDOWS')
        return

    log.info("Selected Profile Name: {0}".format(cfg.profile))

    # Obtain the path to the driver to load. At this point, this check should
    # not fail, but you never know.
    if not cfg.get_driver_path():
        log.error("Unable to find a proper winpmem driver")
        queue_errors.put('NO_DRIVER')
        return

    log.info("Selected Driver: {0}".format(cfg.driver))

    # This is the ugliest black magic ever, but somehow helps.
    # Just tries to brutally destroy the winpmem service if there is one
    # lying around before trying to launch a new one again.
    destroyer = threading.Thread(target=destroy, args=(cfg.driver, cfg.service_name))
    destroyer.start()
    destroyer.join()

    # Initialize the winpmem service.
    try:
        service = Service(driver=cfg.driver, service=cfg.service_name)
        service.create()
        service.start()
    except DetectorError as e:
        log.critical("Unable to start winpmem service: %s", e)
        queue_errors.put('SERVICE_NO_START')
        return
    else:
        log.info("Service started")

    # Launch the scanner.
    try:
        scan(cfg.service_path, cfg.profile, queue_results)
    except DetectorError as e:
        log.critical("Yara scanning failed: %s", e)
        queue_errors.put('SCAN_FAILED')
    else:
        log.info("Scanning finished")

    # Stop the winpmem service and unload the driver. At this point we should
    # have cleaned up everything left on the system.
    try:
        service.stop()
        service.delete()
    except DetectorError as e:
        log.error("Unable to stop winpmem service: %s", e)
    else:
        log.info("Service stopped")

    log.info("Analysis finished")
开发者ID:RoeeM,项目名称:detekt,代码行数:73,代码来源:detector.py

示例2: ServiceGroup

# 需要导入模块: from service import Service [as 别名]
# 或者: from service.Service import delete [as 别名]
    py_dict = {'display_name': 'Service-1', 'value': '1234', \
               'application_protocol': 'TCP', 'source_port': '2345'}
    result_objs = base_client.bulk_create(service_client_1, [py_dict])
    print "Create Service Status code: %s" % result_objs[0].status_code
    print "Service id: %s" % service_client_1.id

    #Create composite service group for testing
    composite_service_group_client = ServiceGroup(neutron=neutron_object)
    py_dict = {'display_name': 'Composite Service Group - 1', 'description': 'SG Description'}
    result_objs = base_client.bulk_create(composite_service_group_client, [py_dict])
    print "Create ServiceGroup Status code: %s" % result_objs[0].status_code
    print "ServiceGroup id: %s" % composite_service_group_client.id

    #Add Service-1 to Composite Service Group
    service_group_member_1 = ServiceGroupMember(composite_service_group_client)
    py_dict = {'_member_id': service_client_1.id}
    result_objs = base_client.bulk_create(service_group_member_1, [py_dict])
    print "Add Service to Composite Service Group Status code: %s" % result_objs[0].status_code

    #Delete Service-1 from Composite Service Group
    response_status = service_group_member_1.delete()
    print "Delete service from CompositeServiceGroup result response: %s" % \
          response_status.status_code

    #Delete composite service group
    response_status = composite_service_group_client.delete()
    print "Delete Composite Service Group result response: %s" % response_status.status_code

    #Delete service-1
    response_status = service_client_1.delete()
    print "Delete service result response: %s" % response_status.status_code
开发者ID:carriercomm,项目名称:MyProject,代码行数:33,代码来源:servicegroupmember.py


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