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


Python Database.delete_processing_task方法代码示例

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


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

示例1: instance

# 需要导入模块: from lib.cuckoo.core.database import Database [as 别名]
# 或者: from lib.cuckoo.core.database.Database import delete_processing_task [as 别名]
def instance(instance):
    maxcount = cfg.cuckoo.max_analysis_count
    count = 0
    db = Database()

    try:
        while not maxcount or count != maxcount:
            if maxcount:
                limit = min(maxcount - count, 32)
            else:
                limit = 32

            tps = db.list_processing_tasks(instance=instance, count=limit)

            # No new tasks, we can wait a small while before we query again
            # for new tasks.
            if not tps:
                # Just make sure this instance is still available - it is not
                # if the scheduler has been restarted. In that case there will
                # be no records at all for this processing task.
                if not db.count_processing_tasks(instance):
                    log.info("This instance (%s) is not available anymore, "
                             "stopping.", instance)
                    break

                time.sleep(1)
                continue

            for tp in tps:
                task = db.view_task(tp.task_id)
                if task.status != TASK_COMPLETED:
                    log.warning("Task #%d: status (%s) is not completed, "
                                "ignoring", task.id, task.status)
                    continue

                log.info("Task #%d: reporting task", task.id)

                if task.category == "file":
                    sample = db.view_sample(task.sample_id)

                    copy_path = os.path.join(CUCKOO_ROOT, "storage",
                                             "binaries", sample.sha256)
                else:
                    copy_path = None

                try:
                    process(task.target, copy_path, task=task.to_dict(),
                            report=True, auto=True)
                    db.set_status(task.id, TASK_REPORTED)
                except Exception as e:
                    log.exception("Task #%d: error reporting: %s", task.id, e)
                    db.set_status(task.id, TASK_FAILED_PROCESSING)

                db.delete_processing_task(tp)
    except KeyboardInterrupt:
        raise
    except Exception as e:
        log.exception("Caught unknown exception: %s", e)
开发者ID:LittleHann,项目名称:cuckoo-linux,代码行数:60,代码来源:process2.py

示例2: main

# 需要导入模块: from lib.cuckoo.core.database import Database [as 别名]
# 或者: from lib.cuckoo.core.database.Database import delete_processing_task [as 别名]
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("instance", type=str, help="Task processing instance.")
    parser.add_argument("-d", "--debug", help="Display debug messages", action="store_true", required=False)
    parser.add_argument("-u", "--user", type=str, help="Drop user privileges to this user")
    parser.add_argument("-m", "--modules", help="Path to signature and reporting modules - overrides default modules path.", type=str, required=False)
    args = parser.parse_args()

    if args.user:
        drop_privileges(args.user)

    if args.debug:
        log.setLevel(logging.DEBUG)

    if args.modules:
        sys.path.insert(0, args.modules)

    init_modules()

    db = Database()

    if args.instance == "scheduler":
        # When restarting the scheduler, we first stop all currently running
        # nodes, so to reset the state. This will then stop the instances and
        # they will be restarted by Upstart.
        for tp in db.list_processing_tasks(None, 128):
            db.delete_processing_task(tp)

        scheduler()
    else:
        # Register this instance.
        tp = TaskProcessing(None, args.instance)
        Database().add_processing_task(tp)

        try:
            # Run the instance.
            instance(args.instance)
        except Exception as e:
            log.exception("Keyboard Interrupt? -> %s", e)

        # Unregister the instance.
        Database().delete_processing_task(tp)
开发者ID:LittleHann,项目名称:cuckoo-linux,代码行数:44,代码来源:process2.py


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