def setUp(self): """ Configure database for test purposes. Remind to close db after data insertion. """ database.DEFAULT_DATABASE = 'test.db' self.db = database.opendb()
def solveN(N, store=False): s = time.time() assert N >= 4 board = create_board(N) solutions = [] dbsession = opendb() if store else None solve(board, 0, N, solutions, store, dbsession) return solutions, (time.time() - s)
def open_story(path): global body, context if not database.opendb(path): body = "Unable to open file." return ver = database.get("SELECT pystory_ver FROM info")[0][0] # Check version. if ver != database.PYSTORY_VER: body = "Story file structure version mismatch." return storyfile.sql_to_abs() context = ["\"{0}\"".format(storyfile.data[-1]["info"]["name"]), "STORY", None]
def open_story(path): global body, context if not database.opendb(path): body = "Unable to open file." return ver = database.get("SELECT pystory_ver FROM info")[0][0] # Check version. if ver != database.PYSTORY_VER: body = "Story file structure version mismatch." return storyfile.sql_to_abs() context = [ "\"{0}\"".format(storyfile.data[-1]["info"]["name"]), "STORY", None ]
def main(): global DB DB = opendb(config.worldfile) socket.setdefaulttimeout(config.timeout) S = socket.socket() print "[{0}] Starting up.".format(int(time.time())) if not connect(S): # Connection failed. print "[{0}] Connection failed.".format(int(time.time())) S.close() DB.close() time.sleep(config.retryrate) # Wait a bit. print "[{0}] Retrying connection.".format(int(time.time())) main() # Try again. while True: # Main Loop receive(S) time.sleep(0.04) # 1/25 Second. Let's not be too conspicuous.
if n > 0.05: end = len(y)-h break h += 1 return end if __name__ == "__main__": import sys platformd = {"linux2" : u"linux", "win32" : u"windows"} class DataForTest: def __init__(self,limitvalue = 10): self.xvalue = range(1,limitvalue,1) self.yvalue = range(1,limitvalue,1) self.fftxvalue = range(1,limitvalue,1) self.fftyvalue = range(1,limitvalue,1) self.params = {} self.params['wiretype'] = u"multicord" self.params['wire'] = u"154.6290.600-01" self.params['antenna'] = u"Воздушная" self.params['range'] = u"Центр" self.params['distance'] = u"1см" self.params['amplitude'] = u"20кВ" self.params['measure'] = u"Напряжение" self.type = ["Time", "Spectrogram"] self.device = u"Oscilloscope" self.units = u"Volts" self.path = "D:\\1.csv" data1 = DataForTest() draw1 = Draw(platform = platformd[sys.platform], outputlevel = 2, showplot = True, save_flag = True, replot = True) conn = database.opendb() draw1.plot(data1, conn)
if i[0:2] == '説明': ##print('【説明】') d = i.split('<br/>') SHUOMING = [] for d1 in d[1:]: # if d1!='': p = BeautifulSoup(d1, 'lxml') SHUOMING.append(p.get_text()) ##print(p.get_text()) YUFA.SHUOMING = '######'.join(str(i) for i in SHUOMING) ##print() return YUFA #i=input('请输入id:') print('start...........') conn = database.opendb('yufa.sqlite') f = open("yufaid.txt", "r") ids = f.readlines() for id in ids: try: yufa = spaide(int(id)) database.insert_into_T_YUFA(conn, yufa) for l in yufa.LIJU: lijuObj = database.toTYUFA_LIJU(l) database.insert_into_T_SENTENCE(conn, l) break except: print(str(id)) print('end...........')
report_flag = True save_flag = True platformd = {"linux2" : u"linux", "win32" : u"windows"} dt = lambda x,y: " " + "in" + " " + str((y-x)/60) + " " + "min" fileproc = filesys.FileSys(device,outputlevel) filedir = GUI.dirchoise(1) savepath = GUI.dirchoise(2) t1 = time.clock() data = [] for path in fileproc.filelist(filedir): if outputlevel >= 1: print path measurment = filesys.Data(fileproc.csvread(path), path) conn = database.opendb(savepath) database.inittable(conn, tablename = "main") database.insert(conn, measurment, tablename = "main") data.append(measurment) if measurment.a_flag == True and outputlevel >= 2: print "attenuator!!!" t2 = time.clock() print "taking data DONE" + dt(t1,t2) if plot_flag == True: t1 = time.clock() pl = draw.Draw(platform = platformd[sys.platform], outputlevel, showplot, replot, save_flag) for element in data: pl.plot(element,conn) t2 = time.clock() print "plotting DONE" + dt(t1,t2)