def test_1_2(self): print self.userinstance print "test_1_2" app1 = application(1, 2) res = app1.operation1() self.assertTrue(2 == res, "1,2 input testcase failed")
def confirm(self): # a = self.PicPath.get() # print(a) # print(type(a)) #application.pre_pic(a) # b = 'D:\pic\0.png' # application.pre_pic(b) #application.pre_pic(r'D:\pic\0.png') value = app.application(self.PicPath.get()) Label(self, text = ["识别出的数字是:",value]). \ grid(row = 3, column = 0, padx = 5, pady = 5)
def setUp(self): self.app = application('testing') self.app_ctx = self.app.app_context() self.app_ctx.push() self.client = self.app.test_client() db.create_all() User.addUser('test', '*****@*****.**', 'test') User.updateExamCountById(1, 5) User.commitSession() Question.addQuestion('test', 'difficult', 't-d-q-1', 't-d-o-1-1', 't-d-o-2-1', 't-d-o-3-1', 't-d-o-4-1', 1) Question.addQuestion('test', 'simple', 't-s-q-1', 't-s-o-1-1', 't-s-o-2-1', 't-s-o-3-1', 't-s-o-4-1', 2) Question.commitSession()
def confirm(self): # a = self.PicPath.get() # print(a) # print(type(a)) #application.pre_pic(a) # b = 'D:\pic\0.png' # application.pre_pic(b) #application.pre_pic(r'D:\pic\0.png') # b = r'D:\pic\0.png' # value = app.application(b) # print(self.PicPath.get()) value = app.application(self.PicPath.get()) if self.flag == 1: speech.say('识别出来的数字是') speech.say(value) Label(self, text = ["识别出的数字是:",value]). \ grid(row = 3, column = 0, padx = 5, pady = 5)
def run(self, application): try: result = application(self.environ, self.start_response) for data in result: self.write(data) if not self.started: self.request.set_content_length(0) if hasattr(result, 'close'): result.close() except: traceback.print_exc(None, self.environ['wsgi.errors']) if not self.started: self.request.status = 500 self.request.content_type = 'text/plain' data = "A server error occurred. Please contact the administrator." self.request.set_content_length(len(data)) self.request.write(data)
def run(self): file = self.lineEdit.text() # print("file:",file) path_ = "/".join(file.split("/")[:-1]) name = file.split("/")[-1] # print("path:",path_) # print("name:",name) if path_: names = app.get_names(path_) # print(names) for n in names: if name == n: img = app.get_image(path_, [name]) img_tensor = app.img_to_tensor(img) img_tensor = img_tensor[np.newaxis, :] predValue = app.application(img_tensor) # print("the image is :", app.classes[predValue[0]]) self.label_2.setText(app.classes[predValue[0]])
def test_app_root_path(): input = MockedInput("") env = { "wsgi.input": input, "REQUEST_METHOD": "GET", "QUERY_STRING": "", "PATH_INFO": "/", } assert ("".join( map(lambda x: x.decode("UTF-8"), application(env, lambda x, y: None))) == """<html> <body> <a href="/users">Users</a> </body> </html>""")
def test_app_users_path(): input = MockedInput("") env = { "wsgi.input": input, "REQUEST_METHOD": "GET", "QUERY_STRING": "", "PATH_INFO": "/users", } assert ("".join( map(lambda x: x.decode("UTF-8"), application(env, lambda x, y: None))) == """<html> <body> <form action="/users" method="POST"> <input type="text" name="username" placeholder="username" /> <input type="text" name="email" placeholder="email" /> <input type="submit" /> </form> <table> <tr> <td>user1</td> <td>email1</td> </tr> <tr> <td>user2</td> <td>email2</td> </tr> <tr> <td>user3</td> <td>email3</td> </tr> </table> </body> </html>""")
def main(): application() return None
QtWidgets.QMessageBox.warning( self, 'Error', 'Bad user or password') def check_acc(self): account = [] cursor = self.db.cursor() try: cursor.execute('''SELECT one, two FROM account''') all_rows = cursor.fetchall() for row in all_rows: account.append(row[0]) account.append(row[1]) return account except: return None class Window(QtWidgets.QMainWindow): def __init__(self, parent=None): super(Window, self).__init__(parent) if __name__ == '__main__': import sys app = QtWidgets.QApplication(sys.argv) login = Login() if login.exec_() == QtWidgets.QDialog.Accepted: window = application() window.show() sys.exit(app.exec_())
def run_in_fg(): from app import application application()
# operation1 test casese: """ case1: inp: 1,2 outp=2 case2: inp: None,None outp=None case3: inp: 2,"str1" outp=str1str1 case4:inp:() outp=None """ import app # case1 app1 = app.application(1, 2) if not 2 == app1.operation1(): print "test1 failed" else: print "test1pass"
from app import app_factory as application application = application()
def test_None_None(self): print "test_None_None" app1 = application(None, None) res = app1.operation1() self.assertTrue(None == res, "None,None input testcase failed")
def run(self): result = detect.application(tempImgPath, rknn_) global simprice simprice = result[1] self.sinOut.emit(str(result[0]), result[1], result[2])
from webtest import TestApp from app import application app = TestApp(application()) def test_index(): response = app.get('/') assert 'Hello world!' in str(response)
environ["SERVER_PROTOCOL"] = protocol # wsgi environ keys environ["wsgi.version"] = (1, 0) environ["wsgi.url_scheme"] = protocol.lower() environ["wsgi.input"] = io.StringIO(body) environ["wsgi.errors"] = sys.stderr environ["wsgi.multhread"] = False environ["wsgi.multiprocess"] = False environ["wsgi.run_once"] = False return environ with socket.socket() as s: s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.bind((URL, PORT)) s.listen() while True: # conn - new socket object usable to send & receive data on the connection # address - address bound to the socket on the other side of the connection conn, addr = s.accept() print(f"Remote Address: {addr}") with conn: request = conn.recv(4096).decode("utf-8") method, path, protocol, headers, body = parser(request) environ = get_environ(method, path, protocol, headers, body) response = application(start_response, environ) # application returns an iterable of data for data in response: conn.sendall(data.encode("utf-8"))
import app TESTING_APP_OBJECT = app.application("yashsehgal", "pluto") TESTING_APP_OBJECT.home()
from app import application if __name__ == "__main__": application()
import os from app import application, db if __name__ == "__main__": config_name = os.getenv("FLASK_CONFIG") app = application(config_name) with app.app_context(): db.create_all() app.run() else: config_name = os.getenv("FLASK_CONFIG") gapp = application(config_name) with gapp.app_context(): db.create_all()
from app import create_app as application import os settings_module = os.getenv('APP_SETTINGS_MODULE') app = application(settings_module)
import backward as bw import app if __name__ == '__main__': ''' 训练过程调用 train表示是否需要继续训练 若需要继续训练,将该参数改为True, 若需要重新训练,请将model文件夹清空并将该参数改为True ''' train = False if train: bw.main() ''' 测试过程调用 file_path表示用于测试的文件路径 若想测试其他图片,请将file_path修改成相应的路径 ''' file_path = 'test_images/1.jpg' app.application(file_path)
from app import application, db from model import * app = application('development') with app.app_context(): for user in User.getAllUser(): print('Staring to check exam to archive for user '+ str(user) +'.') ui = user['userid'] completed_exam = Exam.getCompletedExamForUser(ui) completed_exam.sort() print('List of completed exams: '+ str(completed_exam)) l = len(completed_exam) if l < 2 : print('Nothing to archive for the user.') else : c = 0 while c < ( l - 1 ) : e = completed_exam[c] c += 1 print('Starting to archive: ' + str(e)) tq = 0 ts = 0 ql = ExamQuestion.getExamQuestion(e) for q in ql : tq += 1 qd = Question.getQuestionById(q['questionid']) print('Considering Question: '+ str(qd)) if q['choice'] == qd['answer'] : qs = 1 ts += 1 else :
def test_2_str1(self): print "test_2_str1" app1 = application(2, "str1") res = app1.operation1() self.assertTrue("str1str1" == res, "2,str1 input testcase failed")
def main(): application(environment) return None
from app import create_app as application app = application("production") if __name__ == "__main__": app.run(port=3030, host="0.0.0.0")
from app import application app = application()