def update_cache(self, parent=None, timeout=10, force=False, suppress_progress=False): if self.lock.acquire(False): try: update_thread = CacheUpdateThread(self.cache, self.seralize_books, timeout) if not suppress_progress: progress = CacheProgressDialog(parent) progress.set_message( _('Updating MobileRead book cache...')) update_thread.total_changed.connect(progress.set_total) update_thread.update_progress.connect( progress.set_progress) update_thread.update_details.connect(progress.set_details) progress.rejected.connect(update_thread.abort) progress.open() update_thread.start() while update_thread.is_alive() and not progress.canceled: QCoreApplication.processEvents() if progress.isVisible(): progress.accept() return not progress.canceled else: update_thread.start() finally: self.lock.release()
def start_import_data(self): config = self.getCurrentConfig() dest_dir = config.get('hdf5', 'dir') if not os.path.exists(dest_dir) or not os.path.isdir(dest_dir): print("错误:", '指定的目标数据存放目录不存在!') sys.exit(-1) #return if config.getboolean('tdx', 'enable') \ and (not os.path.exists(config['tdx']['dir'] or os.path.isdir(config['tdx']['dir']))): print("错误:", "请确认通达信安装目录是否正确!") sys.exit(-1) #return self.import_running = True print("正在启动任务....") QCoreApplication.processEvents() if config.getboolean('tdx', 'enable'): self.hdf5_import_thread = UseTdxImportToH5Thread(config) else: self.hdf5_import_thread = UsePytdxImportToH5Thread(config) self.hdf5_import_thread.message.connect(self.on_message_from_thread) self.hdf5_import_thread.start() self.escape_time = 0.0 self.escape_time_thread = EscapetimeThread() self.escape_time_thread.message.connect(self.on_message_from_thread) self.escape_time_thread.start()
def update_cache(self, parent=None, timeout=10, force=False, suppress_progress=False): if self.lock.acquire(False): try: update_thread = CacheUpdateThread(self.cache, self.seralize_books, timeout) if not suppress_progress: progress = CacheProgressDialog(parent) progress.set_message(_('Updating MobileRead book cache...')) update_thread.total_changed.connect(progress.set_total) update_thread.update_progress.connect(progress.set_progress) update_thread.update_details.connect(progress.set_details) progress.rejected.connect(update_thread.abort) progress.open() update_thread.start() while update_thread.is_alive() and not progress.canceled: QCoreApplication.processEvents() if progress.isVisible(): progress.accept() return not progress.canceled else: update_thread.start() finally: self.lock.release()
def show_shutdown_message(self, message): smw = self.shutdown_message_widget smw.setVisible(True) txt = smw.text() txt += '\n' + message smw.setText(txt) # Force processing the events needed to show the message QCoreApplication.processEvents()
def show_shutdown_message(self, message=''): smw = self.shutdown_message_widget smw.setGeometry(0, 0, self.width(), self.height()) smw.setVisible(True) smw.raise_() smw.setText(_('<h2>Shutting down</h2><div>') + message) # Force processing the events needed to show the message QCoreApplication.processEvents()
def chapter_rendered(self, num): if num > 0: self.progress_bar.setMinimum(0) self.progress_bar.setMaximum(num) self.progress_bar.setValue(0) self.progress_label.setText('Laying out '+ self.document_title) else: self.progress_bar.setValue(self.progress_bar.value()+1) QCoreApplication.processEvents()
def check_library(self): from calibre.gui2.dialogs.check_library import CheckLibraryDialog, DBCheck self.gui.library_view.save_state() m = self.gui.library_view.model() m.stop_metadata_backup() db = m.db db.prefs.disable_setting = True d = DBCheck(self.gui, db) d.start() try: d.conn.close() except: pass d.break_cycles() self.gui.library_moved(db.library_path, call_close=not d.closed_orig_conn) if d.rejected: return if d.error is None: if not question_dialog( self.gui, _("Success"), _( "Found no errors in your calibre library database." " Do you want calibre to check if the files in your " " library match the information in the database?" ), ): return else: return error_dialog( self.gui, _("Failed"), _("Database integrity check failed, click Show details" " for details."), show=True, det_msg=d.error[1], ) self.gui.status_bar.show_message(_("Starting library scan, this may take a while")) try: QCoreApplication.processEvents() d = CheckLibraryDialog(self.gui, m.db) if not d.do_exec(): info_dialog( self.gui, _("No problems found"), _("The files in your library match the information " "in the database."), show=True, ) finally: self.gui.status_bar.clear_message()
def _change_multisampling(self, sample_count): """Creates a new instance of SceneViewer, to support interactive changing of multisampling parameters""" new_canvas = SceneCanvas(self.sceneContainer, samples=sample_count) old_canvas = self.openGLWidget self.sceneContainer.layout().removeWidget(old_canvas) old_canvas.setParent(None) self.sceneContainer.layout().addWidget(new_canvas) self.openGLWidget = new_canvas old_canvas.deleteLater() self._setup_canvas() QCoreApplication.processEvents() # required for repaint below to take self.openGLWidget.repaint()
def downloadOpdsCatalog(self, gui, opdsCatalogUrl): print "downloading catalog: %s" % opdsCatalogUrl opdsCatalogFeed = parse(opdsCatalogUrl) self.books = self.makeMetadataFromParsedOpds(opdsCatalogFeed.entries) self.filterBooks() QCoreApplication.processEvents() nextUrl = self.findNextUrl(opdsCatalogFeed.feed) while nextUrl is not None: nextFeed = parse(nextUrl) self.books = self.books + self.makeMetadataFromParsedOpds(nextFeed.entries) self.filterBooks() QCoreApplication.processEvents() nextUrl = self.findNextUrl(nextFeed.feed)
def check_library(self): from calibre.gui2.dialogs.check_library import CheckLibraryDialog, DBCheck self.gui.library_view.save_state() m = self.gui.library_view.model() m.stop_metadata_backup() db = m.db db.prefs.disable_setting = True library_path = db.library_path d = DBCheck(self.gui, db) d.start() try: m.close() except: pass d.break_cycles() self.gui.library_moved(library_path) if d.rejected: return if d.error is None: if not question_dialog( self.gui, _('Success'), _('Found no errors in your calibre library database.' ' Do you want calibre to check if the files in your ' ' library match the information in the database?')): return else: return error_dialog( self.gui, _('Failed'), _('Database integrity check failed, click Show details' ' for details.'), show=True, det_msg=d.error[1]) self.gui.status_bar.show_message( _('Starting library scan, this may take a while')) try: QCoreApplication.processEvents() d = CheckLibraryDialog(self.gui, m.db) if not d.do_exec(): info_dialog( self.gui, _('No problems found'), _('The files in your library match the information ' 'in the database.'), show=True) finally: self.gui.status_bar.clear_message()
def check_library(self): from calibre.gui2.dialogs.check_library import CheckLibraryDialog, DBCheck self.gui.library_view.save_state() m = self.gui.library_view.model() m.stop_metadata_backup() db = m.db db.prefs.disable_setting = True library_path = db.library_path d = DBCheck(self.gui, db) d.start() try: m.close() except: pass d.break_cycles() self.gui.library_moved(library_path, call_close=False) if d.rejected: return if d.error is None: if not question_dialog(self.gui, _('Success'), _('Found no errors in your calibre library database.' ' Do you want calibre to check if the files in your ' ' library match the information in the database?')): return else: return error_dialog(self.gui, _('Failed'), _('Database integrity check failed, click Show details' ' for details.'), show=True, det_msg=d.error[1]) self.gui.status_bar.show_message( _('Starting library scan, this may take a while')) try: QCoreApplication.processEvents() d = CheckLibraryDialog(self.gui, m.db) if not d.do_exec(): info_dialog(self.gui, _('No problems found'), _('The files in your library match the information ' 'in the database.'), show=True) finally: self.gui.status_bar.clear_message()
def regtask(self, tv, t1, t2, t3, s1, s2, p1, p2, sm1, sm2, mc1, mc2, M1, M2, mka, md1, deltav, deltatt, ae1, ae2, hal, tt11, tt12, tt21, tt22, mc22, s22, p22): def polet1(): time1, h1, v1, m1, TT1, fi1, tt = 0, 0, 0, M1 + M2 + mka, pi / 2, 0, pi / 2 mTT1, mh1, mt1, mtt1, ml1 = [], [], [], [], [] mTT1.append(TT1 * 180 / pi) mh1.append(h1) mtt1.append((alpha(time1) * pi / 180 + TT1 - fi1) / pi * 180) mt1.append(time1) ml1.append(fi1 * 0.18 / pi * R) while time1 < t1: v1, TT1, h1, fi1, m1 = runge(v1, TT1, h1, fi1, m1, time1, F1) time1 += sh mTT1.append(TT1 * 180 / pi) mh1.append(h1) mtt1.append((alpha(time1) * pi / 180 + TT1 - fi1) / pi * 180) mt1.append(time1) ml1.append(fi1 * 0.18 / pi * R) return mTT1, mh1, mt1, mtt1, ml1, time1, h1, v1, m1, TT1, fi1, mtt1[ len(mtt1) - 1] / 180 * pi def polet2(time1, h1, v1, m1, TT1, fi1, tt1, TET1): TET1 = TET1 time2, h2, v2, m2, TT2, fi2, tt = time1, h1, v1, m1, TT1, fi1, tt1 mTT2, mh2, mt2, mtt2, ml2 = [], [], [], [], [] while time2 < t2: v2, TT2, h2, fi2, m2 = runge(v2, TT2, h2, fi2, m2, time2, F2) time2 += sh mTT2.append(TT2 * 180 / pi) mh2.append(h2) mtt2.append((tt + TET1 * (time2 - t1)) * 180 / pi) mt2.append(time2) ml2.append(fi2 * 0.18 / pi * R) return mTT2, mh2, mt2, mtt2, ml2, time2, h2, v2, m2, TT2, fi2, mtt2[ len(mtt2) - 1] / 180 * pi def polet3(time2, h2, v2, m2, TT2, fi2, tt2, TET2): TET2 = TET2 time3, h3, v3, m3, TT3, fi3 = time2, h2, v2, m2, TT2, fi2 mTT3, mh3, mt3, mtt3, ml3 = [], [], [], [], [] while time3 <= t3: v3, TT3, h3, fi3, m3 = runge(v3, TT3, h3, fi3, m3, time3, F3) time3 += sh mTT3.append(TT3 * 180 / pi) mh3.append(h3) mtt3.append((tt2 + TET2 * (time3 - t2)) * 180 / pi) mt3.append(time3) ml3.append(fi3 * 0.18 / pi * R) if (h3 < 90000): return 0, 0, 0, 0, 0, 0, 0, 0, 0, False return mTT3, mh3, mt3, mtt3, ml3, h3, m3, TT3, fi3, v3 def alpha(t): a = 0.14 if t <= tv: return 0 else: return 4 * ae * exp(a * (tv - t)) * (1 - exp(a * (tv - t))) def F1(V, tetta, H, fi, m, t): plot, davl, skzv = inte(H, height, Roh), inte(H, height, Ph), inte(H, height, Ah) Mah = V / skzv if V == 0 or t <= tv: return (((p1 - davl * s1) * cos(alpha(t) * pi / 180) - cx1(Mah, H) * plot * sm1 * V ** 2 / 2) / m - gc \ * sin(tetta) / (1 + H / R) ** 2) * sh, \ 0, \ V * sin(tetta) * sh, \ 0, \ -mc1 * sh else: return (((p1 - davl * s1) * cos(alpha(t) * pi / 180) - cx1(Mah,H) * plot * sm1 * V ** 2 / 2) / m - gc \ * sin(tetta) / (1 + H / R) ** 2) * sh, \ 1 / V * (((p1 - davl * s1) * sin(alpha(t) * pi / 180) + cy1( Mah) * plot * sm1 * V ** 2 / 2 * alpha(t) * pi / 180) / m - (gc * cos(tetta) / (1 + H / R) ** 2 * (1 - V ** 2 / 7900 ** 2 * (1 + H / R)))) * sh, \ V * sin(tetta) * sh, \ V * cos(tetta) / (R + H) * sh, \ -mc1 * sh def F2(V, tetta, H, fi, m, t): plot, davl, skzv = inte(H, height, Roh), inte(H, height, Ph), inte(H, height, Ah) Mah = V / skzv return (((p2 - davl * s2) * cos(tt1 + TET1 * (t - t1) - tetta + fi) - cx2(Mah, H) * plot * sm2 * V ** 2 / 2) / m - gc * sin( tetta) / (1 + H / R) ** 2) * sh, \ 1 / V * (((p2 - davl * s2) * ( tt1 + TET1 * ( t - t1) - tetta + fi) + cy2 * plot * sm2 * V ** 2 / 2 * alpha( t) * pi / 180) / m - (gc * cos(tetta) / (1 + H / R) ** 2 * ( 1 - V ** 2 / 7900 ** 2 * (1 + H / R)))) * sh, \ V * sin(tetta) * sh, \ V * cos(tetta) / (R + H) * sh, \ -mc2 * sh def F3(V, tetta, H, fi, m, t): plot, davl, skzv = inte(H, height, Roh), inte(H, height, Ph), inte(H, height, Ah) Mah = V / skzv return (((p22 - davl * s22) * cos(tt2 + TET2 * (t - t1) - tetta + fi) - cx2(Mah, H) * plot * sm2 * V ** 2 / 2) / m - gc * sin( tetta) / (1 + H / R) ** 2) * sh, \ 1 / V * (((p22 - davl * s22) * ( tt2 + TET2 * ( t - t1) - tetta + fi) + cy2 * plot * sm2 * V ** 2 / 2 * alpha( t) * pi / 180) / m - (gc * cos(tetta) / (1 + H / R) ** 2 * ( 1 - V ** 2 / 7900 ** 2 * (1 + H / R)))) * sh, \ V * sin(tetta) * sh, \ V * cos(tetta) / (R + H) * sh, \ -mc22 * sh def runge(v, TT, h, fi, m, t, F): cf1 = F(v, TT, h, fi, m, t) cf2 = F(v + cf1[0] / 2, TT + cf1[1] / 2, h + cf1[2] / 2, fi + cf1[3] / 2, m + cf1[4] / 2, t + sh / 2) cf3 = F(v + cf2[0] / 2, TT + cf2[1] / 2, h + cf2[2] / 2, fi + cf2[3] / 2, m + cf2[4] / 2, t + sh / 2) cf4 = F(v + cf3[0], TT + cf3[1], h + cf3[2], fi + cf3[3], m + cf3[4], t + sh) A = [v, TT, h, fi, m] for el in range(len(A)): A[el] += (cf1[el] + 2 * cf2[el] + 2 * cf3[el] + cf4[el]) / 6 return A[0], A[1], A[2], A[3], A[4] for k in range(-int(ae1 * 1000000), -int(ae2 * 1000000), -int(hal * 1000000)): sh = 1 ae = -k / 10**6 mTT1, mh1, mt1, mtt1, ml1, time1, h1, v1, m1, TT1, fi1, tt1 = polet1() m1 -= md1 sh = 5 v3, h3 = 0, 0 TET11, TET21 = tt11, tt12 v = 0 self.textEdit_48.setText(str(-k / 10**6)) while (abs(v3 - (398600.44 * 10**9 / (R + h3))**0.5) > deltav): TET1 = (TET11 + TET21) / 2 self.textEdit_49.setText(str(TET1 / pi * 180)) TT3 = deltatt + 1 mTT2, mh2, mt2, mtt2, ml2, time2, h2, v2, m2, TT2, fi2, tt2 = polet2( time1, h1, v1, m1, TT1, fi1, tt1, TET1) TET12, TET22 = tt21, tt22 w = 0 while (abs(TT3) / pi * 180 > deltatt): TET2 = (TET12 + TET22) / 2 self.textEdit_50.setText(str(TET2 / pi * 180)) mTT3, mh3, mt3, mtt3, ml3, h3, m3, TT3, fi3, v3 = polet3( time2, h2, v2, m2, TT2, fi2, tt2, TET2) if v3 == False: break if (TT3 > 0): TET12 = TET2 else: TET22 = TET2 w += 1 if (w > 20): break QCoreApplication.processEvents() if (v3 - (398600.44 * 10**9 / (R + h3))**0.5 > 0): TET21 = TET1 else: TET11 = TET1 if (v == 15): break v += 1 if (abs(v3 - (398600.44 * 10**9 / (R + h3))**0.5) < deltav and abs(TT3) / pi * 180 < deltatt): desi.Ui_MainWindow.plot(self, [ mTT1 + mTT2 + mTT3, mh1 + mh2 + mh3, mtt1 + mtt2 + mtt3, mt1 + mt2 + mt3, ml1 + ml2 + ml3 ]) self.consoletext.setText( self.consoletext.toPlainText() + "αэкс=" + str(-k / 10**6) + "° ϑ1`=" + str(TET1) + "°/сек ϑ2`=" + str(TET2) + "°/сек\nH=" + str(h3) + "м θ=" + str(TT3) + "° V=" + str(v3) + "м/с dV=" + str(abs(v3 - (398600.44 * 10**9 / (R + h3))**0.5)) + "м/с\n" + "\n") QCoreApplication.processEvents()