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


Python log.log_exc函数代码示例

本文整理汇总了Python中voodoo.log.log_exc函数的典型用法代码示例。如果您正苦于以下问题:Python log_exc函数的具体用法?Python log_exc怎么用?Python log_exc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: confirm_resource_disposal

    def confirm_resource_disposal(self, lab_coordaddress, reservation_id, lab_session_id, experiment_instance_id, experiment_response, initial_time, end_time):

        experiment_finished  = True
        information_to_store = None
        time_remaining       = 0.5 # Every half a second by default

        if experiment_response is None or experiment_response == 'ok' or experiment_response == '':
            pass # Default value
        else:
            try:
                response = json.loads(experiment_response)
                experiment_finished   = response.get(FINISH_FINISHED_MESSAGE, experiment_finished)
                time_remaining        = response.get(FINISH_ASK_AGAIN_MESSAGE, time_remaining)
                information_to_store  = response.get(FINISH_DATA_MESSAGE, information_to_store)
            except Exception as e:
                log.log( AbstractCoordinator, log.level.Error, "Could not parse experiment server finishing response: %s; %s" % (e, experiment_response) )
                log.log_exc( AbstractCoordinator, log.level.Warning )

        if not experiment_finished:
            time.sleep(time_remaining)
            # We just ignore the data retrieved, if any, and perform the query again
            self.confirmer.enqueue_free_experiment(lab_coordaddress, reservation_id, lab_session_id, experiment_instance_id)
            return
        else:
            # Otherwise we mark it as finished
            self.post_reservation_data_manager.finish(reservation_id, json.dumps(information_to_store))
            try:
                # and we remove the resource
                # print "AT CONFIRM_RESOURCE_DISPOSAL"
                self._release_resource_instance(experiment_instance_id)
            finally:
                self.finished_store.put(reservation_id, information_to_store, initial_time, end_time)

            # It's done here so it's called often enough
            self.post_reservation_data_manager.clean_expired()
开发者ID:JamesHyunKim,项目名称:weblabdeusto,代码行数:35,代码来源:coordinator.py

示例2: _call_from_coordaddr

    def _call_from_coordaddr(self, *args, **kwargs):
        try:
            servers = self._easy_locator._get_server_from_coordaddr(self._other_coord, server_type, self._how_many)
        except LocatorErrors.NoServerFoundError:
            log.log( EasyLocator, log.level.Error, "Can't get %s servers! Error in get_server_from_coordaddr " % server_type)
            raise LocatorErrors.UnableToCompleteOperationError(
                    "Couldn't connect to %s" % server_type
                )

        tested = 0
        for server in servers:
            tested += 1
            try:
                return getattr(server, method)(*args, **kwargs)
            except ProtocolErrors.RemoteError:
                log.log(
                    EasyLocator,
                    log.level.Warning,
                    "%s failed in reserve_session" % server_type
                )
                log.log_exc( EasyLocator, log.level.Warning )
                self._easy_locator.inform_server_not_working(
                        server,
                        server_type,
                        ()
                    )

        log.log( EasyLocator, log.level.Error, "Can't get a %s server! Error in get_server after testing %s servers " % (server_type, tested))
        raise LocatorErrors.UnableToCompleteOperationError(
                "Couldn't connect to any %s" % server_type
            )
开发者ID:arobles1980,项目名称:weblabdeusto,代码行数:31,代码来源:EasyLocator.py

示例3: _get_server_from_coordinator

 def _get_server_from_coordinator(self, session_id):
     try:
         return self._coordinator.get_server(session_id)
     except CoordinatorServerErrors.NoServerFoundError as nsfe:
         raise nsfe
     except ProtocolErrors.ProtocolError as pe:
         log.log(
                 ServerLocator,
                 log.level.Error,
                 "Problem while asking for other server to the coordinator server. %s" % pe
             )
         log.log_exc(
                 ServerLocator,
                 log.level.Warning
             )
         raise LocatorErrors.ProblemCommunicatingWithCoordinatorError(
                 "Couldn't ask for other server to coordinator server: " + str(pe),
                 pe
             )
     except Exception as e:
         log.log(
                 ServerLocator,
                 log.level.Error,
                 "Unexpected exception while asking for other server to the coordinator server. %s" % e
             )
         log.log_exc(
                 ServerLocator,
                 log.level.Warning
             )
         raise LocatorErrors.ProblemCommunicatingWithCoordinatorError(
                 "Unexpected exception while asking for other server to the coordinator server: " + str(e),
                 e
             )
