예제 #1
0
파일: session.py 프로젝트: maximerobin/Ufwi
 def authenticationFailure(self, failure, context, login):
     # Log the authentiacation failure
     message = exceptionAsUnicode(failure)
     user = context.user
     self.error(context, u'Authentication failure from %s:%s (login "%s"): %s'
         % (user.host, user.port, login, message))
     return False
예제 #2
0
 def sendError(self, err):
     self.writeError(err, "Error on sending data to %s" % self)
     try:
         text = exceptionAsUnicode(err)
         packet = UDPacket(error=text)
         self.sendData(packet)
     except Exception, err:
         self.writeError(err, "Error on sending error to %s" % self)
예제 #3
0
 def load(self):
     if not exists(self.filename):
         return
     try:
         with open(self.filename) as fp:
             xml = etree.parse(fp).getroot()
     except IOError, err:
         raise RulesetError(
             tr('Unable to open the generic links file: %s'),
             exceptionAsUnicode(err))
예제 #4
0
    def success(self, tmp_configuration):
        if self.responsible.has_no_diff() and exists(self.filenames.last_working):
            self.overrideconf(tmp_configuration)
            returnValue([])

        post_apply_errors = []
        try:
            yield self.writeLastWorking()
        except Exception, err:
            self.manager.writeError(err, "Error on saving the new configuration")
            post_apply_errors.append(exceptionAsUnicode(err))
예제 #5
0
 def run(self, tmp_configuration):
     # returned value:
     #  - None         if there is nothing to apply (see apply method)
     #  - []           no error was encountered (see success method)
     #  - [err1, err2] errors were encountered (see rollback method)
     self.journal.log_global(GLOBAL)
     try:
         try:
             yield self.apply()
         except Exception, err:
             yield self.rollback(err)
             errors = [exceptionAsUnicode(err)]
         else:
예제 #6
0
 def encodeError(self, context, err, traceback):
     info = {'type': err.__class__.__name__}
     if isinstance(err, UnicodeException):
         info['format'] = err.format
         info['application'] = err.application
         info['component'] = err.component
         info['error_code'] = err.error_code
         if err.format_arguments:
             info['arguments'] = err.format_arguments
         if err.additionals:
             info['additional'] = err.additionals
     else:
         info['message'] = exceptionAsUnicode(err, add_type=False)
     if traceback and context and context.hasRole("nucentral_debug"):
         info['traceback'] = formatTraceback(traceback)
     return info
예제 #7
0
    def callService(self, args, request):
        context = Context.fromClient(request)
        component_name = None
        service_name = None
        try:
            # Read the arguments
            if len(args) < 3:
                raise CoreError(CORE_CALL_SERVICE_ERROR,
                    tr("callService(cookie, component, service, *args)"
                       " requires at least 3 parameters"))
            cookie, component_name, service_name = args[:3]
            args = args[3:]

            # Validate arguments
            cookie = getUnicode("cookie", cookie, 0, COOKIE_BASE64_LENGTH)
            component_name = getUnicode("component", component_name, 1, 100)
            service_name = getUnicode("service", service_name, 1, 100)

            return self._callService(context, cookie, component_name, service_name, args)
        except SessionError, err:
            self.core.critical("Session error from %s: %s" % (unicode(context.user), exceptionAsUnicode(err)))
            return self.serviceError(err, context, component_name, service_name, display=False)
예제 #8
0
 def _get(self, object, name, value):
     try:
         value = self.getter(object, name, value)
     except Exception, err:
         raise ValueError("Attribute %s.%s error: %s" % (
             object.__class__.__name__, name, exceptionAsUnicode(err)))
예제 #9
0
파일: task.py 프로젝트: maximerobin/Ufwi
 def setError(self, err):
     self.status = exceptionAsUnicode(err)
예제 #10
0
파일: master.py 프로젝트: maximerobin/Ufwi
 def request_failed(self, err, job):
     self.critical("An error occured while I tried to establish connection with slave '%s': %s" % (job.hostname, err.value))
     if job.firewall and (not job.firewall.error or job.firewall.state != Firewall.ERROR):
         job.firewall.state = Firewall.ERROR
         job.firewall.error = exceptionAsUnicode(err.value)
         job.firewall.save()