コード例 #1
0
def add_socketio():
    for class_name in globs.step_socketio_methods.keys():
        if globs.step_objects[class_name] == None:
            cls = getattr(sys.modules["app." + class_name], class_name)
            step = cls()
            globs.step_objects[class_name] = step
            for func, namespace in globs.step_socketio_methods[class_name]:
                socketio.on_event(func.__name__,
                                  partial(func, step),
                                  namespace=namespace)
コード例 #2
0
def post(postID):
    post = Post.query.get_or_404(postID)
    socketio.on_event("like", like)
    user = db.session.query(User).get(current_user.id)
    print(user.has_liked(post))
    likedUsers = len(post.LikedUsers.all())
    interests = post.PostInterests.all()
    return render_template('posts/post.html',
                           title="Posts",
                           post=post,
                           interests=interests,
                           likedUsers=likedUsers)
コード例 #3
0
def chatroom(chatroomID):
    chatroom = Chatroom.query.get_or_404(chatroomID)
    members = chatroom.Members
    chats = db.session.query(Chat).with_parent(chatroom).all()
    # flask_socketio.join_room(chatroom.id)
    socketio.on_event("join", join)
    socketio.on_event("disconnect", disconnect)
    socketio.on_event("chat", create_and_update_chats)
    socketio.on_event("closed", closed)
    return render_template('chatroom/chatroom.html',
                           title="Chatroom",
                           chatroom=chatroom,
                           members=members,
                           chats=chats)
コード例 #4
0
def question(questionID):
    form = AnswerForm()
    if form.validate_on_submit():
        post = Answer(Content=form.content.data,
                      QuestionID=questionID,
                      Authora=current_user)
        db.session.add(post)
        db.session.commit()
        flash("Succesfully Answered!", category='success')
        return redirect(url_for('posts.question', questionID=questionID))
    post = Question.query.get_or_404(questionID)
    answers = Answer.query.filter(Answer.QuestionID == questionID)
    print(answers)
    socketio.on_event("likeq", likeq)
    user = db.session.query(User).get(current_user.id)
    print(user.has_liked_q(post))
    likedUsersQ = len(post.LikedUsersQ.all())
    return render_template('question/question_post.html',
                           title="Questions",
                           post=post,
                           likedUsersQ=likedUsersQ,
                           answers=answers,
                           form=form)
コード例 #5
0
def index():

    connected = 'NO'
    if mqtt.connected:
        connected = 'YES'

    socketio.on_event('deleteHost', deleteHost, namespace='/info')
    socketio.on_event('justaddHost', justaddHost, namespace='/info')
    socketio.on_event('installsnips', installsnips, namespace='/info')

    return render_template('info.html',
                           table=get_mqtt_table(),
                           devicestable=get_device_table(),
                           connected=connected,
                           version=git_version())
コード例 #6
0
ファイル: project.py プロジェクト: Greenhouse-Lab/MicroSPAT
BIN_NAMESPACE = table_to_string_mapping[Bin]

# project_schema = GenotypingProjectSchema()
project_schema = dict_schemas.GenotypingProjectSchema()
channel_schema = DeferredChannelSchema(exclude="data")
locus_params_schema = dict_schemas.GenotypingLocusParamsSchema()
project_sample_annotations_schema = DeferredProjectSampleAnnotationsSchema()
project_channel_annotations_schema = DeferredProjectChannelAnnotationsSchema()
genotype_schema = DeferredGenotypeSchema()

locus_bin_set_schema = dict_schemas.LocusBinSetSchema()
bin_schema = dict_schemas.BinSchema()


socketio.on_event('list', base_list(GenotypingProject, project_schema, JSON_NAMESPACE,
                                    query=GenotypingProject.get_serialized_list),
                  namespace=SOCK_NAMESPACE)
# socketio.on_event('get_updated', base_get_updated(GenotypingProject, project_schema, project_schema, JSON_NAMESPACE), namespace=SOCK_NAMESPACE)


@socketio.on('get_updated', namespace=SOCK_NAMESPACE)
@socketio.on('get', namespace=SOCK_NAMESPACE)
def get_genotyping_project(json):
    ids = extract_ids(json)
    # projects = []
    # channels = []
    # locus_parameters = []
    # genotypes = []
    # project_sample_annotations = []
    # project_channel_annotations = []
    #
