Private
Public Access
1
0

first attempts parsing yaml from messg body

This commit is contained in:
Sander Roosendaal
2017-09-25 16:24:57 +02:00
parent 73178a9cd4
commit cffb75ff9f
3 changed files with 46 additions and 0 deletions

View File

@@ -30,6 +30,7 @@ from rowingdata import summarydata,get_file_type
from scipy.signal import savgol_filter
from rowers.mailprocessing import make_new_workout_from_email,send_confirm
import rowers.uploads as uploads
def rdata(file,rower=rrower()):
try:
@@ -50,6 +51,8 @@ class Command(BaseCommand):
extension = a.document.name[-3:].lower()
donotdelete = 0
m = Message.objects.get(id=a.message_id)
body = m.text
uploadoptions = uploads.upload_options(body)
from_address = m.from_address[0].lower()
name = m.subject
cntr += 1

View File

@@ -11,12 +11,51 @@ from rowers.tasks import (
from rowers.models import GraphImage
import numpy as np
import yaml
import argparse
import yamllint
from subprocess import call
try:
from cStringIO import StringIO
except:
from StringIO import StringIO
from rowers.utils import (
geo_distance,serialize_list,deserialize_list,uniqify,
str2bool,range_to_color_hex,absolute
)
#Configuration for argument parsing
parser = argparse.ArgumentParser()
parser.add_argument("path", help='File/Directory path to be examined', type=str)
args = (parser.parse_args())
#The main loop
#Verify file is in YAML, if so save as dict then end
#ignore = set([])
#with open(args.path, "r") as f:
# try:
# yml = (yaml.load(f))
# print yml
# #If not yaml run through yamllint
# except yaml.YAMLError as exc:
# call(["yamllint","-f","parsable",args.path])
def upload_options(body):
uploadoptions = {}
# ok, a temp solution - write to temp file
with open('temp.txt','w') as f:
f.write(body)
with open('temp.txt','r') as f:
try:
yml = (yaml.load(f))
print yml
except yaml.YAMLError as exc:
call(["yamllint","-f","parsable",'temp.txt'])
return uploadoptions
def make_plot(r,w,f1,f2,plottype,title,imagename='',plotnr=0):
if imagename == '':

4
temp.txt Normal file
View File

@@ -0,0 +1,4 @@
---
aap: noot
mies: jet
...