def post(self): self.response.headers['Content-Type'] = 'application/json' phone = self.request.get('phone') services = self.request.get('services').rstrip(',') query = db.GqlQuery( "SELECT * FROM SMSSubscriber WHERE phone = :1", phone) number_rows = query.count() if number_rows > 0: self.response.status = 409 self.response.out.write(json.dumps({ "error": phone + " is already subscribed." })) return txt = sms.SMS() try: txt.send(phone, "Successfully subscribed to Balanced " + services + " incidents. Reply with STOP to unsubscribe.") except TwilioException, e: LOGGER.error("Failed to send SMS via Twilio - " + e.msg) self.response.status = 400 self.response.out.write(json.dumps({ "error": e.msg })) return
def send_smses(service, current_state=None, twitter_tweet=None): # This is filthy. Don't judge me bro if service == "DASH": service = "DASHBOARD" sms_subscribers = models.SMSSubscriber.gql("WHERE services IN (:1)", service) if settings.DEBUG: LOGGER.info("SENDING NOTIFICATION TO [" + str(sms_subscribers.count()) + "] SMS SUBSCRIBERS") if service in settings.NOTIFY_SERVICES: txt = sms.SMS() for sms_subscriber in sms_subscribers: try: # Tweet if (twitter_tweet): twitter_tweet = twitter_tweet.strip() txt.send( sms_subscriber.phone, "@balancedstatus: {} - {}".format( service, twitter_tweet)) # UP/DOWN else: txt.send( sms_subscriber.phone, "Balanced {} is {}. Reply with STOP to unsubscribe.". format(service, current_state)) except TwilioException, e: LOGGER.error("Failed to send SMS via Twilio - " + e.msg) pass
def send(self, frm, sender, text): #send the message on behalf of the applcation #figure out if the message is bulk. s = sms.SMS() try: s.send(frm, sender, text) #sms.send_broadcasit('antani') except SMSException as e: print "Error: %s" % e
def sendbulk(self, sender, text): #send the message on behalf of the applcation #figure out if the message is bulk. s = sms.SMS() try: #s.send(20000, sender, text) s.send_broadcast_from(text,'all',sender) #sms.send_broadcast(text,'all') except SMSException as e: print "Error: %s" % e
def __init__(self,filename, parent = None, *args, **kwargs): #init the parent frame with the args passed to the constructor tk.Frame.__init__(self, parent, *args, **kwargs) self.filename = filename #make the window not resizable and pack it self.master.minsize(width = 600, height=400) self.master.maxsize(width=600, height = 400) self.pack() #main display self.mainDisplay = tk.Frame(self) self.sms = sms.SMS(self.filename) self.main() #PRODUCT VARS self.productDisplay = tk.Frame(self) self.addProductDisplay = tk.Frame(self) self.editProductDisplay =tk.Frame(self) self.viewDisplay = tk.Frame(self) self.deleteView = tk.Frame(self) self.queryProductID = tk.IntVar() self.productOptions = ('ID','Name','Price','Unit','Quantity','Case') self.productVars = dict([('id',tk.IntVar()),('name',tk.StringVar()),('price',tk.DoubleVar()),('unit',tk.StringVar()),('quantity',tk.IntVar()),('case',tk.IntVar())]) #ORDER VARS self.orderDisplay = tk.Frame(self) self.addOrderDisplay = tk.Frame(self) self.viewOrderDisplay = tk.Frame(self) self.orderHistoryDisplay = tk.Frame(self) self.makeOrderDisplay = tk.Frame(self) self.OrderVars = dict([('vendor', tk.StringVar()),('id',tk.IntVar()),('day',tk.IntVar()),('month',tk.IntVar()),('year',tk.IntVar())]) self.OrderOptions = ('id','vendor','products','date') self.viewOrderDate = tk.StringVar() self.viewOrderMode = tk.IntVar() self.vendorDisplay = tk.Frame(self) self.addVendorDisplay = tk.Frame(self) self.deleteVendorDisplay = tk.Frame(self) self.viewVendorDisplay = tk.Frame(self) self.viewVendorAll = tk.Frame(self) self.vendorVars = dict([('name',tk.StringVar()),('address',tk.StringVar()),('id',tk.IntVar())]) self.vendorID = tk.StringVar() #REPORTS VARS self.reportsDisplay = tk.Frame(self) self.inventoryDisplay = tk.Frame(self)
def construct_sms(self, text, sender): """ Constructs an SMS object and stores it internally. SMS messages should be created using this method instead of being instantiated directly. Once an SMS is created, it can be obtained via get_message_with_path. @param text: The message contents, in UTF-8 format. @param sender: The phone number of the sender. @returns: An instance of sms.SMS. """ if self._bus is None: raise SmsHandlerException('A bus has to be set before SMS objects ' 'can be created.') sms_object = sms.SMS(self._bus, sender, text) self._messages[sms_object.path] = sms_object # TODO(armansito): Split SMSs that are too big into multiple chunks. return sms_object
def send_smses(service, current_state): sms_subscribers = models.SMSSubscriber.gql("WHERE services IN (:1)", service) if settings.DEBUG: LOGGER.info("SENDING NOTIFICATION TO [" + str(sms_subscribers.count()) + "] SMS SUBSCRIBERS") txt = sms.SMS() for sms_subscriber in sms_subscribers: try: txt.send( sms_subscriber.phone, "Balanced {} is {}. Reply with STOP to unsubscribe.".format( service, current_state)) except TwilioException, e: LOGGER.error("Failed to send SMS via Twilio - " + e.msg) pass
'Host':'hq.sinajs.cn', 'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0' } headerOption = { 'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Encoding':'gzip, deflate', 'Accept-Language':'zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3', 'Cache-Control':'max-age=0', 'Connection':'keep-alive', 'Cookie':'YM=v=2&u=qjjOLtiPsy7pXio7PK9qzesIpfMEGuWd04IIew--&d=&f=CAA&t=6Cq3RB&s=48uT; DK=v=2&p=NnwyMzMwfFZpcnR1YWx8RGVza3RvcCBCcm93c2VyfHw-; B=ejb8t3d8tt85q&b=4&d=Ttv38YxpYFSNLwtnQHNVTA--&s=36&i=M0ZjKI7WKsEIbtERiDQv; Y=v=1&n=86klq4qqtui0v&l=5x1zsx3v1tvx0sv0z52wzruwwyvxv5zx/o&p=02qvvcn002000000&iz=&r=ro&lg=en-US%2Czh-Hans-CN%2Czh-CN&intl=cn&np=1; T=z=6Cq3RB6WR8RBL0H1s.K/mw9&a=YAE&sk=DAAXwtEc.FpIXn&ks=EAAUZdV4z.p3QoFTVE2LDYOtQ--~E&d=YQFZQUUBZwFLSEhMN05XR0taN1pSSFI2UlZCNVRVTVlNNAFzY2lkAWtLSmRkankyT01aOThQU0tMSlZrRGNTa05Qby0Bb2sBWlcwLQFhbAFoZnV0c3VjaGFvQGdtYWlsLmNvbQFzYwFtd2ViAXp6ATZDcTNSQkE3RQF0aXABaWhJT3VE&af=QkJBQzhaOGEmdHM9MTM3MzU0NDYzNCZwcz1NS1o2Si54Vm40UC5ZT2U0WXZwQ3VnLS0-; PRF=&t=BIDU&bid=sogo; ucs=bnas=0; ywadp10001840545256=3922551523; fpc10001840545256=ZWkKGWn1|mETNEVvNaa|fses10001840545256=|Yr6u7wrNaa|ZWkKGWn1|fvis10001840545256=|8Mo1H7so11|8Mo1H7so11|8Mo1H7so11|8|8Mo1H7so11|8Mo1H7so11; RMBX=ejb8t3d8tt85q&b=4&d=Ttv38YxpYFSNLwtnQHNVTA--&s=36&i=M0ZjKI7WKsEIbtERiDQv&t=251; fpc1000911397279=ZfeZCW8I|fkKFEVvNaa|fses1000911397279=|fkKFEVvNaa|ZfeZCW8I|fvis1000911397279=|8Mo1H7soM0|8Mo1H7soM0|8Mo1H7soM0|8|8Mo1H7soM0|8Mo1H7soM0; U=mt=CTnXoZ2MhYiREBb0ZmFNxn2Bk0Bl37vsqP0jy5fu&ux=MVYmSB&un=86klq4qqtui0v; ypcdb=491eab95295a54d471d92b9311a4854e', 'Host':'finance.yahoo.com', 'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0' } htmlHandle = html.Html() smsHandle = sms.SMS() #{{{ price get def stockDetail(stockNum): global htmlHandle,header myurl = 'http://hq.sinajs.cn/?_=0.7342358745470643&list=gb_' + stockNum html = htmlHandle.get(myurl,'') detail = html.split('="')[1].split(',') stockName = detail[0] nowPrice = detail[1] yesterdayPrice = detail[26] maxPrice = detail[8] minPrice = detail[7] changeRate = detail[2] return stockName,nowPrice,yesterdayPrice,maxPrice,minPrice,changeRate
def test_150_eh_1555500(self): self.sms = sms.SMS() sequencia = self.sms.converter('150') self.assertEquals('1555500', sequencia)
def test_python_e_10_eh_7999844666_660330100(self): self.sms = sms.SMS() sequencia = self.sms.converter('python e 10') self.assertEquals('7999844666_660330100', sequencia)
def test_ola_mundo_eh_66655520688663666(self): self.sms = sms.SMS() sequencia = self.sms.converter('ola mundo') self.assertEquals('66655520688663666', sequencia)
def test_hudson_eh_48376_6(self): self.sms = sms.SMS() sequencia = self.sms.converter('hudson') self.assertEquals('448837777666_66', sequencia)
def test_aa_eh_2_2(self): self.sms = sms.SMS() sequencia = self.sms.converter('aa') self.assertEquals('2_2', sequencia)
def test_ad_eh_23(self): self.sms = sms.SMS() sequencia = self.sms.converter('ad') self.assertEquals('23', sequencia)
def test_q_eh_7(self): self.sms = sms.SMS() sequencia = self.sms.converter('q') self.assertEquals('77', sequencia)
def test_b_eh_2(self): self.sms = sms.SMS() sequencia = self.sms.converter('b') self.assertEquals('22', sequencia)
from datetime import datetime from consoleColors import consoleColors from whois.parser import PywhoisError #global constants domainsPath = "../domains.txt" savedData = "../saved_data/data.json" expiredDomains = "../saved_data/expired.txt" domainMap = {} domains = [] recipient = None with open("../config.json") as config: conf = json.load(config) recipient = conf['recipient'] domains = [x.strip() for x in conf['domains']] messenger = sms.SMS(recipient) def stringToDateTime(string): return datetime.strptime(string, "%Y-%m-%d %H:%M:%S") def hasDomainBeenRenewed(prevDate, newDate): if prevDate == "None" or newDate is None: return False if stringToDateTime(newDate) > stringToDateTime(prevDate): return True else: return False
import fuzzy import flame import dht11 import sms import time dht = dht11.DHT11(pin=4) fis = fuzzy.FIS.instance() sender = sms.SMS() dht.set_next(fis) fis.set_next(sender) def onFlame(): dht.handle({}) time.sleep(10) if __name__ == '__main__': flame.register_callback(onFlame) while True: time.sleep(5)
#coding:utf-8 import sys import html, time import BeautifulSoup import sms import os htmlHandle = html.Html() sms = sms.SMS() #url = 'http://store.apple.com/cn/browse/finance/installments' url = 'http://store.apple.com/cn_cmb/browse/finance/installments/cmb' dic = {} def checkRate(): try: content = htmlHandle.get(url, '') content = BeautifulSoup.BeautifulSoup(content) for tr in content.findAll('tr', {'class': 'row-container-upper'}): tds = tr.findAll('th') for i, td in enumerate(tds): times = td.contents[0] dic[i] = times.strip() for tr in content.findAll('tr', {'class': 'row-container-percentage'}): tds = tr.findAll('td') for i, td in enumerate(tds):
def send_sms(*args): text_message = ",".join(args) ret = sms_buster.sendMessage(text_message,"09478727449") return ret def getIrKeyPress(): while True: code = lirc.nextcode() if len(code) > 0: code = code[0] print(code) eel.getKeyPressed(code) if ( code == "key_ok"): break #eel.spawn(getIrKeyPress) eel.start("index.html",block=False,cmdline_args=["--start-fullscreen"]) print("Running rural") socketid = lirc.init("test") lirc.set_blocking(False,socketid) sms_buster = sms.SMS(port = "/dev/ttyS0", baud = 115200, timeout = 1); eel.sleep(5.0) print("running IR") while True: getIrKeyPress() eel.sleep(5.0)