コード例 #7
0
ファイル: plate.py プロジェクト: Greenhouse-Lab/MicroSPAT
JSON_NAMESPACE = table_to_string_mapping[Plate]
SOCK_NAMESPACE = make_namespace(JSON_NAMESPACE)

WELL_NAMESPACE = table_to_string_mapping[Well]
PLATE_NAMESPACE = table_to_string_mapping[Plate]
CHANNEL_NAMESPACE = table_to_string_mapping[Channel]

plate_schema = PlateSchema()
plate_list_schema = PlateListSchema()
well_schema = WellSchema()
well_list_schema = WellListSchema()
channel_list_schema = ChannelListSchema()

plate_list_query = Plate.get_serialized_list
socketio.on_event('list', base_list(Plate, plate_list_schema, JSON_NAMESPACE, query=plate_list_query),
                  namespace=SOCK_NAMESPACE)

socketio.on_event('get_updated', base_get_updated(Plate, plate_schema, plate_list_schema, JSON_NAMESPACE),
                  namespace=SOCK_NAMESPACE)


@socketio.on('get', namespace=SOCK_NAMESPACE)
def get_plate(json):
    ids = extract_ids(json)
    plates = []
    wells = []
    channels = []
    for plate_id in ids:
        p = Plate.query.get(plate_id)
        if p:
            plates.append(p)
コード例 #8
0
        #processThread = threading.Thread(target=processLine, args=(cmd,));
        #processThread.start();
        ##time.sleep(5)
        ##msg = check_output(cmd, shell=True).decode()
        ###msg = check_output("%s --app chrome-extension://%s/index.html#popou" % (pythin_bin, json['rid']), shell=True).decode()
        ##print("reload:msg:", msg)
        #print("reload:msg:", msg)
        socketio.emit('message', {
            'action': 'resp_status',
            'p': 0
        },
                      namespace='/canary',
                      room=json['rid'])


socketio.on_event('resp', resp, namespace='/canary')


def line_background_stuff():
    """ python code in main.py """
    print('In background_stuff')
    while True:
        t = str(time.clock())
        #LineFuncuntionView._heartbeat('cohdjlnickbddofkgnnmkjlcehfeedld')
        print('In background_stuff', t)
        time.sleep(10)


#@app.before_request
#def before_request():
#    g.status = {}
コード例 #9
0
from app.microspat.models import LocusArtifactEstimator
from app.microspat.schemas import LocusArtifactEstimatorSchema
from app.microspat.events.base import base_get, table_to_string_mapping, make_namespace, base_get_updated
from app import socketio

JSON_NAMESPACE = table_to_string_mapping[LocusArtifactEstimator]
SOCK_NAMESPACE = make_namespace(JSON_NAMESPACE)
schema = LocusArtifactEstimatorSchema()


socketio.on_event('get', base_get(LocusArtifactEstimator, schema, JSON_NAMESPACE), namespace=SOCK_NAMESPACE)
socketio.on_event('get_updated', base_get_updated(LocusArtifactEstimator, schema, schema, JSON_NAMESPACE),
                  namespace=SOCK_NAMESPACE)
コード例 #10
0
ファイル: sample.py プロジェクト: Greenhouse-Lab/MicroSPAT
from app.utils import CaseInsensitiveDictReader

from ..base import base_list, table_to_string_mapping, make_namespace, TaskNotifier, extract_ids, base_get_updated

JSON_NAMESPACE = table_to_string_mapping[Sample]
SOCK_NAMESPACE = make_namespace(JSON_NAMESPACE)

SAMPLE_NAMESPACE = table_to_string_mapping[Sample]
WELL_NAMESPACE = table_to_string_mapping[Well]
CHANNEL_NAMESPACE = table_to_string_mapping[Channel]

sample_schema = SampleSchema()
well_schema = WellSchema()
channel_schema = ChannelSchema()

socketio.on_event('list', base_list(Sample, sample_schema, SAMPLE_NAMESPACE, query=Sample.get_serialized_list),
                  namespace=make_namespace(SAMPLE_NAMESPACE))
socketio.on_event('get_updated', base_get_updated(Sample, sample_schema, sample_schema, SAMPLE_NAMESPACE),
                  namespace=make_namespace(SAMPLE_NAMESPACE))


