示例#1
0
def setup_app(command, conf, vars):
    """Place any commands to setup abstrackr here"""
    load_environment(conf.global_conf, conf.local_conf)

    filename = os.path.split(conf.filename)[-1]
    if filename == 'test.ini':
        # Permanently drop any existing tables
        log.info("Dropping existing tables...")
        Base.metadata.drop_all(checkfirst=True, bind=Session.bind)
    # Create the tables if they don't already exist
    log.info("Creating database tables")
    Base.metadata.drop_all(checkfirst=True, bind=Session.bind)
    Base.metadata.create_all(bind=Session.bind)
    log.info("Finished setting up")

    g = Group()
    g.name = u'admin'
    meta.Session.add(g)
    p = Permission()
    p.name = u'admin'
    meta.Session.add(p)

    # give myslf a login.
    u = User()
    u.username = u'byron'
    u.fullname = u'byron wallace'
    u.experience = 2
    u._set_password('pignic')
    u.email = u'*****@*****.**'
    meta.Session.add(u)
    meta.Session.commit()
示例#2
0
def setup_app(command, conf, vars):
    """Place any commands to setup abstrackr here"""
    # Don't reload the app if it was loaded under the testing environment
    if not pylons.test.pylonsapp:
        load_environment(conf.global_conf, conf.local_conf)

    # Create the tables if they don't already exist
    log.info("Creating database tables")
    Base.metadata.create_all(bind=Session.bind)
    log.info("Finished setting up")

    g = Group()
    g.name = u'admin'
    meta.Session.add(g)
    
    p = Permission()
    p.name = u'admin'
    meta.Session.add(p)

    # give myslf a login. 
    u = User()
    u.username = u'byron'
    u.fullname = u'byron wallace'
    u.experience = 2
    u._set_password('pignic')
    u.email = u'*****@*****.**'
    meta.Session.add(u)

    meta.Session.commit()
示例#3
0
def setup_app(command, conf, vars):
    """Place any commands to setup abstrackr here"""
    load_environment(conf.global_conf, conf.local_conf)

    filename = os.path.split(conf.filename)[-1]
    if filename == 'test.ini':
        # Permanently drop any existing tables
        log.info("Dropping existing tables...")
        Base.metadata.drop_all(checkfirst=True, bind=Session.bind)
    # Create the tables if they don't already exist
    log.info("Creating database tables")
    Base.metadata.drop_all(checkfirst=True, bind=Session.bind)
    Base.metadata.create_all(bind=Session.bind)
    log.info("Finished setting up")

    g = Group()
    g.name = u'admin'
    meta.Session.add(g)
    p = Permission()
    p.name = u'admin'
    meta.Session.add(p)

    # give myslf a login. 
    u = User()
    u.username = u'byron'
    u.fullname = u'byron wallace'
    u.experience = 2
    u._set_password('pignic')
    u.email = u'*****@*****.**'
    meta.Session.add(u)
    meta.Session.commit()
示例#4
0
def make_app(global_conf, full_stack=True, static_files=True, **app_conf):
    """Create a Pylons WSGI application and return it

    ``global_conf``
        The inherited configuration for this application. Normally from
        the [DEFAULT] section of the Paste ini file.

    ``full_stack``
        Whether this application provides a full WSGI stack (by default,
        meaning it handles its own exceptions and errors). Disable
        full_stack when this application is "managed" by another WSGI
        middleware.

    ``static_files``
        Whether this application serves its own static files; disable
        when another web server is responsible for serving them.

    ``app_conf``
        The application's local configuration. Normally specified in
        the [app:<name>] section of the Paste ini file (where <name>
        defaults to main).

    """
    # Configure the Pylons environment
    config = load_environment(global_conf, app_conf)

    # The Pylons WSGI app
    app = PylonsApp(config=config)

    # Routing/Session/Cache Middleware
    app = RoutesMiddleware(app, config['routes.map'], singleton=False)
    app = SessionMiddleware(app, config)

    # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares)
    # Add the custom repoze.what middleware app here and pass it the config
    # variable
    app = add_auth(app, config)


    if asbool(full_stack):
        # Handle Python exceptions
        app = ErrorHandler(app, global_conf, **config['pylons.errorware'])

        # Display error documents for 401, 403, 404 status codes (and
        # 500 when debug is disabled)
        if asbool(config['debug']):
            app = StatusCodeRedirect(app)
        else:
            app = StatusCodeRedirect(app, [400, 401, 403, 404, 500])

    # Establish the Registry for this application
    app = RegistryManager(app)

    if asbool(static_files):
        # Serve static files
        static_app = StaticURLParser(config['pylons.paths']['static_files'])
        app = Cascade([static_app, app])
    app.config = config
    return app
