Revision d5705e2c vncauthproxy/proxy.py

b/vncauthproxy/proxy.py
246 246

  
247 247
            for sock in rlist:
248 248
                self.client, addrinfo = sock.accept()
249
                self.info("Connection from %s:%d", addrinfo[:2])
249
                self.info("Connection from %s:%d", *addrinfo[:2])
250 250

  
251 251
                # Close all listening sockets, we only want a one-shot
252 252
                # connection from a single client.
......
314 314
            s.bind(sa)
315 315
            s.listen(1)
316 316
            sockets.append(s)
317
            logger.debug("Listening on %s:%d", sa[:2])
317
            logger.debug("Listening on %s:%d", *sa[:2])
318 318
        except socket.error, msg:
319 319
            logger.error("Error binding to %s:%d: %s", sa[0], sa[1], msg[1])
320 320
            if s:
......
353 353
                continue
354 354

  
355 355
            try:
356
                logger.debug("Connecting to %s:%s", sa[:2])
356
                logger.debug("Connecting to %s:%s", *sa[:2])
357 357
                server.connect(sa)
358
                logger.debug("Connection to %s:%s successful", sa[:2])
358
                logger.debug("Connection to %s:%s successful", *sa[:2])
359 359
            except socket.error:
360 360
                server.close()
361 361
                server = None
......
447 447

  
448 448

  
449 449
def main():
450
    """Run the daemon from the command line."""
450
    """Run the daemon from the command line"""
451 451

  
452 452
    (opts, args) = parse_arguments(sys.argv[1:])
453 453

  
......
496 496
    gevent.reinit()
497 497

  
498 498
    if os.path.exists(opts.ctrl_socket):
499
        logger.critical("Socket '%s' already exists" % opts.ctrl_socket)
499
        logger.critical("Socket '%s' already exists", opts.ctrl_socket)
500 500
        sys.exit(1)
501 501

  
502 502
    # TODO: make this tunable? chgrp as well?
......
508 508
    os.umask(old_umask)
509 509

  
510 510
    ctrl.listen(1)
511
    logger.info(("Initialized, waiting for control connections at %s" %
512
                 opts.ctrl_socket))
511
    logger.info("Initialized, waiting for control connections at %s",
512
                opts.ctrl_socket)
513 513

  
514 514
    # Catch signals to ensure graceful shutdown,
515 515
    # e.g., to make sure the control socket gets unlink()ed.
......
567 567
                dport = int(req['destination_port'])
568 568
                password = req['password']
569 569
            except Exception, e:
570
                logger.warn("Malformed request: %s" % buf)
570
                logger.warn("Malformed request: %s", buf)
571 571
                client.send(json.dumps(response))
572 572
                client.close()
573 573
                continue
......
580 580
                if sport_orig == 0:
581 581
                    sport = random.choice(ports)
582 582
                    ports.remove(sport)
583
                    logger.debug(("Got port %d from pool, %d remaining",
584
                                  sport, len(ports)))
583
                    logger.debug("Got port %d from pool, %d remaining",
584
                                 sport, len(ports))
585 585
                    pool = ports
586 586
                else:
587 587
                    sport = sport_orig
......
595 595
                VncAuthProxy.spawn(logger, listeners, pool, daddr, dport,
596 596
                                   server, password, opts.connect_timeout)
597 597

  
598
                logger.info(("New forwarding: %d (client req'd: %d) -> %s:%d" %
599
                             (sport, sport_orig, daddr, dport)))
598
                logger.info("New forwarding: %d (client req'd: %d) -> %s:%d",
599
                            sport, sport_orig, daddr, dport)
600 600
                response = {"source_port": sport,
601 601
                            "status": "OK"}
602 602
            except IndexError:
603 603
                logger.error(("FAILED forwarding, out of ports for [req'd by "
604
                              "client: %d -> %s:%d]" % (sport_orig, daddr,
605
                                                        dport)))
604
                              "client: %d -> %s:%d]"),
605
                             sport_orig, daddr, dport)
606 606
            except Exception, msg:
607 607
                logger.error(msg)
608 608
                logger.error(("FAILED forwarding: %d (client req'd: %d) -> "
609
                              "%s:%d" % (sport, sport_orig, daddr, dport)))
609
                              "%s:%d"), sport, sport_orig, daddr, dport)
610 610
                if not pool is None:
611 611
                    pool.append(sport)
612
                    logger.debug(("Returned port %d to pool, %d remanining",
613
                                  sport, len(pool)))
612
                    logger.debug("Returned port %d to pool, %d remanining",
613
                                 sport, len(pool))
614 614
                if not server is None:
615 615
                    server.close()
616 616
            finally:
......
622 622
        except SystemExit:
623 623
            break
624 624

  
625
    logger.info("Unlinking control socket at %s" % opts.ctrl_socket)
625
    logger.info("Unlinking control socket at %s", opts.ctrl_socket)
626 626
    os.unlink(opts.ctrl_socket)
627 627
    daemon_context.close()
628 628
    sys.exit(0)

Also available in: Unified diff