• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python subscriber.Subscriber类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: add

    def add(self, msisdn, credit):
        sub = Subscriber()
        sms = SMS();
        try:
            mysub = sub.get(msisdn)
        except SubscriberException as e:
            raise CreditException(e)

        current_balance = sub.get_balance(msisdn)
        new_balance = Decimal(str(credit)) + Decimal(str(current_balance))

        # update subscriber balance
        try:
            cur = db_conn.cursor()
            cur.execute('UPDATE subscribers SET balance=%(new_balance)s WHERE msisdn=%(msisdn)s', {'new_balance': Decimal(str(new_balance)), 'msisdn': msisdn})
            sms.send(config['smsc'], msisdn, sms_credit_added % (credit, new_balance))
        except psycopg2.DatabaseError as e:
            raise CreditException('PG_HLR error updating subscriber balance: %s' % e)

        # insert transaction into the credit history
        try:
            cur = db_conn.cursor()
            cur.execute('INSERT INTO credit_history(msisdn,previous_balance,current_balance,amount) VALUES(%s,%s,%s,%s)', (msisdn, current_balance, new_balance, credit))
        except psycopg2.DatabaseError as e:
            db_conn.rollback()
            raise CreditException('PG_HLR error inserting invoice in the history: %s' % e)
        finally:
            db_conn.commit()
开发者ID:ciaby,项目名称:rccn,代码行数:28,代码来源:credit.py


示例2: validate_data

 def validate_data(self, pin):
     res_log.debug('Check PIN length')
     if len(pin) > 4 or len(pin) < 4:
         raise ResellerException('PIN invalid length')
 
 
     res_log.debug('Check if Reseller exists')
     # check if reseller exists in the database and the PIN is valid
     try:
         cur = db_conn.cursor()
         cur.execute('SELECT msisdn,pin FROM resellers WHERE msisdn=%(msisdn)s', {'msisdn': str(self.reseller_msisdn)})
         if cur.rowcount > 0:
             res_log.debug('Valid Reseller found')
             res_log.debug('Auth PIN')
             data = cur.fetchone()
             if data[1] != pin:
                 raise ResellerException('Invalid PIN!')
             res_log.debug('Check if subscriber is valid')
             # check if subscriber exists
             try:
                 sub = Subscriber()
                 sub.get(self.subscriber_msisdn)
             except SubscriberException as e:
                 raise ResellerException('Invalid subscriber')
     
         else:
             raise ResellerException('Invalid Reseller')
     except psycopg2.DatabaseError as e:
         raise ResellerException('Database error getting reseller msisdn: %s' % e)
开发者ID:Rhizomatica,项目名称:rccn,代码行数:29,代码来源:reseller.py


示例3: test_non_ascii_char

 def test_non_ascii_char(self):
     subscriber = Subscriber()
     subscriber.lastname = u'Toto°°'
     subscriber.issues_to_receive = 1
     subscriber.save()
     line = get_first_line()
     self.assertTrue(line is not None)
开发者ID:rtouze,项目名称:GAabo,代码行数:7,代码来源:test_subscriber_exporter.py


示例4: test_email_in_lowercase

 def test_email_in_lowercase(self):
     """Tests that in generated file, the emails are in lower case"""
     subscriber = Subscriber()
     subscriber.issues_to_receive = 0
     subscriber.email_address = '[email protected]'
     subscriber.save()
     lines = self.export_and_get_lines()
      
     self.assertEqual('[email protected]', lines.strip())
开发者ID:rtouze,项目名称:GAabo,代码行数:9,代码来源:test_subscriber_exporter.py


示例5: test_remaining_issues_subscriber

    def test_remaining_issues_subscriber(self):
        """Tests when the subscriber has remaining issues"""
        subs = Subscriber()
        subs.issues_to_receive = 1
        subs.email_address = '[email protected]'
        subs.save()
        lines = self.export_and_get_lines()

        self.assertEqual('', lines)
开发者ID:rtouze,项目名称:GAabo,代码行数:9,代码来源:test_subscriber_exporter.py


示例6: test_one_email

    def test_one_email(self):
        """Test retrieval of one subscriber's email"""
        subscriber = Subscriber()
        subscriber.issues_to_receive = 0
        subscriber.email_address = '[email protected]'
        subscriber.save()
        lines = self.export_and_get_lines()

        self.assertEqual('[email protected]', lines.strip())
开发者ID:rtouze,项目名称:GAabo,代码行数:9,代码来源:test_subscriber_exporter.py


示例7: test_null_post_code_format

 def test_null_post_code_format(self):
     """Test the postcode format when a null postcode is in db: 00000 is
     ugly"""
     sub = Subscriber()
     sub.lastname = 'toto'
     address = Address()
     address.post_code = 0
     sub.address = address
     sub.save()
     dict_list = SubscriberAdapter.get_subscribers_from_lastname('toto')
     new_sub = dict_list[0]
     self.assertEquals('', new_sub['post_code'])
