예제 #1
0
def train():
    if request.method == "POST":
        file = request.files['file']
        name = session['user']
        mess_folder = 'message/' + name
        if not os.path.exists(mess_folder):
            os.makedirs(mess_folder)
        path = "aiml/" + name + "/Temp"
        if not os.path.exists(path):
            os.makedirs(path)
        path1 = "aiml/" + name + "/XMLS"
        if not os.path.exists(path1):
            os.makedirs(path1)
        path2 = "aiml/" + name + "/brain"
        if not os.path.exists(path2):
            os.makedirs(path2)
        filename = secure_filename(file.filename)
        if filename == "messages.htm":
            app.config['UPLOAD_FOLDER'] = 'message/' + name + '/'
            file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
            process(name)
            return redirect('/')
        else:
            return ("Bad kind of filename, Kindly Upload your message.htm")
    else:
        return render_template('Train.html', user=session['user'])
예제 #2
0
def train(client):
    uid = client.uid
    USER = client.fetchUserInfo(client.uid)[client.uid]
    name = USER.name.split(" ")[0]

    path = "msg/"
    if not os.path.exists(path):
        os.makedirs(path)

    path = "aiml/"
    if not os.path.exists(path):
        os.makedirs(path)

    path = "aiml/" + name
    if not os.path.exists(path):
        os.makedirs(path)

    path = "aiml/" + name + "/Temp"
    if not os.path.exists(path):
        os.makedirs(path)

    path1 = "aiml/" + name + "/XMLS"
    if not os.path.exists(path1):
        os.makedirs(path1)

    path2 = "aiml/" + name + "/brain"
    if not os.path.exists(path2):
        os.makedirs(path2)

    messages(client)
    process(name)
예제 #3
0
def index():
    app.logger.debug("Main page entry")
    if 'schedule' not in flask.session:
        app.logger.debug("Processing raw schedule file")
        raw = open(CONFIG.schedule)
        flask.session['schedule'] = pre.process(raw)

    return flask.render_template('syllabus.html')
예제 #4
0
def index():
  app.logger.debug("Main page entry")
  if 'schedule' not in flask.session:
      app.logger.debug("Processing raw schedule file")
      raw = open('static/schedule.txt')
      flask.session['schedule'] = pre.process(raw)

  return flask.render_template('syllabus.html')
예제 #5
0
def index():
    app.logger.debug("Main page entry")
    if 'schedule' not in flask.session:
        app.logger.debug("Processing raw schedule file")
        raw = open('static/schedule.txt')
        flask.session['schedule'], base = pre.process(raw)
        flask.session['current_week'] = get_week(base)

    return flask.render_template('syllabus.html')
예제 #6
0
def index():
    app.logger.debug("Main page entry")
    if 'schedule' not in flask.session:
        app.logger.debug("Processing raw schedule file")
        raw = open('static/schedule.txt')
        flask.session['schedule'] = pre.process(raw)
        for week in flask.session['schedule']:
            do_date_stuff(week)
        

    return flask.render_template('syllabus.html')
예제 #7
0
def set_start():
  """
  Get the places of interest for the map.
  """
  app.logger.debug("Got a JSON set_start post");

  reply = [ ]
  raw = open(CONFIG.pins)   #get points of interest from file
  reply = pre.process(raw)  #processing the file

  return jsonify(result=reply)  
예제 #8
0
def index():
    prevWeek = arrow.now().replace(weeks=-1).format(
        'MM/DD/YYYY')  #The date as of a week ago
    currentWeek = arrow.now().format('MM/DD/YYYY')  #The current date
    app.logger.debug("Main page entry")
    if 'schedule' not in flask.session:
        app.logger.debug("Processing raw schedule file")
        raw = open(CONFIG.schedule)
        flask.session['schedule'] = pre.process(raw)

    return flask.render_template(
        'syllabus.html', currentWeek=currentWeek, prevWeek=prevWeek
    )  #Sends off the current date and the prev week to help determine the week to highlight.
예제 #9
0
def test_location():
    raw = open("poi.txt")
    places = pre.process(raw)
    assert places[0]['name'] == 'Student Tennis Center'
    assert places[0]['lat'] == '44.04157'
    assert places[0]['lon'] == '-123.0732'

    assert places[1]['name'] == 'Student Tennis Courts'
    assert places[1]['lat'] == '44.04044'
    assert places[1]['lon'] == '-123.07312'

    assert places[2]['name'] == 'The Y Tennis Courts'
    assert places[2]['lat'] == '44.03612'
    assert places[2]['lon'] == '-123.0833'
예제 #10
0
def index():
  app.logger.debug("Main page entry")
  if 'schedule' not in flask.session:
      app.logger.debug("Processing raw schedule file")
      raw = open('static/schedule.txt')
      syllabus_list = pre.process(raw) #here you collect, week, date, project, and topic per week. List of dicts
      for entry in syllabus_list:   
        arrow_date_low = arrow.get(entry['date'], 'ddd MM/DD/YYYY')
        arrow_date_high = arrow_date_low.replace(weeks=+1)
        arrow_date_now = arrow.now()
        if arrow_date_low <= arrow_date_now < arrow_date_high:
            curr_week = entry['week']
        
      flask.session['cur_week'] = curr_week 
      flask.session['schedule'] = syllabus_list  

  return flask.render_template('syllabus.html') 
