本文整理汇总了Python中preferences.Preferences.timezone方法的典型用法代码示例。如果您正苦于以下问题:Python Preferences.timezone方法的具体用法?Python Preferences.timezone怎么用?Python Preferences.timezone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类preferences.Preferences
的用法示例。
在下文中一共展示了Preferences.timezone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: App
# 需要导入模块: from preferences import Preferences [as 别名]
# 或者: from preferences.Preferences import timezone [as 别名]
#.........这里部分代码省略.........
logging.info("User has paused HipStatus")
else:
self.icon = _menu_bar_icon(0)
sender.title = "Pause HipStatus"
logging.info("User has resumed HipStatus")
sender.state = not sender.state
def timer_trigger(self, sender):
now = datetime.datetime.now()
delta = (5 - (now.minute % 5)) * 60 - now.second
logging.debug("Timer will execute in {} seconds".format(delta))
t = threading.Thread(target=self._update_status, args=[delta])
t.start()
def _update_status(self, delay):
time.sleep(delay)
if self.menu_pause_button.state:
logging.info("HipStatus is paused: status will not be updated")
return
now = datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S")
try:
hipchat_user = self.hipchat.get_status(self.preferences.email())
except Unauthorized:
rumps.notification("Authentication error to HipChat",'',
"It looks like something may be wrong with your API token. Click here to update, or use "
"the 'Preferences...' menu option.",
data={'update_token': ''})
return
except UserNotFound:
rumps.notification("Could not find the user in HipChat", self.preferences.email(),
"Your saved email address could not be found in HipChat. Click here to update, or use "
"the 'Preferences...' menu option.", data={'update_email': ''})
return
except (RateLimited, ServerError, ServiceUnavailable):
rumps.notification("There seems to be a problem with HipChat", '', "There was an error indicating an issue "
"on HipChat's end. If the issue persists click here to open an IT Help ticket.",
data={'open_ticket': ticket_url})
return
if not hipchat_user['presence']:
logging.info("The user is not online")
return
busy_hipstatus = True if hipchat_user['presence']['show'] != 'chat' else False
try:
office365_calendar = self.office365.calendar_status(now)
except Unauthorized:
rumps.notification("Authentication error to Office 365", '',
"Something may be wrong with your Office 365 email address/password. Click here to try "
"updating your password.", data={'update_o365': ''})
return
except ServerError:
rumps.notification("There seems to be a problem with Office 365", '', "There was an error indicating an "
"issue on Office 365's end. If the issue persists click here to open an IT Help ticket.",
data={'open_ticket': ticket_url})
return
if office365_calendar['value']:
busy_office365 = True if office365_calendar['value'][0]['ShowAs'] == 'Busy' else False
else:
busy_office365 = False
if busy_hipstatus == busy_office365:
logging.info("Status unchanged")
return
message = ''
update_data = {
'name': hipchat_user['name'],
'email': hipchat_user['email'],
'mention_name': hipchat_user['mention_name'],
'title': hipchat_user['title'],
'timezone': self.preferences.timezone(),
'is_group_admin': hipchat_user['is_group_admin'],
'presence': {
'status': None,
'show': None,
}
}
if busy_hipstatus and not busy_office365:
logging.info("Setting HipChat status to 'Available'")
update_data['presence']['status'] = ''
update_data['presence']['show'] = None
message = "You are now 'Available'"
elif busy_office365 and not busy_hipstatus:
logging.info("Setting HipChat status to 'Do not disturb'")
update_data['presence']['status'] = self.preferences.default_message()
update_data['presence']['show'] = 'dnd'
message = "You are now set to 'Do not disturb'"
self.hipchat.update_status(update_data)
rumps.notification("Status Updated", message, "Your status in HipChat has been updated", sound=False)