예제 #1
0
    def test_predictor_validation(self, logging_mock):
        res = main(argv=['testdata/trainer/model.dat'])
        self.assertEquals(res, PARAMETERS_REQUIRED)
        logging_mock.warn.assert_called_with("Need to either specify -i or -e")
        logging_mock.reset_mock()

        res = main(argv=['testdata/extractorxml/train-import-handler.xml'])
        self.assertEquals(res, INVALID_TRAINER)
        self.assertFalse(logging_mock.called)
예제 #2
0
 def test_csv_method(self, logging_mock):
     res = main(argv=[
         'testdata/trainer/model.dat', '-i',
         'testdata/trainer/trainer.data.json', '-m', 'csv'
     ])
     self.assertEquals(res, DONE)
     os.remove('result.csv')
예제 #3
0
 def test_extraction(self, db_mock, logging_mock):
     res = main(argv=[
         'testdata/trainer/model.dat', '-e',
         'testdata/extractorxml/train-import-handler.xml', '-U',
         'start=2012-12-03', '-U', 'end=2012-12-04'
     ])
     self.assertEquals(res, DONE)
     self.assertFalse(logging_mock.called)
예제 #4
0
	def test_predictor(self):
		print('\n\n')
		dimg1 = util.get_full_imgpath('Al_Cardenas', 1)
		dimg2 = util.get_full_imgpath('Mary_Landrieu', 3)
		util.set_trained_model_name(ext_cmt='on_ext_features')
		base_model_fname = util.get_trained_model_name()
		use_batchnorm = False
		th = 0.5
		output = predictor.main(base_model_fname, dimg1, dimg2, use_batchnorm, th)
		print(output)
예제 #5
0
def loaded():

    target = os.path.join(APP_ROOT, 'files/')
    print(target)
    if not os.path.isdir(target):
        os.mkdir(target)
    print(request.files.getlist("file"))
    for upload in request.files.getlist("file"):
        print(upload)
        print("{} is the file name".format(upload.filename))
        filename = upload.filename
        # This is to verify files are supported
        ext = os.path.splitext(filename)[1]
        if (ext == ".txt") or (ext == ".pdf"):
            print("File supported moving on...")
        else:
            pass
        destination = "/".join([target, filename])
        print("Accept incoming file:", filename)
        print("Save it to:", destination)
        upload.save(destination)
    label, intro_text, main_text, end_text = predictor.main()
    if label == 0:
        language = 'русский'
    if label == 1:
        language = 'английский'
    if label == 2:
        language = 'украинский'


# return send_from_directory("images", filename, as_attachment=True)
    return render_template('loaded.html',
                           lang=language,
                           intro_text=intro_text,
                           main_text=main_text,
                           end_text=end_text)
예제 #6
0
import easytrader
import predictor
import datetime
import time
import sys
import tushare as ts

try:
    predictor.sendMessage("新的交易开始啦:" + str(datetime.datetime.now()))
except:
    pass
code = predictor.main()
#code = '600875'
#amount = 600
print("-----马上开始交易_%s -----" % code)
user = easytrader.use('ths')
while 1:
    try:
        user.connect(r'D:\Program Files\ths\xiadan.exe')
        break
    except:
        pass
balance = user.balance

print(balance['总资产'])
print("waiting at:%s" % datetime.datetime.today())
while datetime.datetime.now().hour != 14 or datetime.datetime.now().minute != 56:
    time.sleep(30)
while 1:
    try:
        price = ts.get_today_ticks(code).iloc[0]['price']
예제 #7
0
 def test_roc_method(self, logging_mock):
     res = main(argv=[
         'testdata/trainer/model.dat', '-i',
         'testdata/trainer/trainer.data.json', '-m', 'roc'
     ])
     self.assertEquals(res, DONE)
예제 #8
0
 def test_input_data(self, logging_mock):
     res = main(argv=[
         'testdata/trainer/model.dat', '-i',
         'testdata/trainer/trainer.data.csv'
     ])
     self.assertEquals(res, DONE)
예제 #9
0
파일: wsgi.py 프로젝트: aunz/sm-container
def invocations():
    return main(flask.request.get_data(cache=False))