예제 #11
0
def index():
    app.logger.debug("Main page entry")
    raw = open('static/schedule.txt')
    processed = pre.process(raw)

    if 'schedule' not in flask.session:
        app.logger.debug("Processing raw schedule file")
        flask.session['schedule'] = processed[0]

    date = []
    thisWeek = arrow.now().week
    for index in range(len(processed[0])):
        w = processed[1].replace(weeks=+index)
        if (w.week == arrow.now().week):
            nownindex = index
        date.append(w)

    return flask.render_template('syllabus.html', date=date)
예제 #12
0
def index():
  app.logger.debug("Main page entry")
  raw = open('static/schedule.txt')
  processed = pre.process(raw)
 
  if 'schedule' not in flask.session:
      app.logger.debug("Processing raw schedule file")
      flask.session['schedule'] = processed[0]


  date=[]
  thisWeek =arrow.now().week
  for index in range(len(processed[0])):
    w = processed[1].replace(weeks=+index)
    if(w.week == arrow.now().week):
      nownindex = index
    date.append(w)

  return flask.render_template('syllabus.html', date=date)
예제 #13
0
def index():
    app.logger.debug("Main page entry")
    if 'schedule' not in flask.session:
        app.logger.debug("Processing raw schedule file")
        raw = open('static/schedule.txt')
        syllabus_list = pre.process(
            raw
        )  #here you collect, week, date, project, and topic per week. List of dicts
        for entry in syllabus_list:
            arrow_date_low = arrow.get(entry['date'], 'ddd MM/DD/YYYY')
            arrow_date_high = arrow_date_low.replace(weeks=+1)
            arrow_date_now = arrow.now()
            if arrow_date_low <= arrow_date_now < arrow_date_high:
                curr_week = entry['week']

        flask.session['cur_week'] = curr_week
        flask.session['schedule'] = syllabus_list

    return flask.render_template('syllabus.html')
예제 #14
0
def refresh():
    """Admin user (or debugger) can use this to reload the schedule."""
    app.logger.debug("Refreshing schedule")
    global schedule
    schedule = pre.process(open(configuration.SYLLABUS))
    return flask.redirect(flask.url_for("index"))
예제 #15
0
# Globals
###
app = flask.Flask(__name__)
if __name__ == "__main__":
    configuration = config.configuration()
else:
    # If we aren't main, the command line doesn't belong to us
    configuration = config.configuration(proxied=True)

if configuration.DEBUG:
    app.logger.setLevel(logging.DEBUG)

# Pre-processed schedule is global, so be careful to update
# it atomically in the view functions.
#
schedule = pre.process(open(configuration.SYLLABUS))

###
# Pages
# Each of these transmits the default "200/OK" header
# followed by html from the template.
###


@app.route("/")
@app.route("/index")
def index():
    """Main application page; most users see only this"""
    app.logger.debug("Main page entry")
    flask.g.schedule = schedule  # To be accessible in Jinja2 on page
    return flask.render_template('syllabus.html')
예제 #16
0
# Globals
###
app = flask.Flask(__name__)
if __name__ == "__main__":
    configuration = config.configuration()
else:
    # If we aren't main, the command line doesn't belong to us
    configuration = config.configuration(proxied=True)

if configuration.DEBUG:
    app.logger.setLevel(logging.DEBUG)

# Pre-processed schedule is global, so be careful to update
# it atomically in the view functions.
#
schedule = pre.process(open(configuration.SYLLABUS, encoding='utf-8', errors='replace'))


###
# Pages
# Each of these transmits the default "200/OK" header
# followed by html from the template.
###

@app.route("/")
@app.route("/index")
def index():
    """Main application page; most users see only this"""
    app.logger.debug("Main page entry")
    flask.g.schedule = schedule  # To be accessible in Jinja2 on page
    return flask.render_template('syllabus.html')
예제 #17
0
def capitols():
    map_application.logger.debug("Capitols call entry")
    found_capitols = pre.process("poi.xml", True)
    return flask.jsonify(result=found_capitols)
예제 #18
0
def is_current_week( i ):
    ithweek = pre.process(open('static/schedule.txt'))[1].week + i;
    return 'currentweek' if ithweek == arrow.now().week+1 else ''
예제 #19
0
def index():
    raw = open('poi.txt')
    flask.session['places'] = pre.process(raw)
    return flask.render_template('index.html')
예제 #20
0
def is_current_week(i):
    ithweek = pre.process(open('static/schedule.txt'))[1].week + i
    return 'currentweek' if ithweek == arrow.now().week + 1 else ''
예제 #21
0
def index():
    app.logger.debug("Processing locations file")
    location_data = pre.process(CONFIG.locations)
    app.logger.debug(location_data)

    return flask.render_template('maps.html', locations=json.dumps(location_data))