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)
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)
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)
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 = []
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))
def handler(event, context): print(os.system("id")) service.main(True) return {'statusCode': 200, 'body': json.dumps('Hello from Lambda!')}
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()
def script_call(): return redirect( service.main( "D:/Degree/7thSem/Minorproject/VideoCategorisation/videos/", app.config['SRC']))
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()
def setup_module(module): module.http_server_thread, module.http_server = main()
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()
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()