本文整理汇总了Python中misc.Logger.info方法的典型用法代码示例。如果您正苦于以下问题:Python Logger.info方法的具体用法?Python Logger.info怎么用?Python Logger.info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类misc.Logger
的用法示例。
在下文中一共展示了Logger.info方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Deployable
# 需要导入模块: from misc import Logger [as 别名]
# 或者: from misc.Logger import info [as 别名]
class Deployable(Communicable):
"""
Should be responsible for sending the "deploy" action
"""
def __init__(self):
self.log = Logger().get_logger()
super(Deployable, self).__init__()
def send_deploy(self):
deploy_route = Path().get_route_for(self.class_name, 'deploy') % self.data_hash['id']
if self._send_deploy_request(deploy_route):
self.log.info("Successfully sent 'deploy' for url=%s" % self.absolute_url)
return True
else:
return False
def _send_deploy_request(self, deploy_route):
"""
Makes a 'deploy' request
"""
url = "%s%s" % (self.uri, deploy_route)
self.log.info("Sending deploy GET request to url=%s" %url)
try:
response = self._api_get_json(url)
except urllib2.HTTPError, e:
response = None
self.log.error("Could not send deploy GET request because %s" % e)
if response:
return True
else:
return False
示例2: Serializer
# 需要导入模块: from misc import Logger [as 别名]
# 或者: from misc.Logger import info [as 别名]
class Serializer(object):
"""
Should be responsible for representing instances of classes in desired form
"""
def __init__(self):
self.log = Logger().get_logger()
self.log.debug("Instantiated Serializer with data %s" % self.data_hash)
pass
def __repr__(self):
return str(self.data_hash)
def __str__(self):
return self.data_hash
def _assign_attributes(self):
"""
Should change the key names from original API keys to the ones we want
:return: None
"""
for new_key, old_key in self.attributes.iteritems():
try:
self.data[new_key] = self.data_hash[old_key]
except SerializerException, e:
""" possible do something fancy here """
except Exception, e:
self.log.info("Could not assign attribute %s while operating on Object: %s because %s" % (old_key, self.data_hash, e))
示例3: Deletable
# 需要导入模块: from misc import Logger [as 别名]
# 或者: from misc.Logger import info [as 别名]
class Deletable(Communicable):
"""
@summary: Should be responsible for the deletion of an object
"""
def __init__(self):
self.log = Logger().get_logger()
super(Deletable, self).__init__()
def send_delete(self):
"""
@summary: sends the "delete" GET request to a route
"""
delete_route = Path().get_route_for(self.class_name, 'delete') % self.data_hash['id']
if self._send_delete_request(delete_route):
self.log.info("Successfully sent 'delete' to url=%s" % self.absolute_url)
return True
else:
return False
def _send_delete_request(self, delete_route):
"""
@rtype: bool
"""
url = "%s%s" % (self.uri, delete_route)
self.log.info("Sending 'delete' to url=%s" %url)
try:
response = self._api_get_html(url)
except urllib2.HTTPError, e:
response = None
self.log.error("Could not send 'delete' because %s" % e)
if response:
return True
else:
return False
示例4: Startupable
# 需要导入模块: from misc import Logger [as 别名]
# 或者: from misc.Logger import info [as 别名]
class Startupable(Communicable):
"""
@summary: Should be responsible for sending "startup" command to live activities,
controllers, spaces and live groups.
"""
def __init__(self):
self.log = Logger().get_logger()
super(Startupable, self).__init__()
def send_startup(self):
startup_route = Path().get_route_for(self.class_name, 'startup') % self.data_hash['id']
if self._send_startup_request(startup_route):
self.log.info("Successfully sent 'startup' for url=%s" % self.absolute_url)
return True
else:
return False
def _send_startup_request(self, startup_route):
"""
@summary: makes a startup request
"""
url = "%s%s" % (self.uri, startup_route)
self.log.info("Sending 'startup' GET request to url=%s" %url)
try:
response = self._api_get_json(url)
except urllib2.HTTPError, e:
response = None
self.log.error("Could not send 'startup' GET request because %s" % e)
if response:
return True
else:
return False
示例5: Searcher
# 需要导入模块: from misc import Logger [as 别名]
# 或者: from misc.Logger import info [as 别名]
class Searcher(dict):
"""
Class responsible for search methods on strings
"""
def __init__(self):
self.log = Logger().get_logger()
def wrap(self, regular_expression):
"""
Turns windows/search type of regexp into python re regexp.
It adds explicit begining '^' and end '$' to matcher and converts
all wildcards to re wildcard '(.*)'
:rtype: str
:param string: regular_expression
"""
return '^' + regular_expression.replace('*', '(.*)') + '$'
def match(self, string, regular_expression):
"""
Match string with a regular expression
:rtype: bool
:param string: given string for matching
:param regular_expression: expression to be run against the given string
"""
regular_expression = self.wrap(regular_expression)
self.log.info("Trying to match regexp: %s against string: %s" % (regular_expression, string))
regex = re.compile(regular_expression)
if re.match(regex, string):
return True
else:
return False
示例6: Shutdownable
# 需要导入模块: from misc import Logger [as 别名]
# 或者: from misc.Logger import info [as 别名]
class Shutdownable(Communicable):
"""
Should be responsible for sending "shutdown" command to live activities,
controllers, spaces and live groups.
"""
def __init__(self):
self.log = Logger().get_logger()
super(Shutdownable, self).__init__()
def send_shutdown(self):
shutdown_route = Path().get_route_for(self.class_name, 'shutdown') % self.data_hash['id']
if self._send_shutdown_request(shutdown_route):
self.log.info("Successfully sent shutdown for url=%s" % self.absolute_url)
return True
else:
return False
def _send_shutdown_request(self, shutdown_route):
"""
Makes a shutdown request
"""
url = "%s%s" % (self.uri, shutdown_route)
self.log.info("Sending 'shutdown' GET request to url=%s" %url)
try:
response = self._api_get_json(url)
except urllib2.HTTPError, e:
response = None
self.log.error("Could not send 'shutdown' GET request because %s" % e)
if e=='HTTP Error 500: No connection to controller in 5000 milliseconds':
raise CommunicableException('HTTP Error 500: No connection to controller in 5000 milliseconds')
if response:
return True
else:
return False
示例7: Configurable
# 需要导入模块: from misc import Logger [as 别名]
# 或者: from misc.Logger import info [as 别名]
class Configurable(Communicable):
"""
@summary: Should be responsible for sending the "configure" action
"""
def __init__(self):
self.log = Logger().get_logger()
super(Configurable, self).__init__()
def send_configure(self):
configure_route = Path().get_route_for(self.class_name, 'configure') % self.data_hash['id']
if self._send_configure_request(configure_route):
self.log.info("Successfully sent 'configure' for url=%s" % self.absolute_url)
return True
else:
return False
def _send_configure_request(self, configure_route):
"""
@summary: makes a 'configure' request
"""
url = "%s%s" % (self.uri, configure_route)
self.log.info("Sending configure GET request to url=%s" %url)
try:
response = self._api_get_json(url)
except urllib2.HTTPError, e:
response = None
self.log.error("Could not send configure GET request because %s" % e)
if response:
return True
else:
return False
示例8: Space
# 需要导入模块: from misc import Logger [as 别名]
# 或者: from misc.Logger import info [as 别名]
class Space(Fetchable, Statusable, Deletable, Shutdownable,
Startupable, Activatable, Configurable, Metadatable,
Deployable, Cleanable):
"""
@summary: Space is a LiveActivityGroup aggregator
"""
def __init__(self, data_hash, uri, name=None, ):
self.log = Logger().get_logger()
self.data_hash = data_hash
self.uri = uri
self.absolute_url = self._get_absolute_url()
self.class_name = self.__class__.__name__
super(Space, self).__init__()
self.log.info("Instantiated Activity object with url=%s" % self.absolute_url)
def __repr__(self):
return str(self.data_hash)
def __str__(self):
return self.data_hash
def create(self, live_activity_group_name, live_activity_names):
"""
@summary: Should be responsible for creating space
@param live_activity_group_name: string
@param live_activity_names: list of existing names
"""
raise NotImplementedError
def to_json(self):
"""
@summary: Should selected attributes in json form defined by the template
"""
self.serializer = SpaceSerializer(self.data_hash)
return self.serializer.to_json()
def id(self):
return self.data_hash['id']
def name(self):
"""
@param: Should return live activity name
"""
return self.data_hash['name']
def description(self):
"""
@param: Should return Space description
"""
return self.data_hash['description']
""" Private methods below """
def _get_absolute_url(self):
live_activity_group_id = self.data_hash['id']
url = "%s/space/%s/view.json" % (self.uri, live_activity_group_id)
return url
示例9: Statusable
# 需要导入模块: from misc import Logger [as 别名]
# 或者: from misc.Logger import info [as 别名]
class Statusable(Communicable):
"""
Should be responsible for _refreshing_ status of the object,
which means that it will send "status" command to IS Controllers.
In order to fetch the fresh and most up-to-date status you should use
.fetch() method on the object.
"""
def __init__(self):
self.log = Logger().get_logger()
super(Statusable, self).__init__()
def send_status_refresh(self):
"""
Extracts self.data_hash and self.class_name from children class
and finds out to which route send GET request to ands sends it
"""
refresh_route = Path().get_route_for(self.class_name, 'status') % self.data_hash['id']
if self._send_status_refresh(refresh_route):
self.log.info("Successfully refreshed status for url=%s" % self.absolute_url)
return True
else:
return False
def _send_status_refresh(self, refresh_route):
"""
Should tell master to retrieve status info from controller
so master has the most up to date info from the controller
:param refresh_route: status.json route for specific class
:rtype: bool
"""
url = "%s%s" % (self.uri, refresh_route)
self.log.info("Sending status refresh to url=%s" %url)
try:
response = self._api_get_json(url)
except urllib2.HTTPError, e:
response = None
self.log.error("Could not send status refresh because %s" % e)
if response:
return True
else:
return False
示例10: Metadatable
# 需要导入模块: from misc import Logger [as 别名]
# 或者: from misc.Logger import info [as 别名]
class Metadatable(Communicable):
"""
@summary: Should be responsible for setting metadata
"""
def __init__(self):
self.log = Logger().get_logger()
super(Metadatable, self).__init__()
def set_metadata(self, metadata_dictionary):
"""
@summary: Accepts dictionary of keys that will be unpacked to "key=value" strings and
makes a request overwriting any previous metadata
@rtype: bool
@param metadata_args: Dictionary with keys and values
"""
metadata = {"values" : self._unpack_metadata(metadata_dictionary)}
self.log.info("Updating metadata of %s with %s" % (self.class_name, metadata))
metadata_route = Path().get_route_for(self.class_name, 'metadata') % self.data_hash['id']
if self._send_metadatable_request(metadata_route, metadata):
self.log.info("Successfully sent metadata for url=%s" % self.absolute_url)
return True
else:
return False
def _unpack_metadata(self, metadata_dictionary):
"""
@summary: accepts dictionary and converts it to string
@rtype: string
@param metadata_dictionary: dict containing metadata
"""
metadata_text = ""
try:
for key, value in metadata_dictionary.iteritems():
metadata_text = metadata_text + ("\r\n") + key + "=" + value
return metadata_text
except Exception, e:
self.log.error("Could not unpack supplied metadata dictionary because %s" % e)
raise
示例11: Cleanable
# 需要导入模块: from misc import Logger [as 别名]
# 或者: from misc.Logger import info [as 别名]
class Cleanable(Communicable):
"""
Should be responsible for permanent clean and cleaning the tmp
"""
def __init__(self):
self.log = Logger().get_logger()
super(Cleanable, self).__init__()
def send_clean_permanent(self):
configure_route = Path().get_route_for(self.class_name, 'clean_permanent') % self.data_hash['id']
if self._send_cleanable_request(configure_route):
self.log.info("Successfully sent 'clean_permanent' for url=%s" % self.absolute_url)
return True
else:
return False
def send_clean_tmp(self):
configure_route = Path().get_route_for(self.class_name, 'clean_tmp') % self.data_hash['id']
if self._send_cleanable_request(configure_route):
self.log.info("Successfully sent 'clean_tmp' for url=%s" % self.absolute_url)
return True
else:
return False
def _send_cleanable_request(self, cleanable_route):
"""
Makes a cleanable request
"""
url = "%s%s" % (self.uri, cleanable_route)
self.log.info("Sending cleanable GET request to url=%s" %url)
try:
response = self._api_get_json(url)
except urllib2.HTTPError, e:
response = None
self.log.error("Could not send cleanable GET request because %s" % e)
if e=='HTTP Error 500: No connection to controller in 5000 milliseconds':
raise CommunicableException('HTTP Error 500: No connection to controller in 5000 milliseconds')
if response:
return True
else:
return False
示例12: Connectable
# 需要导入模块: from misc import Logger [as 别名]
# 或者: from misc.Logger import info [as 别名]
class Connectable(Communicable):
"""
Should be responsible for connecting/disconnecting space controllers
"""
def __init__(self):
self.log = Logger().get_logger()
super(Connectable, self).__init__()
def send_connect(self):
connect_route = Path().get_route_for(self.class_name, 'connect') % self.data_hash['id']
if self._send_connectable_request(connect_route):
self.log.info("Successfully sent 'connect' for url=%s" % self.absolute_url)
return True
else:
return False
def send_disconnect(self):
disconnect_route = Path().get_route_for(self.class_name, 'disconnect') % self.data_hash['id']
if self._send_connectable_request(disconnect_route):
self.log.info("Successfully sent 'disconnect' for url=%s" % self.absolute_url)
return True
else:
return False
def _send_connectable_request(self, connectable_route):
"""
Makes a connectable request
"""
url = "%s%s" % (self.uri, connectable_route)
self.log.info("Sending connectable GET request to url=%s" %url)
try:
response = self._api_get_json(url)
except urllib2.HTTPError, e:
response = None
self.log.error("Could not send connectable GET request because %s" % e)
if response:
return True
else:
return False
示例13: Master
# 需要导入模块: from misc import Logger [as 别名]
# 或者: from misc.Logger import info [as 别名]
class Master(Communicable):
"""
@summary: This is the main class with all the logic needed for
high level stuff. You will typically use instance of Master for all your scripts.
"""
def __init__(self, host='lg-head', port='8080', prefix='/interactivespaces'):
"""
@param host: default value is lg-head
@param port: default value is 8080
@param prefix: default value is /interactivespaces
@todo: refactor filter_* methods because they're not DRY
"""
self.host, self.port, self.prefix = host, port, prefix
self.log = Logger().get_logger()
self.uri = "http://%s:%s%s" % (self.host, self.port, prefix)
super(Master, self).__init__()
def get_activities(self, search_pattern=None):
"""
Retrieves a list of Activity objects
@rtype: list
@param search_pattern: dictionary of regexps used for searching through Activities
- example regexp dict: {
"activity_name" : "regexp",
"activity_version" : "regexp"
}
- every search_pattern dictionary key may be blank/null
"""
url = self._compose_url(class_name='Master', method_name='get_activities', uri=self.uri)
self.log.info("Trying to retrieve url=%s" % url)
response = self._api_get_json(url)
self.log.info('Got response for "get_activities" %s ' % str(response))
self.log.info('get_activities returned %s objects' % str(len(response)))
activities = self._filter_activities(response, search_pattern)
return activities
def get_activity(self, search_pattern=None):
"""
Retrieves a list of Activity objects
@rtype: list
@param search_pattern: dictionary of regexps used for searching through Activities
- example regexp dict: {
"activity_name" : "regexp",
"activity_version" : "regexp"
}
- every search_pattern dictionary key may be blank/null
"""
url = self._compose_url(class_name='Master', method_name='get_activities', uri=self.uri)
self.log.info("Trying to retrieve url=%s" % url)
response = self._api_get_json(url)
self.log.info('Got response for "get_activities" %s ' % str(response))
self.log.info('get_activities returned %s objects' % str(len(response)))
activity = self._filter_activities(response, search_pattern)
if len(activity) > 1:
raise MasterException("get_activity returned more than one row (%s)" % len(activity))
elif isinstance(activity[0], Activity):
activity[0].fetch()
self.log.info("get_activity returned Activity:%s" % str(activity))
return activity
else:
raise MasterException("Could not get specific activity for given search pattern")
def get_live_activities(self, search_pattern=None):
"""
Retrieves a list of LiveActivity objects
@rtype: list
@param search_pattern: dictionary of regexps used for searching through LiveActivity names
- example regexp dict: {
"live_activity_name" : "regexp",
"space_controller_name" : "regexp"
}
- each search_pattern dictionary key may be blank/null
"""
url = self._compose_url(class_name='Master', method_name='get_live_activities', uri=self.uri)
self.log.info("Trying to retrieve url=%s" % url)
response = self._api_get_json(url)
self.log.debug('Got response for "get_live_activities" %s ' % str(response))
self.log.info('get_live_activities returned %s objects' % str(len(response)))
live_activities = self._filter_live_activities(response, search_pattern)
return live_activities
def get_live_activity(self, search_pattern=None):
"""
Retrieves a list of LiveActivity objects
@rtype: LiveActivity or False
@param search_pattern: dictionary of regexps used for searching through LiveActivity names
- example regexp dict: {
"live_activity_name" : "GE ViewSync Master on Node A",
"space_controller_name" : "ISCtlDispAScreen00"
}
- each search_pattern dictionary key may be blank/null
"""
url = self._compose_url(class_name='Master', method_name='get_live_activities', uri=self.uri)
self.log.info("Trying to retrieve url=%s" % url)
response = self._api_get_json(url)
self.log.debug('Got response for "get_live_activities" %s ' % str(response))
self.log.info('get_live_activities returned %s objects' % str(len(response)))
live_activity = self._filter_live_activities(response, search_pattern)
if len(live_activity) > 1:
raise MasterException("get_live_activity returned more than one row (%s)" % len(live_activity))
#.........这里部分代码省略.........
示例14: Master
# 需要导入模块: from misc import Logger [as 别名]
# 或者: from misc.Logger import info [as 别名]
class Master(Communicable):
"""
This is the main class with all the logic needed for
high level stuff. You will typically use instance of
Master for all your scripts.
"""
def __init__(self, host='lg-head', port='8080', prefix='/interactivespaces', logfile_path='ispaces-client.log'):
"""
:param host: default value is lg-head
:param port: default value is 8080
:param prefix: default value is /interactivespaces
:todo: refactor filter_* methods because they're not DRY
"""
self.host, self.port, self.prefix = host, port, prefix
self.log = Logger(logfile_path=logfile_path).get_logger()
self.uri = "http://%s:%s%s" % (self.host, self.port, prefix)
super(Master, self).__init__()
def get_activities(self, search_pattern=None):
"""
Retrieves a list of Activity objects
:rtype: list
:param search_pattern: dictionary of regexps used for searching through Activities
example regexp dict::
{\
"activity_name" : "regexp"\
"activity_version" : "regexp"\
}
every search_pattern dictionary key may be blank/null
"""
url = self._compose_url(class_name='Master', method_name='get_activities', uri=self.uri)
self.log.info("Trying to retrieve url=%s" % url)
response = self._api_get_json(url)
self.log.info('Got response for "get_activities" %s ' % str(response))
self.log.info('get_activities returned %s objects' % str(len(response)))
activities = self._filter_activities(response, search_pattern)
return activities
def get_activity(self, search_pattern=None):
"""
Retrieves a list of Activity objects
:rtype: list
:param search_pattern: dictionary of regexps used for searching through Activities
example regexp dict::
{\
"activity_name" : "regexp",\
"activity_version" : "regexp"\
}
every search_pattern dictionary key may be blank/null
"""
url = self._compose_url(class_name='Master', method_name='get_activities', uri=self.uri)
self.log.info("Trying to retrieve url=%s" % url)
response = self._api_get_json(url)
self.log.info('Got response for "get_activities" %s ' % str(response))
self.log.info('get_activities returned %s objects' % str(len(response)))
activity = self._filter_activities(response, search_pattern)
return self._validate_single_getter_results(activity, Activity, ActivityNotFoundException)
def get_live_activities(self, search_pattern=None):
"""
Retrieves a list of LiveActivity objects
:rtype: list
:param search_pattern: dictionary of regexps used for searching through LiveActivity names
example regexp dict::
{\
"live_activity_name" : "regexp",\
"space_controller_name" : "regexp"\
}
- each search_pattern dictionary key may be blank/null
"""
url = self._compose_url(class_name='Master', method_name='get_live_activities', uri=self.uri)
self.log.info("Trying to retrieve url=%s" % url)
response = self._api_get_json(url)
self.log.debug('Got response for "get_live_activities" %s ' % str(response))
self.log.info('get_live_activities returned %s objects' % str(len(response)))
live_activities = self._filter_live_activities(response, search_pattern)
return live_activities
def get_live_activity(self, search_pattern=None):
"""
Retrieves a list of LiveActivity objects
:rtype: LiveActivity or False
#.........这里部分代码省略.........
示例15: Path
# 需要导入模块: from misc import Logger [as 别名]
# 或者: from misc.Logger import info [as 别名]
class Path(object):
'''
Should be responsible for static translation of routes
'''
def __init__(self):
self.routes = {
'Master': {
'get_activities': '/activity/all.json',
'get_live_activities': '/liveactivity/all.json',
'get_live_activity_groups': '/liveactivitygroup/all.json',
'get_spaces': '/space/all.json',
'get_space_controllers': '/spacecontroller/all.json',
'get_named_scripts': '/admin/namedscript/all.json',
'new_live_activity_group': '/liveactivitygroup/new',
'new_space': '/space/new.json',
'new_controller': '/spacecontroller/new.json',
'new_named_script': '/admin/namedscript/new.json'
},
'Activity': {
'view': '/activity/%s/view.json',
'upload': '/activity/upload',
'delete': '/activity/%s/delete.html'
},
'LiveActivity': {
'status': '/liveactivity/%s/status.json',
'view': '/liveactivity/%s/view.json',
'new': '/liveactivity/new',
'delete': '/liveactivity/%s/delete.html',
'shutdown': '/liveactivity/%s/shutdown.json',
'startup': '/liveactivity/%s/startup.json',
'activate': '/liveactivity/%s/activate.json',
'deactivate': '/liveactivity/%s/deactivate.json',
'deploy': '/liveactivity/%s/deploy.json',
'configure': '/liveactivity/%s/configure.json',
'clean_tmp': '/liveactivity/%s/cleantmpdata.json',
'clean_permanent': '/liveactivity/%s/cleanpermanentdata.json',
'metadata': '/liveactivity/%s/metadata/edit',
'config': '/liveactivity/%s/config/edit'
},
'LiveActivityGroup': {
'view': '/liveactivitygroup/%s/view.json',
'new': '/liveactivitygroup/new',
'status': '/liveactivitygroup/%s/liveactivitystatus.json',
'delete': '/liveactivitygroup/%s/delete.html',
'shutdown': '/liveactivitygroup/%s/shutdown.json',
'startup': '/liveactivitygroup/%s/startup.json',
'activate': '/liveactivitygroup/%s/activate.json',
'deactivate': '/liveactivitygroup/%s/deactivate.json',
'deploy': '/liveactivitygroup/%s/deploy.json',
'configure': '/liveactivitygroup/%s/configure.json',
'metadata': '/liveactivitygroup/%s/metadata/edit',
'edit': '/liveactivitygroup/%s/edit.json'
},
'Space': {
'view': '/space/%s/view.json',
'status': '/space/%s/status.json',
'delete': '/space/%s/delete.html',
'new': '/space/new',
'shutdown': '/space/%s/shutdown.json',
'startup': '/space/%s/startup.json',
'activate': '/space/%s/activate.json',
'deactivate': '/space/%s/deactivate.json',
'deploy': '/space/%s/deploy.json',
'configure': '/space/%s/configure.json',
'metadata': '/space/%s/metadata/edit',
'edit': '/space/%s/edit.json'
},
'SpaceController': {
'new': '/spacecontroller/new',
'status': '/spacecontroller/%s/status.json',
'delete': '/spacecontroller/%s/delete.html',
'shutdown': '/spacecontroller/%s/shutdown.json',
'deploy': '/spacecontroller/%s/deploy.json',
'connect': '/spacecontroller/%s/connect.json',
'disconnect': '/spacecontroller/%s/disconnect.json'
}
}
self.log = Logger().get_logger()
def get_route_for(self, class_name, method_name):
"""
Should receive caller class name and caller method in order
to return a proper route in the master API
:rtype: string
"""
try:
return self.routes[class_name][method_name]
except PathException, e:
self.log.info(
"Could not return route for class_name %s and method %s because %s"
% (class_name, method_name, e))