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
|
|
|
|
def load_goodreads_shelf_into_wishlist(user, shelf_name='all', goodreads_user_id=None, max_books=None):
|
|
|
|
return goodreads.load_goodreads_shelf_into_wishlist(user,shelf_name,goodreads_user_id,max_books)
|
|
|
|
|
2011-11-02 00:42:39 +00:00
|
|
|
@task
|
|
|
|
def load_librarything_into_wishlist(user, lt_username, lt_password, max_books=None):
|
|
|
|
return librarything.load_librarything_into_wishlist(user, lt_username, lt_password, max_books)
|
|
|
|
|
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
|
|
|
|
def fac(n):
|
|
|
|
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
|
|
|
|
fac.update_state(state="PROGRESS!", meta={"current": i, "total": n})
|
|
|
|
sleep(0.01)
|
|
|
|
return res
|
|
|
|
|
|
|
|
|
|
|
|
|