Пример #1
0
from uuid import uuid4
from bson.objectid import ObjectId
from datetime import datetime,timedelta
from flask import session, jsonify, abort, request, Response
import uuid

from hpit.server.app import ServerApp
app_instance = ServerApp.get_instance()
app = app_instance.app
mongo = app_instance.mongo
db = app_instance.db
csrf = app_instance.csrf

from hpit.server.models import Plugin, Tutor, Subscription, MessageAuth, ResourceAuth

from hpit.management.settings_manager import SettingsManager
settings = SettingsManager.get_server_settings()

import random

def _map_mongo_document(document):
    mapped_doc = {}

    for k, v in document.items():
        if k == '_id':
            v = str(v)
        elif k == 'message_id':
            v = str(v)
        elif isinstance(v, datetime):
            v = v.isoformat()
Пример #2
0
 def __init__(self):
     self.settings = SettingsManager.get_server_settings()
     self.app_instance = ServerApp.get_instance()
     self.app_instance.bootstrap_user()
Пример #3
0
import os
from hpit.server.app import ServerApp
from pymongo import MongoClient
app_instance = ServerApp.get_instance()
app = app_instance.app
db = app_instance.db
mongo = app_instance.mongo

from hpit.management.settings_manager import SettingsManager
settings = SettingsManager.get_server_settings()
plugin_settings = SettingsManager.get_plugin_settings()


class Command:
    description = "Indexes the Mongo Database."
    
    def __init__(self, manager, parser):
        self.manager = manager

    def run(self, arguments, configuration):
        self.arguments = arguments
        self.configuration = configuration

        #server dbs
        with app.app_context():
            mongo.db.plugin_messages.create_index('receiver_entity_id')
            mongo.db.plugin_transactions.create_index('receiver_entity_id')

            mongo.db.sent_messages_and_transactions.create_index('time_received')
            #mongo.db.sent_responses.create_index('time_response_received')
Пример #4
0
import urllib.parse

from hpit.server.app import ServerApp
app = ServerApp.get_instance().app

class Command:
    description = "Lists all the available routes."
    
    def __init__(self, manager, parser):
        self.manager = manager

    def run(self, arguments, configuration):
        self.arguments = arguments
        self.configuration = configuration

        output = []
        for rule in app.url_map.iter_rules():

            options = {}
            for arg in rule.arguments:
                options[arg] = "[{0}]".format(arg)

            methods = ','.join(rule.methods)
            output.append(urllib.parse.unquote("{:50s} {:20s} {}".format(rule.endpoint, methods, str(rule))))

        for line in sorted(output):
            print(line)
Пример #5
0
import os

from hpit.server.app import ServerApp
db = ServerApp.get_instance().db

from hpit.server.models import User

class Command:
    description = "Change user Administrator status."

    def __init__(self, manager, parser):
        self.manager = manager

        parser.add_argument("--add",type=str,help="Make username in argument an administrator")
        parser.add_argument("--remove",type=str,help="Make username in argument a non administrator")
        parser.add_argument("--status",type=str,help="Is username an administrator?")

    def run(self, arguments, configuration):
        self.arguments = arguments
        self.configuration = configuration
        
        if arguments.status:
            user = User.query.filter(User.username==arguments.add).first()
            if user:
                if user.administrator == True:
                    print ("User " + arguments.add + " is an Administrator.")
                else:
                    print ("User " + arguments.add + " is not an Administrator.")
            else:
                print("Could not find user " + arguments.add)
        
Пример #6
0
from hpit.server.app import ServerApp
db = ServerApp.get_instance().db


class ResourceAuth(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    entity_id = db.Column(db.String(255), nullable=False)
    resource_id = db.Column(db.String(255), nullable=False)
    is_owner = db.Column(db.Boolean(), nullable=False)
Пример #7
0
 def __init__(self):
     self.settings = SettingsManager.get_server_settings()
     self.app_instance = ServerApp.get_instance()
     self.app_instance.bootstrap_user()
Пример #8
0
"""
This script is used to start the Flask server through uWSGI on *nix systems.
"""

import os
from hpit.management.settings_manager import SettingsManager

try:
    settings_manager = SettingsManager.init_instance(os.environ['HPIT_ENV'])
except KeyError:
    settings_manager = SettingsManager.init_instance('debug')

from hpit.server.views.api import *
from hpit.server.views.dashboard import *
from hpit.server.app import ServerApp

server_app = ServerApp.get_instance()
server_app.bootstrap_user()

app = server_app.app