pylint fixes for nova/server.py
This commit is contained in:
@@ -52,13 +52,8 @@ def stop(pidfile):
|
|||||||
"""
|
"""
|
||||||
# Get the pid from the pidfile
|
# Get the pid from the pidfile
|
||||||
try:
|
try:
|
||||||
pf = file(pidfile,'r')
|
pid = int(open(pidfile,'r').read().strip())
|
||||||
pid = int(pf.read().strip())
|
|
||||||
pf.close()
|
|
||||||
except IOError:
|
except IOError:
|
||||||
pid = None
|
|
||||||
|
|
||||||
if not pid:
|
|
||||||
message = "pidfile %s does not exist. Daemon not running?\n"
|
message = "pidfile %s does not exist. Daemon not running?\n"
|
||||||
sys.stderr.write(message % pidfile)
|
sys.stderr.write(message % pidfile)
|
||||||
return # not an error in a restart
|
return # not an error in a restart
|
||||||
@@ -79,14 +74,15 @@ def stop(pidfile):
|
|||||||
|
|
||||||
|
|
||||||
def serve(name, main):
|
def serve(name, main):
|
||||||
|
"""Controller for server"""
|
||||||
argv = FLAGS(sys.argv)
|
argv = FLAGS(sys.argv)
|
||||||
|
|
||||||
if not FLAGS.pidfile:
|
if not FLAGS.pidfile:
|
||||||
FLAGS.pidfile = '%s.pid' % name
|
FLAGS.pidfile = '%s.pid' % name
|
||||||
|
|
||||||
logging.debug("Full set of FLAGS: \n\n\n" )
|
logging.debug("Full set of FLAGS: \n\n\n")
|
||||||
for flag in FLAGS:
|
for flag in FLAGS:
|
||||||
logging.debug("%s : %s" % (flag, FLAGS.get(flag, None) ))
|
logging.debug("%s : %s", flag, FLAGS.get(flag, None))
|
||||||
|
|
||||||
action = 'start'
|
action = 'start'
|
||||||
if len(argv) > 1:
|
if len(argv) > 1:
|
||||||
@@ -102,7 +98,11 @@ def serve(name, main):
|
|||||||
else:
|
else:
|
||||||
print 'usage: %s [options] [start|stop|restart]' % argv[0]
|
print 'usage: %s [options] [start|stop|restart]' % argv[0]
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
daemonize(argv, name, main)
|
||||||
|
|
||||||
|
|
||||||
|
def daemonize(args, name, main):
|
||||||
|
"""Does the work of daemonizing the process"""
|
||||||
logging.getLogger('amqplib').setLevel(logging.WARN)
|
logging.getLogger('amqplib').setLevel(logging.WARN)
|
||||||
if FLAGS.daemonize:
|
if FLAGS.daemonize:
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
@@ -115,7 +115,7 @@ def serve(name, main):
|
|||||||
else:
|
else:
|
||||||
if not FLAGS.logfile:
|
if not FLAGS.logfile:
|
||||||
FLAGS.logfile = '%s.log' % name
|
FLAGS.logfile = '%s.log' % name
|
||||||
logfile = logging.handlers.FileHandler(FLAGS.logfile)
|
logfile = logging.FileHandler(FLAGS.logfile)
|
||||||
logfile.setFormatter(formatter)
|
logfile.setFormatter(formatter)
|
||||||
logger.addHandler(logfile)
|
logger.addHandler(logfile)
|
||||||
stdin, stdout, stderr = None, None, None
|
stdin, stdout, stderr = None, None, None
|
||||||
@@ -137,4 +137,4 @@ def serve(name, main):
|
|||||||
stdout=stdout,
|
stdout=stdout,
|
||||||
stderr=stderr
|
stderr=stderr
|
||||||
):
|
):
|
||||||
main(argv)
|
main(args)
|
||||||
|
|||||||
Reference in New Issue
Block a user