File: pk-spawn-test-sigquit.py

package info (click to toggle)
packagekit 1.3.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 14,704 kB
  • sloc: ansic: 56,209; cpp: 13,919; python: 4,970; xml: 4,945; sh: 313; perl: 60; makefile: 57
file content (30 lines) | stat: -rwxr-xr-x 881 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python3
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

# Copyright (C) 2010 Richard Hughes <richard@hughsie.com>

from signal import *
from time import sleep
from sys import stdout

def process_quit(signum, frame):
    exit()

def main():
    signal(SIGQUIT, process_quit)

    for i in [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]:
        stdout.write("percentage\t%i\n" % (i * 10))
        stdout.flush()
        sleep(0.3)

if __name__ == "__main__":
    main()