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


Python Session.send_sms方法代码示例

本文整理汇总了Python中session.Session.send_sms方法的典型用法代码示例。如果您正苦于以下问题:Python Session.send_sms方法的具体用法?Python Session.send_sms怎么用?Python Session.send_sms使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在session.Session的用法示例。


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

示例1: str

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import send_sms [as 别名]
    for phone_number in farmers:
        s = Subscription.objects.select_related().filter(phone_number_id=phone_number).order_by('market')
        market_id = 0
        substring = ''
        substrings_list = []
        for item in s:
            if market_id != item.market_id:
                market_id = item.market_id
                if substring:
                    substrings_list.append(substring[:-1])
                substring = market_abbr[market_id] + '-'
            substring += str(item._crop_cache) + ':' + quotes[market_id][item.crop_id] + ','
        substrings_list.append(substring[:-1])
        message = '/'.join(substrings_list)
        try:
            response = session.send_sms(phone_number, message)
            if not response['Queued']:
                syslog.syslog('Error - Failed to send message to %s. - %s' % (phone_number,response['SMSError']))
            sms = SMS(phone_number = Farmer.objects.get(phone_number=phone_number),
                      message = message,
                      posttime = timezone.now(),
                      cdyne_posttime = response['SentDateTime'],
                      cdyne_sms_id = response['MessageID'],
                      cancelled = response['Cancelled'],
                      error = response['SMSError'],
                      queued = response['Queued'],
                      sent = response['Sent'])
            sms.save()
        except Exception, e:
            syslog.syslog(str(e))
开发者ID:gei08a,项目名称:ews,代码行数:32,代码来源:send_sms.py

示例2: send_sms

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import send_sms [as 别名]
def send_sms(phone_number):

    m = Market.objects.all()
    market_abbr = {}

    for item in m:
        market_abbr[item.id] = item.abbreviation

    f = Farmer.objects.all()
    farmers = []

    for item in f:
        farmers.append(item.phone_number)

    q = Quote.objects.filter(date=timezone.now().strftime('%Y-%m-%d')).order_by('market')
    if not q:
        return False
    quotes = {}

    market_id = 0
    for item in q:
        if market_id != item.market_id:
            market_id = item.market_id
            quotes[market_id] = {}
        quotes[market_id][item.crop_id] = str(item.price)

    license_key = get_license_key()
    session = Session(license_key)

    s = Subscription.objects.select_related().filter(phone_number_id=phone_number).order_by('market')
    market_id = 0
    substring = ''
    substrings_list = []
    for item in s:
        if market_id != item.market_id:
            market_id = item.market_id
            if substring:
                substrings_list.append(substring[:-1])
            substring = market_abbr[market_id] + '-'
        substring += str(item._crop_cache) + ':' + quotes[market_id][item.crop_id] + ','
    substrings_list.append(substring[:-1])
    message = '/'.join(substrings_list)
    if not message:
        return False

    try:
        response = session.send_sms(phone_number, message)
        if not response['Queued']:
            syslog.syslog('Error - Failed to send message to %s. - %s' % (phone_number,response['SMSError']))
        sms = SMS(phone_number = Farmer.objects.get(phone_number=phone_number),
                  message = message,
                  posttime = timezone.now(),
                  cdyne_posttime = response['SentDateTime'],
                  cdyne_sms_id = response['MessageID'],
                  cancelled = response['Cancelled'],
                  error = response['SMSError'],
                  queued = response['Queued'],
                  sent = response['Sent'])
        sms.save()
        return message
    except Exception, e:
        syslog.syslog(str(e))
        return False
开发者ID:gei08a,项目名称:ews,代码行数:65,代码来源:views.py


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