Beispiel #1
0
    def post(self):
        print "register"
        print datetime.now()
        with open('./log/logfile.txt', 'a') as log:
            log.write('register, ' + str(datetime.now()) + '\n')

        json_file = json.loads(self.get_argument('JSON_SIGN'))
        name = json_file['name']
        email = json_file['email']
        phone = json_file['phone']
        password = json_file['password']

        password = info_encrypt.encrypt(password)
        info = {
            'name': name,
            'email': email,
            'phone': phone,
            'password': password,
            'create_time': str(datetime.now()),
        }

        query_1 = {'email': email}
        query_2 = {'phone': phone}

        query = {'$or': [query_1, query_2]}

        collection = db_handler.DBHandler(self.client, 'users',
                                          'contact_with_password')
        collection.do_find_one(query, self.func, info)
Beispiel #2
0
    def __init__(self, accountID):
        self.accountID = accountID
        self.db = db_handler.DBHandler()

        account = self.db.get_websim_account(accountID)
        self.ws = websim.WebSim(login = account[0], password = account[1])
        self.ws.authorise()
Beispiel #3
0
    def __init__(self, accountID, top_config=None):
        self.db = db_handler.DBHandler()
        self.accountID = accountID
        self.top_config = top_config

        account = self.db.get_client_account(accountID)
        self.ws = websim.WebSim(login=account[0], password=account[1])
        self.ws.authorise()
Beispiel #4
0
    def __init__(self, accountID, top_config):
        self.accountID = accountID
        self.top_config = top_config
        self.db = db_handler.DBHandler()
        self.corr = correlation.Correlation(accountID)

        account = self.db.get_websim_account(accountID)
        self.ws = websim.WebSim(login = account[0], password = account[1])
        self.ws.authorise()
Beispiel #5
0
    def __init__(self, accountID):
        self.accountID = accountID
        self.db = db_handler.DBHandler()

        self.tops = top_handler.AllTopHandler(accountID)

        account = self.db.get_websim_account(accountID)
        self.ws = websim.WebSim(login=account[0], password=account[1])
        self.ws.authorise()
        self.sb = submitter.Submitter(accountID)
Beispiel #6
0
    def post(self):
        json_file = json.loads(self.get_argument('JSON_ITEM_JOIN'))
        item_id = json_file['item_id']
        join_email = json_file['join_email']

        query = {
            'item_id': ObjectId(item_id),
        }

        info = {'item_id': ObjectId(item_id), 'join_email': join_email}

        collection = db_handler.DBHandler(self.client, 'resource', 'items')

        document = collection.do_find_one(query, func, info)
Beispiel #7
0
    def __init__(self, alphaStreamID = None, sending = None):
        '''
        :param alphaStreamID: if presented, creates presentation of passed steramId
        :param sendingID: if presented, creates new alphaStrem (and creates presentation object), containing the sending
        :returns: presentation of alphaStreeamId object (that is new, if sendingId passed)
        '''
        self.db = db_handler.DBHandler()

        self.sending_list = []
        if not alphaStreamID:
            self.alphaStreamID = self.db.alpha_stream_create(sending.sendingID)
        else:
            self.alphaStreamID = alphaStreamID

        self.__update_sequence()
Beispiel #8
0
    def __init__(self, sendingID = None, code = None, params = {'delay': 0, 'decay': 7, 'univid': 'TOP2000', 'opneut': 'Subindustry'}, status = None):
        self.db = db_handler.DBHandler()
        self.__code = None
        self.__params = None
        self.__result = None
        self.__status = None

        if not sendingID:
            self.__code = code
            self.__params = params
            codeID = self.db.add_code(code)
            self.sendingID = self.db.add_sending(codeID, delay = params['delay'], decay = params['decay'], univid = params['univid'], opneut = params['opneut'])
        else:
            self.sendingID = sendingID
            self.__status = self.db.get_sending_status(sendingID)
Beispiel #9
0
    def post(self):
        print "connected"
        print datetime.now()
        with open('./log/logfile.txt', 'a') as log:
            log.write('connected, ' + str(datetime.now()) + '\n')

        json_file = json.loads(self.get_argument('JSON_LOGIN'))
        tag = json_file['tag']
        info = json_file['info']
        password = json_file['password']

        collection = db_handler.DBHandler(self.client, 'users',
                                          'contact_with_password')
        query = {tag: info}

        collection.do_find_one(query, self.func, {'password': password})
Beispiel #10
0
def main(accid, hour):
    db = db_handler.DBHandler()
    account = db.get_client_account(accid)
    ws = websim.WebSim(login=account[0], password=account[1])
    ws.authorise()
    while True:
        state = ws.get_state()
        count = ws.get_my_alphas_count()
        logger.critical(
            'Total Alphas: {}; Total Alphas in Out of Sample: {}; Rank: {}; Score: {}; Level: {}.'
            .format(count['result']['NumAlphas']['NumTotalAlphas'],
                    count['result']['NumAlphas']['NumOSAlphas'],
                    state['result']['userData']['OverallRank'],
                    state['result']['userData']['TotalScore'],
                    state['result']['userData']['Level']))
        time.sleep(float(hour) * 60 * 60)
