当前位置: 首页>>代码示例>>Python>>正文


Python smshelper.SMSHelper类代码示例

本文整理汇总了Python中helpers.smshelper.SMSHelper的典型用法代码示例。如果您正苦于以下问题:Python SMSHelper类的具体用法?Python SMSHelper怎么用?Python SMSHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SMSHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: send_offline_remind_sms

    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.")
开发者ID:jcsy521,项目名称:ydws,代码行数:25,代码来源:checkertask.py

示例2: notify_maintainer

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)
开发者ID:jcsy521,项目名称:ydws,代码行数:34,代码来源:public.py

示例3: get

    def get(self):
        status = ErrorCode.SUCCESS
        try:
            tid = self.get_argument('tid',None) 
            # check tid whether exist in request and update current_user
            self.check_tid(tid)

            terminal = self.db.get("SELECT id FROM T_TERMINAL_INFO"
                                   "  WHERE tid = %s"
                                   "    AND service_status = %s",
                                   self.current_user.tid,
                                   UWEB.SERVICE_STATUS.ON)
            if terminal: 
                lq_sms_key = get_lq_sms_key(self.current_user.tid) 
                sms = SMSCode.SMS_LQ % SMS.LQ.WEB 
                biz_type = QueryHelper.get_biz_type_by_tmobile(self.current_user.sim, self.db)
                if biz_type != UWEB.BIZ_TYPE.YDWS:
                    pass
                else:
                    SMSHelper.send_to_terminal(self.current_user.sim, sms) 
                self.redis.setvalue(lq_sms_key, True, SMS.LQ_INTERVAL)

                lq_interval_key = get_lq_interval_key(self.current_user.tid) 
                self.redis.setvalue(lq_interval_key, int(time.time()), (SMS.LQ.WEB*60 - 160))
                logging.info("[UWEB] wake up, send %s to Sim: %s", sms, self.current_user.sim) 
            else:
                status = ErrorCode.LOGIN_AGAIN
            self.write_ret(status) 
        except Exception as e:
            logging.exception("[UWEB] uid: %s wake up tid: %s failed.  Exception: %s", 
                              self.current_user.uid, self.current_user.tid, e.args) 
            status = ErrorCode.SERVER_BUSY
            self.write_ret(status)
开发者ID:jcsy521,项目名称:ydws,代码行数:33,代码来源:wakeup.py

示例4: sms_to_whitelist

    def sms_to_whitelist(self, sms, whitelist=None):
        if not sms:
            return

        if whitelist:
            for white in whitelist:
                SMSHelper.send(white['mobile'], sms)
开发者ID:jcsy521,项目名称:ydws,代码行数:7,代码来源:packettask.py

示例5: notify

    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)
开发者ID:jcsy521,项目名称:ydws,代码行数:7,代码来源:error.py

示例6: check_service

 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)
开发者ID:jcsy521,项目名称:ydws,代码行数:26,代码来源:checkservice.py

示例7: post

    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)
开发者ID:jcsy521,项目名称:ydws,代码行数:31,代码来源:announcement.py

示例8: move_data

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)
开发者ID:jcsy521,项目名称:ydws,代码行数:35,代码来源:move_table_location.py

示例9: login_sms_remind

    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)
开发者ID:jcsy521,项目名称:ydws,代码行数:9,代码来源:login.py

示例10: sms_to_user

    def sms_to_user(self, dev_id, sms, mobile):
        if not sms:
            return

        if not mobile:
            return

        if mobile:
            SMSHelper.send(mobile, sms)
开发者ID:jcsy521,项目名称:ydws,代码行数:9,代码来源:packettask.py

示例11: send_domain_sms

def send_domain_sms(db, redis, tid, mobile, domain):
    """Send domain sms to terminal..
    """
    sms_domain = SMSCode.SMS_DOMAIN % domain
    SMSHelper.send_to_terminal(mobile, sms_domain)
    self.db.execute("UPDATE T_TERMINAL_INFO SET domain = %s"
                    "  WHERE tid = %s",
                    domain_ip, tid)
    logging.info("[PUBLIC] Send domain sms: %s to mobile: %s",
                 sms_domain, mobile)
开发者ID:jcsy521,项目名称:ydws,代码行数:10,代码来源:public.py

示例12: kqly

def kqly(db, redis, tids):
    """Start bluetooth.
    """
    for tid in tids:
        terminal = QueryHelper.get_terminal_by_tid(tid, db)
        kqly_key = get_kqly_key(tid)
        kqly_value = redis.getvalue(kqly_key)
        if not kqly_value:
            interval = 30  # in minute
            sms = SMSCode.SMS_KQLY % interval
            SMSHelper.send_to_terminal(terminal.mobile, sms)
            redis.setvalue(kqly_key, True, SMS.KQLY_SMS_INTERVAL)
开发者ID:jcsy521,项目名称:ydws,代码行数:12,代码来源:public.py

示例13: check_sms

 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!")
开发者ID:jcsy521,项目名称:ydws,代码行数:12,代码来源:checkdb.py

示例14: check_push

 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!")
开发者ID:jcsy521,项目名称:ydws,代码行数:12,代码来源:checkdb.py

示例15: alarm

 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)
开发者ID:jcsy521,项目名称:ydws,代码行数:13,代码来源:terminal.py


注:本文中的helpers.smshelper.SMSHelper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。