示例#5
0
def make_app(global_conf, full_stack=True, static_files=True, **app_conf):
    """Create a Pylons WSGI application and return it

    ``global_conf``
        The inherited configuration for this application. Normally from
        the [DEFAULT] section of the Paste ini file.

    ``full_stack``
        Whether this application provides a full WSGI stack (by default,
        meaning it handles its own exceptions and errors). Disable
        full_stack when this application is "managed" by another WSGI
        middleware.

    ``static_files``
        Whether this application serves its own static files; disable
        when another web server is responsible for serving them.

    ``app_conf``
        The application's local configuration. Normally specified in
        the [app:<name>] section of the Paste ini file (where <name>
        defaults to main).

    """
    # Configure the Pylons environment
    config = load_environment(global_conf, app_conf)

    # The Pylons WSGI app
    app = PylonsApp(config=config)

    # Routing/Session/Cache Middleware
    app = RoutesMiddleware(app, config['routes.map'], singleton=False)
    app = SessionMiddleware(app, config)

    # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares)
    # Add the custom repoze.what middleware app here and pass it the config
    # variable
    app = add_auth(app, config)

    if asbool(full_stack):
        # Handle Python exceptions
        app = ErrorHandler(app, global_conf, **config['pylons.errorware'])

        # Display error documents for 401, 403, 404 status codes (and
        # 500 when debug is disabled)
        if asbool(config['debug']):
            app = StatusCodeRedirect(app)
        else:
            app = StatusCodeRedirect(app, [400, 401, 403, 404, 500])

    # Establish the Registry for this application
    app = RegistryManager(app)

    if asbool(static_files):
        # Serve static files
        static_app = StaticURLParser(config['pylons.paths']['static_files'])
        app = Cascade([static_app, app])
    app.config = config
    return app
def setup_app(command, conf, vars):
    """Place any commands to setup abstrackr here"""
    load_environment(conf.global_conf, conf.local_conf)

    filename = os.path.split(conf.filename)[-1]
    if filename == 'test.ini':
        # Permanently drop any existing tables
        log.info("Dropping existing tables...")
        Base.metadata.drop_all(checkfirst=True, bind=Session.bind)
    # Create the tables if they don't already exist
    log.info("Creating database tables")
    Base.metadata.drop_all(checkfirst=True, bind=Session.bind)
    Base.metadata.create_all(bind=Session.bind)
    log.info("Finished setting up")

    g = Group()
    g.name = u'admin'
    meta.Session.add(g)
    p = Permission()
    p.name = u'admin'
    meta.Session.add(p)

    meta.Session.commit()
from sqlalchemy.orm import load_only
from sqlalchemy import func
from sqlalchemy.orm import Load
from sqlalchemy import desc

from random import randrange
from random import sample

from collections import defaultdict

reload(sys)

sys.setdefaultencoding('utf-8')

conf = appconfig('config:development.ini', relative_to='.')
load_environment(conf.global_conf, conf.local_conf)


def _create_reviews(p_id, iter_size, which_iter):
    lock_file_path = join(dirname(abspath(__file__)), '_delete_lock.lck')

    if not isfile(lock_file_path):
        Session.query(
            model.Citation).filter(model.Citation.project_id != p_id).delete()
        Session.query(
            model.Label).filter(model.Label.project_id != p_id).delete()
        Session.commit()
        open(lock_file_path, 'w+').close()

    u_id = 2629
    k_init = 400
示例#8
0
#import pubmedpy
import time
import csv

from paste.deploy import appconfig
from pylons import config

from abstrackr.config.environment import load_environment
from abstrackr.model.meta import Session

import abstrackr.model as model

from sqlalchemy import and_

conf = appconfig('config:production.ini', relative_to='.')
load_environment(conf.global_conf, conf.local_conf)

### This is fixing Emily's project. The refman ids weren't saved when she imported the project
PROJECT_ID = 219
FILE_PATH = './Abstraktr_Update_Lit_Review_11.12.13.txt'
citations_q = Session.query(model.Citation)

found = 0
not_found = 0

with open(FILE_PATH, 'r') as f:
    reader = csv.DictReader(f, delimiter='\t')

    for row in reader:
        #print(row['id'], row['title'], row['abstract'])
        citation = citations_q.filter_by(title=row['title'], project_id=PROJECT_ID).first()