pep8 fixes

This commit is contained in:
Michael DeHaan 2012-10-30 20:42:07 -04:00
parent 958b2909f8
commit 8d3f73d562
7 changed files with 29 additions and 28 deletions

2
cron
View file

@ -154,7 +154,7 @@ def add_job(name,job,tmpfile):
def update_job(name,job,tmpfile):
return _update_job(name,job,tmpfile,do_add_job)
def do_add_job (lines, comment, job):
def do_add_job(lines, comment, job):
lines.append(comment)
lines.append(job)

View file

@ -77,7 +77,7 @@ syslog.openlog('ansible-%s' % os.path.basename(__file__))
PIDFILE = os.path.expanduser("~/.fireball.pid")
def log(msg):
syslog.syslog(syslog.LOG_NOTICE, msg)
syslog.syslog(syslog.LOG_NOTICE, msg)
if os.path.exists(PIDFILE):
try:
@ -92,17 +92,17 @@ if os.path.exists(PIDFILE):
HAS_ZMQ = False
try:
import zmq
HAS_ZMQ = True
import zmq
HAS_ZMQ = True
except ImportError:
pass
pass
HAS_KEYCZAR = False
try:
from keyczar.keys import AesKey
HAS_KEYCZAR = True
from keyczar.keys import AesKey
HAS_KEYCZAR = True
except ImportError:
pass
pass
# NOTE: this shares a fair amount of code in common with async_wrapper, if async_wrapper were a new module we could move
# this into utils.module_common and probably should anyway
@ -163,9 +163,9 @@ def command(data):
def fetch(data):
if 'data' not in data:
return dict(failed=True, msg='internal error: data is required')
return dict(failed=True, msg='internal error: data is required')
if 'in_path' not in data:
return dict(failed=True, msg='internal error: out_path is required')
return dict(failed=True, msg='internal error: out_path is required')
fh = open(data['in_path'])
data = fh.read()

View file

@ -157,12 +157,14 @@ def absent(module, dest, regexp, backup):
f.close()
cre = re.compile(regexp)
found = []
def matcher(line):
if cre.search(line):
found.append(line)
return False
else:
return True
lines = filter(matcher, lines)
changed = len(found) > 0
if changed:

View file

@ -176,7 +176,7 @@ def privileges_get(cursor, user,host):
privileges = res.group(1).split(", ")
privileges = ['ALL' if x=='ALL PRIVILEGES' else x for x in privileges]
if "WITH GRANT OPTION" in res.group(4):
privileges.append('GRANT')
privileges.append('GRANT')
db = res.group(2).replace('`', '')
output[db] = privileges
return output
@ -213,8 +213,7 @@ def privileges_grant(cursor, user,host,db_table,priv):
priv_string = ",".join(filter(lambda x: x != 'GRANT', priv))
query = "GRANT %s ON %s TO '%s'@'%s'" % (priv_string,db_table,user,host)
if 'GRANT' in priv:
query = query + " WITH GRANT OPTION"
query = query + " WITH GRANT OPTION"
cursor.execute(query)
def load_mycnf():

View file

@ -149,7 +149,7 @@ def main():
# To use defaults values, keyword arguments must be absent, so
# check which values are empty and don't include in the **kw
# dictionary
params_map = {
params_map = {
"login_host":"host",
"login_user":"user",
"login_password":"password",

View file

@ -379,7 +379,7 @@ def main():
# To use defaults values, keyword arguments must be absent, so
# check which values are empty and don't include in the **kw
# dictionary
params_map = {
params_map = {
"login_host":"host",
"login_user":"user",
"login_password":"password",

26
setup
View file

@ -853,19 +853,19 @@ def run_setup(module):
# templating w/o making a nicer key for it (TODO)
if os.path.exists("/usr/bin/ohai"):
cmd = subprocess.Popen("/usr/bin/ohai", shell=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = cmd.communicate()
ohai = True
try:
ohai_ds = json.loads(out)
except:
ohai = False
if ohai:
for (k,v) in ohai_ds.items():
if type(v) == str or type(v) == unicode:
k2 = "ohai_%s" % k.replace('-', '_')
setup_options[k2] = v
cmd = subprocess.Popen("/usr/bin/ohai", shell=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = cmd.communicate()
ohai = True
try:
ohai_ds = json.loads(out)
except:
ohai = False
if ohai:
for (k,v) in ohai_ds.items():
if type(v) == str or type(v) == unicode:
k2 = "ohai_%s" % k.replace('-', '_')
setup_options[k2] = v
setup_result = {}
setup_result['ansible_facts'] = setup_options