12 |
12 |
13 from VirtualMailManager import ENCODING, errors |
13 from VirtualMailManager import ENCODING, errors |
14 from VirtualMailManager.config import BadOptionError, ConfigValueError |
14 from VirtualMailManager.config import BadOptionError, ConfigValueError |
15 from VirtualMailManager.cli import w_err |
15 from VirtualMailManager.cli import w_err |
16 from VirtualMailManager.cli.handler import CliHandler |
16 from VirtualMailManager.cli.handler import CliHandler |
17 from VirtualMailManager.constants import DATABASE_ERROR, EX_SUCCESS, \ |
17 from VirtualMailManager.constants import EX_SUCCESS, EX_USER_INTERRUPT, \ |
18 EX_USER_INTERRUPT, INVALID_ARGUMENT |
18 INVALID_ARGUMENT |
19 from VirtualMailManager.cli.subcommands import RunContext, setup_parser |
19 from VirtualMailManager.cli.subcommands import RunContext, setup_parser |
20 |
20 |
21 |
21 |
22 _ = lambda msg: msg |
22 _ = lambda msg: msg |
23 |
23 |
44 except (EOFError, KeyboardInterrupt): |
44 except (EOFError, KeyboardInterrupt): |
45 # TP: We have to cry, because root has killed/interrupted vmm |
45 # TP: We have to cry, because root has killed/interrupted vmm |
46 # with Ctrl+C or Ctrl+D. |
46 # with Ctrl+C or Ctrl+D. |
47 w_err(EX_USER_INTERRUPT, '', _('Ouch!'), '') |
47 w_err(EX_USER_INTERRUPT, '', _('Ouch!'), '') |
48 except errors.VMMError as err: |
48 except errors.VMMError as err: |
49 if err.code != DATABASE_ERROR: |
49 if handler.has_warnings(): |
50 if handler.has_warnings(): |
50 w_err(0, _('Warnings:'), *handler.get_warnings()) |
51 w_err(0, _('Warnings:'), *handler.get_warnings()) |
51 w_err(err.code, _('Error: %s') % err.msg) |
52 w_err(err.code, _('Error: %s') % err.msg) |
|
53 w_err(err.code, str(err.msg, ENCODING, 'replace')) |
|
54 except (BadOptionError, ConfigValueError) as err: |
52 except (BadOptionError, ConfigValueError) as err: |
55 w_err(INVALID_ARGUMENT, _('Error: %s') % err) |
53 w_err(INVALID_ARGUMENT, _('Error: %s') % err) |
56 except NoSectionError as err: |
54 except NoSectionError as err: |
57 w_err(INVALID_ARGUMENT, |
55 w_err(INVALID_ARGUMENT, |
58 _("Error: Unknown section: '%s'") % err.section) |
56 _("Error: Unknown section: '%s'") % err.section) |