本文整理汇总了Python中helpers.smshelper.SMSHelper.send方法的典型用法代码示例。如果您正苦于以下问题:Python SMSHelper.send方法的具体用法?Python SMSHelper.send怎么用?Python SMSHelper.send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类helpers.smshelper.SMSHelper
的用法示例。
在下文中一共展示了SMSHelper.send方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: notify_maintainer
# 需要导入模块: from helpers.smshelper import SMSHelper [as 别名]
# 或者: from helpers.smshelper.SMSHelper import send [as 别名]
def notify_maintainer(db, redis, content, category):
"""Notify alarm info to maintainers.
:arg category: int, e.g.
1: gateway
2: eventer
"""
mobiles = []
emails = []
alarm_key = 'maintainer_alarm:%s' % category
alarm_interval = 60 * 5 # 5 minutes
alarm_flag = redis.getvalue(alarm_key)
if not alarm_flag:
maintainers = db.query(
"SELECT mid, mobile, email FROM T_MAINTAINER WHERE valid = 1")
for item in maintainers:
mobiles.append(item['mobile'])
emails.append(item['email'])
for mobile in mobiles:
SMSHelper.send(mobile, content)
for email in emails:
EmailHelper.send(email, content)
redis.setvalue(alarm_key, True, alarm_interval)
logging.info("[PUBLIC] Notify alarm to maintainers. content: %s, category: %s.",
content, category)
else:
logging.info("[PUBLIC] Notify alarm is ignored in 5 minutes. content: %s, category: %s.",
content, category)
示例2: send_offline_remind_sms
# 需要导入模块: from helpers.smshelper import SMSHelper [as 别名]
# 或者: from helpers.smshelper.SMSHelper import send [as 别名]
def send_offline_remind_sms(self):
logging.info("[CELERY] checkertask send offline remind sms started.")
try:
currenttime = int(time.time())
terminals = self.db.query("SELECT tid, alias, mobile, owner_mobile, offline_time"
" FROM T_TERMINAL_INFO"
" WHERE login = 0"
" AND service_status = 1"
" AND offline_time < %s",
(currenttime - 24*60*60))
for terminal in terminals:
sms_option = QueryHelper.get_sms_option_by_uid(terminal.owner_mobile, 'heartbeat_lost', self.db)
if sms_option == UWEB.SMS_OPTION.SEND:
ctime = get_terminal_time(currenttime)
ctime = safe_unicode(ctime)
alias = terminal['alias'] if terminal['alias'] else terminal['mobile']
sms = SMSCode.SMS_HEARTBEAT_LOST % (alias, ctime)
SMSHelper.send(terminal.owner_mobile, sms)
logging.info("[CELERY] Send offline remind sms to user:%s, tid:%s", terminal.owner_mobile, terminal.tid)
logging.info("[CELERY] checkertask send offline remind sms finished.")
except Exception as e:
logging.exception("[CELERY] Check terminal poweroff timeout exception.")
示例3: post
# 需要导入模块: from helpers.smshelper import SMSHelper [as 别名]
# 或者: from helpers.smshelper.SMSHelper import send [as 别名]
def post(self):
"""Insert new items."""
status = ErrorCode.SUCCESS
try:
data = DotDict(json_decode(self.request.body))
content = data.get('content', '')
mobiles = data.get('mobiles', None)
logging.info("[UWEB] Announcement request: %s", data)
except Exception as e:
status = ErrorCode.ILLEGAL_DATA_FORMAT
self.write_ret(status)
return
try:
mobiles_ = u''
if mobiles is not None:
mobiles_ = ','.join(mobiles)
for mobile in mobiles:
SMSHelper.send(mobile, content)
announcement = dict(cid=self.current_user.cid,
content=content,
mobiles=mobiles_)
record_announcement(self.db, announcement)
self.write_ret(status)
except Exception as e:
status = ErrorCode.SERVER_BUSY
logging.exception(
"[UWEB] record share failed, Exception: %s", e.args)
self.write_ret(status)
示例4: sms_to_whitelist
# 需要导入模块: from helpers.smshelper import SMSHelper [as 别名]
# 或者: from helpers.smshelper.SMSHelper import send [as 别名]
def sms_to_whitelist(self, sms, whitelist=None):
if not sms:
return
if whitelist:
for white in whitelist:
SMSHelper.send(white['mobile'], sms)
示例5: notify
# 需要导入模块: from helpers.smshelper import SMSHelper [as 别名]
# 或者: from helpers.smshelper.SMSHelper import send [as 别名]
def notify(self):
content = SMSCode.SMS_GW_ERROR_REPORT % ConfHelper.UWEB_CONF.url_out
for mobile in self.mobiles:
SMSHelper.send(mobile, content)
for email in self.emails:
EmailHelper.send(email, content)
示例6: check_service
# 需要导入模块: from helpers.smshelper import SMSHelper [as 别名]
# 或者: from helpers.smshelper.SMSHelper import send [as 别名]
def check_service(self):
try:
base_id = self.get_lid_by_tid(self.tid)
while True:
time.sleep(600) # 10 minutes
new_lid = self.get_lid_by_tid(self.tid)
logging.info("[CK] simulator terminal location base_id:%s, new_lid:%s",
base_id, new_lid)
if new_lid > base_id:
base_id = new_lid
else:
for mobile in self.mobiles:
sms = SMSCode.SMS_SERVICE_EXCEPTION_REPORT % ConfHelper.UWEB_CONF.url_out
SMSHelper.send(mobile, sms)
logging.info("[CK] Notify Administrator:%s By SMS, service exception!",
mobile)
for email in self.emails:
content = SMSCode.SMS_SERVICE_EXCEPTION_REPORT % ConfHelper.UWEB_CONF.url_out
EmailHelper.send(email, content)
logging.info("[CK] Notify Administrator:%s By EMAIL, service exception!",
email)
except KeyboardInterrupt:
logging.error("Ctrl-C is pressed.")
except Exception as e:
logging.exception("[CK] Check service failed. Exception: %s",
e.args)
示例7: move_data
# 需要导入模块: from helpers.smshelper import SMSHelper [as 别名]
# 或者: from helpers.smshelper.SMSHelper import send [as 别名]
def move_data():
db = DBConnection().db
mobiles = ['18310505991', '13693675352', '13581731204']
message = "数据库T_LOCATION已经完全转移到T_LOCATION_NEW,请及确认表信息的正确性和完整性。"
#max_row = 1000000000
max_row = 250000000
begin_time = time.gmtime(time.time())
for i in range(10000, max_row, 10000):
sql = "INSERT INTO T_LOCATION_NEW" \
" SELECT * FROM T_LOCATION WHERE id <=%d AND id > %d -10000" \
" and (timestamp between 0 and 1448899200)" % (i, i)
logging.info("exectue sql:%s", sql)
n = db.execute(sql)
#time.sleep(0.1)
logging.info("last record row id =%s", n)
break
# if i = 250000000:
if i == 240000000:
for mobile in mobiles:
SMSHelper.send(mobile, message)
print "send", mobile
end_time = time.gmtime(time.time())
L_bak = "alter table T_LOCATION rename to T_LOCATION_bak"
NEW_L = "alter table T_LOCATION_NEW rename to T_LOCATION"
for i in range(1, 5):
time.sleep(1)
logging.info("Will rename table neame after %d second", 5-i)
db.execute(L_bak)
db.execute(NEW_L)
logging.info("exchange tables T_LOCATION and T_LOCATION_NEW is accomplished ")
logging.info("Move table data begin_time:%s, end_time:%s", begin_time, end_time)
示例8: sms_to_user
# 需要导入模块: from helpers.smshelper import SMSHelper [as 别名]
# 或者: from helpers.smshelper.SMSHelper import send [as 别名]
def sms_to_user(self, dev_id, sms, mobile):
if not sms:
return
if not mobile:
return
if mobile:
SMSHelper.send(mobile, sms)
示例9: login_sms_remind
# 需要导入模块: from helpers.smshelper import SMSHelper [as 别名]
# 或者: from helpers.smshelper.SMSHelper import send [as 别名]
def login_sms_remind(self, uid, owner_mobile, terminals, login="WEB"):
sms_option = QueryHelper.get_sms_option_by_uid(uid, "login", self.db)
if sms_option == UWEB.SMS_OPTION.SEND:
login_time = time.strftime("%Y-%m-%d %H:%M:%S")
login_method = UWEB.LOGIN_WAY[login]
terminal_mobile = u"”,“".join(terminal.alias for terminal in terminals)
remind_sms = SMSCode.SMS_LOGIN_REMIND % (login_time, login_method, owner_mobile, terminal_mobile)
SMSHelper.send(owner_mobile, remind_sms)
示例10: check_push
# 需要导入模块: from helpers.smshelper import SMSHelper [as 别名]
# 或者: from helpers.smshelper.SMSHelper import send [as 别名]
def check_push(self):
"""
"""
res = self.db_push.get(
"SELECT count(id) as count FROM T_PUSH where status = 1")
if res and res['count'] >= self.alarm_size:
content = SMSCode.SMS_PUSH_REPORT % ConfHelper.UWEB_CONF.url_out
for mobile in self.mobiles:
SMSHelper.send(mobile, content)
for email in self.emails:
EmailHelper.send(email, content)
logging.info("[CK] Notify push queue exception to administrator!")
示例11: check_sms
# 需要导入模块: from helpers.smshelper import SMSHelper [as 别名]
# 或者: from helpers.smshelper.SMSHelper import send [as 别名]
def check_sms(self):
"""Notify administrators when sms to be send is more than alarm_size;
"""
res = self.db.get(
"SELECT count(id) as count FROM T_SMS where send_status = -1")
if res and res['count'] >= self.alarm_size:
content = SMSCode.SMS_SMS_REPORT % ConfHelper.UWEB_CONF.url_out
for mobile in self.mobiles:
SMSHelper.send(mobile, content)
for email in self.emails:
EmailHelper.send(email, content)
logging.info("[CK] Notify sms queue exception to administrator!")
示例12: alarm
# 需要导入模块: from helpers.smshelper import SMSHelper [as 别名]
# 或者: from helpers.smshelper.SMSHelper import send [as 别名]
def alarm(self):
"""
#NOTE: Send alarm message if need.
"""
send_flag = self.redis.getvalue(self.alarm_key)
if (not send_flag):
content = SMSCode.SMS_GW_DELAY_REPORT % ConfHelper.UWEB_CONF.url_out
for mobile in self.mobiles:
SMSHelper.send(mobile, content)
for email in self.emails:
EmailHelper.send(email, content)
logging.info("[CK] Notify S packet delay to administrator!")
self.redis.setvalue(self.alarm_key, True, self.alarm_interval)
示例13: send
# 需要导入模块: from helpers.smshelper import SMSHelper [as 别名]
# 或者: from helpers.smshelper.SMSHelper import send [as 别名]
def send(content, mobile):
logging.info("Send %s to %s", content, mobile)
#NOTE: send encrypt sms to mobile
response = SMSHelper.send(mobile, content)
#NOTE: send general sms to mobile
#response = SMSHelper.send(mobile, content)
logging.info("Response: %s", response)
示例14: post
# 需要导入模块: from helpers.smshelper import SMSHelper [as 别名]
# 或者: from helpers.smshelper.SMSHelper import send [as 别名]
def post(self):
"""Send captcha to user's phone through sms.
"""
status = ErrorCode.SUCCESS
try:
mobile = self.get_argument('mobile','')
captcha = ''.join(random.choice(string.digits) for x in range(6))
ios_captcha_sms = SMSCode.SMS_IOS_CAPTCHA % (captcha)
ret = SMSHelper.send(mobile, ios_captcha_sms)
ret = DotDict(json_decode(ret))
if ret.status == ErrorCode.SUCCESS:
logging.info("[CLIENT] passenger get sms captcha: %s successfully, mobile: %s",
captcha, mobile)
captcha_key = get_captcha_key(mobile)
self.redis.setvalue(captcha_key, captcha, UWEB.SMS_CAPTCHA_INTERVAL)
else:
status = ErrorCode.SERVER_BUSY
logging.error("[CLIENT] passenger get sms captcha failed, mobile: %s", mobile)
self.write_ret(status)
except Exception as e:
logging.exception("[CLIENT] passenger get sms captcha failed, mobile: %s. Exception: %s",
mobile, e.args)
status = ErrorCode.SERVER_BUSY
self.write_ret(status)
示例15: send
# 需要导入模块: from helpers.smshelper import SMSHelper [as 别名]
# 或者: from helpers.smshelper.SMSHelper import send [as 别名]
def send(self, content, mobile):
return
logging.info("Send %s to %s", content, mobile)
#NOTE: send encrypt sms to mobile
#response = SMSHelper.send_to_terminal(mobile, content)
#NOTE: send general sms to mobile
response = SMSHelper.send(mobile, content)
logging.info("Response: %s", response)