开发者ID:rtouze,项目名称:GAabo,代码行数:12,代码来源:test_gaabo_controler.py


示例8: SubscriberTest

class SubscriberTest(unittest.TestCase):
    def setUp(self):
        self.subscriber = Subscriber('asd', '[email protected]')

    def test_get_id(self):
        self.assertEqual(-1, self.subscriber.get_id())

    def test_get_name(self):
        self.assertEqual('asd', self.subscriber.get_name())

    def test_get_email(self):
        self.assertEqual('[email protected]', self.subscriber.get_email())
开发者ID:smo93,项目名称:MailList-1,代码行数:12,代码来源:test_subscriber.py


示例9: set_regular_subscriber

 def set_regular_subscriber(self):
     sub = Subscriber()
     sub.lastname = 'Nom'
     sub.firstname = 'Prenom'
     sub.name_addition = 'NameAddition'
     a = Address()
     a.address1 = 'Adresse'
     a.address2 = 'Addition'
     a.post_code = 12345
     a.city = 'Ville'
     sub.address = a
     return sub
开发者ID:rtouze,项目名称:GAabo,代码行数:12,代码来源:test_subscriber_exporter.py


示例10: test_5_digit_post_code

 def test_5_digit_post_code(self):
     """Checks that the exported post_code is always written with 5 digits,
     even if the first one is 0."""
     sub = Subscriber()
     sub.issues_to_receive = 1
     a = Address()
     a.post_code = 1300
     sub.address = a
     sub.save()
     line = self.export_and_get_first_line()
     splitted_line = line.split('\t')
     self.assertEqual(splitted_line[8], '01300')
开发者ID:rtouze,项目名称:GAabo,代码行数:12,代码来源:test_subscriber_exporter.py


示例11: test_create_and_delete_subscriber

    def test_create_and_delete_subscriber(self):
        sub = Subscriber()
        sub.lastname = 'toto'
        sub.save()
        ident = sub.identifier

        SubscriberAdapter.delete_from_id(ident)

        actual_result_count = len(
                Subscriber.get_subscribers_from_lastname('toto')
                )

        self.assertEqual(0, actual_result_count)
开发者ID:rtouze,项目名称:GAabo,代码行数:13,代码来源:test_gaabo_controler.py


示例12: test_subscriber_without_remaining_issue

 def test_subscriber_without_remaining_issue(self):
     """Test if a subscriber that has no issue left will not receive a free
     number :)"""
     subscriber = Subscriber()
     subscriber.lastname = 'toto'
     subscriber.issues_to_receive = 1
     subscriber.save()
     subscriber = Subscriber()
     subscriber.lastname = 'tata'
     subscriber.issues_to_receive = 0
     subscriber.save()
     self.exporter.do_export()
     self.__test_presence_toto_tata()
开发者ID:rtouze,项目名称:GAabo,代码行数:13,代码来源:test_subscriber_exporter.py


示例13: test_empty_email

    def test_empty_email(self):
        """Tests what appens when a subscriber has no email"""
        subscriber = Subscriber()
        subscriber.email_address = '[email protected]'
        subscriber.issues_to_receive = 0
        subscriber.save()
        subscriber = Subscriber()
        subscriber.email_address = ''
        subscriber.issues_to_receive = 0
        subscriber.save()
        lines = self.export_and_get_lines()

        self.assertEqual('[email protected]\n', lines)
开发者ID:rtouze,项目名称:GAabo,代码行数:13,代码来源:test_subscriber_exporter.py


示例14: test_two_email

    def test_two_email(self):
        """Tests when we have two emails in generated file"""
        subscriber = Subscriber()
        subscriber.email_address = '[email protected]'
        subscriber.issues_to_receive = 0
        subscriber.save()
        subscriber = Subscriber()
        subscriber.email_address = '[email protected]'
        subscriber.issues_to_receive = 0
        subscriber.save()
        lines = self.export_and_get_lines()

        self.assertEqual('[email protected]\[email protected]\n', lines)
开发者ID:rtouze,项目名称:GAabo,代码行数:13,代码来源:test_subscriber_exporter.py


示例15: send_subscription_fee_notice

    def send_subscription_fee_notice(self, msg):
        # get all subscribers
        try:
            sub = Subscriber()
            subscribers_list = sub.get_all()
        except SubscriberException as e:
            raise SubscriptionException('%s' % e)

        sms = SMS()

        for mysub in subscribers_list:
            self.logger.debug("Send sms to %s %s" % (mysub[1], msg))
            sms.send(config['smsc'],mysub[1], msg)
