Example #1
0
def update(context, service, indicator):
    ws_url = serveistic_config().ws_indicadors_endpoint
    ws_key = serveistic_config().ws_indicadors_key
    registry = get_registry(context)

    reporter = WebServiceReporter(ws_url, ws_key)
    reporter.report(get_data_to_report(registry, service, indicator))
Example #2
0
def update(context, service, indicator):
    ws_url = serveistic_config().ws_indicadors_endpoint
    ws_key = serveistic_config().ws_indicadors_key
    registry = get_registry(context)

    reporter = WebServiceReporter(ws_url, ws_key)
    reporter.report(get_data_to_report(registry, service, indicator))
Example #3
0
 def _get_reporter(self):
     try:
         return GoogleAnalyticsReporter(
             json.loads(serveistic_config().ga_key_json))
     except (TypeError, ValueError) as e:
         raise CalculatorException("Invalid GA JSON key ({0})".format(e))
     except GoogleAnalyticsReporterException as e:
         raise CalculatorException(
             "Cannot instantiate GA reporter ({0})".format(e))
Example #4
0
 def _get_reporter(self):
     try:
         return GoogleAnalyticsReporter(
             json.loads(serveistic_config().ga_key_json))
     except (TypeError, ValueError) as e:
         raise CalculatorException(
             "Invalid GA JSON key ({0})".format(e))
     except GoogleAnalyticsReporterException as e:
         raise CalculatorException(
             "Cannot instantiate GA reporter ({0})".format(e))
Example #5
0
def update_indicators_on_serveitic_review_state_change(obj, event):
    try:
        update_indicators(obj,
                          service=serveistic_config().ws_indicadors_service_id,
                          indicator='servei-n',
                          after_commit=True)
        logger.info("Indicators were successfully reported")
    except RegistryException as e:
        logger.warning(
            "Error while loading indicator registry ({0})".format(e))
    except ReporterException as e:
        logger.warning("Error while reporting indicators ({0})".format(e))
Example #6
0
def update_indicators_on_serveitic_deletion(obj, event):
    try:
        update_indicators_if_state(
            obj, ('published', ),
            service=serveistic_config().ws_indicadors_service_id,
            indicator='servei-n')
        logger.info("Indicators were successfully reported")
    except RegistryException as e:
        logger.warning(
            "Error while loading indicator registry ({0})".format(e))
    except ReporterException as e:
        logger.warning("Error while reporting indicators ({0})".format(e))
 def render(self):
     if not self._is_authorised():
         self._set_unauthorised_response()
         return
     try:
         for indicator in ('visita-n-data_mes', 'visita-n-data_setmana',
                           'visita-n-data_ahir'):
             update_indicators(
                 self.context,
                 service=serveistic_config().ws_indicadors_service_id,
                 indicator=indicator)
         return "Indicators were successfully reported"
     except (RegistryException, ReporterException) as e:
         self.request.response.setStatus(500)
         logger.warning("Error while reporting indicators ({0})".format(e))
         self.request.response.setBody("Error while reporting indicators")
 def render(self):
     if not self._is_authorised():
         self._set_unauthorised_response()
         return
     try:
         for indicator in (
                 'visita-n-data_mes',
                 'visita-n-data_setmana',
                 'visita-n-data_ahir'):
             update_indicators(
                 self.context,
                 service=serveistic_config().ws_indicadors_service_id,
                 indicator=indicator)
         return "Indicators were successfully reported"
     except (RegistryException, ReporterException) as e:
         self.request.response.setStatus(500)
         logger.warning(
             "Error while reporting indicators ({0})".format(e))
         self.request.response.setBody("Error while reporting indicators")
Example #9
0
 def url_serveistic_servei(self):
     return serveistic_config().url_info_serveistic
 def _is_authorised(self):
     passphrase = serveistic_config().update_indicadors_passphrase
     return self._parse_passphrase() == passphrase
Example #11
0
 def _get_ids(self):
     if serveistic_config().ga_view_id:
         return "ga:{0}".format(serveistic_config().ga_view_id)
     return None
Example #12
0
 def url_serveistic_servei(self):
     return serveistic_config().url_info_serveistic
 def _is_authorised(self):
     passphrase = serveistic_config().update_indicadors_passphrase
     return self._parse_passphrase() == passphrase
Example #14
0
 def _get_ids(self):
     if serveistic_config().ga_view_id:
         return "ga:{0}".format(serveistic_config().ga_view_id)
     return None