|
| 1 | + |
| 2 | + |
| 3 | +class BasePoller(BaseGlue): |
| 4 | + base_type = 'Poller' |
| 5 | + |
| 6 | + def run(self): |
| 7 | + usage = 'usage: %prog [options]' |
| 8 | + parser = OptionParser(usage=usage) |
| 9 | + parser.add_option( |
| 10 | + '-s', '--settings', |
| 11 | + dest='settings', default='staging', |
| 12 | + help='specify the settings to use [default: %default]', |
| 13 | + ) |
| 14 | + parser.add_option( |
| 15 | + '-d', '--debug', type='int', |
| 16 | + dest='debug', default=1, |
| 17 | + help='specify the debugging level [default: %default]', |
| 18 | + ) |
| 19 | + parser.add_option( |
| 20 | + '-w', '--wait', type='int', |
| 21 | + dest='wait', default=0, |
| 22 | + help='specify the time to wait between polls [default: %default]', |
| 23 | + ) |
| 24 | + parser.add_option( |
| 25 | + '', '--hours', type='int', |
| 26 | + dest='hours', default=0, |
| 27 | + help='specify the number of search hours [default: %default]', |
| 28 | + ) |
| 29 | + (self.opts, self.args) = parser.parse_args() |
| 30 | + self.configure() |
| 31 | + |
| 32 | + try: |
| 33 | + while True: |
| 34 | + self.poll(process=self.process_wrapper) |
| 35 | + if self.opts.wait > 0: |
| 36 | + time.sleep(self.opts.wait) |
| 37 | + else: |
| 38 | + break |
| 39 | + except KeyboardInterrupt: |
| 40 | + pass |
| 41 | + self.connection.close() |
| 42 | + if self.agent: |
| 43 | + try: |
| 44 | + self.agent.shutdown_agent(timeout=2.5) |
| 45 | + except RuntimeError: |
| 46 | + pass |
| 47 | + |
0 commit comments