开发者ID:arobles1980,项目名称:weblabdeusto,代码行数:33,代码来源:ServerLocator.py

示例4: _free_experiment

    def _free_experiment(self, lab_session_id):
        if not self._session_manager.has_session(lab_session_id):
            return

        session = self._session_manager.get_session_locking(lab_session_id)
        finished = True
        experiment_response = None
        try:
            # Remove the async requests whose results we have not retrieved.
            # It seems that they might still be running when free gets called.
            # TODO: Consider possible issues.
            session_id = session['session_id']
            if session_id in self._async_requests:
                del self._async_requests[session_id]

            experiment_instance_id = session['experiment_instance_id']
            try:
                experiment_response = self._free_experiment_from_assigned_experiments(experiment_instance_id, lab_session_id)
            except Exception as e:
                log.log( LaboratoryServer, log.level.Error, "Exception freeing experiment" % e )
                log.log_exc(LaboratoryServer, log.level.Error)
                experiment_response = ''

            if experiment_response is not None and experiment_response.lower() != 'ok' and experiment_response != '':
                try:
                    response = json.loads(experiment_response)
                    finished = response.get(Coordinator.FINISH_FINISHED_MESSAGE)
                except:
                    traceback.print_exc()
        finally:
            if finished:
                self._session_manager.delete_session_unlocking(lab_session_id)
            else:
                self._session_manager.modify_session_unlocking(lab_session_id, session)
            return experiment_response
开发者ID:zstars,项目名称:weblabdeusto,代码行数:35,代码来源:server.py

示例5: _iterate

    def _iterate(self, element):
        elements = [element]
        while True:
            try:
                new_element = self.queue.get_nowait()
                elements.append(new_element)
            except Queue.Empty:
                break

        if not self.stopped:
            execute = True
            with self.period_lock:
                if time.time() - self._latest_update <= self.next_period_between_updates:
                    execute = False
                else:
                    self._latest_update = time.time()
                    self._update_period_between_updates()

            if execute:
                try:
                    self.scheduler.update()
                except:
                    log.log(SchedulerTransactionsSynchronizer, log.level.Critical, "Exception updating scheduler")
                    log.log_exc(SchedulerTransactionsSynchronizer, log.level.Critical)


        self._notify_elements(elements)
开发者ID:arobles1980,项目名称:weblabdeusto,代码行数:27,代码来源:scheduler_transactions_synchronizer.py

示例6: _test_server

    def _test_server(self,server,address):
        """ _test_server(self,server,address) -> bool

        It returns True (if we could perform a call to "test_me"), or False (if we couldn't)
        """
        # Check if the server is up and running
        try:
            random_msg = str(random.random())
            result_msg = server.test_me(random_msg)
            if random_msg != result_msg:
                # This was not a valid server, try another
                log.log(
                    ServerLocator,
                    log.level.Warning,
                    "Test message received from server %s different from the message sent (%s vs %s). Trying another server" %(
                        address.address,
                        random_msg,
                        result_msg
                    )
                )
                return False
        except Exception as e:
            #There was a exception: this is not a valid server, try another
            log.log(
                ServerLocator,
                log.level.Warning,
                "Testing server %s raised exception %s. Trying another server" % (
                    address.address,
                    e
                )
            )
            log.log_exc(ServerLocator, log.level.Info)
            return False
        else:
            return True
开发者ID:arobles1980,项目名称:weblabdeusto,代码行数:35,代码来源:ServerLocator.py

示例7: _retrieve_all_servers_from_coordinator

    def _retrieve_all_servers_from_coordinator(self,original_server_address,server_type,restrictions):
        try:
            return self._coordinator.get_all_servers(original_server_address,server_type,restrictions)
        except ProtocolErrors.ProtocolError as pe:
            # TODO: not unittested
            log.log(
                    ServerLocator,
                    log.level.Error,
                    "Problem while asking for all servers to the coordinator server. %s" % pe
                )
            log.log_exc(
                    ServerLocator,
                    log.level.Warning
                )

            raise LocatorErrors.ProblemCommunicatingWithCoordinatorError(
                    "Couldn't retrieve all servers from coordinator server: " + str(pe),
                    pe
                )
        except Exception as e:
            # TODO: not unittested
            log.log(
                    ServerLocator,
                    log.level.Error,
                    "Unexpected exception while asking for all servers to the coordinator server. %s" % e
                )
            log.log_exc(
                    ServerLocator,
                    log.level.Warning
                )

            raise LocatorErrors.ProblemCommunicatingWithCoordinatorError(
                    "Unexpected exception while asking all servers from coordinator server: " + str(e),
                    e
                )
