本文整理汇总了Python中subscriber.Subscriber.authorized方法的典型用法代码示例。如果您正苦于以下问题:Python Subscriber.authorized方法的具体用法?Python Subscriber.authorized怎么用?Python Subscriber.authorized使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类subscriber.Subscriber
的用法示例。
在下文中一共展示了Subscriber.authorized方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: deactivate_subscriptions
# 需要导入模块: from subscriber import Subscriber [as 别名]
# 或者: from subscriber.Subscriber import authorized [as 别名]
def deactivate_subscriptions(self, msg):
try:
sms = SMS()
sub = Subscriber()
cur = db_conn.cursor()
cur.execute('SELECT msisdn FROM subscribers WHERE subscription_status = 0')
count = cur.rowcount
if count > 0:
self.logger.info('Found %d subscribers to be deactivated' % count)
subscribers_list = cur.fetchall()
for mysub in subscribers_list:
self.logger.debug('Send SMS that account is deactivated to %s' % mysub[0])
sms.send(config['smsc'],mysub[0], msg)
# disable subscriber
try:
sub.authorized(mysub[0], 0)
except SubscriberException as e:
raise SubscriptionException('PG_HLR error in deactivating subscription: %s' % e)
else:
self.logger.info('No subscribers need to be deactivate')
except psycopg2.DatabaseError as e:
raise SubscriptionException('PG_HLR error in checking subscriptions to deactivate: %s' % e)