Changeset 1681:7a2cb17411e2
- Timestamp:
- 06/26/08 18:51:36 (2 months ago)
- Author:
- klai@…
- Branch:
- default
- Message:
-
Print user-friendly error when there are insufficient funds in account
- Location:
- src/Tycoon
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r1674
|
r1681
|
|
| 129 | 129 | if "error" in result: |
| 130 | 130 | raise BankClientException( |
| 131 | | "Could not transfer %s funds from %s to %s:\n%s" % ( |
| | 131 | "Could not transfer %s funds from %s to %s: %s" % ( |
| 132 | 132 | amount, src_account, dest_account, result['error'])) |
| 133 | 133 | |
-
|
r1673
|
r1681
|
|
| 484 | 484 | |
| 485 | 485 | def __multi_host_command( |
| 486 | | self, host_addrs, finish_cb, finish_arg, command, *args): |
| | 486 | self, host_addrs, finish_cb, error_cb, finish_arg, command, *args): |
| 487 | 487 | """Perform the specified command on multiple hosts. |
| 488 | 488 | """ |
| … |
… |
|
| 494 | 494 | d = f(*args) |
| 495 | 495 | d.addCallback(finish_cb, host_addr, auc, finish_arg, *args) |
| | 496 | if error_cb != None: |
| | 497 | d.addErrback(error_cb, host_addr, auc, finish_arg, *args) |
| | 498 | |
| 496 | 499 | d.addErrback(self.__host_eb, command, host_addr) |
| 497 | 500 | dl.append(d) |
| … |
… |
|
| 576 | 579 | bid, config, min_duration = Bid.parse(args) |
| 577 | 580 | d, dl = self.__multi_host_command( |
| 578 | | host_addrs, self.__bid_finish, None, "bid", bid, |
| | 581 | host_addrs, self.__bid_finish, None, None, "bid", bid, |
| 579 | 582 | self.__options.HostAccountName) |
| 580 | 583 | d.addCallback(self.__multi_host_finish) |
| … |
… |
|
| 612 | 615 | args[1:], duration=[100000000L], config_names=config_names) |
| 613 | 616 | d, dl = self.__multi_host_command( |
| 614 | | host_addrs, self.__create_account_cb, |
| | 617 | host_addrs, self.__create_account_cb, self.__create_account_error, |
| 615 | 618 | (0, max_deposit, min_duration), "create_account", initial_deposit, |
| 616 | 619 | bid, config, self.__options.HostAccountName) |
| … |
… |
|
| 654 | 657 | return rval |
| 655 | 658 | |
| | 659 | def __create_account_error( |
| | 660 | self, result, host_addr, auc, args, initial_deposit, bid, config, |
| | 661 | account_name): |
| | 662 | self.__l.error(result.value) |
| | 663 | |
| 656 | 664 | def __parse_status_fields(self, args): |
| 657 | 665 | """ |
| … |
… |
|
| 686 | 694 | bid, config, min_duration = Bid.parse(args[1:]) |
| 687 | 695 | d, dl = self.__multi_host_command( |
| 688 | | host_addrs, self.__fund_finish, None, "fund", funding_amount, bid, |
| 689 | | self.__options.HostAccountName) |
| | 696 | host_addrs, self.__fund_finish, None, None, "fund", funding_amount, |
| | 697 | bid, self.__options.HostAccountName) |
| 690 | 698 | d.addCallback(self.__multi_host_finish) |
| 691 | 699 | return d |
| … |
… |
|
| 722 | 730 | time_out = 30.0 |
| 723 | 731 | d, dl = self.__multi_host_command( |
| 724 | | host_addrs, self.__shutdown_finish, None, "shutdown", time_out, |
| 725 | | self.__options.HostAccountName) |
| | 732 | host_addrs, self.__shutdown_finish, None, None, "shutdown", |
| | 733 | time_out, self.__options.HostAccountName) |
| 726 | 734 | d.addCallback(self.__multi_host_finish) |
| 727 | 735 | return d |
| … |
… |
|
| 762 | 770 | value = args[1] |
| 763 | 771 | d, dl = self.__multi_host_command( |
| 764 | | host_addrs, self.__set_finish, None, "set", field, value, |
| | 772 | host_addrs, self.__set_finish, None, None, "set", field, value, |
| 765 | 773 | self.__options.HostAccountName) |
| 766 | 774 | d.addCallback(self.__multi_host_finish) |
| … |
… |
|
| 789 | 797 | bid, config, min_duration = Bid.parse(args[1:]) |
| 790 | 798 | d, dl = self.__multi_host_command( |
| 791 | | host_addrs, self.__refund_finish, None, "refund", refund, bid, |
| | 799 | host_addrs, self.__refund_finish, None, None, "refund", refund, bid, |
| 792 | 800 | self.__options.HostAccountName) |
| 793 | 801 | d.addCallback(self.__multi_host_finish) |
| … |
… |
|
| 820 | 828 | fields = self.__parse_status_fields(args) |
| 821 | 829 | d, dl = self.__multi_host_command( |
| 822 | | host_addrs, self.__get_status_finish, None, "get_status", fields) |
| | 830 | host_addrs, self.__get_status_finish, None, None, "get_status", |
| | 831 | fields) |
| 823 | 832 | d.addCallback(self.__multi_host_finish) |
| 824 | 833 | return d |
| … |
… |
|
| 845 | 854 | raise ArgumentError("Incorrect number of arguments") |
| 846 | 855 | d, dl = self.__multi_host_command( |
| 847 | | host_addrs, self.__get_account_list_finish, None, |
| | 856 | host_addrs, self.__get_account_list_finish, None, None, |
| 848 | 857 | "get_account_list", bank_account_name) |
| 849 | 858 | d.addCallback(self.__multi_host_finish) |
| … |
… |
|
| 870 | 879 | fields = self.__parse_status_fields(args) |
| 871 | 880 | d, dl = self.__multi_host_command( |
| 872 | | host_addrs, self.__get_account_status_finish, None, |
| | 881 | host_addrs, self.__get_account_status_finish, None, None, |
| 873 | 882 | "get_account_status", fields, self.__options.HostAccountName) |
| 874 | 883 | d.addCallback(self.__multi_host_finish) |
| … |
… |
|
| 900 | 909 | raise ArgumentError("Incorrect number of arguments") |
| 901 | 910 | d, dl = self.__multi_host_command( |
| 902 | | host_addrs, self.__delete_account_finish, None, "delete_account", |
| 903 | | an) |
| | 911 | host_addrs, self.__delete_account_finish, None, None, |
| | 912 | "delete_account", an) |
| 904 | 913 | d.addCallback(self.__multi_host_finish) |
| 905 | 914 | return d |
| … |
… |
|
| 932 | 941 | time_out = 60.0 |
| 933 | 942 | d, dl = self.__multi_host_command( |
| 934 | | host_addrs, self.__boot_finish, None, "boot", time_out, |
| | 943 | host_addrs, self.__boot_finish, None, None, "boot", time_out, |
| 935 | 944 | self.__options.HostAccountName) |
| 936 | 945 | d.addCallback(self.__multi_host_finish) |
| … |
… |
|
| 959 | 968 | |
| 960 | 969 | d, dl = self.__multi_host_command( |
| 961 | | host_addrs, self.__configure_file_system_finish, None, |
| | 970 | host_addrs, self.__configure_file_system_finish, None, None, |
| 962 | 971 | "configure_file_system", file_system_path, |
| 963 | 972 | self.__options.HostAccountName) |