python类CallAfter()的实例源码

DialerFrame.py 文件源码 项目:fmc-dialer 作者: sguron 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def makeCall(self):
        if self.wxapp.phonenum:
            wx.CallAfter(self.wxapp.pstnCall)
            self.make_call = False

            self.flag_bitmap.ChangeSource(u'images/flags/%s.png' % self.wxapp.phonecountry[1].lower())
            self.m_staticText5.UpdateLabel(u"00:00:00")
            codelen = len(self.wxapp.phonecountry[3])
            if self.wxapp.phonecountry[3]:
                self.m_staticText6.UpdateLabel(u"+%s %s" % ( self.wxapp.phonecountry[3], self.wxapp.phonenum[codelen:]))
            else:
                self.m_staticText6.UpdateLabel(self.wxapp.phonenum)

            #self.presencepanel.Refresh()

            self.call_btn.ChangeButtonImages(u"images/keypad/normal/end-call.png")
bciplayer.py 文件源码 项目:cebl 作者: idfah 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def testClassify(self):
        cap = self.src.getEEGSecs(time.time() - self.testTime)
        self.testTime = time.time()

        cap = self.bandpass(cap)
        seg = cap.segment(start=self.windowStart, end=self.windowEnd)
        seg = self.downsample(seg)

        # if verbose XXX - idfah
        #wx.LogMessage('nSeg: %d' % seg.getNSeg())
        assert seg.getNSeg() == len(self.choices)

        stim = [self.markToStim(m) for m in seg.getMarkers()]

        x = self.standardizer.apply(seg.chanEmbed())

        dv = self.classifier.discrim(x)
        choice = stim[np.argmax(dv, axis=0)[0]]

        if self.pieMenu.growBar(choice, amount=1.0/self.nTestTrial):
            wx.CallAfter(self.controlPlayer, choice)
        else:
            wx.CallLater(1000.0*self.isi, self.runTestEpoch)
motorpong.py 文件源码 项目:cebl 作者: idfah 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def testDecision(self, probs):
        for i,choice in enumerate(self.choices):
            self.pieMenu.growBar(choice, self.gain*(probs[i]-self.loss), refresh=False)
        self.pieMenu.refresh()

        self.curDecision += 1

        finalSelection = self.pieMenu.getSelection()

        if finalSelection is None:
            wx.CallAfter(self.runTestEpoch)

        else:
            self.pieMenu.clearAllHighlights(refresh=False)
            self.pieMenu.highlight(finalSelection, style='jump', secs=self.pauseSecs)
            finalLabel = self.choices.index(finalSelection)
            self.src.incrementMarker(finalLabel+1)
            self.confusion[finalLabel, self.choices.index(self.curChoice)] += 1.0

            wx.CallLater(1000.0*self.pauseSecs, self.testClearTrial)
p300bot.py 文件源码 项目:cebl 作者: idfah 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def testClassify(self):
        cap = self.src.getEEGSecs(time.time() - self.testTime)
        self.testTime = time.time()

        cap = self.decimate(cap)
        seg = cap.segment(start=self.windowStart, end=self.windowEnd)

        assert seg.getNSeg() == len(self.choices)

        stim = [self.markToStim(m) for m in seg.getMarkers()]

        x = self.standardizer.apply(seg.chanEmbed())

        dv = self.classifier.discrim(x)
        choice = stim[np.argmax(dv, axis=0)[0]]

        if self.pieMenu.growBar(choice, amount=1.0/self.nTestTrial):
            wx.CallAfter(self.moveRobot, choice)
        else:
            wx.CallLater(1000.0*self.isi, self.runTestEpoch)
ztv.py 文件源码 项目:CAAPR 作者: Stargrazer82301 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def set_and_get_xy_limits(self):
        canvas_size = self.canvas.GetSize()
        num_x_pixels = canvas_size.x
        halfsize = (num_x_pixels / 2.0) / self.ztv_frame.zoom_factor
        xlim = (self.center.x - halfsize, self.center.x + halfsize)
        self.axes.set_xlim(xlim)
        num_y_pixels = canvas_size.y
        halfsize = (num_y_pixels / 2.0) / self.ztv_frame.zoom_factor
        ylim = (self.center.y - halfsize, self.center.y + halfsize)
        self.axes.set_ylim(ylim)
        self.figure.canvas.draw()  # bulk of time in method is spent in this line: TODO: look for ways to make faster
        send_change_message = True
        if xlim == self.xlim and ylim == self.ylim:
            send_change_message = False
        self.xlim, self.ylim = xlim, ylim
        if send_change_message:
            wx.CallAfter(pub.sendMessage, 'primary-xy-limits-changed', msg=None)
        return {'xlim':xlim, 'ylim':ylim}
