本文整理汇总了Python中voodoo.log.log_exc函数的典型用法代码示例。如果您正苦于以下问题:Python log_exc函数的具体用法?Python log_exc怎么用?Python log_exc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了log_exc函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: run
def run(self):
while self.keep_running:
try:
self.iterations += 1
self.iterate()
except:
if self.PRINT_ERRORS:
import traceback
traceback.print_exc()
log.log( TemporalInformationRetriever, log.level.Critical, "Exception iterating in TemporalInformationRetriever!!!")
log.log_exc( TemporalInformationRetriever, log.level.Critical )
开发者ID:zstars,项目名称:weblabdeusto,代码行数:11,代码来源:data_retriever.py
示例17: _process
def _process(self):
redis_client = self.redis_maker()
pending_results = []
for reservation_id in redis_client.hkeys(self.external_weblabdeusto_pending):
pending_result_str = redis_client.hget(self.external_weblabdeusto_pending, reservation_id)
if pending_result_str is not None:
pending_result = json.loads(pending_result_str)
pending_result['reservation_id'] = reservation_id
pending_results.append(pending_result)
if len(pending_results) > 0:
try:
session_id, client = self.create_client_func(None)
except urllib2.URLError:
# Remote server is down, try later
return
remote_reservation_ids = [ SessionId(pending_result['remote_reservation_id']) for pending_result in pending_results ]
results = client.get_experiment_uses_by_id(session_id, remote_reservation_ids)
for pending_result, result in zip(pending_results, results):
if result.is_alive():
continue
username = pending_result['username']
try:
request_info = pickle.loads(pending_result['serialized_request_info'].encode('utf-8'))
except Exception as e:
log.log(ResultsRetriever, log.level.Critical, "Probably serialized_request_info was truncated in %s" % pending_result)
log.log_exc(ResultsRetriever, log.level.Error)
request_info = {'error' : 'could not be stored: %s' % e}
reservation_id = pending_result['reservation_id']
remote_reservation_id = pending_result['remote_reservation_id']
if not redis_client.hdel(self.external_weblabdeusto_pending, reservation_id):
log.log(ResultsRetriever, log.level.Info, "Pending reservation %r not found. Assuming it is managed by other thread" % pending_result)
continue
if result.is_finished():
use = result.experiment_use
use.experiment_id = ExperimentId.parse(pending_result['experiment_id_str'])
use.remote_reservation_id = remote_reservation_id
use.reservation_id = reservation_id
for key in [ key for key in request_info ]:
if not isinstance(request_info[key], (basestring, numbers.Number)):
request_info.pop(key)
use.request_info = request_info
callback = lambda : self.post_reservation_data_manager.delete(reservation_id)
self.completed_store.put(username, use, callback)
else:
log.log(ResultsRetriever, log.level.Info, "Reservation id %s was cancelled and therefore not stored" % reservation_id)
开发者ID:JamesHyunKim,项目名称:weblabdeusto,代码行数:53,代码来源:weblabdeusto_scheduler_retriever.py
示例18: get_json
def get_json():
rv = request.get_json(force=True, silent=True)
if rv:
return rv
data = request.data
print("Error: could not deserialize:", data, file=sys.stderr)
sys.stderr.flush()
log(__name__, level.Warning, "Error retrieving JSON contents")
log(__name__, level.Warning, data)
log_exc(__name__, level.Info)
return None
开发者ID:JamesHyunKim,项目名称:weblabdeusto,代码行数:12,代码来源:new_server.py
示例19: _remove_expired_reservations
def _remove_expired_reservations(self):
session = self.session_maker()
try:
now = self.time_provider.get_time()
current_expiration_time = datetime.datetime.utcfromtimestamp(now - EXPIRATION_TIME)
reservations_removed = False
enqueue_free_experiment_args_retrieved = []
expired_query = session.query(ConcreteCurrentReservation).filter(ConcreteCurrentReservation.expired_timestamp != 0).filter(ConcreteCurrentReservation.expired_timestamp < self.time_provider.get_time())
for expired_concrete_current_reservation in expired_query.all():
expired_reservation = expired_concrete_current_reservation.current_reservation_id
if expired_reservation is None:
continue # Maybe it's not an expired_reservation anymore
enqueue_free_experiment_args = self._clean_current_reservation(session, expired_concrete_current_reservation)
enqueue_free_experiment_args_retrieved.append(enqueue_free_experiment_args)
session.delete(expired_concrete_current_reservation)
self.reservations_manager.delete(session, expired_reservation)
reservations_removed = True
for expired_reservation_id in self.reservations_manager.list_expired_reservations(session, current_expiration_time):
concrete_current_reservation = session.query(ConcreteCurrentReservation).filter(ConcreteCurrentReservation.current_reservation_id == expired_reservation_id).first()
if concrete_current_reservation is not None:
enqueue_free_experiment_args = self._clean_current_reservation(session, concrete_current_reservation)
enqueue_free_experiment_args_retrieved.append(enqueue_free_experiment_args)
session.delete(concrete_current_reservation)
waiting_reservation = session.query(WaitingReservation).filter(WaitingReservation.reservation_id == expired_reservation_id).first()
if waiting_reservation is not None:
session.delete(waiting_reservation)
self.reservations_manager.delete(session, expired_reservation_id)
reservations_removed = True
if reservations_removed:
try:
session.commit()
except ConcurrentModificationError as e:
if DEBUG:
print("Other error when commiting when reservations_removed: ", sys.exc_info())
log.log(
PriorityQueueScheduler, log.level.Warning,
"IntegrityError: %s" % e )
log.log_exc(PriorityQueueScheduler, log.level.Info)
pass # Someone else removed these users before us.
else:
for enqueue_free_experiment_args in enqueue_free_experiment_args_retrieved:
if enqueue_free_experiment_args is not None:
self.confirmer.enqueue_free_experiment(*enqueue_free_experiment_args)
else:
session.rollback()
finally:
session.close()
开发者ID:Kiolali,项目名称:weblabdeusto,代码行数:53,代码来源:priority_queue_scheduler.py
示例20: _validate_simple_authn
def _validate_simple_authn(self, username, credentials):
"""
When the login() method is called, this method is used with the
username and credentials (e.g., password, IP address, etc.). This
method will only check the SimpleAuthn instances.
"""
try:
login, role_name, user_auths = self._db.retrieve_role_and_user_auths(username)
except DbUserNotFoundError:
return self._process_invalid()
# login could be different to username.
# For example, in MySQL, where login = 'pablo' is equivalent to where login = 'pablo '
# For this reason, we don't trust "username", and retrieve login from the database
errors = False
for user_auth in user_auths:
# Take only those auth types that use a simple interface
if user_auth.is_simple_authn():
# With each user auth, try to authenticate the user.
try:
authenticated = user_auth.authenticate(login, credentials)
except:
# If there is an error, the user could not be authenticated.
log.log(
LoginManager, log.level.Warning, "Username: %s with user_auth %s: ERROR" % (login, user_auth)
)
log.log_exc(LoginManager, log.level.Warning)
errors = True
traceback.print_exc()
continue
if authenticated:
# If authenticated, return that it was correctly authenticated.
log.log(
LoginManager, log.level.Debug, "Username: %s with user_auth %s: SUCCESS" % (login, user_auth)
)
return ValidDatabaseSessionId(login, role_name)
else:
# If not authenticated, log it and continue with the next user_auth.
log.log(
LoginManager, log.level.Warning, "Username: %s with user_auth %s: FAIL" % (login, user_auth)
)
if errors:
# Raise error: there was a server problem and this might be the reason for not
# authenticating the user. Examples: LDAP server is down, there is an error in the
# local database or so.
raise LoginErrors.LoginError("Error checking credentials. Contact administrators!")
return self._process_invalid()
开发者ID:JamesHyunKim,项目名称:weblabdeusto,代码行数:53,代码来源:manager.py
注:本文中的voodoo.log.log_exc函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论