Beispiel #11
0
    def post(self):
        print "follow"
        print datetime.now()
        with open('./log/logfile.txt', 'a') as log:
            log.write('follow, ' + str(datetime.now()) + '\n')

        json_file = json.loads(self.get_argument('JSON_FOLLOW'))
        follower_email = json_file['follower_email']
        aim_email = json_file['aim_email']

        query = {
            'follower_email': follower_email,
            'aim_email': aim_email,
        }

        collection = db_handler.DBHandler(self.client, 'users', 'relationship')
        collection.do_find_one(query, self.func, query)
Beispiel #12
0
    def post(self):
        print 'get_new_item'
        print datetime.now()
        with open('./log/logfile.txt', 'a') as log:
            log.write('get_new_item, ' + str(datetime.now()) + '\n')

        json_file = json.loads(self.get_argument('JSON_NEW_ITEM'))

        # ids = get_str_list(json_file['ids'])
        ids = json_file['ids']
        ids = [ObjectId(x) for x in ids]

        if not ids:
            info = 0
        else:
            info = max(ids)

        collection = db_handler.DBHandler(self.client, 'resource', 'items')
        collection.do_find({},
                           self.func,
                           info,
                           direction=-1,
                           axis="_id",
                           limit=15)
Beispiel #13
0
def uncorr_top():
    db = db_handler.DBHandler()
    return list(db.iterate_over_top_alpha('top_for_generators'))
Beispiel #14
0
import re

import requests
from bs4 import BeautifulSoup

import db_handler

db_name = 'url.db'

requests_get = requests.get('https://gitee.com/search',
                            params={'language': 'Java', 'q': 'spring', 'type': '', 'page': '1'})
home_url = 'https://gitee.com/'
print('搜索页访问完毕...')

handler_db_handler = db_handler.DBHandler(db_name)
# 初始化表
handler_db_handler.init_table()
# 查询已经爬取过的url
has_insert = handler_db_handler.select_has_insert()


# 获取查询出来的工程总条数
def get_page_count(get):
    beautiful_soup = BeautifulSoup(get.content, features='html.parser')
    find_all = beautiful_soup.find_all(text=re.compile('我们已为您搜索到.*'))
    strip = str(find_all[0])
    return re.findall('\d+', strip)[0]


# 获取搜索出来的列表
def get_project_list(get):
Beispiel #15
0
import sys
#import websim
import db_handler
#import generators.tree_generator as tg
#import generators.parser as ps
#import generators.alpha_stream_generator as asg
from numpy import random
import time
#import submitter

db = db_handler.DBHandler()
f = open('market_data', 'r')
data = [code[:-1] for code in f]
print data
for code1 in data:
    for code2 in data:
        if code1 != code2:
            print '(' + code1 + '/' + code2 + ')'
            codeID = db.add_code('(' + code1 + '/' + code2 + ')',
                                 'trivial relationships',
                                 'trivial relationships')
            db.add_sending(codeID)
f.close()
'''
tree = tg.dict_tree(ps.parse('(((high + low)/2 - close)/stddev((high+low)/2-close,90)^3))'))
print tree
print tg.count_market_data_consts(tree)
'''
'''
sb = submitter.Submitter(1)
sb.submit_alpha(12425)
import subprocess
import socket
import base64


from tornado.ioloop import IOLoop
from tornado.websocket import WebSocketHandler
from tornado.web import RequestHandler
from tornado.web import Application
from tornado.web import StaticFileHandler
from twilio.rest import TwilioRestClient
import requests as rq

import db_handler

secret_key_db_handler_instance = db_handler.DBHandler()
otp_db_handler_instance = db_handler.DBHandler(table_name="client_otp", column_name="otp")

active_clients = list()
host = "192.168.42.1"
port = 8000
GOOGLE_API_KEY = "AIzaSyDwa6GFZkseZqQ_Vv2yvSLBA_nfHVtCgKw"
GOOGLE_CLOUD_VISION_URL = "https://vision.googleapis.com/v1/images:annotate"


def get_image_features(file_path):
    try:
        with open(file_path, 'rb') as image_handle:
            b64_string = base64.b64encode(image_handle.read())

        req_data = {
Beispiel #17
0
    def __init__(self, sendingID):
        self.db = db_handler.DBHandler()

        self.sendingID = sendingID
        self.params = self.db.get_sending_result(sendingID)
 def __init__(self):
     self.db = db_handler.DBHandler()
Beispiel #19
0
@app.route('/')
def home():
    return render_template('home.html',
                           data=json.dumps(config_obj['Categories']))


if __name__ == '__main__':
    run_flask = True
    config_obj = None
    dbhandler = None

    if DB_Config.work_mode == 'Local':
        dbhandler = db_handler.DBHandler(DB_Config.DATABASE_URL,
                                         DB_Config.work_mode,
                                         DB_Config.DATABASE_NAME,
                                         DB_Config.DATABASE_USER,
                                         DB_Config.DATABASE_PASSWORD)
    elif DB_Config.work_mode == 'Cloud':
        dbhandler = db_handler.DBHandler(DB_Config.DATABASE_URL,
                                         DB_Config.work_mode,
                                         DB_Config.DATABASE_NAME)
    else:
        print("An error occurred while reading DB Config file.")
        exit(1)
    if not dbhandler.connected:
        print(
            f"An error occurred while trying to connect to database: {dbhandler.error_msg}"
        )
        exit(1)
    dbhandler.create_tables()
Beispiel #20
0
 def __init__(self):
     self.dbh = db_handler.DBHandler("../names.db")
Beispiel #21
0
 def __init__(self):
     self.streamList = []
     self.db = db_handler.DBHandler()