Beispiel #1
0
def root():
    # only trigger the service when the cron job is run
    if not ('X-Appengine-Cron' in request.headers
            and request.headers['X-Appengine-Cron'] == 'true'):
        return Response(status=403)
    try:
        main()
        return Response(status=200)
    except Exception as e:
        print(e)
        return Response(status=500)
Beispiel #2
0
def root():
    # only trigger the service when the cron job is run
    if not ('X-Appengine-Cron' in request.headers
            and request.headers['X-Appengine-Cron'] == 'true'):
        return Response(status=403)
    try:
        main()
        return Response(status=200)
    except Exception as e:
        import traceback, sys
        traceback.print_exc(file=sys.stdout)
        print(e)
        return Response(status=500)
Beispiel #3
0
    def setUp(self):
        from service import main
        from paste.deploy import appconfig
        from webtest import TestApp

        # set settings
        os.environ['PYRAMID_SETTINGS'] = 'development.ini#main'
        self.settings = appconfig('config:{}'.format(os.environ['PYRAMID_SETTINGS']), relative_to='.')
        app = main({}, **self.settings)
        self.testapp = TestApp(app)
        self.config = testing.setUp(settings=self.settings)

        self.created_ids = []

        # init user
        self.user = User.create('*****@*****.**', 'hello')
        payload = {
            'email': '*****@*****.**',
            'password': '******',
        }
        response = self.testapp.post_json('/api/v1/authenticate', payload, status=200)
        self.access_token = response.json['access_token']

        # init business
        address = {
            'street1': 'Central Park',
            'city': 'New York',
            'state': 'NY',
        }
        self.business = Business.create('Test Location', address)
Beispiel #4
0
    def setUp(self):
        from service import main
        from paste.deploy import appconfig
        from webtest import TestApp

        # set settings
        os.environ['PYRAMID_SETTINGS'] = 'development.ini#main'
        self.settings = appconfig('config:{}'.format(os.environ['PYRAMID_SETTINGS']), relative_to='.')
        app = main({}, **self.settings)
        self.testapp = TestApp(app)
        self.config = testing.setUp(settings=self.settings)

        self.created = []
Beispiel #5
0
def countVatClasses(folder, limit):
    names = []
    for file in os.listdir(folder):
        if file.endswith(".jpg"):
            name = file.split(".jpg")[0]
            number = name.split("_")[1]
            if int(number) <= limit:
                names.append(name)
    countA = 0
    countB = 0
    for name in names:
        print(name)
        jsonPath = folder + "/" + name + "-40.webp.json"
        result = service.main(jsonPath)
        articles = result["articles"]
        for article in articles:
            vat = article["vat"]
            if vat.lower() == "a":
                countA += 1
            if vat.lower() == "b":
                countB += 1
    print("------------------------")
    print("countA: " + str(countA))
    print("countB: " + str(countB))
Beispiel #6
0
def handler(event, context):
    print(os.system("id"))
    service.main(True)
    return {'statusCode': 200, 'body': json.dumps('Hello from Lambda!')}
Beispiel #7
0
import sys, os

current = os.path.dirname(__file__)

sys.path.insert(0, os.path.normpath(os.path.join(current, '..')))
from service import main

if not os.path.exists('temp'):
    os.mkdir('temp')

main()
Beispiel #8
0
def script_call():
    return redirect(
        service.main(
            "D:/Degree/7thSem/Minorproject/VideoCategorisation/videos/",
            app.config['SRC']))
Beispiel #9
0
def main():
    service.main()
#!/usr/bin/env python3
from __future__ import print_function
import sys

if (sys.version_info.major, sys.version_info.minor) < (3,6):
    print('This script needs at least Python v3.6')
    sys.exit(1)

import service
service.main()
Beispiel #11
0
def setup_module(module):
    module.http_server_thread, module.http_server = main()
Beispiel #12
0
            else:
                #print 'not find service'
                nfs+=1
    tot=len(testTasks)
    tEnd=time.time()
    print nMatch/tot,tot,nfs,aim,(tEnd-tStart),divmod((tEnd-tStart),60)
    return nMatch/tot,tot,nfs,aim,(tEnd-tStart),divmod((tEnd-tStart),60)
if __name__=='__main__':
    import service
    fileopen = open('result.txt','w')
    for i in range(10):
        ont_num=1000*i
        if i ==0:
            r_rate=0
        else:
            r_rate=i/10
        service.main(r_rate,ont_num)
        fileopen.write('ontology rate='+str(r_rate))
        fileopen.write('\n')
        for j in range(1):
            (rate,tot,nfs,aim,time_s,time_ms)=main()
            fileopen.write('rate='+str(rate)+' ')
            fileopen.write('tot='+str(tot)+' ') 
            fileopen.write('nfs='+str(nfs)+' ') 
            fileopen.write('aim='+str(aim)+' ') 
            fileopen.write('time_s='+str(time_s)+' ')    
            fileopen.write('time_ms='+str(time_ms)+' ')
            fileopen.write('\n')
    fileopen.close()  
        
Beispiel #13
0
    tot = len(testTasks)
    tEnd = time.time()
    print nMatch / tot, tot, nfs, aim, (tEnd - tStart), divmod((tEnd - tStart),
                                                               60)
    return nMatch / tot, tot, nfs, aim, (tEnd - tStart), divmod(
        (tEnd - tStart), 60)


if __name__ == '__main__':
    import service
    fileopen = open('result.txt', 'w')
    for i in range(10):
        ont_num = 1000 * i
        if i == 0:
            r_rate = 0
        else:
            r_rate = i / 10
        service.main(r_rate, ont_num)
        fileopen.write('ontology rate=' + str(r_rate))
        fileopen.write('\n')
        for j in range(1):
            (rate, tot, nfs, aim, time_s, time_ms) = main()
            fileopen.write('rate=' + str(rate) + ' ')
            fileopen.write('tot=' + str(tot) + ' ')
            fileopen.write('nfs=' + str(nfs) + ' ')
            fileopen.write('aim=' + str(aim) + ' ')
            fileopen.write('time_s=' + str(time_s) + ' ')
            fileopen.write('time_ms=' + str(time_ms) + ' ')
            fileopen.write('\n')
    fileopen.close()
Beispiel #14
0
import sys, os

current = os.path.dirname(__file__)

sys.path.insert(0, os.path.normpath(os.path.join(current, '..')))
from service import main

if not os.path.exists('temp'):
	os.mkdir('temp')

main()