本文整理汇总了Python中logger.warn方法的典型用法代码示例。如果您正苦于以下问题:Python logger.warn方法的具体用法?Python logger.warn怎么用?Python logger.warn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类logger
的用法示例。
在下文中一共展示了logger.warn方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: short_url
# 需要导入模块: import logger [as 别名]
# 或者: from logger import warn [as 别名]
def short_url(apiUrl):
try:
logger.debug("将长URL[%s]转化成短URL",apiUrl)
target_url = urllib.quote(str(apiUrl))
url = "http://suo.im/api.php?format=json&url=" + target_url
logger.debug("调用短URL生成[%s]", apiUrl)
request = urllib2.Request(url)
response = urllib2.urlopen(request,timeout=3)
result_dict = json.loads(response.read())
if response.getcode() != 200:
logger.warn("调用短URL服务失败:%s", result_dict["err"])
return None
logger.debug("调用短URL服务返回结果:%s", result_dict["url"])
return urllib.unquote(result_dict["url"])
except Exception as e:
logger.warn("调用短URL服务[%s],发生错误[%s]", apiUrl, str(e))
return None
示例2: generate_json_segments
# 需要导入模块: import logger [as 别名]
# 或者: from logger import warn [as 别名]
def generate_json_segments():
while True:
pil.livestream_obj['delay'] = (int(pil.epochtime) - pil.livestream_obj['published_time'])
if 'initial_buffered_duration' not in pil.livestream_obj and pil.broadcast_downloader.initial_buffered_duration:
pil.livestream_obj['initial_buffered_duration'] = pil.broadcast_downloader.initial_buffered_duration
pil.livestream_obj['segments'] = pil.broadcast_downloader.segment_meta
try:
with open(pil.live_folder_path + ".json", 'w') as json_file:
json.dump(pil.livestream_obj, json_file, indent=2)
if not pil.broadcast_downloader.stream_id:
pil.broadcast_downloader.stream_id = pil.livestream_obj['id']
#check_if_guesting()
if pil.kill_segment_thread:
break
else:
time.sleep(2.5)
except Exception as e:
logger.warn(str(e))
示例3: get_user_names
# 需要导入模块: import logger [as 别名]
# 或者: from logger import warn [as 别名]
def get_user_names(self, kwargs=None):
monitor_db = database.MonitorDatabase()
user_cond = ''
if session.get_session_user_id():
user_cond = 'AND user_id = %s ' % session.get_session_user_id()
try:
query = 'SELECT user_id, ' \
'(CASE WHEN users.friendly_name IS NULL OR TRIM(users.friendly_name) = "" \
THEN users.username ELSE users.friendly_name END) AS friendly_name ' \
'FROM users ' \
'WHERE deleted_user = 0 %s' % user_cond
result = monitor_db.select(query)
except Exception as e:
logger.warn("Tautulli Users :: Unable to execute database query for get_user_names: %s." % e)
return None
return session.friendly_name_to_username(result)
示例4: set_user_login
# 需要导入模块: import logger [as 别名]
# 或者: from logger import warn [as 别名]
def set_user_login(self, user_id=None, user=None, user_group=None, ip_address=None, host=None, user_agent=None, success=0):
if user_id is None or str(user_id).isdigit():
monitor_db = database.MonitorDatabase()
keys = {'timestamp': helpers.timestamp(),
'user_id': user_id}
values = {'user': user,
'user_group': user_group,
'ip_address': ip_address,
'host': host,
'user_agent': user_agent,
'success': success}
try:
monitor_db.upsert(table_name='user_login', key_dict=keys, value_dict=values)
except Exception as e:
logger.warn("Tautulli Users :: Unable to execute database query for set_login_log: %s." % e)
示例5: get_devices
# 需要导入模块: import logger [as 别名]
# 或者: from logger import warn [as 别名]
def get_devices(self):
db = database.MonitorDatabase()
try:
query = 'SELECT * FROM mobile_devices WHERE official = 1'
result = db.select(query=query)
except Exception as e:
logger.warn("Tautulli Notifiers :: Unable to retrieve Android app devices list: %s." % e)
return {'': ''}
devices = {}
for device in result:
if device['friendly_name']:
devices[device['device_id']] = device['friendly_name']
else:
devices[device['device_id']] = device['device_name']
return devices
示例6: set_img_info
# 需要导入模块: import logger [as 别名]
# 或者: from logger import warn [as 别名]
def set_img_info(self, img_hash=None, img_title=None, img_url=None, delete_hash=None, service=None):
monitor_db = database.MonitorDatabase()
keys = {'img_hash': img_hash}
if service == 'imgur':
table = 'imgur_lookup'
values = {'imgur_title': img_title,
'imgur_url': img_url,
'delete_hash': delete_hash}
elif service == 'cloudinary':
table = 'cloudinary_lookup'
values = {'cloudinary_title': img_title,
'cloudinary_url': img_url}
else:
logger.warn("Tautulli DataFactory :: Unable to execute database query for set_img_info: "
"service not provided.")
return
monitor_db.upsert(table, key_dict=keys, value_dict=values)
示例7: set_recently_added_item
# 需要导入模块: import logger [as 别名]
# 或者: from logger import warn [as 别名]
def set_recently_added_item(self, rating_key=''):
monitor_db = database.MonitorDatabase()
pms_connect = pmsconnect.PmsConnect()
metadata = pms_connect.get_metadata_details(rating_key)
keys = {'rating_key': metadata['rating_key']}
values = {'added_at': metadata['added_at'],
'section_id': metadata['section_id'],
'parent_rating_key': metadata['parent_rating_key'],
'grandparent_rating_key': metadata['grandparent_rating_key'],
'media_type': metadata['media_type'],
'media_info': json.dumps(metadata['media_info'])
}
try:
monitor_db.upsert(table_name='recently_added', key_dict=keys, value_dict=values)
except Exception as e:
logger.warn("Tautulli DataFactory :: Unable to execute database query for set_recently_added_item: %s." % e)
return False
return True
示例8: add_mobile_device
# 需要导入模块: import logger [as 别名]
# 或者: from logger import warn [as 别名]
def add_mobile_device(device_id=None, device_name=None, device_token=None, friendly_name=None):
db = database.MonitorDatabase()
keys = {'device_id': device_id}
values = {'device_name': device_name,
'device_token': device_token,
'official': validate_device_id(device_id=device_id)}
if friendly_name:
values['friendly_name'] = friendly_name
try:
result = db.upsert(table_name='mobile_devices', key_dict=keys, value_dict=values)
except Exception as e:
logger.warn("Tautulli MobileApp :: Failed to register mobile device in the database: %s." % e)
return
if result == 'insert':
logger.info("Tautulli MobileApp :: Registered mobile device '%s' in the database." % device_name)
else:
logger.debug("Tautulli MobileApp :: Re-registered mobile device '%s' in the database." % device_name)
return True
示例9: set_mobile_device_config
# 需要导入模块: import logger [as 别名]
# 或者: from logger import warn [as 别名]
def set_mobile_device_config(mobile_device_id=None, **kwargs):
if str(mobile_device_id).isdigit():
mobile_device_id = int(mobile_device_id)
else:
logger.error("Tautulli MobileApp :: Unable to set exisiting mobile device: invalid mobile_device_id %s." % mobile_device_id)
return False
keys = {'id': mobile_device_id}
values = {'friendly_name': kwargs.get('friendly_name', '')}
db = database.MonitorDatabase()
try:
db.upsert(table_name='mobile_devices', key_dict=keys, value_dict=values)
logger.info("Tautulli MobileApp :: Updated mobile device agent: mobile_device_id %s." % mobile_device_id)
return True
except Exception as e:
logger.warn("Tautulli MobileApp :: Unable to update mobile device: %s." % e)
return False
示例10: send
# 需要导入模块: import logger [as 别名]
# 或者: from logger import warn [as 别名]
def send(self):
self.newsletter = self.generate_newsletter()
if self.template_error:
logger.error("Tautulli Newsletters :: %s newsletter failed to render template. Newsletter not sent." % self.NAME)
return False
if not self._has_data():
logger.warn("Tautulli Newsletters :: %s newsletter has no data. Newsletter not sent." % self.NAME)
return False
self._save()
if self.config['save_only']:
return True
return self._send()
示例11: analytics_event
# 需要导入模块: import logger [as 别名]
# 或者: from logger import warn [as 别名]
def analytics_event(category, action, label=None, value=None, **kwargs):
data = {'category': category, 'action': action}
if label is not None:
data['label'] = label
if value is not None:
data['value'] = value
if kwargs:
data.update(kwargs)
if TRACKER:
try:
TRACKER.send('event', data)
except Exception as e:
logger.warn("Failed to send analytics event for category '%s', action '%s': %s" % (category, action, e))
示例12: check_folder_writable
# 需要导入模块: import logger [as 别名]
# 或者: from logger import warn [as 别名]
def check_folder_writable(folder, fallback, name):
if not folder:
folder = fallback
if not os.path.exists(folder):
try:
os.makedirs(folder)
except OSError as e:
logger.error("Could not create %s dir '%s': %s" % (name, folder, e))
if fallback and folder != fallback:
logger.warn("Falling back to %s dir '%s'" % (name, fallback))
return check_folder_writable(None, fallback, name)
else:
return folder, None
if not os.access(folder, os.W_OK):
logger.error("Cannot write to %s dir '%s'" % (name, folder))
if fallback and folder != fallback:
logger.warn("Falling back to %s dir '%s'" % (name, fallback))
return check_folder_writable(None, fallback, name)
else:
return folder, False
return folder, True
示例13: get_sections
# 需要导入模块: import logger [as 别名]
# 或者: from logger import warn [as 别名]
def get_sections(self):
monitor_db = database.MonitorDatabase()
try:
query = 'SELECT section_id, section_name, section_type, agent ' \
'FROM library_sections WHERE deleted_section = 0'
result = monitor_db.select(query=query)
except Exception as e:
logger.warn("Tautulli Libraries :: Unable to execute database query for get_sections: %s." % e)
return None
libraries = []
for item in result:
library = {'section_id': item['section_id'],
'section_name': item['section_name'],
'section_type': item['section_type'],
'agent': item['agent']
}
libraries.append(library)
return libraries
示例14: get_token
# 需要导入模块: import logger [as 别名]
# 或者: from logger import warn [as 别名]
def get_token(self):
plextv_response = self.get_plex_auth(output_format='xml')
if plextv_response:
try:
xml_head = plextv_response.getElementsByTagName('user')
if xml_head:
user = {'auth_token': xml_head[0].getAttribute('authToken'),
'user_id': xml_head[0].getAttribute('id')
}
else:
logger.warn("Tautulli PlexTV :: Could not get Plex authentication token.")
except Exception as e:
logger.warn("Tautulli PlexTV :: Unable to parse XML for get_token: %s." % e)
return None
return user
else:
return None
示例15: get_plexpy_pms_token
# 需要导入模块: import logger [as 别名]
# 或者: from logger import warn [as 别名]
def get_plexpy_pms_token(self, force=False):
if force:
logger.debug("Tautulli PlexTV :: Forcing refresh of Plex.tv token.")
devices_list = self.get_devices_list()
device_id = next((d for d in devices_list if d['device_identifier'] == plexpy.CONFIG.PMS_UUID), {}).get('device_id', None)
if device_id:
logger.debug("Tautulli PlexTV :: Removing Tautulli from Plex.tv devices.")
try:
self.delete_plextv_device(device_id=device_id)
except:
logger.error("Tautulli PlexTV :: Failed to remove Tautulli from Plex.tv devices.")
return None
else:
logger.warn("Tautulli PlexTV :: No existing Tautulli device found.")
logger.info("Tautulli PlexTV :: Fetching a new Plex.tv token for Tautulli.")
user = self.get_token()
if user:
token = user['auth_token']
plexpy.CONFIG.__setattr__('PMS_TOKEN', token)
plexpy.CONFIG.write()
logger.info("Tautulli PlexTV :: Updated Plex.tv token for Tautulli.")
return token