Example #1
0
    def __init__(self):
        handlers = [(r"/", IndexHandler), (r"/login", LoginHandler),
                    (r"/home", HomeHandler), (r"/back/(.*)", BackHandler),
                    (r"/debug", DebugHandler), (r"/logout", AuthLogoutHandler),
                    (r'/statics/(.*)', tornado.web.StaticFileHandler, {
                        'path': os.path.join(os.path.dirname(__file__),
                                             "statics")
                    })]
        settings = dict(
            app_title=u"uhpweb",
            template_path=os.path.join(os.path.dirname(__file__), "app"),
            static_path=os.path.join(os.path.dirname(__file__), "statics"),
            xsrf_cookies=False,
            cookie_secret="FS24FADSDSFDS$^&$$DJFHSJFDF",
            login_url="/login",
            debug=True,
        )
        tornado.web.Application.__init__(self, handlers, **settings)

        self.engine = database.getEngine()
Example #2
0
 def __init__(self):
     handlers = [
         (r"/", IndexHandler),
         (r"/login", LoginHandler),
         (r"/home", HomeHandler),
         (r"/back/(.*)", BackHandler),
         (r"/debug", DebugHandler),
         (r"/logout", AuthLogoutHandler),
         (r'/statics/(.*)', tornado.web.StaticFileHandler, {'path':os.path.join(os.path.dirname(__file__), "statics")})
     ]
     settings = dict(
         app_title=u"uhpweb",
         template_path=os.path.join(os.path.dirname(__file__), "app"),
         static_path=os.path.join(os.path.dirname(__file__), "statics"),
         xsrf_cookies=False,
         cookie_secret="FS24FADSDSFDS$^&$$DJFHSJFDF",
         login_url="/login",
         debug=True,
     )
     tornado.web.Application.__init__(self, handlers, **settings)
     
     self.engine = database.getEngine();
Example #3
0
import itertools
import md5
import database

import functools
import flask
import flask.ext.login
import flask.ext.session

import subprocess

login_manager = flask.ext.login.LoginManager()
session = flask.ext.session.Session()

appDir = os.path.abspath(os.path.dirname(__file__))
engine = database.getEngine(os.path.join(appDir, 'db.sql'))


def logexceptions(func):
    def inner(*args, **kwargs):
        try:
            return func(*args, **kwargs)
        except Exception as e:
            traceback.print_exc()

            return {'status': False, 'msg': str(e)}

    return inner


app = flask.Flask('training')
            self.b_Zone_id=0
        temp = b_time.split('_')
        self.b_Date=int(temp[0])*10000+int(temp[1])*100+int(temp[2])
        self.b_Time=int(temp[3])*100+int(temp[4])
#         
        
    __tablename__='Cars'
    
    record_id=Column(Integer, primary_key=True,autoincrement=True)
    Car_lic_No= Column(String)
    Car_provider	=Column(String)
    Car_id	= Column(String)
    Car_type= Column(String)
    Car_model= Column(String)
    b_Location_X= Column(Float)
    b_Location_Y= Column(Float)
    b_Zone_id    = Column(Integer)
    b_Date =  Column(Integer)
    b_Time=Column(Integer)
    r_Time=Column(Integer)
    r_Date =  Column(Integer)
    r_Zone_id    = Column(Integer)
    r_Location_X= Column(Float)
    r_Location_Y= Column(Float)
    
   
        
engine = database.getEngine()
print "got engine ", engine
Base.metadata.create_all(engine)
 
Example #5
0
#%%
import mldb2
import sys
import os
import re

appDir = "/home/bbales2/scraping/training/"
sys.path.append(appDir)
import database

session, engine = mldb2.getSession()

figures = session.query(mldb2.Figure).all()
targetEngine = database.getEngine(os.path.join(appDir, "db.sql"))
targetSession = database.getSession(targetEngine)

# targetSession.query(database.Figure).delete()

#%%

for i, figure in enumerate(figures):
    filename = figure.filename.replace(".sml", ".jpg")
    paperUrl = "http://www.sciencedirect.com/science/article/pii/{0}".format(
        re.sub("[^A-Z0-9]", "", figure.paper.data["pii"])
    )
    caption = " ".join([s.string for s in figure.sentences])
    url = "/static/papers/{0}/{1}".format(figure.paper.data["pii"], filename)
    targetSession.add(database.Figure(caption=caption, url=url, paperUrl=paperUrl))
    if i % 1000 == 0:
        print "commit"
        targetSession.commit()
Example #6
0
#!python
#coding=utf8

import os
import sys

commondir=os.path.join( os.getenv('UHP_HOME'),"uhpcommon");
sys.path.append(commondir)
import database
from model.callback import CallBack

engine = database.getEngine()
CallBack.metadata.drop_all(engine) 
CallBack.metadata.create_all(engine)
Example #7
0
#%%
import sys
sys.path.append('/home/bbales2/scraping/training/')
import database

dbpath = '/home/bbales2/scraping/training/db.sql'

engine = database.getEngine(dbpath)
session = database.getSession(engine)

#%%
figures = session.query(database.Figure).all()
#%%

import re
from miningTools import stemSentence
import gensim
import nltk
import shutil
import os

#%%

stopwords = stemSentence(' '.join(nltk.corpus.stopwords.words("english"))) + ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i']

notword = re.compile(r'[^a-zA-Z -]')
loWords = []
for i, figure in enumerate(figures):
    words = [word for word in stemSentence(figure.caption) if len(notword.sub('', word)) > 0 and word not in stopwords]

    loWords.append(words)
Example #8
0
import database
import datetime

import functools
import flask
import flask.ext.login
import flask.ext.session

appDir = os.path.abspath(os.path.dirname(__file__))

templateLoader = jinja2.FileSystemLoader(searchpath = "templates")
templateEnv = jinja2.Environment(loader = templateLoader)

session = flask.ext.session.Session()

engine = database.getEngine(os.path.join(appDir, 'db.sql'))

def logexceptions(func):
    def inner(*args, **kwargs):
        try:
            return func(*args, **kwargs)
        except Exception as e:
            traceback.print_exc()

            return { 'status' : False, 'msg' : str(e) }

    return inner

app = flask.Flask('microstructure_quiz')

@app.before_request
Example #9
0
#%%
import numpy
import matplotlib.pyplot as plt
import sklearn.linear_model

import os

os.chdir('/home/bbales2/scraping/training')
import database

engine = database.getEngine('db.sql')
session = database.getSession(engine)
#%%
figures = session.query(database.Figure).all()

classifications = session.query(database.Classification).all()

categories = set()

for cls in classifications:
    for ca in cls.data:
        if len(ca) > 0:
            categories.add(ca)

categories = sorted(list(categories))
categories = dict([(name, i) for i, name in enumerate(categories)])

data = []
target = []

for i, cls in enumerate(classifications):
Example #10
0
#%%
import sys

sys.path.append('/home/bbales2/scraping/training/')
import database

dbpath = '/home/bbales2/scraping/training/db.sql'

engine = database.getEngine(dbpath)
session = database.getSession(engine)

#%%
figures = session.query(database.Figure).all()
#%%

import re
from miningTools import stemSentence
import gensim
import nltk
import shutil
import os

#%%

stopwords = stemSentence(' '.join(nltk.corpus.stopwords.words("english"))) + [
    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'
]

notword = re.compile(r'[^a-zA-Z -]')
loWords = []
for i, figure in enumerate(figures):