new macro DEBUG

main
ColsonZhang 2021-04-01 13:26:36 +08:00
parent 60b74ab0be
commit 1e1687bde3
7 changed files with 33 additions and 14 deletions

View File

@ -68,6 +68,7 @@ app.py ----服务器的主程序
* bugPIN POUT暂时无作用
* to do:主页面取消跳转采用判定是否登录的方法改写login logou
* fix当仿真失败时会提醒用户Fail
* new: 代码新增DEBUG宏变量为False时关闭print
* 2021年3月31日前后端更新
* 新增在服务器上成功部署后端代码为适配centos服务器而做了一些修改。

View File

@ -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')

View File

@ -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

View File

@ -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)