ztv.py 文件源码 项目:CAAPR 作者: Stargrazer82301 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def set_cmap(self, msg):
        """
        Verify that requested cmap is in the list (or it's reversed equivalent) and set it

        msg is tuple:  (pause_redraw_image, new_cmap)
        """
        pause_redraw_image, new_cmap = msg
        old_cmap = self.cmap
        lower_available_cmaps = [a.lower() for a in self.available_cmaps]
        if new_cmap.lower() in lower_available_cmaps:
            self.cmap = self.available_cmaps[lower_available_cmaps.index(new_cmap.lower())]
            self.set_cmap_inverted(((pause_redraw_image or self._pause_redraw_image), False))
        elif new_cmap.replace('_r', '').lower() in lower_available_cmaps:
            self.cmap = self.available_cmaps[lower_available_cmaps.index(new_cmap.lower().replace('_r', ''))]
            self.set_cmap_inverted(((pause_redraw_image or self._pause_redraw_image), True))
        elif (new_cmap.lower() + '_r') in lower_available_cmaps:
            self.cmap = self.available_cmaps[lower_available_cmaps.index(new_cmap.lower() + '_r')]
            self.set_cmap_inverted(((pause_redraw_image or self._pause_redraw_image), True))
        else:
            sys.stderr.write("unrecognized cmap ({}) requested\n".format(new_cmap))
        if self.cmap != old_cmap:
            wx.CallAfter(pub.sendMessage, 'cmap-changed', msg=None)
            if not (pause_redraw_image or self._pause_redraw_image):
                wx.CallAfter(pub.sendMessage, 'redraw-image', msg=False)
ztv.py 文件源码 项目:CAAPR 作者: Stargrazer82301 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def set_clim(self, msg):
        """
        msg is tuple:  (pause_redraw_image, (clim[0], clim[1]))
        """
        pause_redraw_image, clim = msg
        old_clim = self.clim
        if clim[0] is None:
            clim[0] = self.clim[0]
        if clim[1] is None:
            clim[1] = self.clim[1]
        if clim[0] > clim[1]:
            self.clim = [clim[1], clim[0]]
            self.set_cmap_inverted(((pause_redraw_image or self._pause_redraw_image), not self.is_cmap_inverted))
        else:
            self.clim = clim
        if old_clim != self.clim:
            wx.CallAfter(pub.sendMessage, 'clim-changed', msg=((pause_redraw_image or self._pause_redraw_image),))
source_panel.py 文件源码 项目:CAAPR 作者: Stargrazer82301 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def run(self):
        latest_mtime = 0.0
        while self.keep_running:
            filename_to_open = None
            possible_matches = glob.glob(self.source_panel.autoload_match_string)
            if len(possible_matches) > 0:
                for cur_match in possible_matches:
                    cur_match_mtime = os.path.getmtime(cur_match)
                    if cur_match_mtime > latest_mtime:
                        filename_to_open = cur_match
                        latest_mtime = cur_match_mtime
                if filename_to_open is not None:
                    wx.CallAfter(pub.sendMessage, 'load-fits-file', msg=filename_to_open)
            time.sleep(self.source_panel.autoload_pausetime)
            if self.source_panel.autoload_mode != 'file-match':
                self.keep_running = False
