From 14730276b92b3d83746d07a983064211861e1f96 Mon Sep 17 00:00:00 2001 From: Sam Lang Date: Thu, 31 Jan 2013 07:58:57 -0600 Subject: [PATCH] Fixes for syntax errors found by pyflakes. This patch includes minor fixes to the teuthology python code for syntax errors found by running check-syntax.sh (which runs pyflakes on each file). Signed-off-by: Sam Lang Reviewed-by: Josh Durgin --- teuthology/task/ceph-fuse.py | 2 +- teuthology/task/ceph_manager.py | 1 - teuthology/task/exec.py | 2 -- teuthology/task/hadoop.py | 2 -- teuthology/task/kcon_most.py | 1 - teuthology/task/mds_thrash.py | 3 +-- teuthology/task/mpi.py | 4 ---- teuthology/task/nfs.py | 1 - teuthology/task/pexec.py | 3 --- teuthology/task/recovery_bench.py | 2 +- teuthology/task/rgw-logsocket.py | 9 +-------- teuthology/task/ssh_keys.py | 3 --- teuthology/task/workunit.py | 4 ++-- 13 files changed, 6 insertions(+), 31 deletions(-) diff --git a/teuthology/task/ceph-fuse.py b/teuthology/task/ceph-fuse.py index abcc964e5d..1eb0d78abe 100644 --- a/teuthology/task/ceph-fuse.py +++ b/teuthology/task/ceph-fuse.py @@ -135,7 +135,7 @@ def task(ctx, config): mnt, ], ) - except CommandFailedError as e: + except run.CommandFailedError: log.info('Failed to unmount ceph-fuse on {name}, aborting...'.format(name=remote.name)) # abort the fuse mount, killing all hung processes remote.run( diff --git a/teuthology/task/ceph_manager.py b/teuthology/task/ceph_manager.py index 1b96d1fac2..22b84b13ca 100644 --- a/teuthology/task/ceph_manager.py +++ b/teuthology/task/ceph_manager.py @@ -6,7 +6,6 @@ import gevent import json import threading from teuthology import misc as teuthology -from ..orchestra import run class Thrasher: def __init__(self, manager, config, logger=None): diff --git a/teuthology/task/exec.py b/teuthology/task/exec.py index 8961ee6faf..a914101e40 100644 --- a/teuthology/task/exec.py +++ b/teuthology/task/exec.py @@ -1,6 +1,4 @@ -import contextlib import logging -import os from teuthology import misc as teuthology diff --git a/teuthology/task/hadoop.py b/teuthology/task/hadoop.py index 38b88e460d..034716c8f7 100644 --- a/teuthology/task/hadoop.py +++ b/teuthology/task/hadoop.py @@ -3,7 +3,6 @@ from cStringIO import StringIO import contextlib import logging import os -import re from teuthology import misc as teuthology from teuthology import contextutil @@ -298,7 +297,6 @@ def _download_hadoop_binaries(remote, hadoop_url): @contextlib.contextmanager def binaries(ctx, config): path = config.get('path') - tmpdir = None if path is None: # fetch from gitbuilder gitbuilder diff --git a/teuthology/task/kcon_most.py b/teuthology/task/kcon_most.py index a831bfad7d..5836f2faa9 100644 --- a/teuthology/task/kcon_most.py +++ b/teuthology/task/kcon_most.py @@ -1,6 +1,5 @@ import contextlib import logging -import os from teuthology import misc as teuthology diff --git a/teuthology/task/mds_thrash.py b/teuthology/task/mds_thrash.py index d143b4f7a9..d37651d4a2 100644 --- a/teuthology/task/mds_thrash.py +++ b/teuthology/task/mds_thrash.py @@ -119,7 +119,7 @@ class MDSThrasher: skip = random.randrange(0.0, 1.0) if self.weight < 1.0 and skip > self.weight: - self.log('skipping thrash iteration with skip ({skip}) > weight ({weight})'.format(skip=skip, weight=weight)) + self.log('skipping thrash iteration with skip ({skip}) > weight ({weight})'.format(skip=skip, weight=self.weight)) continue # find the active mds in the failure group @@ -239,7 +239,6 @@ def task(ctx, config): random.seed(seed) max_thrashers = config.get('max_thrash', 1) - managers = {} thrashers = {} (first,) = ctx.cluster.only('mds.{_id}'.format(_id=mdslist[0])).remotes.iterkeys() diff --git a/teuthology/task/mpi.py b/teuthology/task/mpi.py index c5a13745b3..67d444f935 100644 --- a/teuthology/task/mpi.py +++ b/teuthology/task/mpi.py @@ -1,7 +1,4 @@ -import contextlib import logging -import os -from datetime import datetime from teuthology import misc as teuthology @@ -94,7 +91,6 @@ def task(ctx, config): # write out the mpi hosts file log.info('mpi nodes: [%s]' % (', '.join(hosts))) - hostfiledata = '\n'.join(hosts) + '\n' teuthology.write_file(remote=master_remote, path='/tmp/cephtest/mpi-hosts', data='\n'.join(hosts)) log.info('mpiexec on {name}: {cmd}'.format(name=master_remote.name, cmd=mpiexec)) args=['mpiexec', '-f', '/tmp/cephtest/mpi-hosts'] diff --git a/teuthology/task/nfs.py b/teuthology/task/nfs.py index b2864a11c8..ed92f5f88f 100644 --- a/teuthology/task/nfs.py +++ b/teuthology/task/nfs.py @@ -1,7 +1,6 @@ import contextlib import logging import os -import re from teuthology import misc as teuthology diff --git a/teuthology/task/pexec.py b/teuthology/task/pexec.py index 5e7b7be198..de0fb519c0 100644 --- a/teuthology/task/pexec.py +++ b/teuthology/task/pexec.py @@ -1,7 +1,4 @@ -import contextlib import logging -import os -from datetime import datetime from teuthology import misc as teuthology from teuthology.parallel import parallel diff --git a/teuthology/task/recovery_bench.py b/teuthology/task/recovery_bench.py index 72b40c302b..ea4fb765ee 100644 --- a/teuthology/task/recovery_bench.py +++ b/teuthology/task/recovery_bench.py @@ -170,7 +170,7 @@ class RecoveryBencher: sample = json.loads(line) samples = lat.setdefault(sample['type'], []) samples.append(float(sample['latency'])) - except Exception, e: + except Exception: pass for type in lat: diff --git a/teuthology/task/rgw-logsocket.py b/teuthology/task/rgw-logsocket.py index daa29c18cb..0f6b1c7f0a 100644 --- a/teuthology/task/rgw-logsocket.py +++ b/teuthology/task/rgw-logsocket.py @@ -1,18 +1,11 @@ from cStringIO import StringIO from configobj import ConfigObj -import base64 import contextlib import logging -import os -import random -import string import s3tests -import socket from teuthology import misc as teuthology from teuthology import contextutil -from ..orchestra import run -from ..orchestra.connection import split_user log = logging.getLogger(__name__) @@ -60,7 +53,7 @@ def run_tests(ctx, config): netcat_out = StringIO() for client, client_config in config.iteritems(): - proc = ctx.cluster.only(client).run( + ctx.cluster.only(client).run( args = [ 'netcat', '-w', '5', diff --git a/teuthology/task/ssh_keys.py b/teuthology/task/ssh_keys.py index bb7ce8493d..c2637d01ea 100644 --- a/teuthology/task/ssh_keys.py +++ b/teuthology/task/ssh_keys.py @@ -1,8 +1,6 @@ #!/usr/bin/python import contextlib -import errno import logging -import os import paramiko import re @@ -62,7 +60,6 @@ def cleanup_keys(ctx, public_key): # fails 1/2 way through (don't want to break ssh on the vm) old_auth_keys_file = mySftp.open(auth_keys_file) new_auth_keys_file = mySftp.open(auth_keys_file + '.new', 'w') - out_keys = [] for line in old_auth_keys_file.readlines(): match = re.search(re.escape(public_key), line) diff --git a/teuthology/task/workunit.py b/teuthology/task/workunit.py index 5e49b3b8aa..aae28eeaa6 100644 --- a/teuthology/task/workunit.py +++ b/teuthology/task/workunit.py @@ -144,7 +144,7 @@ def _make_scratch_dir(ctx, role, subdir): # if neither kclient nor ceph-fuse are required for a workunit, # mnt may not exist. Stat and create the directory if it doesn't. try: - proc = remote.run( + remote.run( args=[ 'stat', '--', @@ -153,7 +153,7 @@ def _make_scratch_dir(ctx, role, subdir): ) log.info('Did not need to create dir {dir}'.format(dir=mnt)) except: - proc = remote.run( + remote.run( args=[ 'mkdir', '--', -- 2.39.5