pylint cleanup

This commit is contained in:
Gunther Hagleitner 2012-02-08 00:44:13 -08:00
parent 7475b3197d
commit 22f647bf9b
6 changed files with 28 additions and 31 deletions

View File

@ -34,6 +34,8 @@ SYSLOG_CONF = 'rsyslog.conf'
SWIFT_MAKERINGS = 'swift-remakerings'
SWIFT_STARTMAIN = 'swift-startmain'
SWIFT_INIT = 'swift-init'
SWIFT_IMG = 'drives/images/swift.img'
DEVICE_PATH = 'drives/sdb1'
CONFIGS = [SWIFT_CONF, PROXY_SERVER_CONF, ACCOUNT_SERVER_CONF,
CONTAINER_SERVER_CONF, OBJECT_SERVER_CONF, RSYNC_CONF,
SYSLOG_CONF, SWIFT_MAKERINGS, SWIFT_STARTMAIN]
@ -56,7 +58,7 @@ class SwiftUninstaller(comp.PythonUninstallComponent):
self.datadir = sh.joinpths(self.appdir, self.cfg.get('swift', 'data_location'))
def pre_uninstall(self):
sh.umount(sh.joinpths(self.datadir, 'drives/sdb1'))
sh.umount(sh.joinpths(self.datadir, DEVICE_PATH))
sh.replace_in_file('/etc/default/rsync',
'RSYNC_ENABLE=true',
'RSYNC_ENABLE=false',
@ -74,6 +76,10 @@ class SwiftInstaller(comp.PythonInstallComponent):
self.bindir = sh.joinpths(self.appdir, BIN_DIR)
self.datadir = sh.joinpths(self.appdir, self.cfg.get('swift', 'data_location'))
self.logdir = sh.joinpths(self.datadir, 'logs')
self.startmain_file = sh.joinpths(self.bindir, SWIFT_STARTMAIN)
self.makerings_file = sh.joinpths(self.bindir, SWIFT_MAKERINGS)
self.fs_dev = sh.joinpths(self.datadir, DEVICE_PATH)
self.fs_image = sh.joinpths(self.datadir, SWIFT_IMG)
self.auth_server = 'keystone'
def _get_download_locations(self):
@ -116,13 +122,11 @@ class SwiftInstaller(comp.PythonInstallComponent):
}
def __create_data_location(self):
self.fs_image = sh.joinpths(self.datadir, 'drives/images/swift.img')
sh.create_loopback_file(fname=self.fs_image,
size=int(self.cfg.get('swift',
'loopback_disk_size')),
fs_type='xfs')
self.tracewriter.file_touched(self.fs_image)
self.fs_dev = sh.joinpths(self.datadir, 'drives/sdb1/')
sh.mount_loopback_file(self.fs_image, self.fs_dev, 'xfs')
sh.chown_r(self.fs_dev, sh.geteuid(), sh.getegid())
@ -165,13 +169,11 @@ class SwiftInstaller(comp.PythonInstallComponent):
'/etc/rsyslog.d/10-swift.conf')
def __setup_binaries(self):
self.makerings_file = sh.joinpths(self.bindir, SWIFT_MAKERINGS)
sh.move(sh.joinpths(self.cfgdir, SWIFT_MAKERINGS),
self.makerings_file)
sh.chmod(self.makerings_file, 777)
self.tracewriter.file_touched(self.makerings_file)
self.startmain_file = sh.joinpths(self.bindir, SWIFT_STARTMAIN)
sh.move(sh.joinpths(self.cfgdir, SWIFT_STARTMAIN),
self.startmain_file)
sh.chmod(self.startmain_file, 777)

View File

@ -114,7 +114,7 @@ def _pre_run(action_name, root_dir, pkg_manager, config, component_order, instan
_gen_localrc(config, rc_fn)
def _post_run(action_name, root_dir, pkg_manager, config, components, time_taken, results):
def _post_run(action_name, root_dir, config, components, time_taken, results):
LOG.info("It took (%s) to complete action [%s]" % (common.format_secs_taken(time_taken), action_name))
if results:
LOG.info('Check [%s] for traces of what happened.' % ", ".join(results))
@ -161,16 +161,10 @@ def _print_cfgs(config_obj, action):
LOG.info("Passwords:")
map_print(passwords_gotten)
if full_cfgs:
#TODO
#better way to do this?? (ie a list difference?)
filtered_mp = dict()
for key in full_cfgs.keys():
if key in passwords_gotten:
continue
filtered_mp[key] = full_cfgs.get(key)
if filtered_mp:
filtered = {k: v for k, v in full_cfgs.items() if k not in passwords_gotten}
if filtered:
LOG.info("Configs:")
map_print(filtered_mp)
map_print(filtered)
if db_dsns:
LOG.info("Data source names:")
map_print(db_dsns)
@ -347,7 +341,7 @@ def _run_components(action_name, component_order, components, distro, root_dir,
_uninstall(component, instance, force)
end_time = time.time()
#any post run actions go now
_post_run(action_name, root_dir=root_dir, pkg_manager=pkg_manager,
_post_run(action_name, root_dir=root_dir,
config=config, components=components.keys(),
time_taken=(end_time - start_time), results=results)

View File

@ -377,8 +377,7 @@ def getuid(username):
def gethomedir():
#TODO will just using os.path.expanduser("~") work??
return pwd.getpwuid(geteuid()).pw_dir
return os.path.expanduser("~")
def getgid(groupname):

View File

@ -13,7 +13,7 @@
# W0511: TODOs in code comments are fine.
# W0613: Unused argument '??' should be ok (they are useful sometimes to know intention of variable)
# W0622: Redefining id is fine.
disable=C0111,W0142,W0622,C0301,R0902,R0201,R0914,W0613,R0912
disable=C0111,W0142,W0622,C0301,R0902,R0201,R0914,W0613,R0912,R0801
[Basic]

9
stack
View File

@ -24,13 +24,12 @@ import sys
import traceback
#this needs to happen immediately (or thats what it seems)
log_fn = os.getenv('LOG_FILE')
if(log_fn == None):
log_fn = os.path.normpath(os.path.join("conf", 'logging.ini'))
logging.config.fileConfig(log_fn)
LOG_FN = os.getenv('LOG_FILE')
if(LOG_FN == None):
LOG_FN = os.path.normpath(os.path.join("conf", 'logging.ini'))
logging.config.fileConfig(LOG_FN)
from devstack import opts
from devstack import settings
from devstack import shell as sh
from devstack import utils

View File

@ -3,13 +3,8 @@ import os
import sys
if __name__ == "__main__":
me = os.path.basename(sys.argv[0])
if len(sys.argv) == 1:
print("%s filename filename filename..." % (me))
sys.exit(0)
fn = sys.argv[1]
with open(fn, "r") as f:
def clean_file(name):
with open(name, "r") as f:
contents = f.read()
lines = contents.splitlines()
cleaned_up = list()
@ -22,4 +17,12 @@ if __name__ == "__main__":
data = json.loads(cleaned_lines)
output = json.dumps(data, indent=4, sort_keys=True)
print(output)
if __name__ == "__main__":
ME = os.path.basename(sys.argv[0])
if len(sys.argv) == 1:
print("%s filename filename filename..." % (ME))
sys.exit(0)
clean_file(sys.argv[1])
sys.exit(0)