PEP 8 clean thanks to auto pep8

This commit is contained in:
Julien Duponchelle committed 2015-01-20 13:24:00 +01:00
1 parent 7f185663d1
commit f5ed9fbcf1
124 files changed
+340 -210

No files matched your search

+1 -1
View File
@@ -21,4 +21,4 @@
# three numbers are the components of the version number. The fourth
# is zero for an official release, positive for a development branch,
# or negative for a release candidate or beta (after the base version
# number has been incremented)
# number has been incremented)
+14 -8
View File
@@ -1,8 +1,14 @@
"""Generic linux daemon base class for python 3.x."""
import sys, os, time, atexit, signal
import sys
import os
import time
import atexit
import signal
class daemon:
"""A generic daemon class.
Usage: subclass the daemon class and override the run() method."""
@@ -54,7 +60,7 @@ class daemon:
atexit.register(self.delpid)
pid = str(os.getpid())
with open(self.pidfile,'w+') as f:
with open(self.pidfile, 'w+') as f:
f.write(pid + '\n')
def delpid(self):
@@ -74,7 +80,7 @@ class daemon:
# Check for a pidfile to see if the daemon already runs
try:
with open(self.pidfile,'r') as pf:
with open(self.pidfile, 'r') as pf:
pid = int(pf.read().strip())
except IOError:
@@ -101,20 +107,20 @@ class daemon:
# Get the pid from the pidfile
try:
with open(self.pidfile,'r') as pf:
with open(self.pidfile, 'r') as pf:
pid = int(pf.read().strip())
except IOError:
pid = None
if not pid:
message = "pidfile {0} does not exist. " + \
"Daemon not running?\n"
"Daemon not running?\n"
sys.stderr.write(message.format(self.pidfile))
return # not an error in a restart
return # not an error in a restart
# Try killing the daemon process
try:
while 1:
while True:
os.kill(pid, signal.SIGTERM)
time.sleep(0.1)
except OSError as err:
@@ -123,7 +129,7 @@ class daemon:
if os.path.exists(self.pidfile):
os.remove(self.pidfile)
else:
print (str(err.args))
print(str(err.args))
sys.exit(1)
def restart(self):
+5 -2
View File
@@ -23,7 +23,8 @@
# or negative for a release candidate or beta (after the base version
# number has been incremented)
import os, sys
import os
import sys
import json
import logging
import socket
@@ -34,7 +35,9 @@ from gns3dms.cloud.rackspace_ctrl import RackspaceCtrl
LOG_NAME = "gns3dms.rksp"
log = logging.getLogger("%s" % (LOG_NAME))
class Rackspace(object):
def __init__(self, options):
self.username = options["cloud_user_name"]
self.apikey = options["cloud_api_key"]
@@ -54,7 +57,7 @@ class Rackspace(object):
for region in self.rksp.list_regions():
log.debug("Rackspace regions: %s" % (region))
log.debug("Checking region: %s" % (self.region))
self.rksp.set_region(self.region)
for server in self.rksp.list_instances():