@socketio.on('get', namespace=SOCK_NAMESPACE)
def get_sample(json):
    ids = list(set(extract_ids(json)))
    channels = []
    wells = []
    samples = []
    for sample_id in ids:
        sample = Sample.query.get(sample_id)
        if sample:
            samples.append(sample)
            channels += Channel.query.filter(Channel.sample_id == sample_id).all()
コード例 #11
0
from flask_socketio import send

from app.microspat.schemas import BinEstimatorLocusParamsSchema
from app.microspat.models import BinEstimatorLocusParams
from ..base import base_get, table_to_string_mapping, make_namespace, base_get_updated
from app import socketio

JSON_NAMESPACE = table_to_string_mapping[BinEstimatorLocusParams]
SOCK_NAMESPACE = make_namespace(JSON_NAMESPACE)
schema = BinEstimatorLocusParamsSchema()

socketio.on_event('get', base_get(BinEstimatorLocusParams, schema, JSON_NAMESPACE), namespace=SOCK_NAMESPACE)
socketio.on_event('get_updated', base_get_updated(BinEstimatorLocusParams, schema, schema, JSON_NAMESPACE),
                  namespace=SOCK_NAMESPACE)

コード例 #12
0
ファイル: views.py プロジェクト: ti2/snipsWebAdmin
def devicePage():
    global db
    db = tomlDB(current_app.config['APP_SETTINGS'])

    try:

        devicelist = db.get_toml_data("DEVICES")

        #if we delete all device items.. then the heading is left but lists no items
        if len(devicelist) == 0:
            socketio.on_event('scanDevices',
                              scan_devices,
                              namespace='/devices')  #YES DEVICES..DONT CHANGE
            return render_template('device.html', firstrun="YES")

        devicelist.sort(key=operator.itemgetter('FUNCTION'))
        devs = []
        for i in devicelist:
            if "NAME" in i:
                d = {
                    'text':
                    "{} ({}) - {}".format(i['NAME'], i['HOSTNAME'],
                                          i['FUNCTION']),
                    'value':
                    i['HOSTNAME']
                }
                devs.append(d)
            else:
                d = {
                    'text': "{} - {}".format(i['HOSTNAME'], i['FUNCTION']),
                    'value': i['HOSTNAME']
                }
                devs.append(d)

        #devs.sort()

        socketio.on_event('loadDeviceData',
                          load_device_data_handler,
                          namespace='/device')
        socketio.on_event('refresh',
                          load_device_syslog_handler,
                          namespace='/device')
        socketio.on_event('installsnipsasrinjection',
                          install_injection_handler,
                          namespace='/device')
        socketio.on_event('runinjection',
                          run_injection_handler,
                          namespace='/device')

        socketio.on_event('updatesnips', updateSnips, namespace='/device')
        socketio.on_event('restartsnipsservices',
                          restartSnipsServices,
                          namespace='/device')

        socketio.on_event('refreshservice',
                          refreshSnipsService,
                          namespace='/device')
        socketio.on_event('startservice',
                          startSnipsService,
                          namespace='/device')
        socketio.on_event('disableservice',
                          disableSnipsService,
                          namespace='/device')

        socketio.on_event('reloadServicesTable',
                          reloadServicesTable,
                          namespace='/device')

        return render_template('devices.html', devicelist=devs, field="YES")
    except Exception as e:
        print(e)
        if mqtt.connected:
            socketio.on_event('scanDevices',
                              scan_devices,
                              namespace='/devices')  #YES DEVICES..DONT CHANGE
            return render_template('device.html', firstrun="YES")
        else:
            return render_template('device.html', firstrun="MQTT")
コード例 #13
0
from app.microspat.schemas import ArtifactEquationSchema
from app.microspat.models import ArtifactEquation
from app.microspat.events.base import base_get, base_get_updated, table_to_string_mapping, make_namespace
from app import socketio

JSON_NAMESPACE = table_to_string_mapping[ArtifactEquation]
SOCK_NAMESPACE = make_namespace(JSON_NAMESPACE)
schema = ArtifactEquationSchema()

socketio.on_event('get', base_get(ArtifactEquation, schema, JSON_NAMESPACE), namespace=SOCK_NAMESPACE)
socketio.on_event('get_updated', base_get_updated(ArtifactEquation, schema, schema, JSON_NAMESPACE),
                  namespace=SOCK_NAMESPACE)