source_panel.py 文件源码 项目:CAAPR 作者: Stargrazer82301 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def load_sky_subtraction_to_process_stack(self):
        """
        Load sky subtraction into image processing stack
        If sky image is 3-d ([n,x,y]), then collapse to 2-d ([x,y]) by doing a median on axis=0
        """
        self.unload_sky_subtraction_from_process_stack()
        if self.sky_hdulist is not None:
            if self.sky_hdulist[0].data.ndim == 2:
                process_fxn = ImageProcessAction(np.subtract, self.sky_hdulist[0].data)
            elif self.sky_hdulist[0].data.ndim == 3:
                process_fxn = ImageProcessAction(np.subtract, np.median(self.sky_hdulist[0].data, axis=0))
            else:
                raise UnrecognizedNumberOfDimensions("Tried to load sky image with {} dimensions, " + 
                                                     "when can only handle 2-d or 3-d".format(
                                                     self.sky_hdulist[0].data.ndim))
            # assume that sky subtraction should always be first in processing stack.
            self.ztv_frame.image_process_functions_to_apply.insert(0, ('sky-subtraction', process_fxn))
            wx.CallAfter(pub.sendMessage, 'image-process-functions-to-apply-changed', 
                         msg=(self.ztv_frame._pause_redraw_image,))
            wx.CallAfter(pub.sendMessage, 'set-window-title', msg=None)
        self.sky_checkbox.SetValue(True)
ztv.py 文件源码 项目:CAAPR 作者: Stargrazer82301 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def set_and_get_xy_limits(self):
        canvas_size = self.canvas.GetSize()
        num_x_pixels = canvas_size.x
        halfsize = (num_x_pixels / 2.0) / self.ztv_frame.zoom_factor
        xlim = (self.center.x - halfsize, self.center.x + halfsize)
        self.axes.set_xlim(xlim)
        num_y_pixels = canvas_size.y
        halfsize = (num_y_pixels / 2.0) / self.ztv_frame.zoom_factor
        ylim = (self.center.y - halfsize, self.center.y + halfsize)
        self.axes.set_ylim(ylim)
        self.figure.canvas.draw()  # bulk of time in method is spent in this line: TODO: look for ways to make faster
        send_change_message = True
        if xlim == self.xlim and ylim == self.ylim:
            send_change_message = False
        self.xlim, self.ylim = xlim, ylim
        if send_change_message:
            wx.CallAfter(pub.sendMessage, 'primary-xy-limits-changed', msg=None)
        return {'xlim':xlim, 'ylim':ylim}
ztv.py 文件源码 项目:CAAPR 作者: Stargrazer82301 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def set_clim(self, msg):
        """
        msg is tuple:  (pause_redraw_image, (clim[0], clim[1]))
        """
        pause_redraw_image, clim = msg
        old_clim = self.clim
        if clim[0] is None:
            clim[0] = self.clim[0]
        if clim[1] is None:
            clim[1] = self.clim[1]
        if clim[0] > clim[1]:
            self.clim = [clim[1], clim[0]]
            self.set_cmap_inverted(((pause_redraw_image or self._pause_redraw_image), not self.is_cmap_inverted))
        else:
            self.clim = clim
        if old_clim != self.clim:
            wx.CallAfter(pub.sendMessage, 'clim-changed', msg=((pause_redraw_image or self._pause_redraw_image),))
source_panel.py 文件源码 项目:CAAPR 作者: Stargrazer82301 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def run(self):
        latest_mtime = 0.0
        while self.keep_running:
            filename_to_open = None
            possible_matches = glob.glob(self.source_panel.autoload_match_string)
            if len(possible_matches) > 0:
                for cur_match in possible_matches:
                    cur_match_mtime = os.path.getmtime(cur_match)
                    if cur_match_mtime > latest_mtime:
                        filename_to_open = cur_match
                        latest_mtime = cur_match_mtime
                if filename_to_open is not None:
                    wx.CallAfter(pub.sendMessage, 'load-fits-file', msg=filename_to_open)
            time.sleep(self.source_panel.autoload_pausetime)
            if self.source_panel.autoload_mode != 'file-match':
                self.keep_running = False
