本文整理匯總了Python中MaKaC.plugins.PluginsHolder.getOption方法的典型用法代碼示例。如果您正苦於以下問題:Python PluginsHolder.getOption方法的具體用法?Python PluginsHolder.getOption怎麽用?Python PluginsHolder.getOption使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MaKaC.plugins.PluginsHolder
的用法示例。
在下文中一共展示了PluginsHolder.getOption方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _sendEventRequest
# 需要導入模塊: from MaKaC.plugins import PluginsHolder [as 別名]
# 或者: from MaKaC.plugins.PluginsHolder import getOption [as 別名]
def _sendEventRequest(self, key, eventType, avatar, conference):
try:
logger = self.getLogger()
plugin = PluginsHolder().getPluginType('calendaring').getPlugin('outlook')
if not isUserPluginEnabled(avatar.getId()):
logger.info("Outlook plugin disabled for user: {}".format(avatar.getId()))
return {'status_code': 200}
if eventType in ['added', 'updated']:
logger.debug("Performing '{}' for: {}".format(eventType, avatar.getId()))
url = urlHandlers.UHConferenceDisplay.getURL(conference)
location = strip_control_chars(conference.getRoom().getName()) if conference.getRoom() else ''
description = strip_control_chars(conference.getDescription())
self.payload = {'userEmail': avatar.getEmail(),
'uniqueID': plugin.getOption('prefix').getValue() + key,
'subject': strip_control_chars(conference.getTitle()),
'location': location,
'body': '<a href="{}">{}</a><br><br>{}'.format(url, url, description),
'status': plugin.getOption('status').getValue(),
'startDate': format_datetime(conference.getStartDate(),
format=plugin.getOption('datetimeFormat').getValue(),
timezone=pytz.utc),
'endDate': format_datetime(conference.getEndDate(),
format=plugin.getOption('datetimeFormat').getValue(),
timezone=pytz.utc),
'isThereReminder': plugin.getOption('reminder').getValue(),
'reminderTimeInMinutes': plugin.getOption('reminder_minutes').getValue()}
operation = plugin.getOption('addToCalendarOperationName').getValue() if eventType == 'added' else plugin.getOption('updateCalendarOperationName').getValue()
elif eventType == 'removed':
logger.debug("Removing calendar entry for: {}".format(avatar.getId()))
self.payload = {'userEmail': avatar.getEmail(),
'uniqueID': plugin.getOption('prefix').getValue() + key}
operation = plugin.getOption('removeFromCalendarOperationName').getValue()
else:
return None
headers = {'content-type': 'application/x-www-form-urlencoded'}
return requests.post(urlpath.tslash(plugin.getOption('url').getValue()) + operation,
auth=(plugin.getOption('login').getValue(), plugin.getOption('password').getValue()),
data=self.payload, headers=headers, timeout=plugin.getOption('timeout').getValue())
except requests.exceptions.Timeout:
logger.exception('Timeout')
except requests.exceptions.RequestException:
logger.exception('RequestException: Connection problem')
except Exception, e:
logger.exception('Outlook EventException: {}'.format(e))