]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Fix lots of linter errors
authorZack Cerza <zack@cerza.org>
Tue, 25 Mar 2014 20:27:54 +0000 (15:27 -0500)
committerZack Cerza <zack@cerza.org>
Tue, 25 Mar 2014 20:27:54 +0000 (15:27 -0500)
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
teuthology/beanstalk.py

index df809fb9df1a0c9a627b0619675346c754b88805..344ea798b1005a7fb6ce636eb9ac6c51c78408ee 100644 (file)
@@ -6,6 +6,7 @@ from .config import config
 
 log = logging.getLogger(__name__)
 
+
 def beanstalk_connect(machine_type):
     qhost = config.queue_host
     qport = config.queue_port
@@ -19,44 +20,49 @@ def beanstalk_connect(machine_type):
     beanstalk.ignore('default')
     return beanstalk
 
+
 def walk_jobs(beanstalk, machine_type, delete=None):
-    curjobs = beanstalk.stats_tube(machine_type)['current-jobs-ready']
-    if curjobs != 0:
-        x=1
-        while x != curjobs:
-            x += 1
-            job = beanstalk.reserve(timeout=20)
-            if job is not None:
-                if job.body is not None:
-                    job_config = yaml.safe_load(job.body)
-                    job_name=job_config['name']
-                    job_id = job.stats()['id']
-                    job_description = job_config['description']
-                    if delete:
-                        if delete in job_name:
-                            print 'Deleted Job: {job_id} from queue. Name: {job_name}'.format(
-                            job_id = job_id,
-                            job_name = job_name,
-                            )
-                            job.delete()
-                        else:
-                            print "Searching queue... Checked " + str(x) + "/" + str(curjobs)," Jobs\r",
-                    else:
-                        print 'Job: {x}/{curjobs} ID: {job_id} Name: {job_name}'.format(
-                        x=x,
-                        curjobs=curjobs,
+    job_count = beanstalk.stats_tube(machine_type)['current-jobs-ready']
+    if job_count == 0:
+        log.info('No jobs in Beanstalk Queue')
+        return
+    x = 1
+    while x < job_count:
+        x += 1
+        job = beanstalk.reserve(timeout=20)
+        if job is not None and job.body is not None:
+            job_config = yaml.safe_load(job.body)
+            job_name = job_config['name']
+            job_id = job.stats()['id']
+            job_description = job_config['description']
+            if delete:
+                if delete in job_name:
+                    m = 'Deleting {job_id}/{job_name}'.format(
                         job_id=job_id,
                         job_name=job_name,
                         )
-                        if job_description:
-                            for desc in job_description.split():
-                                print '\t {desc}'.format(desc=desc)
-        log.info("Finished checking Beanstalk Queue.")
-    else:
-        log.info('No jobs in Beanstalk Queue')
+                    print m
+                    job.delete()
+                else:
+                    m = "Searching queue... Checked {x}/{count} Jobs\r".format(
+                        x=x, count=job_count)
+                    print m,
+            else:
+                m = 'Job: {x}/{count} ID: {job_id} Name: {job_name}'.format(
+                    x=x,
+                    count=job_count,
+                    job_id=job_id,
+                    job_name=job_name,
+                    )
+                print m
+                if job_description:
+                    for desc in job_description.split():
+                        print '\t {desc}'.format(desc=desc)
+    log.info("Finished checking Beanstalk Queue.")
+
 
 def main(args):
-    machine_type =  args['--machine_type']
+    machine_type = args['--machine_type']
     delete = args['--delete']
     beanstalk = beanstalk_connect(machine_type)
     walk_jobs(beanstalk, machine_type, delete)