source_panel.py 文件源码 项目:CAAPR 作者: Stargrazer82301 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def load_sky_subtraction_to_process_stack(self):
        """
        Load sky subtraction into image processing stack
        If sky image is 3-d ([n,x,y]), then collapse to 2-d ([x,y]) by doing a median on axis=0
        """
        self.unload_sky_subtraction_from_process_stack()
        if self.sky_hdulist is not None:
            if self.sky_hdulist[0].data.ndim == 2:
                process_fxn = ImageProcessAction(np.subtract, self.sky_hdulist[0].data)
            elif self.sky_hdulist[0].data.ndim == 3:
                process_fxn = ImageProcessAction(np.subtract, np.median(self.sky_hdulist[0].data, axis=0))
            else:
                raise UnrecognizedNumberOfDimensions("Tried to load sky image with {} dimensions, " + 
                                                     "when can only handle 2-d or 3-d".format(
                                                     self.sky_hdulist[0].data.ndim))
            # assume that sky subtraction should always be first in processing stack.
            self.ztv_frame.image_process_functions_to_apply.insert(0, ('sky-subtraction', process_fxn))
            wx.CallAfter(pub.sendMessage, 'image-process-functions-to-apply-changed', 
                         msg=(self.ztv_frame._pause_redraw_image,))
            wx.CallAfter(pub.sendMessage, 'set-window-title', msg=None)
        self.sky_checkbox.SetValue(True)
action.py 文件源码 项目:bonsu 作者: bonsudev 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def OnClickStopAction(self, event):
    if self.pipeline_started == True:
        if self.citer_flow[1] == 1:
            self.sequence_timer.Start(1000)
            self.ancestor.GetPage(4).data_poll_timer.Start(1000)
            if self.total_iter > 0:
                self.ancestor.GetPage(2).data_poll_timer.Start(1000)
        if self.citer_flow[1] < 2:
            self.citer_flow[1] = 2
            self.pipeline_started = False
            self.button_pause.SetBitmapLabel(getpause48Bitmap())
            self.ancestor.GetPage(1).button_pause.SetBitmapLabel(getpauseBitmap())
            self.citer_flow[3] = 0
            self.citer_flow[4] = 0
            self.citer_flow[5] = 0
            def ThreadClean(self):
                while len(enumerate()) > 2:
                    sleep(0.1)
                wx.CallAfter(self.OnClickFinal,)
            self.thread = threading.Thread(target=ThreadClean, args=(self,))
            self.thread.daemon = True
            self.thread.start()
functions.py 文件源码 项目:bonsu 作者: bonsudev 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def Sequence_Scale_Array(\
    self,
    pipelineitem
    ):
    if self.pipeline_started == True:
        title = "Sequence " + pipelineitem.treeitem['name']
        self.ancestor.GetPage(0).queue_info.put("Preparing scaled Numpy array...")
        filename_in = pipelineitem.input_filename.objectpath.GetValue()
        filename_out = pipelineitem.output_filename.objectpath.GetValue()
        factor = float(pipelineitem.scale.value.GetValue())
        try:
            array = LoadArray(self, filename_in)
        except:
            msg = "Could not load array."
            wx.CallAfter(self.UserMessage, title, msg)
            self.pipeline_started = False
            return
        array2 = factor*array
        try:
            SaveArray(self, filename_out, array2)
        except:
            msg = "Could not save array."
            wx.CallAfter(self.UserMessage, title, msg)
            self.pipeline_started = False
            return
functions.py 文件源码 项目:bonsu 作者: bonsudev 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def Sequence_Transpose_Array(\
    self,
    pipelineitem
    ):
    if self.pipeline_started == True:
        title = "Sequence " + pipelineitem.treeitem['name']
        self.ancestor.GetPage(0).queue_info.put("Preparing transpose Numpy array...")
        filename_in = pipelineitem.input_filename.objectpath.GetValue()
        filename_out = pipelineitem.output_filename.objectpath.GetValue()
        try:
            array = LoadArray(self, filename_in)
        except:
            msg = "Could not load array."
            wx.CallAfter(self.UserMessage, title, msg)
            self.pipeline_started = False
            return
        array2 = array.transpose((2,1,0))
        try:
            SaveArray(self, filename_out, array2)
        except:
            msg = "Could not save array."
            wx.CallAfter(self.UserMessage, title, msg)
            self.pipeline_started = False
            return
