unfinished business
Need to create a post_progress view taking progress and job id as a POST parameter so that we can send the entire url to rowingdata
This commit is contained in:
@@ -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,23 @@ 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(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')
|
||||||
|
|
||||||
|
kwargs['jobid'] = job_id
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
rowdata = rdata(f1)
|
rowdata = rdata(f1)
|
||||||
except IOError:
|
except IOError:
|
||||||
@@ -377,8 +396,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 += str(progress)+"/"+jobid
|
||||||
|
|
||||||
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)
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user