ソースを参照

we know how to count beans

 also, we removed the option to start the queue seperately
Oz N Tiram 9 年 前
コミット
539a22478f
1 ファイル変更37 行追加28 行削除
  1. 37 28
      frank/frank.py

+ 37 - 28
frank/frank.py

@@ -1,27 +1,27 @@
 """
 Frank can be configured using the following yaml::
-	.frank.yml
-
-	commads:
-	 - test
-	 - deploy
-	 - publish
-
-	newtag:
-	 - python:
-	   - frank.actions:detect_new_tag
-
-	deploy:
-	 - cmd 
-	 - runif:
-	   - test
-	   - newtag
-	
+    .frank.yml
+
+    commads:
+     - test
+     - deploy
+     - publish
+
+    newtag:
+         - python:
+           - frank.actions:detect_new_tag
+
+        deploy:
+         - cmd 
+         - runif:
+           - test
+           - newtag
+        
         publish:
-	  - shell:
+          - shell:
            - cd docs; make html
-	  - python:
-	   - frank.actions:recursive_copy 
+          - python:
+           - frank.actions:recursive_copy 
 
 The sections commands is a simple list of command you would 
 like to define. 
@@ -120,6 +120,7 @@ import conf
 from shell import Shell
 from collections import OrderedDict, namedtuple
 import importlib
+from conf import taskq
 
 PythonCode = namedtuple('PythonCode', ['path', 'args', 'kwargs', 'code'])
 
@@ -267,6 +268,19 @@ def clone(clone_url, branch, depth=1):
     return out, err
 
 
+@taskq.task()
+def count_beans():
+    print "count_12"
+    return "count_12"
+
+
+@app.route('/beans')
+def do_beans():
+    a = count_beans()
+    ans = a.get(blocking=True)
+    return ans
+
+
 @app.route('/', methods=['POST'])
 def start():
     """
@@ -329,19 +343,14 @@ def web(port, debug):
              ignore_unknown_options=True,
              allow_extra_args=True))
 @click.argument('worker_args', nargs=-1, type=click.UNPROCESSED)
-def worker(worker_args):
+def worker(worker_args, short_help='start the consumer of tasks'):
     from huey.bin.huey_consumer import (get_option_parser, Consumer,
         setup_logger, RotatingFileHandler)
     from conf import taskq
     parser = get_option_parser()
     opts, args = parser.parse_args(list(worker_args))
-    setup_logger(logging.INFO, options.logfile)
-    consumer = Consumer(taskq, 2, opts.periodic, optns.initial_delay, 
+    setup_logger(logging.INFO, opts.logfile)
+    consumer = Consumer(taskq, 2, opts.periodic, opts.initial_delay, 
                         opts.backoff, opts.max_delay, opts.utc, 
                         opts.scheduler_interval, opts.periodic_task_interval)
     consumer.run()
-
-
-@cli.command()
-def queue():
-    click.echo('will start the queue')