functions.py 文件源码 项目:bonsu 作者: bonsudev 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def Sequence_Array_to_Memory(\
    self,
    pipelineitem
    ):
    if self.pipeline_started == True:
        title = "Sequence " + pipelineitem.treeitem['name']
        self.ancestor.GetPage(0).queue_info.put("Preparing array in memory...")
        filename_in = pipelineitem.input_filename.objectpath.GetValue()
        filename_out = pipelineitem.output_filename.objectpath.GetValue()
        try:
            array = LoadArray(self, filename_in)
        except:
            msg = "Could not load array."
            wx.CallAfter(self.UserMessage, title, msg)
            self.pipeline_started = False
            return
        try:
            SaveArray(self, filename_out, array)
        except:
            msg = "Could not save array."
            wx.CallAfter(self.UserMessage, title, msg)
            self.pipeline_started = False
            return
functions.py 文件源码 项目:bonsu 作者: bonsudev 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def Sequence_Memory_to_Array(\
    self,
    pipelineitem
    ):
    if self.pipeline_started == True:
        title = "Sequence " + pipelineitem.treeitem['name']
        self.ancestor.GetPage(0).queue_info.put("Saving array in memory...")
        filename_in = pipelineitem.input_filename.objectpath.GetValue()
        filename_out = pipelineitem.output_filename.objectpath.GetValue()
        try:
            array = LoadArray(self, filename_in)
        except:
            msg = "Could not load array."
            wx.CallAfter(self.UserMessage, title, msg)
            self.pipeline_started = False
            return
        try:
            SaveArray(self, filename_out, array)
        except:
            msg = "Could not save array."
            wx.CallAfter(self.UserMessage, title, msg)
            self.pipeline_started = False
            return
functions.py 文件源码 项目:bonsu 作者: bonsudev 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def Sequence_Load_PSF(\
    self,
    pipelineitem
    ):
    if self.pipeline_started == True:
        title = "Sequence " + pipelineitem.treeitem['name']
        self.ancestor.GetPage(0).queue_info.put("Preparing PSF in memory...")
        filename_in = pipelineitem.input_filename.objectpath.GetValue()
        try:
            array = LoadArray(self, filename_in)
        except:
            msg = "Could not load array."
            wx.CallAfter(self.UserMessage, title, msg)
            self.pipeline_started = False
            return
        try:
            self.psf = array
            self.ancestor.GetPage(0).queue_info.put("done.")
        except:
            msg = "Could not save array."
            wx.CallAfter(self.UserMessage, title, msg)
            self.pipeline_started = False
            return
functions.py 文件源码 项目:bonsu 作者: bonsudev 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def Sequence_Wrap(\
    self,
    pipelineitem
    ):
    if self.pipeline_started == True:
        title = "Sequence " + pipelineitem.treeitem['name']
        self.ancestor.GetPage(0).queue_info.put("Preparing wrapped array...")
        filename_in = pipelineitem.input_filename.objectpath.GetValue()
        filename_out = pipelineitem.output_filename.objectpath.GetValue()
        direction = pipelineitem.rbdirection.GetStringSelection()
        try:
            array = LoadArray(self, filename_in)
        except:
            msg = "Could not load array."
            wx.CallAfter(self.UserMessage, title, msg)
            self.pipeline_started = False
            return
        if direction == "Forward":
            arrayfinal = WrapArray(array)
        else:
            arrayfinal = WrapArray(array, direction=-1)
        SaveArray(self, filename_out, arrayfinal)
functions.py 文件源码 项目:bonsu 作者: bonsudev 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def Sequence_Save_Residual(\
    self,
    pipelineitem
    ):
    if self.pipeline_started == True:
        title = "Sequence " + pipelineitem.treeitem['name']
        self.ancestor.GetPage(0).queue_info.put("Saving residual data...")
        filename_out = pipelineitem.output_filename.objectpath.GetValue()
        try:
            data_length = self.citer_flow[0]
            x = numpy.arange(data_length)
            y = self.residual[:data_length]
            xy = numpy.vstack((x,y)).T
            numpy.savetxt(filename_out, xy, delimiter=',')
        except:
            msg = "Could not save array."
            wx.CallAfter(self.UserMessage, title, msg)
            self.pipeline_started = False
            return