コード例 #14
0
ファイル: views.py プロジェクト: ti2/snipsWebAdmin
def watch():
    
    socketio.on_event('checkbox', device_checbox_changed_handler, namespace='/watch')

    return Response(stream_with_context(background()))
コード例 #15
0
def generatorPage():
    global db

    socketio.on_event('languageChange', languageChange, namespace='/generator')
    socketio.on_event('generate', generate, namespace='/generator')
    socketio.on_event('saveslot', saveslot, namespace='/generator')
    socketio.on_event('deleteslot', deleteslot, namespace='/generator')
    socketio.on_event('savenewslot', savenewslot, namespace='/generator')
    socketio.on_event('getSlotDropdownList', getSlotDropdownList, namespace='/generator')

    co = request.cookies.get("language")
    if not co:
        co = "en"

    LoadDB(co)



   
    a = db.get_toml_data('Buildin')
    
    stg = ''
    for item in a:
        stg += "<li><a class='dropdown-item' href='#' onClick='dropClicked(this)' data-value='" + item + "'>" + item + "</a></li>"

    stg += "<li><div class='dropdown-divider'></div></li>"

    a = db.get_toml_data('Custom')
  
    for item in a:
        stg += "<li><a class='dropdown-item' href='#' onClick='dropClicked(this)' data-value='" + item + "'>" + item + "</a></li>"
      
    
    return render_template('generator.html', slotsList=stg)
コード例 #16
0
ファイル: channel.py プロジェクト: Greenhouse-Lab/MicroSPAT
from app.microspat.models import Channel, Well
from ..base import base_get, table_to_string_mapping, make_namespace, extract_ids, base_get_updated
from app import socketio, db

JSON_NAMESPACE = table_to_string_mapping[Channel]
SOCK_NAMESPACE = make_namespace(JSON_NAMESPACE)

WELL_NAMESPACE = table_to_string_mapping[Well]
CHANNEL_NAMESPACE = table_to_string_mapping[Channel]

channel_schema = ChannelSchema()
channel_list_schema = ChannelListSchema()
well_schema = WellSchema(exclude=['plate'])


socketio.on_event('get_updated', base_get_updated(Channel, channel_schema, channel_list_schema, JSON_NAMESPACE), namespace=SOCK_NAMESPACE)


@socketio.on('get', namespace=SOCK_NAMESPACE)
def get_channel(json):
    ids = extract_ids(json)
    channels = []
    wells = []
    for channel_id in ids:
        channel = Channel.query.get(channel_id)
        if channel:
            channels.append(channel)
            well = Well.query.get(channel.well_id)
            wells.append(well)
    missing_ids = list(set(ids) - set([_.id for _ in channels]))
コード例 #17
0
ファイル: project.py プロジェクト: Greenhouse-Lab/MicroSPAT
CONTROL_SAMPLE_ASSOCIATION_NAMESPACE = table_to_string_mapping[ControlSampleAssociation]
PROJECT_SAMPLE_ANNOTATIONS_NAMESPACE = table_to_string_mapping[ProjectSampleAnnotations]
SAMPLE_LOCUS_ANNOTATIONS_NAMESPACE = table_to_string_mapping[SampleLocusAnnotation]
PROJECT_CHANNEL_ANNOTATIONS_NAMESPACE = table_to_string_mapping[ProjectChannelAnnotations]

project_schema = QuantificationBiasEstimatorProjectSchema()
project_dict_schema = dict_schemas.QuantificationBiasEstimatorProjectSchema()
channel_schema = DeferredChannelSchema(exclude="data")
locus_params_schema = QuantificationBiasEstimatorLocusParamsSchema()
control_sample_association_schema = DeferredControlSampleAssociationSchema()
project_sample_annotations_schema = DeferredProjectSampleAnnotationsSchema()
sample_locus_annotations_schema = DeferredSampleLocusAnnotationSchema()
project_channel_annotations_schema = DeferredProjectChannelAnnotationsSchema()

socketio.on_event('list', base_list(QuantificationBiasEstimatorProject, project_dict_schema, JSON_NAMESPACE,
                                    query=QuantificationBiasEstimatorProject.get_serialized_list),
                  namespace=SOCK_NAMESPACE)
