2011-10-20 03:28:36 +00:00
|
|
|
from celery.decorators import task
|
|
|
|
from regluit.core import bookloader
|
2011-11-02 00:42:39 +00:00
|
|
|
from regluit.core import goodreads, librarything
|
2011-11-10 01:31:31 +00:00
|
|
|
from time import sleep
|
2011-10-20 03:28:36 +00:00
|
|
|
|
|
|
|
@task
|
|
|
|
def add_related(isbn):
|
2011-10-20 05:23:30 +00:00
|
|
|
return bookloader.add_related(isbn)
|
2011-10-20 03:28:36 +00:00
|
|
|
|
|
|
|
@task
|
|
|
|
def add_by_isbn(isbn):
|
2011-10-20 05:23:30 +00:00
|
|
|
return bookloader.add_by_isbn(isbn)
|
2011-11-01 00:26:05 +00:00
|
|
|
|
|
|
|
@task
|
2011-11-10 23:14:33 +00:00
|
|
|
def load_goodreads_shelf_into_wishlist(user, shelf_name='all', goodreads_user_id=None, max_books=None,
|
|
|
|
expected_number_of_books=None):
|
|
|
|
return goodreads.load_goodreads_shelf_into_wishlist(user,shelf_name,goodreads_user_id,max_books, expected_number_of_books)
|
2011-11-01 00:26:05 +00:00
|
|
|
|
2011-11-02 00:42:39 +00:00
|
|
|
@task
|
2011-11-17 00:47:29 +00:00
|
|
|
def load_librarything_into_wishlist(user, lt_username, max_books=None):
|
|
|
|
return librarything.load_librarything_into_wishlist(user, lt_username, max_books)
|
2011-11-02 00:42:39 +00:00
|
|
|
|
2011-11-07 14:59:45 +00:00
|
|
|
@task
|
|
|
|
def add(x,y):
|
|
|
|
return x+y
|
|
|
|
|
2011-11-10 01:31:31 +00:00
|
|
|
@task
|
2011-11-10 17:33:22 +00:00
|
|
|
def fac(n, sleep_interval=None):
|
2011-11-10 01:31:31 +00:00
|
|
|
if not(isinstance(n,int) and n >= 0):
|
|
|
|
raise Exception("You can't calculate a factorial of %s " % (str(n)))
|
|
|
|
if n <= 1:
|
|
|
|
return 1
|
|
|
|
else:
|
|
|
|
res = 1
|
|
|
|
for i in xrange(2,n+1):
|
|
|
|
res = res*i
|
2011-11-10 17:33:22 +00:00
|
|
|
fac.update_state(state="PROGRESS", meta={"current": i, "total": n})
|
|
|
|
if sleep_interval is not None:
|
|
|
|
sleep(sleep_interval)
|
2011-11-10 01:31:31 +00:00
|
|
|
return res
|