UI.py 文件源码 项目:AppAutoViewer 作者: RealLau 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def getFullXpath(self, evt):
        fxpath = ""
        l = []
        it = evt.GetItem()
        l.append(it)
        p = self.tree.GetItemParent(it)
        while p!=self.tree.GetRootItem():
            l.append(p) 
            p = self.tree.GetItemParent(p)
        del l[-1]
        l.reverse()
        for i in l:
            xPath = self.tree.ordeDic[i]["class"]+"["+"@index="+"\'%s\'" % self.tree.ordeDic[i]["index"]+"]" 
            fxpath += "/"+xPath

        wx.CallAfter(pub.sendMessage, "updateXPath", msg=fxpath)
UI.py 文件源码 项目:AppAutoViewer 作者: RealLau 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def tellToDoSwipeOrInput(self, evt):
        operationString = self.OpeartionBox.GetStringSelection()    
        inputC = self.inputContent.GetValue()
        sX = self.swipeStartX.GetValue()
        sY = self.swipeStartY.GetValue()
        eX = self.swipeEndX.GetValue()
        eY = self.swipeEndY.GetValue()        

        if operationString=="??":
            if inputC=="":
                dlg = wx.MessageDialog(self, u"???????", u"????????", wx.OK | wx.ICON_ERROR)
                if dlg.ShowModal() == wx.ID_OK:
                    dlg.Destroy()
            else:
                keyb = self.keyboardType.GetValue()
                wx.CallAfter(pub.sendMessage, "DoSwipeOrInput", msg =inputC+"\n"+keyb)
        else:
            if sX=="" or sY=="" or eX=="" or eY=="":
                dlg = wx.MessageDialog(self, u"?????????", u"??????????????????", wx.OK | wx.ICON_ERROR)
                if dlg.ShowModal() == wx.ID_OK:
                    dlg.Destroy()
            else:
                wx.CallAfter(pub.sendMessage, "DoSwipeOrInput", msg ="??\n%d\n%d\n%d\n%d" % (sX,sY,eX,eY))
EnhancedStatusBar.py 文件源码 项目:magic-card-database 作者: drknotter 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def __init__(self, parent, id=wx.ID_ANY, style=wx.ST_SIZEGRIP,
                 name="EnhancedStatusBar"):
        """Default Class Constructor.

        EnhancedStatusBar.__init__(self, parent, id=wx.ID_ANY,
                                   style=wx.ST_SIZEGRIP,
                                   name="EnhancedStatusBar")
        """

        wx.StatusBar.__init__(self, parent, id, style, name)

        self._items = {}
        self._curPos = 0
        self._parent = parent

        wx.EVT_SIZE(self, self.OnSize) 
        wx.CallAfter(self.OnSize, None)
downloader.py 文件源码 项目:pyjam 作者: 10se1ucgo 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def run(self):
        song_urls = iter(self.song_urls)
        errors = []
        with youtube_dl.YoutubeDL(self.opts) as yt:
            while not self.is_aborted():
                try:
                    song_url = next(song_urls)
                    logger.info("Downloading audio/video from {url}".format(url=song_url))
                    try:
                        yt.download([song_url])
                    except youtube_dl.DownloadError:
                        errors.append(song_url)
                    self.downloaded += 100
                    wx.CallAfter(self.parent.download_update, message=self.downloaded)
                except StopIteration:
                    wx.CallAfter(self.parent.download_complete, errors=errors)
                    break
downloader.py 文件源码 项目:pyjam 作者: 10se1ucgo 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def download_complete(self, errors):
        if self.progress_dialog:
            logger.info("Beginning download")
            self.downloader.join()
            if errors:
                done_string = "Songs downloaded with {errors} error(s)".format(errors=len(errors))
            else:
                done_string = "All songs were downloaded succesfully!"
            logger.info(done_string)
            done_message = wx.MessageDialog(parent=self, message=done_string, caption="pyjam")
            done_message.ShowModal()
            done_message.Destroy()

            if errors:
                errors = '\n'.join(errors)
                logger.critical("Error downloading these these URLs:\n{errors}".format(errors=errors))
                error_dialog = wx.MessageDialog(parent=self, message="The following URLs caused errors\n" + errors,
                                                caption="Download Error!", style=wx.ICON_ERROR)
                error_dialog.ShowModal()
                error_dialog.Destroy()

            self.progress_dialog.Destroy()
            self.Destroy()
            wx.CallAfter(self.parent.convert, event=None, in_dir=self.out_dir.GetPath())
