code style reformatting using black
This commit is contained in:
parent
4127bcffd0
commit
744cb0c503
1 changed files with 21394 additions and 10488 deletions
|
|
@ -20,6 +20,7 @@
|
|||
from sat.core.i18n import _, D_
|
||||
from sat.core.constants import Const as C
|
||||
from sat.core.log import getLogger
|
||||
|
||||
log = getLogger(__name__)
|
||||
from sat.core import exceptions
|
||||
import sys
|
||||
|
|
@ -32,7 +33,9 @@ PLUGIN_INFO = {
|
|||
C.PI_TYPE: C.PLUG_TYPE_MISC,
|
||||
C.PI_MAIN: "AndroidPlugin",
|
||||
C.PI_HANDLER: "no",
|
||||
C.PI_DESCRIPTION: D_("""Manage Android platform specificities, like pause or notifications""")
|
||||
C.PI_DESCRIPTION: D_(
|
||||
"""Manage Android platform specificities, like pause or notifications"""
|
||||
),
|
||||
}
|
||||
|
||||
if sys.platform != "android":
|
||||
|
|
@ -44,6 +47,7 @@ PARAM_VIBRATE_CATEGORY = "Notifications"
|
|||
PARAM_VIBRATE_NAME = "vibrate"
|
||||
PARAM_VIBRATE_LABEL = D_(u"Vibrate on notifications")
|
||||
|
||||
|
||||
class AndroidPlugin(object):
|
||||
|
||||
params = """
|
||||
|
|
@ -55,40 +59,41 @@ class AndroidPlugin(object):
|
|||
</individual>
|
||||
</params>
|
||||
""".format(
|
||||
category_name = PARAM_VIBRATE_CATEGORY,
|
||||
category_label = D_(PARAM_VIBRATE_CATEGORY),
|
||||
param_name = PARAM_VIBRATE_NAME,
|
||||
param_label = PARAM_VIBRATE_LABEL,
|
||||
)
|
||||
category_name=PARAM_VIBRATE_CATEGORY,
|
||||
category_label=D_(PARAM_VIBRATE_CATEGORY),
|
||||
param_name=PARAM_VIBRATE_NAME,
|
||||
param_label=PARAM_VIBRATE_LABEL,
|
||||
)
|
||||
|
||||
def __init__(self, host):
|
||||
log.info(_("plugin Android initialization"))
|
||||
self.host = host
|
||||
host.memory.updateParams(self.params)
|
||||
self.cagou_status_fd = open('.cagou_status', 'rb')
|
||||
self.cagou_status = mmap.mmap(self.cagou_status_fd.fileno(), 1, prot=mmap.PROT_READ)
|
||||
self.cagou_status_fd = open(".cagou_status", "rb")
|
||||
self.cagou_status = mmap.mmap(
|
||||
self.cagou_status_fd.fileno(), 1, prot=mmap.PROT_READ
|
||||
)
|
||||
# we set a low priority because we want the notification to be sent after all plugins have done their job
|
||||
host.trigger.add("MessageReceived", self.messageReceivedTrigger, priority=-1000)
|
||||
|
||||
@property
|
||||
def cagou_active(self):
|
||||
# 'R' status means Cagou is running in front
|
||||
return self.cagou_status[0] == 'R'
|
||||
# 'R' status means Cagou is running in front
|
||||
return self.cagou_status[0] == "R"
|
||||
|
||||
def _notifyMessage(self, mess_data, client):
|
||||
# send notification if there is a message and it is not a groupchat
|
||||
if mess_data['message'] and mess_data['type'] != C.MESS_TYPE_GROUPCHAT:
|
||||
message = mess_data['message'].itervalues().next()
|
||||
if mess_data["message"] and mess_data["type"] != C.MESS_TYPE_GROUPCHAT:
|
||||
message = mess_data["message"].itervalues().next()
|
||||
try:
|
||||
subject = mess_data['subject'].itervalues().next()
|
||||
subject = mess_data["subject"].itervalues().next()
|
||||
except StopIteration:
|
||||
subject = u'Cagou new message'
|
||||
subject = u"Cagou new message"
|
||||
|
||||
notification.notify(
|
||||
title = subject,
|
||||
message = message
|
||||
)
|
||||
if self.host.memory.getParamA(PARAM_VIBRATE_NAME, PARAM_VIBRATE_CATEGORY, profile_key=client.profile):
|
||||
notification.notify(title=subject, message=message)
|
||||
if self.host.memory.getParamA(
|
||||
PARAM_VIBRATE_NAME, PARAM_VIBRATE_CATEGORY, profile_key=client.profile
|
||||
):
|
||||
vibrator.vibrate()
|
||||
return mess_data
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue