Esempio n. 1
0
        self._receiveThread = None
        self._dataThread = None
        self.clients = list()

    def __del__(self):
        """Needed in case user forgets to call stop explicitly."""
        if (self._running):
            self._logger.warning('Close server before garbage collection.')
            self.stop()


if __name__ == '__main__':
    # LOG
    from logger import add_stream_handler, add_file_handler
    # Minimal level for logs
    log_level = logging.DEBUG
    logging.getLogger().setLevel(log_level)
    file_handler = add_file_handler('RendezVous.log',
                                    parent='RendezVous',
                                    level=log_level,
                                    filemode='a')
    stream_handler = add_stream_handler(parent='RendezVous', level=log_level)

    # SERVER
    server = RendezVousServerUDP()
    server.start('0.0.0.0', 5000)
    # Stay up x seconds
    time.sleep(20)
    # Stop server
    server.stop()
Esempio n. 2
0
                    type=str,
                    help="Data JSON path.",
                    default='data.json')
parser.add_argument("--logfile", type=str, help="Log to defined file.")

args = parser.parse_args()

BUCKET = args.bucket

try:
    args.logfile = os.environ[_ENV_LOGGING_FILE]
except KeyError:
    pass

if args.logfile:
    logger.add_file_handler(args.logfile, args.verbosity)

logger.set_log_level(args.verbosity)

try:
    args.token = os.environ[_ENV_TELEGRAM_BOT_TOKEN]
except KeyError as key_error:
    if not args.token:
        LOG.critical(
            'No telegram bot token provided. Please do so using --token argument or %s environment variable.',
            _ENV_TELEGRAM_BOT_TOKEN)
        exit(1)

try:
    args.admin = os.environ[_ENV_TELEGRAM_USER_ALIAS]
except KeyError as key_error:
            Return a bytes representation of a python str in FString serialized
            form (length prefixed).
        """
        # String in Unreal are length prefixed
        msg_string = msg.encode(self._encoding)
        msg_bytes = len(msg_string).to_bytes(DestruckUDPServer.INT32_SIZE,
                                             byteorder='big')
        msg_bytes += msg_string
        return msg_bytes


if __name__ == '__main__':
    # LOG
    from logger import add_stream_handler, add_file_handler
    # Minimal level for logs
    log_level = logging.DEBUG
    logging.getLogger().setLevel(log_level)
    file_handler = add_file_handler('DestruckUDPServer.log',
                                    parent='RendezVous',
                                    level=log_level,
                                    filemode='a')
    stream_handler = add_stream_handler(parent='RendezVous', level=log_level)

    # SERVER
    server = DestruckUDPServer()
    server.start('0.0.0.0', 5000)
    # Stay up x seconds
    time.sleep(100)
    # Stop server
    server.stop()