def start_game(self, *args): try: gobject.source_remove(self.timer) except: pass self.start_time = time.time() self.timer = gobject.timeout_add(1000, self.increment_time)
def cancel_clicked(self,widget,temp=False): newtree=devede_other.create_tree(self,"wcancel_job_dialog",self.gladefile,False) window=newtree.get_object("wcancel_job_dialog") window.show() value=window.run() window.hide() window.destroy() if value!=-5: # no return True self.runner.cancel() self.runner.wait_end() gobject.source_remove(self.timer) self.window.hide() self.window.destroy() newtree=devede_other.create_tree(self,"waborted_dialog",self.gladefile,False) window=newtree.get_object("waborted_dialog") window.show() window.run() window.hide() window.destroy() window=None gc.collect() (self.main_window_callback)() # show the main window return True
def deschedule(self): if not self.id: return gobject.source_remove(self.id) self.id = 0 self.active = False self.scheduled.remove(self)
def stop(self, data=None): if self.id_source: gobject.source_remove(self.id_source) self.id_source = None if self.scroll_source: gobject.source_remove(self.scroll_source) self.scroll_source = None
def __do_save(self, status): if self.__save_text_id > 0: gobject.source_remove(self.__save_text_id) if not self.__modified: self.__show_msg(_("Already saved")) return self.__idle_save_text(status)
def _update(self, widget, data=None): # This loop makes sure that we only call _find every 500 ms . if self.timer_id: # We destroy the last event source and create another one. gobject.source_remove(self.timer_id) self.timer_id = gobject.timeout_add(500, self._refresh, widget, data)
def stop_refresh_file_list(self): if self.subprocess != None and self.subprocess.poll() == None: # close the pipe, kill the child self.subprocess.stdout.close() if self.idle_id != None: gobject.source_remove(self.idle_id) self.subprocess = None
def _next_round_robin_buddy(self, recd): logger.debug('meshNextRoundRobinBuddy') if recd.meshReqCallbackId: gobject.source_remove(recd.meshReqCallbackId) recd.meshReqCallbackId = 0 # delete any stub of a partially downloaded file path = recd.getMediaFilepath() if path and os.path.exists(path): os.remove(path) good_buddy_obj = None buds = self.activity._shared_activity.get_joined_buddies() for buddy_obj in buds: buddy = util.sha_data(buddy_obj.props.key) buddy = util.printable_hash(buddy) if recd.triedMeshBuddies.count(buddy) > 0: logger.debug('mnrrb: weve already tried bud ' + buddy_obj.props.nick) else: logger.debug('mnrrb: ask next buddy: ' + buddy_obj.props.nick) good_buddy_obj = buddy_obj break if good_buddy_obj: buddy = util.sha_data(good_buddy_obj.props.key) buddy = util.printable_hash(buddy) self._req_recd_from_buddy(recd, buddy, good_buddy_obj.props.nick) else: logger.debug('weve tried all buddies here, and no one has this recd') recd.meshDownloading = False recd.triedMeshBuddies = [] recd.triedMeshBuddies.append(Instance.keyHashPrintable) self.activity.update_download_progress(recd)
def _check_recd_request(self, recd): #todo: add category for "not active activity, so go ahead and delete" if recd.downloadedFromBuddy: logger.debug('_meshCheckOnRecdRequest: recdRequesting.downloadedFromBuddy') if recd.meshReqCallbackId: gobject.source_remove(recd.meshReqCallbackId) recd.meshReqCallbackId = 0 return False if recd.deleted: logger.debug('_meshCheckOnRecdRequest: recdRequesting.deleted') if recd.meshReqCallbackId: gobject.source_remove(recd.meshReqCallbackId) recd.meshReqCallbackId = 0 return False if recd.meshDownloadingProgress: logger.debug('_meshCheckOnRecdRequest: recdRequesting.meshDownloadingProgress') #we've received some bits since last we checked, so keep waiting... they'll all get here eventually! recd.meshDownloadingProgress = False return True else: logger.debug('_meshCheckOnRecdRequest: ! recdRequesting.meshDownloadingProgress') #that buddy we asked info from isn't responding; next buddy! #self.meshNextRoundRobinBuddy( recdRequesting ) gobject.idle_add(self._next_round_robin_buddy, recd) return False
def _disconnect(self): if self._iowatchevent >= 0: gobject.source_remove(self._iowatchevent) self._iowatchevent = -1 if self._sock: self._sock.close() self._sock = None
def establish_connection(self, force=False): if self._sock: if force: self._disconnect() else: return True # attempt connection, we know we are disconnected at this point if self._connect(): # allow the frontend to see that we may have stale data self.status['epoch'] = self.status['epoch'] + 1 # stop our timer connect event if it exists if self._connectevent >= 0: gobject.source_remove(self._connectevent) self._connectevent = -1 # set up our select-like watcher on our input eventid = gobject.io_add_watch(self._sock, gobject.IO_IN | gobject.IO_PRI | gobject.IO_ERR | gobject.IO_HUP, self._processinput) self._iowatchevent = eventid # we've verified the connection, get powered on status self.querypower() return True else: # connection failed, set up our timer connect event if it doesn't # already exist if self._connectevent < 0: # attempt again in 2 seconds eventid = gobject.timeout_add(2000, self.establish_connection) self._connectevent = eventid return True
def filter_changed(self, filter_bar): # Restart the timer to start the filter. if self.filter_timeout_id: gobject.source_remove(self.filter_timeout_id) self.filter_timeout_id = gobject.timeout_add( self.FILTER_DELAY, self.filter_hosts, filter_bar.get_filter_string())
def end(self): # Remove all the timer first if self.waterlevel_timer : gobject.source_remove(self.waterlevel_timer) # Remove the root item removes all the others inside it self.rootitem.remove()
def mouse_up(self, event): if event.button == LEFT_BUTTON: gobject.source_remove(self.timer) self.end = [event.x, event.y] self.move = False if not self.canvas.resize_marker == 9: self.canvas.renderer.hide_move_frame() if self.moved: self.trafo = self._calc_trafo(event) self.api.transform_selected(self.trafo, self.copy) self.moved = False self.copy = False self.start = [] self.end = [] point = self.canvas.win_to_doc([event.x, event.y]) if not self.selection.is_point_over_marker(point): self.canvas.restore_mode() else: self._draw_center() self.moved = False self.copy = False self.start = [] self.end = [] if event.button == RIGHT_BUTTON and self.moved: self.copy = True self.set_cursor()
def __show_boxes(self, login): for box in self.get_children(): self.remove(box) self.login = login if login: self.pack_start(self.fixed_boxes[0]) self.pack_start(self.connecting_boxes[0]) self.pack_start(self.connecting_boxes[1]) self.pack_start(self.fixed_boxes[1]) for box in self.connecting_boxes: box.show() self.pgbar.show() self.login_button.set_label(gtk.STOCK_DISCONNECT) self.timer = gobject.timeout_add(40, self.__animation) else: self.pack_start(self.input_boxes[0]) self.pack_start(self.fixed_boxes[0]) self.pack_start(self.input_boxes[1]) self.pack_start(self.input_boxes[2]) self.pack_start(self.fixed_boxes[1]) # TODO: set the account's dp _, filename = self._theme_manager.get_dp("dp_amsn") self.dp.set_from_file(filename) self.login_button.set_label(gtk.STOCK_CONNECT) if self.timer is not None: gobject.source_remove(self.timer)
def __remove_timer(self): try: from gobject import source_remove source_remove(self.__timer) except AttributeError: pass return False
def mouse_up(self, event): if self.move and event.button == LEFT_BUTTON: gobject.source_remove(self.timer) new = [event.x, event.y] if event.state & gtk.gdk.CONTROL_MASK: change = [new[0] - self.start[0], new[1] - self.start[1]] if abs(change[0]) > abs(change[1]): new[1] = self.start[1] else: new[0] = self.start[0] self.end = new self.canvas.renderer.hide_move_frame() self.move = False if self.moved: self.trafo = self._calc_trafo(self.start, self.end) bbox = self.presenter.selection.bbox self.trafo = self._snap(bbox, self.trafo) self.api.transform_selected(self.trafo, self.copy) elif event.state & gtk.gdk.SHIFT_MASK: self.canvas.select_at_point(self.start, True) if not self.selection.is_point_over(self.start): self.canvas.restore_mode() if self.copy: self.canvas.restore_cursor() self.moved = False self.copy = False self.start = [] self.end = [] elif self.moved and event.button == RIGHT_BUTTON: self.copy = True cursor = self.app.cursors[modes.COPY_MODE] self.canvas.set_temp_cursor(cursor)
def disconnect_handlers (self): self.disconnect(self.sc_id) self.disconnect(self.sa_id) self.icon_theme.disconnect(self.tc_id) for id in self.resize_id, self.fade_id, self.anim_id: if id != 0: gobject.source_remove (id)
def run(self, widget = None): if not self.killdialog.run(self.hatari): return if self.io_id: gobject.source_remove(self.io_id) args = ["--configfile"] # whether to use Hatari config or unsaved Hatari UI config? if self.config.is_changed(): args += [self.config.save_tmp(self.tmpconfpath)] else: args += [self.config.get_path()] if self.memstate: args += self.memstate # only way to change boot order is to specify disk on command line if self.floppy: args += self.floppy if self.hatariwin: size = self.hatariwin.window.get_size() self.hatari.run(args, self.hatariwin.window) # get notifications of Hatari window size changes self.hatari.enable_embed_info() socket = self.hatari.get_control_socket().fileno() events = gobject.IO_IN | gobject.IO_HUP | gobject.IO_ERR self.io_id = gobject.io_add_watch(socket, events, self._socket_cb) # all keyboard events should go to Hatari window self.hatariwin.grab_focus() else: self.hatari.run(args)
def pause(self): """Pauses the animation""" if self.timer_task != 0: gobject.source_remove(self.timer_task) self.timer_task = 0 self.queue_draw()
def _set_repeat(self, delay=None, interval=None): """Set the key-repetition frequency for held-down keys""" if delay is not None and self.__repeat[0] is None: self.__tick_id = gobject.timeout_add(10, self._tick) elif delay is None and self.__repeat[0] is not None: gobject.source_remove(self.__tick_id) self.__repeat = (delay, interval)
def serve_stop(self): self.closeall_connections() if self.io_watch_tag: gobject.source_remove(self.io_watch_tag) self.close_connection(self.session)
def handle_disconnection(self, serversocket, condition): """ Handles the shutdown of connections. When the serversocket signals the HUP condition. The handler disconnects from the mainloop by returning false. This method is called when the connection was shutdown from the otherside of the connection. The data handler (L{handle_incoming_data}) for incoming data is disconnected and the disconnect signal is fired. If we are in connectable or filtered mode, we will reattach the serversocket watch for gtk.IO_IN with L{handle_connection}) as handler. @type self: BTServer @param self: The BTServer object responsible for handling the connection @type serversocket: bluetooth.BluetoothSocket @param serversocket: A bluetooth socket responsible for handling incoming connections (server side) @type condition: integer (gobject.Enum) @param condition: The condition of the serversocket which caused the handler to be called should always be gobject.IO_HUP (=16) @rtype: bool @return: always False, as we only allow one concurrent connection """ gobject.source_remove(self.client_io_watch) self.server_io_watch = None self.client_io_watch = None self.client_sock = None self.emit("disconnect", self.connected[0], self.connected[1]) self.connected = None if self.connectable == 'yes' or self.connectable == 'filtered': self.server_io_watch = gobject.io_add_watch(self.server_sock, gobject.IO_IN, self.handle_connection) bluetooth.advertise_service(self.server_sock, self.name, self.serverid) return False
def setStopCheck(self, active): "Set/unset timeout check for running processes" if active: self.timeoutCheck = gobject.timeout_add(500, self.checkIfPlaying) else: gobject.source_remove(self.timeoutCheck) self.timeoutCheck = None
def _create_progress(self): self.dialog = gtk.MessageDialog(self.parent, \ 0, 0, gtk.BUTTONS_CANCEL, self.subtitle or self.title) self.dialog.set_modal(True) self.dialog.connect('delete-event', self._on_delete_event) self.dialog.set_title(self.title) self.dialog.set_deletable(self.cancellable) # Avoid selectable text (requires PyGTK >= 2.22) if hasattr(self.dialog, 'get_message_area'): for label in self.dialog.get_message_area(): if isinstance(label, gtk.Label): label.set_selectable(False) self.dialog.set_response_sensitive(gtk.RESPONSE_CANCEL, \ self.cancellable) self.progressbar = gtk.ProgressBar() self.progressbar.set_ellipsize(pango.ELLIPSIZE_END) # If the window is shown after the first update, set the progress # info so that when the window appears, data is there already if self._initial_progress is not None: self.progressbar.set_fraction(self._initial_progress) if self._initial_message is not None: self.progressbar.set_text(self._initial_message) self.dialog.vbox.add(self.progressbar) self.indicator = SpinningProgressIndicator() self.dialog.set_image(self.indicator) self.dialog.show_all() gobject.source_remove(self.source_id) self.source_id = gobject.timeout_add(self.INTERVAL, self._update_gui) return False
def moveEnemies(self): for row in self.grid[::-1]: for label in row[::-1]: if label.enemie: if label.posX == self.posX and label.posY == self.posY: self.restart() return # game over if label.posX == 9: destX = 0 destY = label.posY + 1 gobject.source_remove(self.moveEnemieTimeout) if self.enemiesSpeed > 50: self.enemiesSpeed -= 5 self.moveEnemieTimeout = gobject.timeout_add(self.enemiesSpeed, self.moveEnemies) else: destX = label.posX + 1 destY = label.posY label.enemie = False label.set_label(BLANK) nextLabel = self.grid[destY][destX] nextLabel.set_label(ENEMIE) nextLabel.enemie = True return True
def __handle_image_load(self, url, surface): if url != self.__current_url: return self._logger.debug("loaded url=%s", url) self.emit("loaded", True) req_changed = False if self.__surface: old_width = self.__surface.get_width() old_height = self.__surface.get_height() if old_width != surface.get_width() or old_height != surface.get_height(): req_changed = True else: req_changed = True self.__transition_count = 0 if self.__transition_idle_id > 0: gobject.source_remove(self.__transition_idle_id) self.__transition_idle_id = gobject.timeout_add(100, self.__idle_step_transition) self.__prev_surface = self.__surface self.__surface = surface if req_changed: self.emit_request_changed() self.emit_paint_needed(0, 0, -1, -1)
def update(self, action=None): self.set_label(self.last_left, text_color='green') time.sleep(3) timeout = self.timeout try: stats=self.get_stats() self.last_left=int(stats['traffic_left']) except Exception: print "Update problem ... Last Left: %s" % self.last_left self.set_label(self.last_left, text_color='red') self.traffic_left_label.set_label("Traffic Left: N/A") self.money_left_label.set_label("Money: N/A") self.ip_label.set_label("IP: N/A") timeout = 10*60*1000 #10 minutes else: print "Updating... Left: %s" % self.last_left self.set_label(self.last_left) self.traffic_left_label.set_label("Traffic Left: %s Mb" % self.last_left) self.money_left_label.set_label("Money: %s" % stats['money_left']) self.ip_label.set_label("IP: %s" % stats['ip']) try: gobject.source_remove(self.source_id) except Exception: pass self.source_id = gobject.timeout_add(timeout, self.update)
def process_buffering_stats(self, message): if not self.started_buffering: self.started_buffering = True if self.fill_timeout_id: gobject.source_remove(self.fill_timeout_id) self.fill_timeout_id = gobject.timeout_add(200, self.buffering_timeout)
def close_session(self, do_exit=True): '''close session''' if self.timeout_id: gobject.source_remove(self.timeout_id) self.timeout_id = None if self.session is not None: self.session.quit() self.save_extensions_config() self._save_login_dimensions() if self.session is not None: self.session.save_config() self.session = None self.config.save(self.config_path) if self.conversations: self.conversations.get_parent().hide() self.conversations = None if do_exit: if self.tray_icon is not None: self.tray_icon.set_visible(False) self.window.hide() self.window = None while gtk.events_pending(): gtk.main_iteration(False) sys.exit(0)
def new_handle(self, reset): if self.actualizador: gobject.source_remove(self.actualizador) self.actualizador = False if reset: self.actualizador = gobject.timeout_add(1000, self.__handle)
def _timer_stop(self): if self._timer is not None: gobject.source_remove(self._timer) self._timer = None
def destroy(self): #gtk.DrawingArea.destroy(self) self.close_event() if self._idle_draw_id != 0: gobject.source_remove(self._idle_draw_id)
def cancel(self): self.cancel_event.set() gobject.source_remove(self._thread_id)
def pause(self): gobject.source_remove(self.source_id) self.elapsed_time += time.time() - self.start_time
def cancel(self): gobject.source_remove(self.source_id)
def interrupt(self): """Force the generator to stop running. """ if self.is_alive(): gobject.source_remove(self._idle_id) self._idle_id = 0
def delete_event(self, widget, event, data=None): pygame.mixer.music.stop() pygame.quit() gobject.source_remove(self.source_id) gtk.main_quit() return False
def _on_search_text_changed(self, entry): if self._search_timeout: gobject.source_remove(self._search_timeout) self._search_timeout = gobject.timeout_add(self.SEARCH_DELAY, self.update_search)
def load_clicked(self, widget, data=None): if self.cbfilter.get_model()[self.cbfilter.get_active()][0] == (_("Please select site")): self.progressbar.set_text(_("Please select site")) return stored = None dups = None partial = None errs = None ttime = None # Does the lock acquisition need to be more sophisticated for multiple dirs? # (see comment above about what to do if pipe already open) if self.settings['global_lock'].acquire(wait=False, source="GuiBulkImport"): # returns false immediately if lock not acquired #try: print _("\nGlobal lock taken ...") self.progressbar.set_text(_("Importing...")) self.progressbar.pulse() while gtk.events_pending(): # see http://faq.pygtk.org/index.py?req=index for more hints (3.7) gtk.main_iteration(False) self.timer = gobject.timeout_add(100, self.dopulse) # get the dir to import from the chooser selected = self.chooser.get_filenames() # get the import settings from the gui and save in the importer self.importer.setHandCount(int(self.spin_hands.get_text())) self.importer.setQuiet(self.chk_st_st.get_active()) self.importer.setThreads(int(self.spin_threads.get_text())) self.importer.setHandsInDB(self.n_hands_in_db) cb_model = self.cb_dropindexes.get_model() cb_index = self.cb_dropindexes.get_active() cb_hmodel = self.cb_drophudcache.get_model() cb_hindex = self.cb_drophudcache.get_active() #self.lab_info.set_markup('<span foreground="blue">Importing ...</span>') # uses pango markup! if cb_index: self.importer.setDropIndexes(cb_model[cb_index][0]) else: self.importer.setDropIndexes("auto") if cb_hindex: self.importer.setDropHudCache(cb_hmodel[cb_hindex][0]) else: self.importer.setDropHudCache("auto") sitename = self.cbfilter.get_model()[self.cbfilter.get_active()][0] #self.importer.setFailOnError(self.chk_fail.get_active()) if self.is_archive.get_active(): if sitename == "PokerStars": self.importer.setStarsArchive(True) if sitename == "Full Tilt Poker": self.importer.setFTPArchive(True) for selection in selected: self.importer.addBulkImportImportFileOrDir(selection, site = sitename) self.importer.setCallHud(self.cb_testmode.get_active()) self.importer.bHudTest = self.cb_testmode.get_active() starttime = time() # try: (stored, dups, partial, errs, ttime) = self.importer.runImport() # except: # print "*** EXCEPTION DURING BULKIMPORT!!!" # raise Exceptions.FpdbError # finally: gobject.source_remove(self.timer) ttime = time() - starttime if ttime == 0: ttime = 1 completionMessage = _('Bulk import done: Stored: %d \tDuplicates: %d \tPartial: %d \tErrors: %d in %s seconds - %.0f/sec')\ % (stored, dups, partial, errs, ttime, (stored+0.0) / ttime) print completionMessage log.info(completionMessage) self.importer.clearFileList() if self.n_hands_in_db == 0 and stored > 0: self.cb_dropindexes.set_sensitive(True) self.cb_dropindexes.set_active(0) self.lab_drop.set_sensitive(True) self.cb_drophudcache.set_sensitive(True) self.cb_drophudcache.set_active(0) self.lab_hdrop.set_sensitive(True) self.progressbar.set_text(_("Import Complete")) self.progressbar.set_fraction(0) #except: #err = traceback.extract_tb(sys.exc_info()[2])[-1] #print "*** BulkImport Error: "+err[2]+"("+str(err[1])+"): "+str(sys.exc_info()[1]) #self.settings['global_lock'].release() self.settings['global_lock'].release() else: print _("bulk import aborted - global lock not available")
def disable(self): # Clear old tags self.buffer.remove_tag(self.search_tag, self.buffer.get_start_iter(), self.buffer.get_end_iter()) if self.changed_source is not None: gobject.source_remove(self.changed_source)
def _watch_remove(self): if self._source_id is not None: gobject.source_remove(self._source_id) self._source_id = None self._source_condition = 0
def __on_tap_hold(self, px, py): if (self.__zoom_handler): gobject.source_remove(self.__zoom_handler) self.__zoom_handler = gobject.timeout_add(50, self.__on_zoom_gesture, -1)
def __timeout_remove(self): if self.__timeout_id != 0: gobject.source_remove(self.__timeout_id) self.__timeout_id = 0
def enable(self): if self.timer is None: raise AssertionError("disable() must be called before enable()") gobject.source_remove(self.timer) self.timer = None
def on_finished(self): if self.dialog is not None: self.dialog.destroy() gobject.source_remove(self.source_id)
def cleanup_callback(self, win): if self.timeout_id is not None: gobject.source_remove(self.timeout_id) self.timeout_id = None
def __on_release(self, px, py, kscr): kscr.set_enabled(True) if (self.__zoom_handler): gobject.source_remove(self.__zoom_handler)
def play_sim(self): gobject.source_remove( self.sim_event_source ) # this ensures multiple calls to play_sim do not speed up the simulator self._run_sim() self.viewer.control_panel_state_playing()
def cancel_pulse(self): """ Stop pulsing the progress bar, if it is pulsing. """ if self.pulse_timer: gobject.source_remove(self.pulse_timer) self.pulse_timer = 0
def click_animation_stop(self): """ Stops the mouse click animation """ assert(self.__is_click_animation_playing()) gobject.source_remove(self.timer_click) self.timer_click = None
def pause_sim(self): gobject.source_remove(self.sim_event_source) self.viewer.control_panel_state_paused()
def dormir(self): """para de contar minutos""" self.ind.set_icon("face-tired") gobject.source_remove(self.timeout_id) self.ind.set_label('') self.ind.set_status(appindicator.STATUS_ACTIVE)
def end_sim(self, alert_text=''): gobject.source_remove(self.sim_event_source) self.viewer.control_panel_state_finished(alert_text)
def time_stop(self, play): """Stop play pressed""" if self.playTimer: gobject.source_remove(self.playTimer) self.playTimer = None
def scroll_animation_stop(self): """ Stops the mouse wheel scroll animation """ assert(self.__is_scroll_animation_playing()) gobject.source_remove(self.timer_scroll) self.timer_scroll = None
def restart_timer(self): print "timer reset" gobject.source_remove(self.timer_source_id) self.timer_source_id = gobject.timeout_add(self.RATE_OF_CALLBACK, self.timeout_callback)
def _abortScheduledCheck(self): if self._idleId != -1: gobject.source_remove(self._idleId) self._idleId = -1
def after_cancel(t): if t is not None: gobject.source_remove(t)
def fade_start(self): """start fading timer""" self.fade_level = 1.0 if self.idle: gobject.source_remove(self.idle) self.idle = gobject.timeout_add(25, self.fade_out)