socketio.on_event('get_updated', base_get_updated(QuantificationBiasEstimatorProject, project_schema, project_schema,
                                                  JSON_NAMESPACE), namespace=SOCK_NAMESPACE)


@socketio.on('get', namespace=SOCK_NAMESPACE)
def get_quantification_bias_estimator_project(json):
    ids = extract_ids(json)
    projects = []
    channels = []
    locus_parameters = []
    control_sample_associations = []
    project_sample_annotations = []

    for project_id in ids:
コード例 #18
0
ファイル: control.py プロジェクト: Greenhouse-Lab/MicroSPAT
import sqlite3
import sqlalchemy.exc

from app.microspat.models.sample.exceptions import InvalidAllelesException
from app.microspat.schemas import ControlSchema
from app.microspat.models import Control, ControlSampleAssociation
from app.microspat.events.base import (
    base_get, base_list, table_to_string_mapping, make_namespace, base_get_updated, TaskNotifier
)
from app import socketio, db

JSON_NAMESPACE = table_to_string_mapping[Control]
SOCK_NAMESPACE = make_namespace(JSON_NAMESPACE)
schema = ControlSchema()

socketio.on_event('get', base_get(Control, schema, JSON_NAMESPACE), namespace=SOCK_NAMESPACE)
socketio.on_event('get_updated', base_get_updated(Control, schema, schema, JSON_NAMESPACE), namespace=SOCK_NAMESPACE)
socketio.on_event('list', base_list(Control, schema, JSON_NAMESPACE), namespace=SOCK_NAMESPACE)


@socketio.on('create', namespace=SOCK_NAMESPACE)
def create_control(json):
    task = 'create'
    barcode = json.get('barcode')
    bin_estimator_id = json.get('bin_estimator')
    alleles = json.get('alleles')

    task_notifier = TaskNotifier(task=task, namespace=SOCK_NAMESPACE, barcode=barcode,
                                 bin_estimator_id=bin_estimator_id, alleles=alleles)

    task_notifier.emit_task_start()
コード例 #19
0
ファイル: project.py プロジェクト: Greenhouse-Lab/MicroSPAT
PROJECT_SAMPLE_ANNOTATIONS_NAMESPACE = table_to_string_mapping[ProjectSampleAnnotations]
SAMPLE_LOCUS_ANNOTATIONS_NAMESPACE = table_to_string_mapping[SampleLocusAnnotation]
PROJECT_CHANNEL_ANNOTATIONS_NAMESPACE = table_to_string_mapping[ProjectChannelAnnotations]

project_schema = BinEstimatorProjectSchema()
project_dict_schema = dict_schemas.BinEstimatorProjectSchema()
channel_schema = DeferredChannelSchema(exclude="data")
locus_params_schema = BinEstimatorLocusParamsSchema()
locus_bin_set_schema = LocusBinSetSchema()
bin_schema = BinSchema()
project_sample_annotations_schema = DeferredProjectSampleAnnotationsSchema()
sample_locus_annotations_schema = DeferredSampleLocusAnnotationSchema()
project_channel_annotations_schema = DeferredProjectChannelAnnotationsSchema()

socketio.on_event('list', base_list(BinEstimatorProject, project_dict_schema, JSON_NAMESPACE,
                                    query=BinEstimatorProject.get_serialized_list),
                  namespace=SOCK_NAMESPACE)
# socketio.on_event('get_updated', base_get_updated(BinEstimatorProject, project_schema, project_schema, JSON_NAMESPACE),
#                   namespace=SOCK_NAMESPACE)


# @socketio.on('list', namespace=SOCK_NAMESPACE)
# def list_bin_estimator_projects():
#     projects = BinEstimatorProject.query.all()
#     bins = Bin.query.all()
#     locus_bin_sets = LocusBinSet.query.all()
#     locus_parameters = BinEstimatorLocusParams.query.all()
#     bins_dump = bin_schema.dumps(bins, many=True)
#     socketio.emit('get', {BIN_NAMESPACE: bins_dump.data}, namespace=make_namespace(BIN_NAMESPACE))
#     socketio.sleep()
#
コード例 #20
0
ファイル: well.py プロジェクト: Greenhouse-Lab/MicroSPAT
from app.microspat.schemas import WellSchema, ChannelSchema, WellListSchema
from app.microspat.models import Well, Channel
from ..base import table_to_string_mapping, make_namespace, extract_ids, TaskNotifier, base_get_updated
from app import socketio

