From 8d3f73d562dccce6d69b2e0c76608ec18d1aa031 Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Tue, 30 Oct 2012 20:42:07 -0400 Subject: [PATCH] pep8 fixes --- cron | 2 +- fireball | 18 +++++++++--------- lineinfile | 2 ++ mysql_user | 5 ++--- postgresql_db | 2 +- postgresql_user | 2 +- setup | 26 +++++++++++++------------- 7 files changed, 29 insertions(+), 28 deletions(-) diff --git a/cron b/cron index 01b2d96761c..c04cd27337f 100644 --- a/cron +++ b/cron @@ -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) diff --git a/fireball b/fireball index 0976ae2338b..ecc1df4bbe9 100755 --- a/fireball +++ b/fireball @@ -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() diff --git a/lineinfile b/lineinfile index 053fd1726fc..060256174b7 100755 --- a/lineinfile +++ b/lineinfile @@ -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: diff --git a/mysql_user b/mysql_user index 9b6e7946b5a..e30fde8ee62 100755 --- a/mysql_user +++ b/mysql_user @@ -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(): diff --git a/postgresql_db b/postgresql_db index 98e52f62cd3..1759f5ee2b7 100755 --- a/postgresql_db +++ b/postgresql_db @@ -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", diff --git a/postgresql_user b/postgresql_user index 61fc1a2a532..b38949c43cc 100755 --- a/postgresql_user +++ b/postgresql_user @@ -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", diff --git a/setup b/setup index 4a2eac7874a..0c4ffae769a 100755 --- a/setup +++ b/setup @@ -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