def push_notifs_for_message(sender, recipient, squawk_id, thread_identifier, thread_member_count=2): name = name_for_user(sender, recipient) recipient_user = db.users.find_one({"phone": recipient}) sound = alert = None if push.should_send_push_to_user_for_thread(recipient, thread_identifier): sound = "squawk.caf" n_other_recipients = thread_member_count - 2 if sender == recipient: alert = None elif n_other_recipients <= 0: alert = localized.localized_message(localized.sent_you_a_squawk, recipient_user) % (name) elif n_other_recipients == 1: alert = localized.localized_message( localized.sent_you_and_one_other_a_squawk, recipient_user) % (name) else: alert = localized.localized_message( localized.sent_you_and_n_others_a_squawk, recipient_user) % (name, n_other_recipients) for token_info in db.push_tokens.find({"phone": recipient}): notif = push.Push(recipient, token_info['type'], token_info['token'], alert, sound, { "type": "message", "squawk_id": str(squawk_id) }) if recipient != sender: notif.content_available = True yield notif
def notify(): pushes = [] me = util.myphone() user = db.users.find_one({"phone": me}) if not user.get('notified_friends_yet', False): user['notified_friends_yet'] = True db.users.save(user) matching_listings = db.contact_listings.find( {"contact_phones": { "$in": [me] }}) for listing in matching_listings: recipient = listing['phone'] name = squawk.name_for_user(me, recipient) user_receiving_notif = db.users.find_one({"phone": recipient}) alert = localized.localized_message( localized.contact_joined_squawk, user_receiving_notif) % (name) for token_info in db.push_tokens.find({"phone": recipient}): # def __init__(self, phone, type, token, alert=None, sound=None, data=None): pushes.append( push.Push(recipient, token_info['type'], token_info['token'], alert=alert, data={ "type": "friend_joined", "phone": me })) pushes[-1].content_available = True push.send_pushes(pushes) robot.send_robot_message(me) return json.dumps({"success": True})
def run_push(self): sys.stdout = self ## sys.stderr = self try: del (sys.modules["push"]) except: ## Yeah, it's a real ugly solution... pass import push push.Push() sys.stdout = sys.__stdout__
def pub_depth(event, depth): logging.debug(depth) if settings.USE_ZMQ: import push push = push.Push() r = push.notify_obj({'event': event, 'data': depth}) return try: import tentacle r = tentacle.push_message({'event': event, 'data': depth}) except: logging.debug('error on pushing exchange orderbook', exc_info=True) return
def __init__(self): self._options = {} #Add menu classes self._optionLookup = {} #Add/order your menu option here self._options = [ addSubproject.AddSubproject(), bundle.Bundle(), bundle.Unbundle(), branches.Branches(), status.Status(), stash.Stash(), checkout.Checkout(), push.Push(), pull.Pull(), commit.Commit(), publish.Publish(), clone.Clone(), config.Config(), grapeConfig.WriteConfig(), foreach.ForEach(), merge.Merge(), mergeDevelop.MergeDevelop(), mergeRemote.MergeRemote(), deleteBranch.DeleteBranch(), newWorkingTree.NewWorkingTree(), resolveConflicts.ResolveConflicts(), review.Review(), test.Test(), updateLocal.UpdateLocal(), updateSubproject.UpdateSubproject(), hooks.InstallHooks(), hooks.RunHook(), updateView.UpdateView(), version.Version(), walkthrough.Walkthrough(), quit.Quit() ] #Add/order the menu sections here self._sections = [ 'Getting Started', 'Code Reviews', 'Workspace', 'Merge', 'Gitflow Tasks', 'Hooks', 'Patches', 'Project Management', 'Other' ]
def send_checkmark(): # calling this endpoint with GET is deprecated! recipients = util.args()['recipients'] if 'recipients' in util.args( ) else [util.args()['recipient']] sender = util.myphone() thread_identifier = util.args().get('thread_identifier', '') pushes = [] for recipient in set(recipients): if not push.should_send_push_to_user_for_thread( recipient, thread_identifier): continue name = squawk.name_for_user(sender, recipient) message = u"%s: ✓" % (name) for token_info in db.push_tokens.find({"phone": recipient}): pushes.append( push.Push(recipient, token_info['type'], token_info['token'], message, "", {"type": "checkmark"})) push.send_pushes(pushes) return json.dumps({"success": True})
__author__ = 'chance' from bs4 import BeautifulSoup import tools import time import push inst = push.Push() o_pts = new_o_pts = 0 sleep_interval = 2 url = "http://fantasy.espn.com/baseball/team?leagueId=162788&seasonId=2019&teamId=4&fromTeamId=4" driver = tools.get_driver() driver.get(url) time.sleep(7) while (1): print("Check: " + str(o_pts)) html = driver.page_source soup = BeautifulSoup(html, "lxml") my_data = soup.find_all("span", {"class": "team-record ttl"}) if len(my_data) > 0: new_o_pts = my_data[0].get_text()[:-4] if (new_o_pts != o_pts): chg = int(new_o_pts) - int(o_pts) print("Chg: " + str(chg)) print("New: " + str(new_o_pts)) inst.push_change(chg, "TOT PTS", str(new_o_pts)) o_pts = new_o_pts else:
def start_brew(self): ##initialize sound for acoustic warnings self.sound = Sound.Sound() ##initialize temperature probe self.temperature = Temp.Temp() ##initialize relay for heat self.heat = Relay.Relay(21) self.notification = push.Push() ##TODO - plotting - thread.start_new_thread(self.plot_data, ()) self.status = "heating to mash" self.notification.sendString(self.TITLE, self.status) ##TODO - telegram - thread.start_new_thread(self.telegramchat, ()) ##increase to mash temperature # elapsed_time_tmash=self.temperature.increase_to(self.mash_temp, self.heat) ##acoustic warning -insertgrain- self.notification.sendString(self.TITLE, self.INSERTGRAIN) self.status = "mash" ##keep tmash constant for mash_time taken from recipe # self.temperature.keep_constant(self.mash_temp, self.mash_time, self.heat) ##acoustic warning -removegrain- ##self.sound.play(self.REMOVEGRAIN) self.notification.sendString(self.TITLE, self.REMOVEGRAIN) self.status = "heating to boil" ##increase temperature for boiling elapsed_time_tboil = self.temperature.increase_to( self.boil_temp, self.heat) ##start timers ##end of boiling - timer - timer_end = Timer.Timer(self.boil_time * 60, self.notification, self.BOILEND) ##insert cooling element -timer- timer_coolinginsert = Timer.Timer( (self.boil_time - 15) * 60, self.notification, self.COOLINGINSERT) timer_end.start() timer_coolinginsert.start() if self.hop_bitter: ##timer for inserting hops for bittering timer_hop_bitter = Timer.Timer( (self.boil_time - self.hop_bitter.boil_time) * 60, self.notification, self.HOPBITTER) timer_hop_bitter.start() if self.hop_taste: if (self.hop_taste.boil_time > 0): ##timer for inserting hops for taste timer_hop_taste = Timer.Timer( (self.boil_time - self.hop_taste.boil_time) * 60, self.notification, self.HOPTASTE) timer_hop_taste.start() if self.hop_flav: if (self.hop_flav.boil_time > 0): ##timer for inserting hops for flavour timer_hop_flav = Timer.Timer( (self.boil_time - self.hop_flav.boil_time) * 60, self.notification, self.HOPFLAV) timer_hop_flav.start() ##boil -> keep resistance always on for boil time ##start boiling for boil time -heat always on- self.status = "boil" self.notification.sendString(self.TITLE, self.status) self.temperature.boil(self.boil_time, self.heat) ##boil end ##switch off heat self.status = "end" self.heat.off() self.notification.sendString(self.TITLE, self.BOILEND) print "BREW END" self.plot = 1 self.chat = 1 self.save_data() print "data saved!" print ""