开发者ID:ciaby,项目名称:rccn,代码行数:13,代码来源:subscription.py


示例16: subscription_info

 def subscription_info(self):
     sub = Subscriber()
     unpaid=self.get_unpaid_subscriptions()
     print '---\n\n'
     for number in unpaid:
         print 'PostGres: '+number[0]+':'
         info=sub.print_vty_hlr_info(number)
         if "No subscriber found for extension" in info:
             print 'OsmoHLR: '+info
             print "Checking for 5 digit extension"
             info=sub.print_vty_hlr_info(number[0][-5:])
         print 'OsmoHLR: '+ info
         print '---\n\n'
开发者ID:Rhizomatica,项目名称:rccn,代码行数:13,代码来源:subscription.py


示例17: test_mail_sent_updated_special_issue

    def test_mail_sent_updated_special_issue(self):
        sub = Subscriber()
        sub.lastname = 'toto'
        sub.issues_to_receive = 0
        sub.hors_serie1 = 0
        sub.mail_sent = 1
        sub.save()

        self.assertEqual(1, sub.mail_sent)

        sub.hors_serie1 = 1
        sub.save()
        self.assertEqual(0, sub.mail_sent)
开发者ID:rtouze,项目名称:GAabo,代码行数:13,代码来源:test_subscriber.py


示例18: test_field_length

    def test_field_length(self):
        """test if the fields in the output file does not exceed character limits"""
        big_string = ''.join(['b' for i in xrange(1, 40)])
        subscriber = Subscriber()
        subscriber.lastname = big_string
        subscriber.firstname = big_string
        subscriber.company = big_string
        a = Address()
        a.address1 = big_string
        a.address2 = big_string
        a.post_code = 123456 
        a.city = big_string
        subscriber.address = a
        subscriber.issues_to_receive = 10
        subscriber.save()
        line = self.export_and_get_first_line()

        splitted_line = line.split('\t')
        self.assertTrue(len(splitted_line[0]) <= 20)
        self.assertTrue(len(splitted_line[1]) <= 12)
        self.assertTrue(len(splitted_line[2]) <= 32)
        self.assertTrue(len(splitted_line[3]) <= 20)
        self.assertTrue(len(splitted_line[4]) <= 32)
        self.assertTrue(len(splitted_line[5]) <= 32)
        self.assertTrue(len(splitted_line[6]) <= 32)
        self.assertTrue(len(splitted_line[7]) <= 32)
        self.assertTrue(len(splitted_line[8]) <= 5)
        self.assertTrue(len(splitted_line[9]) <= 26)
        self.assertTrue(len(splitted_line[10]) <= 8)
        self.assertTrue(len(splitted_line[11]) <= 3)
        self.assertTrue(len(splitted_line[12]) <= 32)
        self.assertTrue(len(splitted_line[13]) <= 32)
        self.assertTrue(len(splitted_line[14]) <= 32)
        self.assertTrue(len(splitted_line[15]) <= 32)
开发者ID:rtouze,项目名称:GAabo,代码行数:34,代码来源:test_subscriber_exporter.py


示例19: subscribe_status

 def subscribe_status(self, server, source, target, command):
     target_nick = self.plugin.nick_extract(source)
     available = Subscriber.available_statuses()
     if not command:
         subscriber = self.wrapper.find_subscriber_with_nick(self.plugin.nick_extract(source))
         if subscriber:
             self.plugin.privmsg(server, target_nick, 'current status: '\
                                 + Subscriber.status_from_int(subscriber.status))
         else:
             self.plugin.privmsg(server, target_nick, 'no subscription')
     elif command in available:
         self.wrapper.subscribe_status(target_nick, command)
         self.plugin.privmsg(server, target_nick, 'subscription status set to ' + command)
     else:
         self.plugin.privmsg(server, target_nick, 'invalid command')
开发者ID:cthit,项目名称:DreamTeamBots,代码行数:15,代码来源:anette_controller.py


示例20: broadcast_to_all_subscribers

    def broadcast_to_all_subscribers(self, text, btype):
        sub = Subscriber()
        if btype == 'all':
            subscribers_list = sub.get_all()
        elif btype == 'notpaid':
            subscribers_list = sub.get_all_notpaid()
        elif btype == 'unauthorized':
            subscribers_list = sub.get_all_unauthorized()
        elif btype == 'extension':
            subscribers_list = sub.get_all_5digits()

        for mysub in subscribers_list:
            self.send(config['smsc'], mysub[1], text)
            sms_log.debug('Broadcast message sent to %s' % mysub[1])
            time.sleep(1)
开发者ID:Rhizomatica,项目名称:rccn,代码行数:15,代码来源:sms.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.Subscription类代码示例发布时间:2022-05-27
下一篇:
Python subreddit.Subreddit类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap