# -*- coding: utf-8 -*-
# stdlib
import time

# project
import base_reporter


class VersionReporter(base_reporter.BaseReporter):
    """
    上报已经部署应用的类
    """
    def __init__(self, total_task, org, ip, uc_server):
        """
        初始化
        :param report_uri: 如/api/v1/report
        :param total_task: task总数
        :param org: org
        :param ip: 当前ip
        :param uc_server: uc服务器ip:端口
        :return:
        """
        base_reporter.BaseReporter.__init__(self, total_task, org, ip, uc_server)
        self._report_uri = "/api/v1/deploy_version"


    def _format_event(self, start_time, status, msg, data):
        event = {
            "org": self._org,
            "ip": self._ip,
            "startTime": int(start_time),
            "endTime": int(time.time()),
            "status": status,
            "msg": msg,
            "current": self._current_task,
            "total": self._total_task,
            "data": data
        }
        return event