ffmpeg.py 文件源码 项目:pyjam 作者: 10se1ucgo 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def run(self):
        file_size_dl = 0
        response = requests.get(self.url, stream=True)
        data_chunks = response.iter_content(chunk_size=1024)

        if not os.path.exists('bin'):
            os.mkdir('bin')

        with open('bin/ffmpeg.7z', 'wb') as f:
            while not self.is_aborted():
                try:
                    chunk = next(data_chunks)
                    file_size_dl += len(chunk)
                    logger.info("FFmpeg downloader: Downloaded chunk: {chunk}".format(chunk=len(chunk)))
                    logger.info("FFmpeg downloader: Total downloaded so far: {total}".format(total=file_size_dl))
                    logger.info("FFmpeg downloader: Remaining: {r}".format(r=self.file_size - file_size_dl))
                    if chunk:
                        f.write(chunk)
                        f.flush()
                        # This makes the download super slow.
                        # os.fsync(f.fileno())
                    wx.CallAfter(self.parent.ff_update, message=file_size_dl)
                except StopIteration:
                    wx.CallAfter(self.parent.ff_complete)
                    break
ffmpeg.py 文件源码 项目:pyjam 作者: 10se1ucgo 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def convert_update(self, message):
        progress = "{songs} out of {total}".format(songs=message // 2, total=self.num_songs)
        if self.progress_dialog and self.converter.isAlive():
            if message >= self.num_songs * 2:
                message = self.num_songs * 2 - 1
            if not self.progress_dialog.Update(value=message, newmsg="Converted: {prog}".format(prog=progress))[0]:
                self.converter.abort()
                self.converter.join()
                self.progress_dialog.Destroy()

                alert_string = "Aborted! Only {progress} songs were converted".format(progress=progress)
                alert = wx.MessageDialog(parent=self, message=alert_string, caption="pyjam", style=wx.ICON_EXCLAMATION)
                alert.ToggleWindowStyle(wx.STAY_ON_TOP)
                alert.ShowModal()
                alert.Destroy()

                logger.info("Audio conversion canceled canceled.")
                logger.info(progress)
                # wx.CallAfter(self.progress_dialog.Destroy)
ffmpeg.py 文件源码 项目:pyjam 作者: 10se1ucgo 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def convert_complete(self, errors):
        if self.progress_dialog:
            self.converter.join()
            if errors:
                done_string = "Songs converted with {errors} error(s)".format(errors=len(errors))
            else:
                done_string = "All songs were converted succesfully!"
            done_message = wx.MessageDialog(parent=self, message=done_string, caption="pyjam")
            done_message.ToggleWindowStyle(wx.STAY_ON_TOP)
            done_message.ShowModal()
            done_message.Destroy()

            if errors:
                errors = '\n'.join(errors)
                error_dialog = wx.MessageDialog(parent=self, message="The following files caused errors\n" + errors,
                                                caption="Conversion Error!", style=wx.OK | wx.ICON_ERROR)
                error_dialog.ShowModal()
                error_dialog.Destroy()
                logger.critical("Error converting these files\n{errors}".format(errors=errors))

            logger.info(done_string)
            wx.CallAfter(self.progress_dialog.Destroy)
FindInPouDialog.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def OnFindButton(self, event):
        infos = {
            "find_pattern": self.FindPattern.GetValue(),
            "wrap": self.WrapSearch.GetValue(),
            "case_sensitive": self.CaseSensitive.GetValue(),
            "regular_expression": self.RegularExpressions.GetValue(),
            "filter": "all"}

        if self.infosPrev != infos:
            self.infosPrev = infos
            message = ""
            try:
                self.criteria = infos
                CompilePattern(self.criteria)
            except Exception:
                self.criteria.clear()
                message = self.RegExpSyntaxErrMsg
            self.SetStatusText(message)
        if len(self.criteria) > 0:
            wx.CallAfter(self.ParentWindow.FindInPou,
                         {True: 1, False: -1}[self.Forward.GetValue()],
                         self.criteria)
        event.Skip()


问题


面经


文章

微信
公众号

扫码关注公众号