本文整理汇总了Python中tart.send函数的典型用法代码示例。如果您正苦于以下问题:Python send函数的具体用法?Python send怎么用?Python send使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了send函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handleGetExistingPurchasesResponse
def handleGetExistingPurchasesResponse(self, event):
print(event, event.type, event.code)
if (event.type == SUCCESS_RESPONSE):
purchases = self.getPurchases(event)
tart.send('existingPurchasesResponse', purchases=purchases)
elif (event.type == FAILURE_RESPONSE):
self.handleErrorResponse(event)
示例2: onSendComment
def onSendComment(self, source, text):
res = self.sess.postComment(source, text)
text = text.replace('*', '')
if (res == True):
tart.send('commentPosted', result="true", comment=text)
return
tart.send('commentPosted', result="false", comment="")
示例3: onParseFeed
def onParseFeed(self, snaps):
print("Parsing snaps...")
for snap in snaps:
if 'media' not in snap:
snap['media'] = ''
if snap['countdown'] != '':
snap['countdown'] = int(snap['countdown'])
print("MEDIA TYPE NUMBER", snap['media_type'])
snap['time'] = self.prettyDate(snap['sent'] // 1000)
if snap['media_type'] == 0:
snap['media'] = 'picture'
elif snap['media_type'] in [1, 2]:
snap['media'] = 'video'
if snap['recipient'] == '': # Snap recieved
snap['type'] = 'Recieved' # recieved == 1
else:
snap['user'] = snap['recipient']
print(snap['opened'])
if snap['opened'] == 1:
snap['type'] = 'Opened' # sent == 2
snap['media'] = 'sent'
else:
snap['type'] = 'Sent' # sent == 2
snap['media'] = 'sent'
if snap['media_type'] != '':
if int(snap['media_type']) >= 3: # Notifications
snap['type'] = 'Notification' # notif == 3
for result in sorted(snaps, key=itemgetter('type')):
tart.send('snapsReceived', snap=result)
示例4: send_flags_message
def send_flags_message(self):
allowed = bbmsp_is_access_allowed()
access = self.get_access_code()
profile = bbmsp_can_show_profile_box()
invite = bbmsp_can_send_bbm_invite()
tart.send('bbmFlags', allowed=allowed, access=access,
profile=profile, invite=invite)
示例5: handle_event
def handle_event(self, bps_event):
'''Handle BPS events for bbmsp domain'''
# print('domain', domain, 'bbm_domain', bbmsp_get_domain())
event = self.make_event(bps_event)
if event.is_reg_state_event():
# TODO: build the code into the event somehow (can you
# retrieve it from the event?)
self.prev_access = code = self.get_access_code()
tart.send('bbmAccess', state=code,
text=self.REG_STATE_NAMES.get(code, '?unrecognized?'))
# tart.send('bbmAccessTest', state=code,
# text=self.REG_STATE_NAMES.get(code, '?unrecognized?'))
else:
code = self.get_access_code()
if code != self.prev_access:
self.prev_access = code
tart.send('bbmAccess', state=code,
text=self.REG_STATE_NAMES.get(code, '?unrecognized?'))
# tart.send('bbmAccessTest', state=code,
# text=self.REG_STATE_NAMES.get(code, '?unrecognized?'))
fake_event = BbmEvent(0,
BBMSP_REGISTRATION,
BBMSP_SP_EVENT_ACCESS_CHANGED,
None,
fake=True)
self.fsm.execute(fake_event)
if event.is_user_profile_event():
self.check_user_profile_event(event)
self.fsm.execute(event)
示例6: onCopyComment
def onCopyComment(self, comment, poster):
soup = BeautifulSoup(comment)
from tart import clipboard
c = clipboard.Clipboard()
mimeType = 'text/plain'
c.insert(mimeType, str(soup.text))
tart.send('commentCopied', poster=poster)
示例7: onFillList
def onFillList(self):
print("Getting list of users....")
gd = gitDate()
results = gd.calculateCompatibility(self.personalData)
print("List Received!!")
for result in results:
tart.send('datesReceived', result=result)
示例8: onGetGlobalStream
def onGetGlobalStream(self):
from adn.adn import Adn
app = Adn()
self.stream = app.globalStream()
validStream = True
for item in self.stream['data']:
if 'html' in item:
item['html'] = item['html'].replace("<br>", "<br/>")
validStream = True
else:
validStream = False
if validStream:
tart.send('receivedGlobalStream', stream=self.stream)
import tempfile
temp_dir = tempfile.gettempdir()
import os
for the_file in os.listdir(temp_dir):
filepath = os.path.join(temp_dir, the_file)
try:
if os.path.isfile(filepath):
os.unlink(filepath)
except Exception as e:
print(e)
self.getAvatarImages()
else:
self.onGetGlobalStream()
示例9: run
def run(self):
while True:
# wait for some time or for someone to signal us
try:
msg = self.queue.get(timeout=self.CHECK_PERIOD)
except queue.Empty:
pass
else:
print('got', msg)
if msg is None:
break
# process msg, if any
changed = []
for target in os.listdir(self.folder):
if not target.endswith('.qml'):
# print('ignoring', target)
continue
if re.match(self.CLONE_PAT, target):
# print('ignoring', target)
continue
tpath = os.path.join(self.folder, target)
stat = os.stat(tpath)
signature = (stat.st_mtime, stat.st_size)
if signature != self._prev_sigs.get(target):
print('sig', target, signature)
self._prev_sigs[target] = signature
changed.append(target)
if changed:
print('files changed: {}'.format(', '.join(sorted(changed))))
path = self.clone_target()
tart.send('fileChanged', path=path)
示例10: parseFeed
def parseFeed(self, feed):
print('parsing', feed.feed.title, feed.updated)
self.state['last_published'] = time.mktime(feed.updated_parsed)
self.state['last_checked'] = time.time()
url = self.state['site_url'] = feed.feed.link
tart.send('siteUrl', url=url)
print('found entries:', len(feed.entries))
count = 0
for item in feed.entries:
# ignore ones we've already seen
if item.link in self.entries:
print('ignoring, known', item.link)
continue
count += 1
imagepath = self.addImage(item)
tags = {x.term for x in item.tags} - {'Uncategorized'}
entry = {
'url': item.link,
'title': item.title,
'pubtime': time.mktime(item.published_parsed),
'image': imagepath,
'summary': item.summary.split('Filed under')[0].strip(),
'tags': ', '.join(sorted(tags)),
}
self.addEntry(entry)
self.entries[entry['url']] = entry
return count
示例11: parse_loop_feiertage
def parse_loop_feiertage(self, termine):
results = []
for start_ende in termine.readlines():
if start_ende.startswith('SUMMARY:'):
summary = start_ende[8:-1]
if summary != 'Volkstrauertag':
summary = summary.replace('ue', 'ü')
summary = summary.replace('ae', 'ä')
summary = summary.replace('oe', 'ö')
results.append(summary)
#date of the holiday
if start_ende.startswith('DTSTART;VALUE=DATE:'):
datum_start = start_ende[19:27]
ds = datum_start[6:8]
ms = datum_start[4:6]
ys = datum_start[0:4]
#set day of the week with datetime.weekday()
tag = ["Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag", "Sonntag"][date(int(ys), int(ms), int(ds)).weekday()]
datum = '{0}, {1}.{2}.{3}'.format(tag, ds, ms, ys)
results.append(datum)
#Send the final list to QMLs "onGetPythonList" function via BB-Tart
tart.send("getPythonList", liste=results)
示例12: onCopy
def onCopy(self, data):
from tart import clipboard
c = clipboard.Clipboard()
mimeType = "text/plain"
c.insert(mimeType, articleLink)
tart.send("copyResult", text=data + " copied to clipboard!")
示例13: parse_ferien
def parse_ferien(self, jahr, bundesland):
results = []
with open('app/native/assets/data/{0}/ferien/Ferien_{1}_{2}.ics'.format(jahr, bundesland, jahr)) as termine:
for start_ende in termine.readlines():
#holiday names are found at SUMMARY and is parsed here
if start_ende.startswith('SUMMARY:'):
summary = start_ende[8:-1]
summary = summary.replace('ue', 'ü')
summary = summary[:len(summary)-len(bundesland)]
results.append(summary)
#start and end of the holidays parsed
if start_ende.startswith('DTSTART;VALUE=DATE:'):
datum_start = start_ende[19:27]
ds = datum_start[6:8]
ms = datum_start[4:6]
ys = datum_start[0:4]
if start_ende.startswith('DTEND;VALUE=DATE:'):
datum_ende = start_ende[17:25]
de = datum_ende[6:8]
me = datum_ende[4:6]
ye = datum_ende[0:4]
datum = '{0}.{1}.{2} - {3}.{4}.{5}'.format(ds, ms, ys, de, me, ye)
results.append(datum)
#Send the final list to QMLs "onGetPythonList" function via BB-Tart
tart.send('getPythonList', liste=results)
示例14: onUiReady
def onUiReady(self):
# need to defer sending this, for now, until the event loop has started
tart.send('restoreSettings', **self.settings)
# install BPS event handler for vkb events, which for now reports
# "keyboardState" events with boolean property "visible"
vkb_handler.VkbHandler(self.bps_dispatcher)
示例15: onParseFeed
def onParseFeed(self, updates):
snaps = []
for item in updates['snaps']:
snap = {
'url': item['id'],
'media_id': self.testEmpty(item, 'c_id'),
'media_type': self.testEmpty(item, 'm'), # >3 Friend Request
'time': self.testEmpty(item,'t'),
'sender': self.testEmpty(item, 'sn'),
'recipient': self.testEmpty(item, 'rp'),
'status': item['st'], # Sent, Delivered, Opened, Screenshotted
'sent': item['sts'],
'opened': item['ts']
}
if snap['media_type'] == 0:
snap['media'] = 'image'
elif snap['media_type'] in [1, 2]:
snap['media'] = 'video'
if snap['recipient'] == '': # Snap recieved
snap['type'] = '1' # recieved == 1
else:
snap['type'] = '2' # sent == 2
if snap['media_type'] >= 3: # Notifications
snap['type'] = '3' # notif == 3
snaps.append(snap)
for result in sorted(snaps, key=itemgetter('type')):
tart.send('snapsRecieved', snap=result)