Merged features/mp-sched -r8915:9335 into the trunk. The trunk now
[debian/gnuradio] / gr-pager / src / pager_utils.py
1 #
2 # Copyright 2008 Free Software Foundation, Inc.
3
4 # This file is part of GNU Radio
5
6 # GNU Radio 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, or (at your option)
9 # any later version.
10
11 # GNU Radio 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 along
17 # with this program; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #
20
21 import gnuradio.gr.gr_threading as _threading
22
23 def make_trans_table():
24     table = 256 * ['.']
25     for i in range(256):
26         if (i < 32):
27             table[i] = '.'
28         else:
29             table[i] = chr(i)
30     return ''.join(table)
31
32 _trans_table = make_trans_table()
33
34 def make_printable(s):
35     return s.translate(_trans_table)
36
37 class top_block_runner(_threading.Thread):
38     def __init__(self, tb):
39         _threading.Thread.__init__(self)
40         self.setDaemon(1)
41         self.tb = tb
42         self.done = False
43         self.start()
44
45     def run(self):
46         self.tb.run()
47         self.done = True