Exemple #1
0
 def direct_mouse (self):
     assert self.target,  'target directives not transmitted -- target is unidentified'
     assert self.monitor, 'target directives not transmitted -- target monitor not located'
     self.transformer.process (self.target, self.monitor)
     keystrokes  = [key for key in (VK_UP,VK_DOWN) if Keyboard.pressed(key)]
     keystroke   = keystrokes[-1] if keystrokes else None
     self.button = self.keyboard_mapping[keystroke] if keystroke else self.button
     directive   = MOUSE_DIRECTIVE.format (button=self.button, position=self.transformer.position)
     self.transmitter.process (self.target, directive)
Exemple #2
0
 def direct_mouse(self):
     assert self.target, 'target directives not transmitted -- target is unidentified'
     assert self.monitor, 'target directives not transmitted -- target monitor not located'
     self.transformer.process(self.target, self.monitor)
     keystrokes = [key for key in (VK_UP, VK_DOWN) if Keyboard.pressed(key)]
     keystroke = keystrokes[-1] if keystrokes else None
     self.button = self.keyboard_mapping[
         keystroke] if keystroke else self.button
     directive = MOUSE_DIRECTIVE.format(button=self.button,
                                        position=self.transformer.position)
     self.transmitter.process(self.target, directive)
Exemple #3
0
                        type=str,
                        default='Esc',
                        help='STOP execution key')
    arguments = parser.parse_args()
    stopkey = VK_ESCAPE if arguments.stopkey == 'Esc' else ord(
        arguments.stopkey)
    verbosity = dict(low=logging.WARN, medium=logging.INFO, high=logging.DEBUG)
    logging.basicConfig(level=verbosity[arguments.verbosity])
    # logging.basicConfig (filename='{}.log'.format(DEVICE), filemode='w', verbosity[arguments.verbosity])
    log = logging.getLogger(DEVICE)
    log.info(' started')
    try:
        configuration = SafeConfigParser()
        configuration.readfp(open(arguments.configfile))
        target = Target.create(configuration)
        target.start()
    except (AssertionError, ) as details:
        log.error(' %s', details)
    else:
        while not Keyboard.pressed(stopkey):
            try:
                target.execute()
            except (AssertionError, PartialTransmission) as details:
                log.warning(' %s', details)
            else:
                pass  # TBD log.info (## ???)
        target.stop()
    finally:
        log.info(' stopped')
        logging.shutdown()
Exemple #4
0
    parser = ArgumentParser() # commandline arguments parser
    parser.add_argument ('--verbosity' , type=str, default='low'         , help='logging verbosity', choices=('low','medium','high'))
    parser.add_argument ('--configfile', type=str, default='WiseBall.ini', help='configuration file name')
    parser.add_argument ('--stopkey'   , type=str, default='Esc'         , help='STOP execution key')
    arguments = parser.parse_args()
    stopkey   = VK_ESCAPE if arguments.stopkey == 'Esc' else ord (arguments.stopkey)
    verbosity = dict (low=logging.WARN, medium=logging.INFO, high=logging.DEBUG)
    logging.basicConfig (level=verbosity[arguments.verbosity])
    # logging.basicConfig (filename='{}.log'.format(DEVICE), filemode='w', verbosity[arguments.verbosity])
    log = logging.getLogger (DEVICE)
    log.info (' started')
    try:
        configuration = SafeConfigParser()
        configuration.readfp (open(arguments.configfile))
        target = Target.create (configuration)
        target.start()
    except (AssertionError,) as details:
        log.error (' %s',details)
    else:
        while not Keyboard.pressed (stopkey):
            try:
                target.execute()
            except (AssertionError, PartialTransmission) as details:
                log.warning (' %s',details)
            else:
                pass # TBD log.info (## ???)
        target.stop()
    finally:
        log.info (' stopped')
        logging.shutdown()