def main_not(head_lines): for news in head_lines: for head in news.find_all('a'): title=head.text for cont in news.find_all('p'): msg=cont.text notify(msg,title)
def main_not(head_lines): for news in head_lines: for head in news.find_all('a'): title = head.text for cont in news.find_all('p'): msg = cont.text notify(msg, title)
def send_notifications(url_titles, url_points): if not url_titles: ntfy.notify("No hits were found!", "Hacker News Parser") return for i in range(len(url_titles)): ntfy.notify(url_points[i], url_titles[i]) return
def continueOrExit(): if options.notify: notify('Check the search process!', 'SearchCitations.py says:') ask = raw_input('Do You Want To Accept (a), Pass (p) or run away? ') if ask == 'p': print "... passed!" return 1 elif ask == 'a': print "... accepted." return 0 sys.exit(1)
def test_runcmd(self, mock_post): ret = notify('message', 'title', { 'backends': ['foobar'], 'foobar': { 'backend': 'pushover', 'user_key': 't0k3n', } }) self.assertEqual(ret, 0)
def put(self): args = self.reqparse.parse_args() # Assign a default value to title if nothing was recieved in request args['title'] = "flask" if args['title'] is None else args['title'] # Filter out None's from the dict and pass the cleaned dict directly to ntfy as kwargs if notify( **dict(filter(lambda a: a[1] is not None, args.items()))) != 0: return {'message': 'Unexpected response'}, 500 return {'message': 'Success'}, 200
def notify(rate: float, current_votes: int, threshold: int): prev_votes = None prev_time = None notified = False for response in poll(rate): votes = parse(response) time = arrow.now(SERVER_TZ) if prev_votes is None: prev_votes = votes prev_time = time log.info(f"Votes: {votes} ({current_votes})") continue if time.day != prev_time.day: current_votes = 0 notified = False if time.month != prev_time.month: prev_votes = votes current_votes += votes - prev_votes prev_votes = votes prev_time = time if current_votes > 0: remainder = (current_votes + threshold) % PARTY_FREQ if not notified and 0 <= remainder < threshold: notified = True message = f"Vote party in less than {threshold} votes!" log.info(message) ntfy.notify(message, "BlissScape Vote Party") elif remainder >= threshold: if notified: log.info("New vote party interval") notified = False log.info(f"Votes: {votes} ({current_votes})")
def sync(self, path, reverse=False): if not path.endswith("/"): path = path + "/" for ex in self.excludes: if ex.match(path): logging.info("EXCLUDED: %s" % path) return if '../' in path: logging.critical("What are you trying to do ?") return if not os.path.abspath(self.config["path_source"] + path).startswith( self.config["path_source"]): logging.critical( "What are you trying to do ? Cannot sync relative path.") return if self.notifications: ntfy.notify(title="🚣 Sync in progress", message="📂 %s" % path) logging.info("Sync for path %s has started", path) if reverse: args = (self.config["rsync"], self.rsync_ops, "'%s'" % (self.config["path_dest"] + path.replace(self.config["path_source"], "")), "'%s'" % path) else: args = (self.config["rsync"], self.rsync_ops, "'%s'" % path, "'%s'" % (self.config["path_dest"] + path.replace(self.config["path_source"], ""))) logging.debug("RSYNC: %s", (" ".join(args))) ret = os.system(" ".join(args)) if ret > 0: logging.warning("Sync for path %s has FAILED with error code %s", path, ret) if self.notifications: ntfy.notify(title="💢 FAILED 💢", message="'%s' sync failed with error=%s" % (path, ret)) else: logging.info("Sync for path %s has finished (%s)", path, ret) if self.notifications: ntfy.notify(title="🍻 Sync DONE 👍", message="📂 %s" % path)
def test_backenderror(self, mock_default_notify): mock_default_notify.side_effect = Exception ret = notify('message', 'title') self.assertEqual(ret, 1)
def top_not(title): for i in title: notify('', i.text)
def test_backenderror(self): ret = ntfy.notify('message', 'title') self.assertEqual(ret, 1)
def test_invalidbackend(self): ret = notify('message', 'title', {'backends': ['foobar']}) self.assertEqual(ret, 1)
def notification(des,synonym,query): notify(des.text+"\n"+", ".join(synonym[:3]),query.upper())
exp.diag_table = diag exp.namelist = namelist.copy() exp.namelist['constants_nml'][ 'grav'] = scale * 1.354 #surface gravity exp.namelist['constants_nml'][ 'pstd'] = scale * 14670000.0 #surface pressure - 100 times bigger than below values exp.namelist['constants_nml'][ 'pstd_mks'] = scale * 146700.0 #in Pa exp.namelist['spectral_dynamics_nml'][ 'reference_sea_level_press'] = scale * 146700.0 #in Pa exp.namelist['idealized_moist_phys_nml'][ 'convection_scheme'] = conv exp.namelist['mixed_layer_nml']['depth'] = depth_val exp.namelist['astronomy_nml']['per'] = per_value exp.set_resolution(*RESOLUTION) exp.inputfiles = [ os.path.join(GFDL_BASE, 'input/land_masks/titan_land_t21.nc') ] #!!! new line - location of topography file # with exp_progress(exp, description='o%.0f d{day}' % scale): exp.run(1, use_restart=False, num_cores=NCORES) for i in range(2, 179): # with exp_progress(exp, description='o%.0f d{day}' % scale): exp.run(i, num_cores=NCORES) notify( 'top down with conv scheme = ' + conv + ' has completed', 'isca')
if debug_bool: logfile_obj.write('%s - searching Lvl-String: %s\n' % (datetime.datetime.now(), lvlsearch_str)) for modulesearch_str in modulesearch_list: if debug_bool: logfile_obj.write( '%s - searching Module-String: %s\n' % (datetime.datetime.now(), modulesearch_str)) if lvlsearch_str in line_str and modulesearch_str in line_str: if not "999" in line_str: #This is to prevent getting a message, everytime a sensor reports a false value timestamp_acst, lvl_str, module_str, message_str = parse( '{} - {} - {} - {}', line_str) if not debug_bool: if not ntfyconfig_str: ntfy.notify( message_str, module_str.strip() + '-' + lvl_str.strip()) else: ntfy.notify(message_str, module_str.strip() + '-' + lvl_str.strip(), config=load_config( ntfyconfig_str.strip())) else: logfile_obj.write( '%s - Notify-Message: %s\n\n' % (datetime.datetime.now(), message_str)) sentmsg_int += 1 logfile_obj.write( '%s - %s read and %d messages sent.\n' %
def top_not(title): for i in title: notify('',i.text)