开发者ID:arobles1980,项目名称:weblabdeusto,代码行数:35,代码来源:ServerLocator.py

示例8: wrapper

    def wrapper(*args, **kwargs):
        try:
            for _ in xrange(10):
                try:
                    return func(*args, **kwargs)
                except OperationalError as oe:
                    # XXX MySQL dependent!!!
                    if oe.orig.args[0] == 1213:
                        log.log(
                            PriorityQueueScheduler, log.level.Error,
                            "Deadlock found, restarting...%s" % func.__name__ )
                        log.log_exc(PriorityQueueScheduler, log.level.Warning)
                        continue
                    else:
                        raise
        except:
            if DEBUG:
                print("Error in exc_checker: ", sys.exc_info())
            log.log(
                PriorityQueueScheduler, log.level.Error,
                "Unexpected exception while running %s" % func.__name__ )
            log.log_exc(PriorityQueueScheduler, log.level.Warning)
            raise
	wrapper.__name__ = func.__name__
	wrapper.__doc__ = func.__doc__
开发者ID:Kiolali,项目名称:weblabdeusto,代码行数:25,代码来源:priority_queue_scheduler.py

示例9: run

    def run(self):
        try:
            try:
                self.result = self._func(
                    self._self,
                    *self._args,
                    **self._kargs
                )
                self.finished_ok = True
            finally:
                if self._resource_manager != None:
                    self._resource_manager.remove_resource(self)
        except Exception as e:
            self.raised_exc = e
            if self.logging:
                log.log(
                    _ThreadedFunc,
                    log.level.Warning,
                    "threaded: exception caught while running %s: %s" % (
                            self._func.__name__,
                            e
                        )
                )
                log.log_exc( _ThreadedFunc, log.level.Warning)

            sio = StringIO.StringIO()
            traceback.print_exc(file=sio)
            self.raised_exc_traceback = sio.getvalue()
开发者ID:JamesHyunKim,项目名称:weblabdeusto,代码行数:28,代码来源:threaded.py

示例10: _program_file_t

    def _program_file_t(self, file_content):
        """
        Running in its own thread, this method will program the board
        while updating the state of the experiment appropriately.
        """
        try:
            start_time = time.time()  # To track the time it takes
            self._current_state = STATE_PROGRAMMING
            self._program_file(file_content)
            self._current_state = STATE_READY
            elapsed = time.time() - start_time  # Calculate the time the programming process took

            # Remember when real usage starts, so that we can enforce use-time specific limits.
            self._use_time_start = time.time()
            if DEBUG:
                print "[DBG]: STATE became STATE_READY. UseTimeStart = %s." % self._use_time_start

            # If we are in adaptive mode, change the programming time appropriately.
            # TODO: Consider limiting the variation range to dampen anomalies.
            if self._adaptive_time:
                self._programmer_time = elapsed
        except Exception as e:
            # Note: Currently, running the fake xilinx will raise this exception when
            # trying to do a CleanInputs, for which apparently serial is needed.
            self._current_state = STATE_FAILED
            log.log(UdXilinxExperiment, log.level.Warning, "Error programming file: " + str(e))
            log.log_exc(UdXilinxExperiment, log.level.Warning)
开发者ID:JamesHyunKim,项目名称:weblabdeusto,代码行数:27,代码来源:server.py

示例11: _program_file

    def _program_file(self, file_content):
        try:
            fd, file_name = tempfile.mkstemp(
                prefix="ud_xilinx_experiment_program", suffix="." + self._xilinx_impact.get_suffix()
            )
            try:
                try:
                    # TODO: encode? utf8?
                    if isinstance(file_content, unicode):
                        file_content_encoded = file_content.encode("utf8")
                    else:
                        file_content_encoded = file_content
                    file_content_recovered = ExperimentUtil.deserialize(file_content_encoded)
                    os.write(fd, file_content_recovered)
                finally:
                    os.close(fd)
                self._programmer.program(file_name)
            finally:
                os.remove(file_name)
                # print file_name
                # import sys
                # sys.stdout.flush()
        except Exception as e:

            # TODO: test me
            log.log(UdXilinxExperiment, log.level.Info, "Exception joining sending program to device: %s" % e.args[0])
            log.log_exc(UdXilinxExperiment, log.level.Debug)
            raise ExperimentErrors.SendingFileFailureError("Error sending file to device: %s" % e)
        self._clear()
