Beispiel #1
0
 def do_transfer_money(self, line):
     """transfer_money from_wallet_id to_wallet_id amount"""
     from_w_id, to_w_id, amount = line.split()
     from_w_id, to_w_id = int(from_w_id), int(to_w_id)
     try:
         from_w = Wallet.get_obj(from_w_id)
         to_w = Wallet.get_obj(to_w_id)
         from_w.transfer(to_w, float(amount))
         self.write('Done')
         self.write_table(Wallet.SHOW_PROPS,
                          [from_w.prop_list, to_w.prop_list])
     except WalletError as e:
         self.write('Error: {0}'.format(str(e)))
Beispiel #2
0
 def do_draw_money(self, line):
     """draw_money wallet_id amount"""
     w_id, amount = line.split()
     w_id = int(w_id)
     try:
         w = Wallet.get_obj(w_id)
         w.draw(float(amount))
         self.write('Done')
         self.write_table(w.SHOW_PROPS, [w.prop_list])
     except WalletError as e:
         self.write('Error: {0}'.format(str(e)))
Beispiel #3
0
 def do_show_wallets(self, line):
     """show_accounts [wallet_id]"""
     if line:
         wallet_id = int(line)
         try:
             w = Wallet.get_obj(wallet_id)
             self.write_table(w.SHOW_PROPS, [w.prop_list])
         except WalletError as e:
             self.write('Error: {0}'.format(str(e)))
     elif not Wallet.objects:
         self.columnize([])
     else:
         self.write_table(Wallet.SHOW_PROPS, [
             w.prop_list for _, w in sorted(Wallet.objects.iteritems(),
                                            key=lambda (k, v): k)
         ])