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


Python Bank.deposit方法代码示例

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


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

示例1: test_deposit

# 需要导入模块: from bank import Bank [as 别名]
# 或者: from bank.Bank import deposit [as 别名]
	def test_deposit(self):
		bank = Bank()

		account_1 = Account(001, 50)

		bank.add_account(account_1)

		self.assertEqual(bank.deposit(001, 50), 100)
		self.assertEqual(bank.deposit(002, 50), 'Account does not exist')
开发者ID:anobilisgorse,项目名称:CSC185,代码行数:11,代码来源:bank_test.py

示例2: run

# 需要导入模块: from bank import Bank [as 别名]
# 或者: from bank.Bank import deposit [as 别名]
def run():
    show_logo() 
    _Runner = True
    global config
    config = ConfigParser.ConfigParser()
    config.read('bitbank.cfg')

    connected = False
    while not connected:
        try:
            db = MySQLdb.connect(host=config.get('Database', 'hostname'),
                user=config.get('Database', 'username'),
                passwd=config.get('Database', 'password'),
                db=config.get('Database', 'database'))
            connected =  True
        except Exception:
            print "Database connection failed, retrying.."
            sleep(5)
 
    bank = Bank(db)

    if config.get('Bitwifi','enable') == "True":
        wifi = Wifi(config)

    defaultusername = bank.username
    while _Runner == True:
        if bank.username != defaultusername:
            barcode=raw_input('%s%s%s please scan [product barcode]: ' % (str(Color('yellow')),bank.username,str(Color('reset'))))
        else:
            barcode=raw_input('Please scan [usercard,product barcode]: ')

        line = filter (lambda a: a != "", barcode.split(" "))
        if len(line) > 1 and bank.login(line[-1]) == True:
            bank = process_line(bank,barcode)
            continue

        if barcode == "clear" or barcode == "abort" or barcode == "reset" or barcode.startswith('ABORT'):
            bank.reset()

        elif barcode == "pay" or barcode == "kas" or barcode.startswith('KAS'):
            print "\x1b[H\x1b[J"
            show_logo()
            bank.pay()
            open_la()

        elif barcode == "logout" or barcode.startswith('LOGOUT'):
            print "\x1b[H\x1b[J"
            show_logo() 
            bank.logout()

        elif barcode == "bank" or barcode.startswith('BANK'):
            print "\x1b[H\x1b[J"
            show_logo()
            bank.account()

        elif barcode == "shame":
            bank.shame()

        elif barcode.startswith('deposit'):
            temp = barcode.split(' ')
            amount = temp[1]
            bank.deposit(amount)
            open_la()

        elif barcode.startswith('withdraw'):
            temp = barcode.split(' ')
            amount = temp[1]
            bank.withdraw(amount)
            open_la()

        elif barcode.startswith('plastic'):
            temp = barcode.split(' ')
            amount = temp[1]
            bank.plastic_add(amount)

        elif barcode.startswith('adduser'):
            temp = barcode.split(' ')
            bank.account_add(temp[1])
        elif barcode.startswith('list'):
            bank.list() 

        elif barcode.startswith('mac') and config.get('Bitwifi','enable') == "True":
            wifi.unregister_list()

        elif barcode.startswith('register') and config.get('Bitwifi','enable') == "True":
            temp = barcode.split(' ')
            if bank.member==0:
                print "403: Access denied"
                continue
            wifi.registration(bank.username,temp[1],temp[2])

        elif barcode == "help":
            print help()

        elif barcode == "hug":
            print free_hug()

        elif barcode == "exit":
            _Runner = False
        elif barcode == "":
#.........这里部分代码省略.........
开发者ID:bitlair,项目名称:bitbank,代码行数:103,代码来源:bitbank.py

示例3: Server