开发者ID:JamesHyunKim,项目名称:weblabdeusto,代码行数:29,代码来源:server.py

示例12: run

    def run(self):
        while not self.stopping:
            try:
                sleep(1)
                if self.frequency is None:
                    continue
                # Here self.frequency is configured, so wait the rest of the required time
                if self.frequency > 1:
                    sleep(self.frequency - 1)

                if self.stopping:
                    break

                if self.coordinator is None:
                    continue

                coordinator = self.coordinator()
                if coordinator is None or coordinator.locator is None:
                    continue # coordinator not configured yet
                checker = self.Checker(coordinator)
                checker.check()
            except Exception as e:
                log.log(ResourcesCheckerThread, log.level.Critical,
                    "Exception checking resources: %s" % e )
                log.log_exc(ResourcesCheckerThread, log.level.Error)
开发者ID:arobles1980,项目名称:weblabdeusto,代码行数:25,代码来源:checker_threaded.py

示例13: create_external_user

    def create_external_user(self, external_user, external_id, system, group_names):
        session = self.Session()
        try:
            try:
                auth_type = session.query(model.DbAuthType).filter_by(name=system).one()
                auth = auth_type.auths[0]
            except (NoResultFound, KeyError):
                raise DbErrors.DbUserNotFoundError("System '%s' not found in database" % system)

            groups = []
            for group_name in group_names:
                try:
                    group = session.query(model.DbGroup).filter_by(name=group_name).one()
                except NoResultFound:
                    raise DbErrors.DbUserNotFoundError("Group '%s' not found in database" % group_name)
                groups.append(group)

            try:
                role = session.query(model.DbRole).filter_by(name=external_user.role.name).one()
                user = model.DbUser(external_user.login, external_user.full_name, external_user.email, role = role)
                user_auth = model.DbUserAuth(user, auth, configuration = external_id)
                for group in groups:
                    group.users.append(user)
                session.add(user)
                session.add(user_auth)
                session.commit()
            except Exception as e:
                log.log( DatabaseGateway, log.level.Warning, "Couldn't create user: %s" % e)
                log.log_exc(DatabaseGateway, log.level.Info)
                raise DbErrors.DatabaseError("Couldn't create user! Contact administrator")
        finally:
            session.close()
开发者ID:zstars,项目名称:weblabdeusto,代码行数:32,代码来源:db.py

示例14: _send_async_command_t

    def _send_async_command_t(self, session, command):
        """
        This method is used for asynchronously calling the experiment server's
        send_command_to_device, and for that purpose runs on its own thread.
        This implies that its response will arrive asynchronously to the client.
        """
        
        lab_session_id = session['session_id']
        experiment_instance_id = session['experiment_instance_id']
        api = self._assigned_experiments.get_api(experiment_instance_id)
        
        experiment_coord_address = session['experiment_coord_address']
        experiment_server = self._locator[experiment_coord_address]

        try:
            if api.endswith("concurrent"):
                response = experiment_server.send_command_to_device(lab_session_id, command.get_command_string())
            else:
                response = experiment_server.send_command_to_device(command.get_command_string())
        except Exception as e:
            log.log( LaboratoryServer, log.level.Warning, "Exception sending async command to experiment: %s" % e )
            log.log_exc(LaboratoryServer, log.level.Info)
            raise LaboratoryErrors.FailedToSendCommandError("Couldn't send async command: %s" % str(e))

        return Command.Command(str(response))
开发者ID:zstars,项目名称:weblabdeusto,代码行数:25,代码来源:server.py

示例15: _skeleton

 def _skeleton(self, *parameters, **kparameters):
     """ Dynamically generated method. Protocol: BaseSocket.
          Method name: METHOD_NAME. Documentation: DOCUMENTATION """
     try:
         return getattr(self._parent, "do_" + METHOD_NAME)(*parameters, **kparameters)
     except Exception:
         # TODO: watch out, if server gets a Control + C, the exception is going to propagate
         log.log_exc(self, log.level.Info)
         raise
开发者ID:slok,项目名称:weblabdeusto,代码行数:9,代码来源:ServerBaseSocket.py


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