def run(self): self._cancel = False sync = ptv_sync.ptv_sync(self._dest_dir, delete=self._delete, move=self._move, audio=self._audio) try: for event in sync.sync_gen(): if not self._cancel: self.progress = event[0] self.total = event[1] self.message = event[2] # Append to list of media ids to delete from app if event[3] is not None: self._delete_list.append(event[3]) else: sync.interrupt() #don't exit loop except Exception, e: print "error copying file:",e
def on_preview_button_clicked(self, event): self._dest_dir = self._destination_entry.get_text() if not self._check_dest_dir(self._dest_dir): dialog = gtk.Dialog(title=_("Destination Error"), parent=None, flags=gtk.DIALOG_MODAL, buttons=(gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)) label = gtk.Label( _("The destination you have selected is not valid. Please select another destination and try again." )) dialog.vbox.pack_start(label, True, True, 0) label.show() response = dialog.run() dialog.hide() del dialog return sync = ptv_sync.ptv_sync(self._dest_dir, delete=self._delete_check.get_active(), move=self._move_check.get_active(), audio=self._audio_check.get_active(), dryrun=True) self._preview_dialog.buff.set_text("") self._preview_dialog.Show() self._dialog.hide() def _sync_gen(): text = "" last_message = "" for event in sync.sync_gen(): if not self._cancel: #text+="\n"+event[2] #self._preview_dialog.buff.set_text(text) if last_message != event[2]: self._preview_dialog.buff.insert_at_cursor(event[2] + "\n") last_message = event[2] else: sync.interrupt() #else:... just yield, let the generator run its course yield True if self._cancel: self._preview_dialog.hide() self._cancel = False yield False gobject.idle_add(_sync_gen().next)
def run(self): self._cancel = False sync = ptv_sync.ptv_sync(self._dest_dir, delete=self._delete, move=self._move, audio=self._audio) try: for event in sync.sync_gen(): if not self._cancel: self.progress = event[0] self.total = event[1] self.message = event[2] # Append to list of media ids to delete from app if event[3] is not None: self._delete_list.append(event[3]) else: sync.interrupt() #don't exit loop except Exception, e: print "error copying file:", e
def on_preview_button_clicked(self, event): self._dest_dir = self._destination_entry.get_text() if not self._check_dest_dir(self._dest_dir): dialog = gtk.Dialog(title=_("Destination Error"), parent=None, flags=gtk.DIALOG_MODAL, buttons=(gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)) label = gtk.Label(_("The destination you have selected is not valid. Please select another destination and try again.")) dialog.vbox.pack_start(label, True, True, 0) label.show() response = dialog.run() dialog.hide() del dialog return sync = ptv_sync.ptv_sync(self._dest_dir, delete=self._delete_check.get_active(), move=self._move_check.get_active(), audio=self._audio_check.get_active(), dryrun=True) self._preview_dialog.buff.set_text("") self._preview_dialog.Show() self._dialog.hide() def _sync_gen(): text = "" last_message = "" for event in sync.sync_gen(): if not self._cancel: #text+="\n"+event[2] #self._preview_dialog.buff.set_text(text) if last_message != event[2]: self._preview_dialog.buff.insert_at_cursor(event[2]+"\n") last_message = event[2] else: sync.interrupt() #else:... just yield, let the generator run its course yield True if self._cancel: self._preview_dialog.hide() self._cancel = False yield False gobject.idle_add(_sync_gen().next)