JSON_NAMESPACE = table_to_string_mapping[Well]
SOCK_NAMESPACE = make_namespace(JSON_NAMESPACE)

WELL_NAMESPACE = table_to_string_mapping[Well]
CHANNEL_NAMESPACE = table_to_string_mapping[Channel]

well_schema = WellSchema()
undetailed_well_schema = WellListSchema()
channel_schema = ChannelSchema()

socketio.on_event('get_updated', base_get_updated(Well, well_schema, undetailed_well_schema, JSON_NAMESPACE), namespace=SOCK_NAMESPACE)


@socketio.on('get', namespace=SOCK_NAMESPACE)
def get_well(json):
    ids = extract_ids(json)
    channels = []
    wells = []
    for well_id in ids:
        well = Well.query.get(well_id)
        if well:
            wells.append(well)
            channels += well.channels

    missing_ids = list(set(ids) - set([_.id for _ in wells]))
コード例 #21
0
from app.microspat.schemas import QuantificationBiasEstimatorLocusParamsSchema
from app.microspat.models import QuantificationBiasEstimatorLocusParams
from app.microspat.events.base import base_get, table_to_string_mapping, make_namespace, base_get_updated
from app import socketio

JSON_NAMESPACE = table_to_string_mapping[QuantificationBiasEstimatorLocusParams]
SOCK_NAMESPACE = make_namespace(JSON_NAMESPACE)
schema = QuantificationBiasEstimatorLocusParamsSchema()

socketio.on_event('get', base_get(QuantificationBiasEstimatorLocusParams, schema, JSON_NAMESPACE),
                  namespace=SOCK_NAMESPACE)
socketio.on_event('get_updated', base_get_updated(QuantificationBiasEstimatorLocusParams, schema,
                                                  schema, JSON_NAMESPACE),
                  namespace=SOCK_NAMESPACE)

コード例 #22
0
ファイル: bin.py プロジェクト: Greenhouse-Lab/MicroSPAT
from app.microspat.schemas import BinSchema
from app.microspat.models import Bin, LocusBinSet
from app.microspat.events.base import base_get, table_to_string_mapping, make_namespace, base_get_updated, TaskNotifier
from app import socketio, db

JSON_NAMESPACE = table_to_string_mapping[Bin]
SOCK_NAMESPACE = make_namespace(JSON_NAMESPACE)
schema = BinSchema()

socketio.on_event('get', base_get(Bin, schema, JSON_NAMESPACE), namespace=SOCK_NAMESPACE)
socketio.on_event('get_updated', base_get_updated(Bin, schema, schema, JSON_NAMESPACE), namespace=SOCK_NAMESPACE)


@socketio.on('save_bin', namespace=SOCK_NAMESPACE)
def save_bin(json):
    task = 'save_bin'
    bin_id = json.get('id')
    label = json.get('label')
    base_size = json.get('base_size')
    bin_buffer = json.get('bin_buffer')

    task_notifier = TaskNotifier(task=task, namespace=SOCK_NAMESPACE, **json)
    task_notifier.emit_task_start()

    if not bin_id:
        task_notifier.emit_task_failure(message="Malformed Save Bin Request: No Bin ID.")
        return

    if not label:
        task_notifier.emit_task_failure(message="Label Invalid.")
        return
コード例 #23
0
from app.microspat.schemas import ControlSampleAssociationSchema
from app.microspat.models import ControlSampleAssociation
from ..base import base_get, table_to_string_mapping, make_namespace, base_get_updated
from app import socketio

JSON_NAMESPACE = table_to_string_mapping[ControlSampleAssociation]
SOCK_NAMESPACE = make_namespace(JSON_NAMESPACE)

schema = ControlSampleAssociationSchema()

socketio.on_event('get', base_get(ControlSampleAssociation, schema, JSON_NAMESPACE), namespace=SOCK_NAMESPACE)
socketio.on_event('get_updated', base_get_updated(ControlSampleAssociation, schema, schema, JSON_NAMESPACE),
                  namespace=SOCK_NAMESPACE)