# 需要导入模块: from bank import Bank [as 别名]
# 或者: from bank.Bank import deposit [as 别名]
class Server(da.DistProcess):

    def __init__(self, parent, initq, channel, props):
        super().__init__(parent, initq, channel, props)
        self._ServerReceivedEvent_0 = []
        self._events.extend([da.pat.EventPattern(da.pat.ReceivedEvent, '_ServerReceivedEvent_0', PatternExpr_2, sources=[PatternExpr_3], destinations=None, timestamps=None, record_history=True, handlers=[]), da.pat.EventPattern(da.pat.ReceivedEvent, '_ServerReceivedEvent_1', PatternExpr_5, sources=[PatternExpr_6], destinations=None, timestamps=None, record_history=None, handlers=[self._Server_handler_1]), da.pat.EventPattern(da.pat.ReceivedEvent, '_ServerReceivedEvent_2', PatternExpr_7, sources=[PatternExpr_8], destinations=None, timestamps=None, record_history=None, handlers=[self._Server_handler_2]), da.pat.EventPattern(da.pat.ReceivedEvent, '_ServerReceivedEvent_3', PatternExpr_9, sources=[PatternExpr_10], destinations=None, timestamps=None, record_history=None, handlers=[self._Server_handler_3])])

    def setup(self, servers, index, client, Nlength, master):
        self.client = client
        self.servers = servers
        self.index = index
        self.Nlength = Nlength
        self.master = master
        self.bankobj = Bank('wells', '123')
        self.startindex = 0
        self.head = self.servers[0]
        if (self.index == (self.Nlength - 1)):
            self.output(str(self.index))
            self.next = self.client
        else:
            self.next = self.servers[(self.index + 1)]
        self.endindex = (self.Nlength - 1)
        self.output(('serverindex' + str(self.index)))

    def main(self):
        _thread.start_new_thread(self.sendHealthCheck, ('Thread', 3, self.index, self.master))
        p = request = None

        def ExistentialOpExpr_0():
            nonlocal p, request
            for (_, (_, _, p), (_ConstantPattern15_, request)) in self._ServerReceivedEvent_0:
                if (_ConstantPattern15_ == 'request'):
                    if True:
                        return True
            return False
        _st_label_63 = 0
        while (_st_label_63 == 0):
            _st_label_63 += 1
            if ExistentialOpExpr_0():
                _st_label_63 += 1
            else:
                super()._label('_st_label_63', block=True)
                _st_label_63 -= 1
        _st_label_64 = 0
        while (_st_label_64 == 0):
            _st_label_64 += 1
            if False:
                _st_label_64 += 1
            else:
                super()._label('_st_label_64', block=True)
                _st_label_64 -= 1

    def sendHealthCheck(self, threadName, delay, index, master):
        self.output('inside sendHealthCheck')
        self.output((' %r.' % index))
        while True:
            time.sleep(delay)
            self._send(('HealthCheckmsg', index), master)

    def _Server_handler_1(self, tindex, p):
        self.output('updated tail server end')
        self.endindex = tindex
    _Server_handler_1._labels = None
    _Server_handler_1._notlabels = None

    def _Server_handler_2(self, tindex, p):
        self.output('updated next server end')
        self.next = self.servers[tindex]
    _Server_handler_2._labels = None
    _Server_handler_2._notlabels = None

    def _Server_handler_3(self, request, p):
        if (request.outcome in ['processed', 'inconsistent', 'insufficientfunds']):
            self.bankobj.set(request)
        elif (request.transaction == 'deposit'):
            request = self.bankobj.deposit(request)
        elif (request.transaction == 'withdraw'):
            request = self.bankobj.withdraw(request)
        elif (request.transaction == 'getbalance'):
            request = self.bankobj.getbalance(request)
        if (self.index < self.endindex):
            self._send(('request', request), self.next)
            self.output(('<%r,%s,%r>' % (request.requestid, request.outcome, request.balance)))
        else:
            self._send(('reply', request), self.client)
    _Server_handler_3._labels = None
    _Server_handler_3._notlabels = None
开发者ID:smothiki,项目名称:Replicasystem,代码行数:89,代码来源:clientserver.py


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