import sys

from oii.ifcb2.session import session
from oii.ifcb2.orm import TimeSeries, Bin

if len(sys.argv) < 2:
    print "no time series label specified"
    sys.exit(-1)
else:
    LABEL = sys.argv[1]

# clean up dashboard database
ts = session.query(TimeSeries).filter(TimeSeries.label == LABEL).first()
if ts is not None:
    session.delete(ts)

for b in session.query(Bin).filter(Bin.ts_label == LABEL):
    session.delete(b)

session.commit()

# now clean up workflow database
from dashboard_conf import DASHBOARD_BASE_URL, WORKFLOW_DATABASE_URL
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker, scoped_session

from oii.workflow import orm as worm

dbengine = create_engine(WORKFLOW_DATABASE_URL)
worm.Base.metadata.create_all(dbengine)
session = scoped_session(sessionmaker(bind=dbengine))()
示例#2
0
from oii.utils import gen_id

from oii.ifcb2.session import dbengine, session
from oii.ifcb2.orm import User, Role

from oii.ifcb2.dashboard.flasksetup import user_manager

if __name__=='__main__':
    print 'Searching for default admin user in database ...'
    user = session.query(User).filter_by(email='*****@*****.**').first()
    if user is not None:
        print 'Found user. Deleting ...'
        session.delete(user)
        session.commit()
    else:
        print 'Not found.'
    print 'Creating recovery user/password ...'
    username = '******'
    password = gen_id()[:8]
    u = User(
        first_name='Admin',
        last_name='User',
        email=username,
        username=username,
        password=user_manager.hash_password(password),
        is_enabled=True
    )
    r = session.query(Role).filter_by(name='Admin').first()
    u.roles.append(r)
    session.add(u)
    session.commit()
示例#3
0
import sys

from oii.ifcb2.session import session
from oii.ifcb2.orm import TimeSeries, Bin

if len(sys.argv) < 2:
   print 'no time series label specified'
   sys.exit(-1)
else:
   LABEL = sys.argv[1]

# clean up dashboard database
ts = session.query(TimeSeries).filter(TimeSeries.label==LABEL).first()
if ts is not None:
    session.delete(ts)

for b in session.query(Bin).filter(Bin.ts_label==LABEL):
    session.delete(b)

session.commit()

# now clean up workflow database
from dashboard_conf import DASHBOARD_BASE_URL, WORKFLOW_DATABASE_URL
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker, scoped_session

from oii.workflow import orm as worm

dbengine = create_engine(WORKFLOW_DATABASE_URL)
worm.Base.metadata.create_all(dbengine)
session = scoped_session(sessionmaker(bind=dbengine))()
示例#4
0
from oii.ifcb2.session import dbengine, session
from oii.ifcb2.orm import User, Role

from oii.ifcb2.dashboard.flasksetup import user_manager

if __name__ == '__main__':
    try:
        password = sys.argv[1]
    except IndexError:
        password = gen_id()[:8]
    try:
        email = sys.argv[2]
    except IndexError:
        email = '*****@*****.**'
    user = session.query(User).filter_by(email=email).first()
    if user is not None:
        session.delete(user)
        session.commit()
    u = User(first_name='Admin',
             last_name='User',
             email=email,
             username=email,
             password=user_manager.hash_password(password),
             is_enabled=True)
    r = session.query(Role).filter_by(name='Admin').first()
    u.roles.append(r)
    session.add(u)
    session.commit()
    print "%s|%s" % (email, password)