home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / pyshared / checkbox / lib / signal.py < prev    next >
Encoding:
Python Source  |  2009-04-27  |  2.7 KB  |  90 lines

  1. #
  2. # This file is part of Checkbox.
  3. #
  4. # Copyright 2008 Canonical Ltd.
  5. #
  6. # Checkbox is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # Checkbox is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with Checkbox.  If not, see <http://www.gnu.org/licenses/>.
  18. #
  19. from gettext import gettext as _
  20.  
  21.  
  22. signal_description_table = {
  23.     "SIGHUP":  _("Hangup detected on controlling terminal or death of controlling process"),
  24.     "SIGINT":  _("Interrupt from keyboard"),
  25.     "SIGQUIT": _("Quit from keyboard"),
  26.     "SIGILL":  _("Illegal Instruction"),
  27.     "SIGABRT": _("Abort signal from abort(3)"),
  28.     "SIGFPE":  _("Floating point exception"),
  29.     "SIGKILL": _("Kill signal"),
  30.     "SIGSEGV": _("Invalid memory reference"),
  31.     "SIGPIPE": _("Broken pipe: write to pipe with no readers"),
  32.     "SIGALRM": _("Timer signal from alarm(2)"),
  33.     "SIGTERM": _("Termination signal"),
  34.     "SIGUSR1": _("User-defined signal 1"),
  35.     "SIGUSR2": _("User-defined signal 2"),
  36.     "SIGCHLD": _("Child stopped or terminated"),
  37.     "SIGCONT": _("Continue if stopped"),
  38.     "SIGSTOP": _("Stop process"),
  39.     "SIGTSTP": _("Stop typed at tty"),
  40.     "SIGTTIN": _("tty input for background process"),
  41.     "SIGTTOU": _("tty output for background process")}
  42.  
  43. signal_name_table = {
  44.     1: "SIGHUP",
  45.     2: "SIGINT",
  46.     3: "SIGQUIT",
  47.     4: "SIGILL",
  48.     6: "SIGABRT",
  49.     8: "SIGFPE",
  50.     9: "SIGKILL",
  51.     10: "SIGUSR1",
  52.     11: "SIGSEGV",
  53.     12: "SIGUSR2",
  54.     13: "SIGPIPE",
  55.     14: "SIGALRM",
  56.     15: "SIGTERM",
  57.     16: "SIGUSR1",
  58.     21: "SIGTTIN",
  59.     22: "SIGTTOU",
  60.     23: "SIGSTOP",
  61.     24: "SIGTSTP",
  62.     25: "SIGCONT",
  63.     26: "SIGTTIN",
  64.     27: "SIGTTOU",
  65.     30: "SIGUSR1",
  66.     31: "SIGUSR2"}
  67.  
  68. def signal_to_name(signal):
  69.     """Convert a signal number to its string representation.
  70.  
  71.     Keyword arguments:
  72.     signal -- number of the signal as returned by wait
  73.     """
  74.  
  75.     if signal_name_table.has_key(signal):
  76.         return signal_name_table[signal]
  77.     return _("UNKNOWN")
  78.  
  79. def signal_to_description(signal):
  80.     """Convert a signal number to its corresponding description.
  81.  
  82.     Keyword arguments:
  83.     signal -- number of the signal as returned by wait
  84.     """
  85.  
  86.     name = signal_to_name(signal)
  87.     if signal_description_table.has_key(name):
  88.         return signal_description_table[name]
  89.     return _("Unknown signal")
  90.