Exemple #1
0
 def __init__(self, auth_user, auth_pass):
     self.log = LoggerManager().get_new_logger("result publication mail")
     self.rest_api_helper = RestApiHelper(
         auth_user,
         auth_pass,
         http_mail_serializer=PublishResultsVisitorMail.HTTP_MAIL_SERIALIZER
     )
 def __init__(self, auth_user, auth_pass):
     """
     Constructor
     """
     self.log = LoggerManager().get_new_logger("auto correction selection")
     self.rest_api_helper = RestApiHelper(
         auth_user, auth_pass,
         AutomaticCorrectionSelectionStrategyThroughRestApi.
         HTTP_AUTOMATIC_CORRECTION_SERIALIZER)
Exemple #3
0
class PublishResultsVisitorMail(PublishResultsVisitor):
    """
    Implementation of the publishing visitor which posts a mail through the web interface to await sending
    """

    HTTP_MAIL_SERIALIZER = REST_BASE_URL + '/mailserializer/'
    STATUS_STRINGS = {-1: "failed", 0: "pending", 1: "successfull"}
    STATUS_UNKNOWN = 'unknown status'

    def __init__(self, auth_user, auth_pass):
        self.log = LoggerManager().get_new_logger("result publication mail")
        self.rest_api_helper = RestApiHelper(
            auth_user,
            auth_pass,
            http_mail_serializer=PublishResultsVisitorMail.HTTP_MAIL_SERIALIZER
        )

    def get_status(self, status=10):
        """Returns a status raw value as a human readable value"""
        self.log.debug("translating status %d", status)
        try:
            status_string = PublishResultsVisitorMail.STATUS_STRINGS[status]
        except:
            status_string = PublishResultsVisitorMail.STATUS_UNKNOWN
        return status_string

    def build_mail(self, result):
        self.log.debug("building mail...")
        mail = Mail()
        mail.subject = "Resultado de la correccion automatica"
        mail.recipient = result.automatic_correction.user_mail
        exit_value = result.exit_value
        mail.body = "Ejecucion "
        if (exit_value == 0):
            mail.body += "exitosa, trabajo aprobado"
        else:
            mail.body += "fallida, trabajo no aprobado. Puede corregirlo y volver a intentarlo"
        mail.body += ".\n\n"
        return mail

    def visit(self, visitable):
        self.log.debug("publishing results...")
        visitable.automatic_correction.exit_value = visitable.exit_value
        visitable.automatic_correction.captured_stdout = visitable.captured_stdout
        visitable.automatic_correction.status = 1 + (-2 * visitable.exit_value)
        mail = self.build_mail(visitable)
        self.rest_api_helper.save_mail(mail)
        self.log.debug("results published in through mail.")
class AutomaticCorrectionSelectionStrategyThroughRestApi(
        AutomaticCorrectionSelectionStrategy):
    """
    Implementation of the selection strategy that brings the automatic correction information from the rest api
    """

    HTTP_AUTOMATIC_CORRECTION_SERIALIZER = REST_BASE_URL + '/richautomaticcorrectionserializer/'

    def __init__(self, auth_user, auth_pass):
        """
        Constructor
        """
        self.log = LoggerManager().get_new_logger("auto correction selection")
        self.rest_api_helper = RestApiHelper(
            auth_user, auth_pass,
            AutomaticCorrectionSelectionStrategyThroughRestApi.
            HTTP_AUTOMATIC_CORRECTION_SERIALIZER)

    def get_automatic_corrections(self):
        self.log.debug("searching for deliveries with status pending...")
        pending_automatic_corrections = self.rest_api_helper.get_automatic_corrections(
        )
        count = len(pending_automatic_corrections)
        if count > 0:
            self.log.debug("%d deliveries obtained.", count)
        return pending_automatic_corrections
 def __init__(self, auth_user, auth_pass):
     """
     Constructor
     """
     self.log = LoggerManager().get_new_logger("auto correction selection")
     self.rest_api_helper = RestApiHelper(auth_user, auth_pass, 
                                          AutomaticCorrectionSelectionStrategyThroughRestApi.HTTP_AUTOMATIC_CORRECTION_SERIALIZER)
