Ejemplo n.º 1
0
def main(game=Games.DIRT_RALLY,
         udp_host=UDP_IP,
         udp_port=UDP_PORT,
         callback=None):
    Debug.set_log_level(LogLevel(2))
    Debug.toggle(True)
    try:
        scan = Scan(game, udp_host, udp_port, callback)
        scan.start()
        return scan
    except Exception as e:
        Debug.err(e)
Ejemplo n.º 2
0
 def __init__(self,
              game=Games.DIRT_RALLY,
              udp_host=UDP_IP,
              udp_port=UDP_PORT,
              callback=None):
     Thread.__init__(self)
     Debug.set_log_level(LogLevel(2))
     Debug.toggle(True)
     self.finished = False
     self.callback = callback
     self.game = game
     self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
     self.sock.settimeout(1)
     self.sock.bind((udp_host, udp_port))
     signal.signal(signal.SIGINT, self.exit_gracefully)
     signal.signal(signal.SIGTERM, self.exit_gracefully)
     signal.signal(signal.SIGABRT, self.exit_gracefully)
Ejemplo n.º 3
0
                             dest='gui',
                             action='store_false',
                             help='Console mode')
argument_parser.set_defaults(gui=True)
argument_parser.add_argument(
    '--log_level',
    '-V',
    type=int,
    default=LogLevel.warn,
    help='Set debug verbosity from 0 (only errors) to 2 (full output)',
    choices=range(0, 3))
flags = argument_parser.parse_args()
if flags.debug:
    DEBUG = True
if flags.log_level is not None:
    Debug.set_log_level(LogLevel(flags.log_level))
if flags.gui is not None:
    if flags.gui is False:
        Debug.notice('No gui')
        DEBUG = True
        Debug.set_log_level(LogLevel(2))
    GUI = flags.gui

Debug.toggle(DEBUG)


# noinspection PyUnusedLocal
def exit_gracefully(signum, frame):
    Debug.warn('Process killed (%s). Exiting gracefully' % signum)
    app.stop()
    sys.exit(0)