class PushSafer(): """ Notifier for PushSafer\n For more information visit:\n https://www.pushsafer.com/ """ def __init__(self, config: Config): self.key = config.push_safer["key"] self.device_id = config.push_safer["deviceId"] self.enabled = config.push_safer["enabled"] if self.enabled and (not self.key or not self.device_id): raise PushSaferConfigurationError() if self.enabled: self.client = Client(self.key) def send(self, item: Item) -> None: """ Sends item information to the Pushsafer endpoint. """ if self.enabled: log.debug("Sending PushSafer Notification") message = f"New Amount: {item.items_available}" self.client.send_message(message, item.display_name, self.device_id, "", "", "", "", "", "", "", "", "", "", "", "", "")
class PushsaferNotificationService(BaseNotificationService): """Implement the notification service for Pushsafer.""" def __init__(self, privatekey): """Initialize the service.""" from pushsafer import Client self._privatekey = privatekey self.pushsafer = Client("", privatekey=self._privatekey) def send_message(self, message='', **kwargs): """Send a message to a user.""" # Make a copy and use empty dict if necessary data = dict(kwargs.get(ATTR_DATA) or {}) data['title'] = kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT) targets = kwargs.get(ATTR_TARGET) if not isinstance(targets, list): targets = [targets] for target in targets: if target is not None: data['device'] = target try: self.pushsafer.send_message(message, data['title'], "", "", "", "", "", "", "0", "", "", "") except ValueError as val_err: _LOGGER.error(str(val_err))
class PushsaferNotificationService(BaseNotificationService): """Implement the notification service for Pushsafer.""" def __init__(self, privatekey): """Initialize the service.""" from pushsafer import Client self._privatekey = privatekey self.pushsafer = Client( "", privatekey=self._privatekey) def send_message(self, message='', **kwargs): """Send a message to a user.""" # Make a copy and use empty dict if necessary data = dict(kwargs.get(ATTR_DATA) or {}) data['title'] = kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT) targets = kwargs.get(ATTR_TARGET) if not isinstance(targets, list): targets = [targets] for target in targets: if target is not None: data['device'] = target try: self.pushsafer.send_message(message, data['title'], "", "", "", "", "", "", "0", "", "", "") except ValueError as val_err: _LOGGER.error(str(val_err))
def __init__(self, config: Config): self.key = config.push_safer["key"] self.device_id = config.push_safer["deviceId"] self.enabled = config.push_safer["enabled"] if self.enabled and (not self.key or not self.device_id): raise PushSaferConfigurationError() if self.enabled: self.client = Client(self.key)
def send_push(self, message): try: init(privatekey=conf['keys']['pushsafer']) client = Client("") client.send_message(message=message, title="Found", device='a', sound="1", icon="20", vibration="2", answer=0, picture1=None, picture2=None, picture3=None, expire=None, time2live=None, url="", retry=None, urltitle=None, priority=5) print("Push notification has been send") except Exception as e: print(Fore.RED + str(e) + Fore.RESET)
def push(title="", message="", keys=None): if keys is not None: for key in keys: init(key) Client("").send_message(message, title, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) print "Pushed notification!"
class PushSafer(): def __init__(self, config: Config): self.key = config.push_safer["key"] self.device_id = config.push_safer["deviceId"] self.enabled = config.push_safer["enabled"] if self.enabled and (not self.key or not self.device_id): raise PushSaferConfigurationError() if self.enabled: self.client = Client(self.key) def send(self, item: Item): if self.enabled: log.debug("Sending PushSafer Notification") message = f"New Amount: {item.items_available}" self.client.send_message(message, item.display_name, self.device_id, "", "", "", "", "", "", "", "", "", "", "", "", "")
def pushnoti_init(): parser = argparse.ArgumentParser() parser.add_argument("--pushsafer_key", required=True, type=str, help="PushSafer private key") args = parser.parse_args() init(args.pushsafer_key) global __CLIENT __CLIENT = Client("")
def push_notification(self, time): push_title = str(time) + " min to DC!" Client("").send_message(message="You will disconnect soon!", title=push_title, device="a", icon="1", sound="0", vibration="1", url="http://192.168.0.142:5000/", urltitle="Tojvoroid", time2live="0", priority="0", retry="0", expire="0", answer="0", picture1="0", picture2="0", picture3="0")
metavar=('answer'), type=str, help='1 = Answer is possible, 0 = Answer is not possible.') # Argument processing args = parser.parse_args() privatekey = args.privatekey subject = args.subject message = args.message device = args.device icon = args.icon sound = args.sound vibration = args.vibration url = args.url urltitle = args.urltitle time2live = args.time2live priority = args.priority retry = args.retry expire = args.expire answer = args.answer # Try to send the notification init(privatekey) Client("").send_message(message, subject, device, icon, sound, vibration, url, urltitle, time2live, priority, retry, expire, answer, "", "", "") # Exit with success l("Success: Message sent with Private Key [%s]: " % (privatekey)) sys.exit(0)
def __init__(self, privatekey): """Initialize the service.""" from pushsafer import Client self._privatekey = privatekey self.pushsafer = Client( "", privatekey=self._privatekey)
def __init__(self, privatekey): """Initialize the service.""" from pushsafer import Client self._privatekey = privatekey self.pushsafer = Client("", privatekey=self._privatekey)
url = 'https://hackmit.org/' string_watch = "<!-- nice attempt, but puzzle isn't up yet -->" update_time = 60 event_fire_attempt = 0 event_fired = False while not event_fired: res = requests.get(url) event_fire_attempt = event_fire_attempt + 1 if not res.status_code == 200: print_wtime('failed to retrieve webpage (' + str(res.status_code) + ')... attempt #' + str(event_fire_attempt)) time.sleep(update_time) elif not string_watch in res.text: print_wtime('Event Fired: String detected at ' + url) event_fired = True init("9pF4clfsIC4DQGrQQgul") Client("").send_message("A puzzle has ben uploaded to HackMIT!", "Event Fired!", "17746", "26", "5", "3", "https://hackmit.org/", "HackMIT", "0", "1", "120", "1200", "0", "", "", "") else: print_wtime('no state change detected... attempt #' + str(event_fire_attempt)) time.sleep(update_time)
import logging import os import re import requests import sys from bs4 import BeautifulSoup from pushsafer import init, Client from time import sleep init(os.environ.get("PRIVATE_KEY")) pushClient = Client("iPhone") pattern = re.compile('"inventory_quantity":[0-999999]') url = "https://store.ui.com/collections/unifi-protect-cameras/products/uvc-g4-doorbell" logger = logging.getLogger() handler = logging.StreamHandler() formatter = logging.Formatter( '%(asctime)s %(name)-12s %(levelname)-8s %(message)s') handler.setFormatter(formatter) logger.addHandler(handler) logger.setLevel(logging.INFO) class BadResponseException(Exception): pass def check_inventory(): resp = requests.get(url) if resp.status_code != 200: logger.info("Did not get a valid response from unifi, exiting")
MT_TEMP_OUTSIDE = 6 # send at 0700 and 0730 AM MT_ALL_LIGHTS_OFF = 7 # send at 0900 AM in case of event MT_ISMCS_DOWN = 8 MT_ISMCSGIS_DOWN = 9 # Pushsafer configuration # secure ID HbsZo1UgOxna4oRPfn7x # iPhone7 deviceId 9209 # groupID IPHONE7 = 9209 # init pushsafer API init("HbsZo1UgOxna4oRPfn7x") pushsafer = Client("") # sentMessages stores key-value pairs where key is the message type and value is the time a message of that type was sent # this collection is used to limit sent messages sentMessages = {} def getHeatingOnHours(status): if (status['heating']['value'] == 'OFF'): return 0 if (status['heating']['value'] == None): return 0 since = parser.parse(status['heating']['since']) now = datetime.now(tzutc()) return (now - since).seconds / 3600
if running and dry and not notificationFlag: logger.info("The clothes are dry: sending notification") elapsed_time = time.time() - startTime ets = time.strftime("%H:%M:%S", time.gmtime(elapsed_time)) # Send notification init(pushKey) pushMsg = "Elapsed time : " + ets + "\n" + \ "Now {:.2f} C {:.2f} %RH\n".format(T1, H1) + \ "Delta {:.2f} C {:.2f} %RH".format(dT, dH) Client("").send_message(message=pushMsg, title="Clothes are dry", device=pushDeviceID, icon="62", sound="1", vibration="2", url="", urltitle="", time2live="0", picture1="", picture2="", picture3="") notificationFlag = True updateDisplay() sql = "INSERT INTO `Logs` (`TimeStamp`, `Temperature`, " + \ "`DT`, `Humidity`, `DH`, `DHavg`, `Running`, `Dry`, " + \ "`LCDBacklight`, `RemainingSec`, `Completed`) " + \ " VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)" sqlData = (time.strftime('%Y-%m-%d %H:%M:%S'), "{:.2f}".format(T1), None if dT is None else "{:.2f}".format(dT),
# name='', # version='', # packages=, # url='', # license='', # author='', # author_email='', # description='' import shutil import os import requests from pushsafer import Client,init url = 'http://nen.duckdns.org/dist/index1.php' url1 = 'https://pushmeapi.jagcesar.se' os.chdir('c:\\Users\\NAMIK\\Desktop\\nenra') shutil.make_archive('nenra','zip','nenra') files = {'file': open('c:\\Users\\NAMIK\\Desktop\\nenra\\nenra.zip', 'rb')} r = requests.post(url, files=files) appnot=" Namık ERDOĞAN saat 18:30 da çıkış yapmıştır" files1 = {'title':appnot,'url':'http://nen.duckdns.org/masa.php','token':'uttju5EvfwKMJHftmlPMtmj2WvYbUZRgScOQBPoGTfQRqZgXsp5UxWOI0GXyoi4t'} r = requests.post(url1,json=files1 ) init("cFZr0FW5Han7YxELPMZb") appnot=" Namık ERDOĞAN saat 18:30 da çıkış yapmıştır" Client("").send_message(appnot, "Bishop", "4274", "1", "4", "2", "https://www.pushsafer.com", "Open Pushsafer", "0", "", "", "")
# Arguments parser parser = argparse.ArgumentParser( description='Send Zabbix notification to Pushsafer') parser.add_argument('privatekey', metavar=('Private or Alias Key'), type=str, help='Pushsafer Private or Alias Key') parser.add_argument('subject', metavar=('Subject'), type=str, help='Subject you want to push to the device(s).') parser.add_argument('message', metavar=('Message'), type=str, help='Message you want to push to the device(s).') # Argument processing args = parser.parse_args() privatekey = args.privatekey subject = args.subject message = args.message # Try to send the notification init(privatekey) Client("").send_message(message, subject, "", "", "", "", "", "", "", "", "", "", "", "", "", "") # Exit with success l("Success: Message sent with Private Key [%s]: " % (privatekey)) sys.exit(0)
n_players = 100 starttime = time.time() # Turn off requests verification warning urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) # Get league and team names cookies = { 'espn_s2': 'AEAw9%2Fuxfn6t5tJAomwsmBkwmDu7u35FSUIn%2FDEa1zernBO7QjiTwcVjZTk5ZmbsckQ6Bwe9g5htKyE%2B1VHcdGKe%2BKpnEpcO6wuZa3%2BS1k2RBjsH%2F5wwU4%2BGsMNJbCxJ%2BjrxScV0cAlcSVNBDArKkVHSy6aC5Wjdl86Sc0xJzjrw0NGmCWwCNCQlp%2FYj%2B0WZEk87BCatAaVHsc1Ojwa%2FJ5ce6CMAY2dlhxjCUX3LrY3qTxTCqOftpSjfN51aaiYX5aeYHwWBShNhTnsTI%2Bo5FOi9', 'swid': '{9404E72D-02B1-41C9-84E7-2D02B191C9FC}' } kt_league = League(league_id=79672, year=2022, espn_s2=cookies['espn_s2'], swid=cookies['swid']) client = Client("ifGbTzg7JO0Ij4C2KkJ2") # Initialize activity and player list tmp_kt_act = kt_league.recent_activity()[0] player_list = buildPlayerList() # Get the Free Agent stats while True: try: # Get the recent activity in the league activity_kt = kt_league.recent_activity() except (Timeout, SSLError, ReadTimeoutError, ConnectionError) as e: print("Network error occurred. Keep calm and carry on.") except Exception as e: print("Unexpected error!") finally: logging.info("Stream has crashed. System will restart twitter stream!")