def clear(self): """ Clears all of the badges that have been awarded by an activity WARNING: badges will be lost forever, used to testing purposes """ self._list.destory() datastore.delete(self._list.object_id)
def __notify_state_cb(self, file_transfer, pspec): if file_transfer.props.state == filetransfer.FT_STATE_OPEN: logging.debug('__notify_state_cb OPEN') self._ds_object.metadata['title'] = file_transfer.title self._ds_object.metadata['description'] = file_transfer.description self._ds_object.metadata['progress'] = '0' self._ds_object.metadata['keep'] = '0' self._ds_object.metadata['buddies'] = '' self._ds_object.metadata['preview'] = '' self._ds_object.metadata['icon-color'] = \ file_transfer.buddy.props.color.to_string() self._ds_object.metadata['mime_type'] = file_transfer.mime_type elif file_transfer.props.state == filetransfer.FT_STATE_COMPLETED: logging.debug('__notify_state_cb COMPLETED') self._ds_object.metadata['progress'] = '100' self._ds_object.file_path = file_transfer.destination_path datastore.write(self._ds_object, transfer_ownership=True, reply_handler=self.__reply_handler_cb, error_handler=self.__error_handler_cb) elif file_transfer.props.state == filetransfer.FT_STATE_CANCELLED: logging.debug('__notify_state_cb CANCELLED') object_id = self._ds_object.object_id if object_id is not None: self._ds_object.destroy() datastore.delete(object_id) self._ds_object = None
def remove_all_downloads(): for download in _active_downloads: download.cancelable.cancel(NS_ERROR_FAILURE) if download.dl_jobject is not None: download.datastore_deleted_handler.remove() datastore.delete(download.dl_jobject.object_id) download.cleanup_datastore_write()
def delete_entry(self, widget): treeView = self.viewer.get_treeView() treeselection = treeView.get_selection() model, selection = treeselection.get_selected() row = model[selection] ds_object = datastore.get(row[0]) ds_object.destroy() datastore.delete(ds_object.object_id) model.remove(selection)
def remove_badges(self): """ Removes all of the user's badges from their Sash """ # Find all of the activities that award badges ds_objects, num_objects = datastore.find( {'has_badges': 'True'}) for x in range(num_objects): ds_objects[x].destroy() datastore.delete(ds_objects[x].object_id)
def removeMediaFromDatastore(recd): #before this method is called, the media are removed from the file if not recd.datastoreId or not recd.datastoreOb: return try: recd.datastoreOb.destroy() datastore.delete(recd.datastoreId) recd.datastoreId = None recd.datastoreOb = None finally: #todo: add error message here pass
def __start_response_cb(self, alert, response_id): global _active_downloads if response_id is gtk.RESPONSE_CANCEL: logging.debug('Download Canceled') self.cancelable.cancel(NS_ERROR_FAILURE) try: self.datastore_deleted_handler.remove() datastore.delete(self._object_id) except Exception, e: logging.warning('Object has been deleted already %s' % e) if self.dl_jobject is not None: self.cleanup_datastore_write() if self._stop_alert is not None: self._activity.remove_alert(self._stop_alert)
def __stop_dialog_response_cb(self, alert, response_id): if response_id == gtk.RESPONSE_OK: title = alert.entry.get_text() if self._is_resumed and \ title == self._original_title: datastore.delete(self._jobject_old.get_object_id()) self._jobject.metadata['title'] = title self._do_close(False) if response_id == gtk.RESPONSE_ACCEPT: datastore.delete(self._jobject.get_object_id()) self._do_close(True) if response_id == gtk.RESPONSE_CANCEL: for button in self._stop_buttons: button.set_sensitive(True) self.remove_alert(alert)
def on_delete_clicked(self, widget): if self.selected_name != None: count = 0 for obj in self.model: if obj[0] == self.selected_name: iterator = self.model.iter_nth_child(None, count) self.model.remove(iterator) count += 1 ds_objects, num_objects = datastore.find({ 'title': self.selected_name, 'TimeLapse': 'yes' }) for i in xrange(0, num_objects, 1): print 'DELETING ' + ds_objects[i].metadata['title'] + '...' ds_objects[i].destroy() datastore.delete(ds_objects[i].object_id) self.MainImage.clear() self.get_widget('name_entry').set_text('') description_buffer = gtk.TextBuffer(table=None) description_buffer.set_text('') self.get_widget("description_entry").set_buffer(description_buffer)
def write_file(self, file_path): global SERIALNUMBER global store global online global quitflag f = open(file_path, 'w') f.write('this is a dummy file') f.close() if quitflag: return else: quitflag = True action_request = 5 status = 4 today = strftime(DATEFORMAT)[:10] if online: self.viewer.set_label('closing - online') print 'can_close online' #now the real work begins remove_list = [] wcount = 0 acount = 0 for row in store: self.viewer.set_label('reviewing status: ' + row[0]) #action_request = 0: no action #action_request = +2: download #action_request = +1: upload #action_request = -1: remove if row[status] == 'White': print 'today', today, 'mtime', row[3] if row[3].find(today) < 0: row[action_request] = -1 wcount += 1 if row[status] == 'Red': row[action_request] = +1 if row[action_request] < 0: acount += 1 remove_list.append(row[0]) if online: if row[action_request] == 1 and row[status] == 'Red': #upload it self.viewer.set_label('reviewing status: ' + row[0] + ' upload') mname = row[0] + '.metadata' fname = row[0] srcm = LOCALPATH / mname srcf = LOCALPATH / fname if srcm.exists() and srcf.exists(): pfx = SERIALNUMBER + '@schoolserver:' dst = STOREPATH / SERIALNUMBER cmd = 'scp ' + srcm + ' ' + pfx + dst print 'metadata upload', cmd subprocess.call(cmd, shell=True) cmd = 'scp ' + srcf + ' ' + pfx + dst print 'file upload', cmd subprocess.call(cmd, shell=True) else: print 'upload request but no document', row[1], srcf if row[action_request] > 1 and row[status] == "Green": #download from schoolserver self.viewer.set_label('reviewing status: ' + row[0] + ' download') mname = row[0] + '.metadata' fname = row[0] dst = LOCALPATH pfx = SERIALNUMBER + '@schoolserver:' src = STOREPATH / SERIALNUMBER / mname cmd = 'scp ' + pfx + src + ' ' + dst print 'metadata download', cmd subprocess.call(cmd, shell=True) src = STOREPATH / SERIALNUMBER / fname cmd = 'scp ' + pfx + src + ' ' + dst print 'file download', cmd subprocess.call(cmd, shell=True) if row[action_request] > 1 and row[status] == "cyan": #download from Commons self.viewer.set_label('reviewing status: ' + row[0] + ' download') #if mime_type is activity - install it mname = row[0] + '.metadata' fname = row[0] dst = LOCALPATH pfx = SERIALNUMBER + '@schoolserver:' src = COMMONSPATH / mname cmd = 'scp ' + pfx + src + ' ' + dst print 'metadata download', cmd subprocess.call(cmd, shell=True) src = COMMONSPATH / fname cmd = 'scp ' + pfx + src + ' ' + dst print 'file download', cmd subprocess.call(cmd, shell=True) if row[action_request] == 1 and row[status] == 'cyan': #upload entry to Commons self.viewer.set_label('reviewing status: ' + row[0] + ' upload') #if mime_type is activity - install it mname = row[0] + '.metadata' fname = row[0] dst = COMMONSPATH / mname pfx = SERIALNUMBER + '@schoolserver:' src = LOCALPATH / mname cmd = 'scp ' + src + ' ' + pfx + dst print 'metadata upload', cmd subprocess.call(cmd, shell=True) src = LOCALPATH / fname cmd = 'scp ' + src + ' ' + pfx + dst print 'file upload', cmd subprocess.call(cmd, shell=True) #now remove self.viewer.set_label('removing files ...') print 'removing:' , len(remove_list) print 'white entries:', wcount print 'appended:', acount count = 0 for obj in remove_list: ds_object = datastore.get(obj) if ds_object: ds_object.destroy() datastore.delete(ds_object.object_id) count += 1 else: print 'obj not found', obj txt = 'done ' + str(count) + ' files deleted' self.viewer.set_label(txt) print txt
def delete_button_press_event_cb(self, entry, event): datastore.delete(self.selected_journal_entry.object_id)
def delete_jobject_id_from_datastore(self, jobject_id): try: datastore.delete(jobject_id) except Exception, e: _logger.debug('delete_jobject_id_from_datastore error: %s' % e)
def delete_jobject_id_from_datastore(self,jobject_id): try: datastore.delete(jobject_id) except Exception,e: _logger.debug('delete_jobject_id_from_datastore error: %s'%e)