class PublishResultsVisitorMail(PublishResultsVisitor):
    """
    Implementation of the publishing visitor which posts a mail through the web interface to await sending
    """
    
    HTTP_MAIL_SERIALIZER = REST_BASE_URL + '/mailserializer/'
    STATUS_STRINGS = {-1:"failed", 0:"pending", 1:"successfull"}
    STATUS_UNKNOWN = 'unknown status'
    
    def __init__(self, auth_user, auth_pass):
        self.log = LoggerManager().get_new_logger("result publication mail")
        self.rest_api_helper = RestApiHelper(auth_user, auth_pass, 
                                             http_mail_serializer=PublishResultsVisitorMail.HTTP_MAIL_SERIALIZER)
    
    def get_status(self, status=10):
        """Returns a status raw value as a human readable value"""
        self.log.debug("translating status %d", status)
        try:
            status_string = PublishResultsVisitorMail.STATUS_STRINGS[status]
        except:
            status_string = PublishResultsVisitorMail.STATUS_UNKNOWN
        return status_string
    
    def build_mail(self, result):
        self.log.debug("building mail...")
        mail = Mail()
        mail.subject = "Resultado de la correccion automatica"
        mail.recipient = result.automatic_correction.user_mail
        exit_value = result.exit_value
        mail.body = "Ejecucion "
        if(exit_value==0):
            mail.body += "exitosa, trabajo aprobado"
        else:
            mail.body += "fallida, trabajo no aprobado. Puede corregirlo y volver a intentarlo"
        mail.body += ".\n\n"
        return mail
    
    def visit(self, visitable):
        self.log.debug("publishing results...")
        visitable.automatic_correction.exit_value = visitable.exit_value
        visitable.automatic_correction.captured_stdout = visitable.captured_stdout
        visitable.automatic_correction.status = 1 + (-2 * visitable.exit_value)
        mail = self.build_mail(visitable)
        self.rest_api_helper.save_mail(mail)
        self.log.debug("results published in through mail.")
class PublishResultsVisitorWeb(PublishResultsVisitor):
    """
    
    This is the visitor in charge of publishing the results to the web.
    
    """
    
    HTTP_MAIL_SERIALIZER = REST_BASE_URL + '/automaticcorrectionserializer/'
    
    def __init__(self, auth_user, auth_pass):
        self.log = LoggerManager().get_new_logger("result publication")
        self.rest_api_helper = RestApiHelper(auth_user, auth_pass, PublishResultsVisitorWeb.HTTP_MAIL_SERIALIZER)
    
    def visit(self, visitable):
        self.log.debug("publishing results...")
        visitable.automatic_correction.exit_value = visitable.exit_value
        visitable.automatic_correction.captured_stdout = visitable.captured_stdout
        visitable.automatic_correction.status = 1 + (-2 * visitable.exit_value)
        self.rest_api_helper.save_automatic_correction(visitable.automatic_correction)
        self.log.debug("results published in through the web interface.")
Exemple #8
0
class PublishResultsVisitorWeb(PublishResultsVisitor):
    """
    
    This is the visitor in charge of publishing the results to the web.
    
    """

    HTTP_MAIL_SERIALIZER = REST_BASE_URL + '/automaticcorrectionserializer/'

    def __init__(self, auth_user, auth_pass):
        self.log = LoggerManager().get_new_logger("result publication")
        self.rest_api_helper = RestApiHelper(
            auth_user, auth_pass,
            PublishResultsVisitorWeb.HTTP_MAIL_SERIALIZER)

    def visit(self, visitable):
        self.log.debug("publishing results...")
        visitable.automatic_correction.exit_value = visitable.exit_value
        visitable.automatic_correction.captured_stdout = visitable.captured_stdout
        visitable.automatic_correction.status = 1 + (-2 * visitable.exit_value)
        self.rest_api_helper.save_automatic_correction(
            visitable.automatic_correction)
        self.log.debug("results published in through the web interface.")
class AutomaticCorrectionSelectionStrategyThroughRestApi(AutomaticCorrectionSelectionStrategy):
    """
    Implementation of the selection strategy that brings the automatic correction information from the rest api
    """
    
    HTTP_AUTOMATIC_CORRECTION_SERIALIZER = REST_BASE_URL + '/richautomaticcorrectionserializer/'
    
    def __init__(self, auth_user, auth_pass):
        """
        Constructor
        """
        self.log = LoggerManager().get_new_logger("auto correction selection")
        self.rest_api_helper = RestApiHelper(auth_user, auth_pass, 
                                             AutomaticCorrectionSelectionStrategyThroughRestApi.HTTP_AUTOMATIC_CORRECTION_SERIALIZER)
    
    def get_automatic_corrections(self):
        self.log.debug("searching for deliveries with status pending...")
        pending_automatic_corrections = self.rest_api_helper.get_automatic_corrections()
        count = len(pending_automatic_corrections)
        if count > 0:
            self.log.debug("%d deliveries obtained.", count)
        return pending_automatic_corrections
 def __init__(self, auth_user, auth_pass):
     self.log = LoggerManager().get_new_logger("result publication")
     self.rest_api_helper = RestApiHelper(auth_user, auth_pass, PublishResultsVisitorWeb.HTTP_MAIL_SERIALIZER)
 def __init__(self, auth_user, auth_pass):
     self.log = LoggerManager().get_new_logger("result publication mail")
     self.rest_api_helper = RestApiHelper(auth_user, auth_pass, 
                                          http_mail_serializer=PublishResultsVisitorMail.HTTP_MAIL_SERIALIZER)
Exemple #12
0
 def __init__(self, auth_user, auth_pass):
     self.log = LoggerManager().get_new_logger("result publication")
     self.rest_api_helper = RestApiHelper(
         auth_user, auth_pass,
         PublishResultsVisitorWeb.HTTP_MAIL_SERIALIZER)