diff --git a/README.md b/README.md index f0ea81b..5303358 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,7 @@ app.py ----服务器的主程序 * bug:PIN POUT暂时无作用 * to do:主页面取消跳转,采用判定是否登录的方法改写login logou * fix:当仿真失败时,会提醒用户Fail + * new: 代码新增DEBUG宏变量,为False时,关闭print * 2021年3月31日,前后端更新 * 新增:在服务器上成功部署;后端代码为适配centos服务器而做了一些修改。 diff --git a/handler/__pycache__/auth.cpython-36.pyc b/handler/__pycache__/auth.cpython-36.pyc index 9d219e1..b7ae86d 100644 Binary files a/handler/__pycache__/auth.cpython-36.pyc and b/handler/__pycache__/auth.cpython-36.pyc differ diff --git a/handler/__pycache__/simulation.cpython-36.pyc b/handler/__pycache__/simulation.cpython-36.pyc index 9664887..00d4994 100644 Binary files a/handler/__pycache__/simulation.cpython-36.pyc and b/handler/__pycache__/simulation.cpython-36.pyc differ diff --git a/handler/__pycache__/spice.cpython-36.pyc b/handler/__pycache__/spice.cpython-36.pyc index 0136e30..5aeae31 100644 Binary files a/handler/__pycache__/spice.cpython-36.pyc and b/handler/__pycache__/spice.cpython-36.pyc differ diff --git a/handler/auth.py b/handler/auth.py index 4f59e4d..a7d2877 100644 --- a/handler/auth.py +++ b/handler/auth.py @@ -2,6 +2,8 @@ from .main import AuthBaseHandler from .account import authenticate, add_user from .MongoDB import * +DEBUG = False + class LoginHandler(AuthBaseHandler): def get(self,*args,**kwargs): self.render('auth/login.html') @@ -16,7 +18,8 @@ class LoginHandler(AuthBaseHandler): if passed: # 保存cookie信息到redis数据库 self.session.set('username',username) #将前面设置的cookie设置为username,保存用户登录信息 - print(self.session.get('username')+' login success !!!') + if DEBUG: + print(self.session.get('username')+' login success !!!') next_url = self.get_argument('next', '') # 获取之前页面的路由 if next_url: Mongo.connect(DataBase='example',Collection=username) @@ -45,11 +48,13 @@ class LogoutHandler(AuthBaseHandler): class RegisterHandler(AuthBaseHandler): def get(self, *args, **kwargs): - print('register') + if DEBUG: + print('register') self.render('auth/register.html') def post(self, *args, **kwargs): - print('registerpost') + if DEBUG: + print('registerpost') username = self.get_argument('username','') email = self.get_argument('email','') @@ -65,5 +70,6 @@ class RegisterHandler(AuthBaseHandler): else: self.write({'msg':'register fail'}) else: - print('register again') + if DEBUG: + print('register again') self.render('auth/register.html') \ No newline at end of file diff --git a/handler/simulation.py b/handler/simulation.py index d89ea54..61f4542 100644 --- a/handler/simulation.py +++ b/handler/simulation.py @@ -15,6 +15,8 @@ libraries_path = 'D:\\Project_2020\\SPICE\\Pyspice\\libraries' #libraries_path = find_libraries() spice_library = SpiceLibrary(libraries_path) +DEBUG = False + class Simulator_CZ : def __init__( self, title='simulation' ): @@ -30,7 +32,8 @@ class Simulator_CZ : def Sim(self, sim_type,properties): parameter = self.Properties_Parse(sim_type,properties) - print("parameter:\n",parameter) + if DEBUG: + print("parameter:\n",parameter) self.simulator = self.circuit.simulator(temperature=25, nominal_temperature=25) # print('simulator:\n',self.simulator) if(sim_type == 'transient'): @@ -41,7 +44,8 @@ class Simulator_CZ : use_initial_condition = parameter['use_initial_condition']) return self.analysis elif(sim_type == 'dc' ): - print("doing the dc simulation !!!") + if DEBUG: + print("doing the dc simulation !!!") src_name = parameter['src_name'] vstart = parameter['start'] vstop = parameter['stop'] @@ -49,18 +53,20 @@ class Simulator_CZ : the_args = "{} = slice({},{},{})".format(src_name, vstart, vstop, vstep) exec("self.analysis = self.simulator.dc( {} )".format(the_args)) - - print("dc simulation finished !!!") + if DEBUG: + print("dc simulation finished !!!") return self.analysis elif(sim_type == 'ac' ): - print("doing the ac simulation !!!") + if DEBUG: + print("doing the ac simulation !!!") self.analysis = self.simulator.ac( start_frequency = parameter['start_frequency'], stop_frequency = parameter['stop_frequency'], number_of_points = parameter['number_of_points'], variation = parameter['variation']) - print("dc simulation finished !!!") + if DEBUG: + print("dc simulation finished !!!") return self.analysis diff --git a/handler/spice.py b/handler/spice.py index 3a379a6..f1054e6 100644 --- a/handler/spice.py +++ b/handler/spice.py @@ -7,6 +7,7 @@ from .sim_data_container import Sim_Data_Container from tornado.escape import json_decode, json_encode, utf8 import json +DEBUG = False # from bokeh.embed import server_document # from jinja2 import Environment, FileSystemLoader @@ -20,7 +21,9 @@ class SpiceHandler(AuthBaseHandler): username = self.get_current_user() message = self.get_argument('spice') - print('SpiceHandler: '+username+' \n'+message) + if DEBUG: + print('SpiceHandler: '+username+' \n'+message) + Mongo.connect(DataBase='example',Collection=username) Mongo.update(behavior=message,tags='spice') @@ -46,11 +49,14 @@ class SimulationHandler(AuthBaseHandler): simulator = Simulator_CZ() simulator.Get_Spice(spice) analysis = simulator.Sim(sim_type,properties) - print('properties:\n',properties) - print('simulation finished !') + if DEBUG: + print('properties:\n',properties) + print('simulation finished !') Container_SimResult.load_analysis(sim_type,analysis) - print('data container load data successfully!! ') + if DEBUG: + print('data container load data successfully!! ') + message = "Simulation: Success \n" message += "Sim_Type="+ sim_type + "\n Properties=" +properties_str Mongo.connect(DataBase='example',Collection=username)