Merge branch 'feature/physicsprogress' into develop
This commit is contained in:
+51
-8
@@ -16,7 +16,9 @@ from matplotlib.backends.backend_agg import FigureCanvas
|
|||||||
#from matplotlib.backends.backend_cairo import FigureCanvasCairo as FigureCanvas
|
#from matplotlib.backends.backend_cairo import FigureCanvasCairo as FigureCanvas
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
|
from rowsandall_app.settings import SITE_URL
|
||||||
|
from rowsandall_app.settings_dev import SITE_URL as SITE_URL_DEV
|
||||||
|
from rowsandall_app.settings import PROGRESS_CACHE_SECRET
|
||||||
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
|
||||||
@@ -296,11 +298,17 @@ def handle_sendemailtcx(first_name, last_name, email, tcxfile,debug=False):
|
|||||||
@app.task
|
@app.task
|
||||||
def handle_zip_file(emailfrom, subject, file,debug=False):
|
def handle_zip_file(emailfrom, subject, file,debug=False):
|
||||||
message = "... zip processing ... "
|
message = "... zip processing ... "
|
||||||
|
if debug:
|
||||||
|
print message
|
||||||
email = EmailMessage(subject, message,
|
email = EmailMessage(subject, message,
|
||||||
emailfrom,
|
emailfrom,
|
||||||
['workouts@rowsandall.com'])
|
['workouts@rowsandall.com'])
|
||||||
email.attach_file(file)
|
email.attach_file(file)
|
||||||
|
if debug:
|
||||||
|
print "attaching"
|
||||||
res = email.send()
|
res = email.send()
|
||||||
|
if debug:
|
||||||
|
print "sent"
|
||||||
time.sleep(60)
|
time.sleep(60)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
@@ -338,12 +346,36 @@ def handle_sendemailcsv(first_name, last_name, email, csvfile,debug=False):
|
|||||||
# Calculate wind and stream corrections for OTW rowing
|
# Calculate wind and stream corrections for OTW rowing
|
||||||
|
|
||||||
|
|
||||||
@app.task
|
@app.task(bind=True)
|
||||||
def handle_otwsetpower(f1, boattype, weightvalue,
|
def handle_otwsetpower(self,f1, boattype, weightvalue,
|
||||||
first_name, last_name, email, workoutid, ps=[
|
first_name, last_name, email, workoutid,
|
||||||
1, 1, 1, 1],
|
**kwargs):
|
||||||
ratio=1.0,
|
# ps=[
|
||||||
debug=False):
|
# 1, 1, 1, 1],
|
||||||
|
# ratio=1.0,
|
||||||
|
# debug=False):
|
||||||
|
job = self.request
|
||||||
|
job_id = job.id
|
||||||
|
|
||||||
|
if 'jobkey' in kwargs:
|
||||||
|
job_id = kwargs.pop('jobkey')
|
||||||
|
if 'ps' in kwargs:
|
||||||
|
ps = kwargs['ps']
|
||||||
|
else:
|
||||||
|
ps = [1,1,1,1]
|
||||||
|
|
||||||
|
if 'ratio' in kwargs:
|
||||||
|
ratio = kwargs['ratio']
|
||||||
|
else:
|
||||||
|
ratio = 1.0
|
||||||
|
if 'debug' in kwargs:
|
||||||
|
debug = kwargs['debug']
|
||||||
|
else:
|
||||||
|
debug = False
|
||||||
|
|
||||||
|
kwargs['jobid'] = job_id
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
rowdata = rdata(f1)
|
rowdata = rdata(f1)
|
||||||
except IOError:
|
except IOError:
|
||||||
@@ -377,8 +409,19 @@ def handle_otwsetpower(f1, boattype, weightvalue,
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
progressurl = SITE_URL
|
||||||
|
if debug:
|
||||||
|
progressurl = SITE_URL_DEV
|
||||||
|
secret = PROGRESS_CACHE_SECRET
|
||||||
|
|
||||||
|
progressurl += "/rowers/record-progress/"
|
||||||
|
progressurl += job_id
|
||||||
|
|
||||||
rowdata.otw_setpower_silent(skiprows=5, mc=weightvalue, rg=rg,
|
rowdata.otw_setpower_silent(skiprows=5, mc=weightvalue, rg=rg,
|
||||||
powermeasured=powermeasured)
|
powermeasured=powermeasured,
|
||||||
|
progressurl=progressurl,
|
||||||
|
secret=secret
|
||||||
|
)
|
||||||
|
|
||||||
# save data
|
# save data
|
||||||
rowdata.write_csv(f1, gzip=True)
|
rowdata.write_csv(f1, gzip=True)
|
||||||
|
|||||||
@@ -144,6 +144,8 @@ urlpatterns = [
|
|||||||
url(r'^test-job/(?P<aantal>\d+)$',views.test_job_view),
|
url(r'^test-job/(?P<aantal>\d+)$',views.test_job_view),
|
||||||
url(r'^test-job2/(?P<aantal>\d+)$',views.test_job_view2),
|
url(r'^test-job2/(?P<aantal>\d+)$',views.test_job_view2),
|
||||||
url(r'^record-progress/(?P<value>\d+)/(?P<id>.*)$',views.post_progress),
|
url(r'^record-progress/(?P<value>\d+)/(?P<id>.*)$',views.post_progress),
|
||||||
|
url(r'^record-progress/(?P<id>.*)$',views.post_progress),
|
||||||
|
url(r'^record-progress$',views.post_progress),
|
||||||
url(r'^list-graphs/$',views.graphs_view),
|
url(r'^list-graphs/$',views.graphs_view),
|
||||||
url(r'^(?P<theuser>\d+)/ote-bests/(?P<startdatestring>\w+.*)/(?P<enddatestring>\w+.*)$',views.rankings_view),
|
url(r'^(?P<theuser>\d+)/ote-bests/(?P<startdatestring>\w+.*)/(?P<enddatestring>\w+.*)$',views.rankings_view),
|
||||||
url(r'^(?P<theuser>\d+)/ote-bests/(?P<deltadays>\d+)$',views.rankings_view),
|
url(r'^(?P<theuser>\d+)/ote-bests/(?P<deltadays>\d+)$',views.rankings_view),
|
||||||
|
|||||||
@@ -222,11 +222,17 @@ def isbreakthrough(delta,cpvalues,p0,p1,p2,p3,ratio):
|
|||||||
def myqueue(queue,function,*args,**kwargs):
|
def myqueue(queue,function,*args,**kwargs):
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
kwargs['debug'] = True
|
kwargs['debug'] = True
|
||||||
|
|
||||||
|
print 'myqueue'
|
||||||
|
print args
|
||||||
|
print kwargs
|
||||||
|
|
||||||
job = function.delay(*args,**kwargs)
|
job = function.delay(*args,**kwargs)
|
||||||
else:
|
else:
|
||||||
job_id = str(uuid.uuid4())
|
job_id = str(uuid.uuid4())
|
||||||
kwargs['job_id'] = job_id
|
kwargs['job_id'] = job_id
|
||||||
kwargs['jobkey'] = job_id
|
kwargs['jobkey'] = job_id
|
||||||
|
|
||||||
job = queue.enqueue(function,*args,**kwargs)
|
job = queue.enqueue(function,*args,**kwargs)
|
||||||
|
|
||||||
return job
|
return job
|
||||||
|
|||||||
+22
-9
@@ -194,9 +194,9 @@ redis_connection = StrictRedis()
|
|||||||
r = Redis()
|
r = Redis()
|
||||||
|
|
||||||
# this doesn't yet work on production
|
# this doesn't yet work on production
|
||||||
if settings.DEBUG:
|
#if settings.DEBUG:
|
||||||
client = SessionTaskListener(r,['tasks'])
|
# client = SessionTaskListener(r,['tasks'])
|
||||||
client.start()
|
# client.start()
|
||||||
|
|
||||||
|
|
||||||
rq_registry = StartedJobRegistry(queue.name,connection=redis_connection)
|
rq_registry = StartedJobRegistry(queue.name,connection=redis_connection)
|
||||||
@@ -367,19 +367,32 @@ def test_job_view2(request,aantal=100):
|
|||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
def post_progress(request,id=None,value=0):
|
def post_progress(request,id=None,value=0):
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
|
try:
|
||||||
secret = request.POST['secret']
|
secret = request.POST['secret']
|
||||||
|
except KeyError:
|
||||||
|
return HttpResponse('Access Denied',status=401)
|
||||||
if secret == settings.PROGRESS_CACHE_SECRET:
|
if secret == settings.PROGRESS_CACHE_SECRET:
|
||||||
if id:
|
if not id:
|
||||||
|
try:
|
||||||
|
id = request.POST['id']
|
||||||
|
except KeyError:
|
||||||
|
return HttpResponse('Invalid request',400)
|
||||||
|
try:
|
||||||
|
value = request.POST['value']
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
||||||
cache.set(id,value,3600)
|
cache.set(id,value,3600)
|
||||||
# test
|
# test
|
||||||
result = cache.get(id)
|
result = cache.get(id)
|
||||||
|
|
||||||
return HttpResponse('progress cached '+str(result),status=200)
|
return HttpResponse('progress cached '+str(result),
|
||||||
else:
|
status=201)
|
||||||
return HttpResponse('access denied',status=400)
|
else: # secret not given
|
||||||
|
return HttpResponse('access denied',status=401)
|
||||||
|
|
||||||
else:
|
else: # request method is not POST
|
||||||
return HttpResponse('hi',status=200)
|
return HttpResponse('GET method not allowed',status=405)
|
||||||
|
|
||||||
def get_all_queued_jobs(userid=0):
|
def get_all_queued_jobs(userid=0):
|
||||||
r = StrictRedis()
|
r = StrictRedis()
|
||||||
|
|||||||
Reference in New Issue
Block a user