def readBundle(self, loader=None): length = self.readInt() if length < 0: return None bundle = Bundle(self, length) if loader != None: bundle.setClassLoader(loader) return bundle
def readBundle(self, loader=None): length = self.readInt() if length < 0: return None bundle = Bundle(self, length) __builtin__.json_output[ __builtin__.debugid ]['Extras'].append( { "Type":"bundle", "Value":bundle } ) if loader != None: bundle.setClassLoader(loader) return bundle
def __init__(self, handle): activity.Activity.__init__(self, handle) self._name = handle # Set up logging. We're sending messages to the default log directory, # which can be browsed with the Log activity. self._logger = logging.getLogger('bundle.BundleActivity') self._logger.setLevel(logging.DEBUG) # Show ALL messages # self._logger.setLevel(logging.WARNING) # Ignore DEBUG/INFO msgs self._logger.debug("Initializing BundleActivity.") # Set title for our Activity self.set_title('Bundle Activity') # Attach sugar toolbox (Share, ...) toolbox = activity.ActivityToolbox(self) self.set_toolbox(toolbox) #toolbox.show() self.activity_toolbar = toolbox.get_activity_toolbar() #create toolbar self.main_toolbar = gtk.Toolbar() #self.main_toolbar.show() toolbox.add_toolbar(_('Bundle'), self.main_toolbar) toolbox.set_current_toolbar(1) toolbox.show() # Create the main container self._main_view = gtk.VBox() # Import our class Bundle(): # Step 1: Load class, which creates Bundle.widget self.myBundle = Bundle(None) self._logger.debug("Bundle instance created.") self.myBundle.parent = self self.myGUI = GUI(self) self.myGUI.xid = handle self.myGUI.myBundle = self.myBundle self.myGUI.set_bundle(self.myBundle) #self.myGUI.parent = self # Step 3: We attach that widget to our window self._main_view.pack_start(self.myGUI.widget) # Display everything self.myGUI.widget.show() self._main_view.show() self.set_canvas(self._main_view) self.show_all() self.scratchDir = os.path.join(self.get_activity_root(), 'instance') self._logger.debug("Scratch dir is %s", self.scratchDir) self._logger.debug("__init__() finished") self.activityRegistry = ActivityRegistry()
def newBundle(): bundleName = request.get_json().get('bundleName', None) bundleDescription = request.get_json().get('bundleDescription', None) userId = request.get_json().get('userId', None) companyId = request.get_json().get('companyId', None) bundleId = config.bundleTable.count() if bundleId == None or bundleName == None or userId == None: logging.error("bundleName, bundleId or userId is undefined") abort(make_response("bundleName, bundleId or userId is undefined", 404)) bundle = Bundle(bundleId, bundleName, userId) bundle.companyId = companyId bundle.description = bundleDescription config.bundleTable.insert(bundle.__dict__) requestResult = config.bundleTable.find_one({"bundleId": bundleId}) return mongodoc_jsonify(requestResult)
def newBundle(): bundleName = request.get_json().get('bundleName', None) bundleDescription = request.get_json().get('bundleDescription', None) userId = request.get_json().get('userId', None) companyId = request.get_json().get('companyId', None) bundleId = str(ObjectId()) if bundleId == None or bundleName == None or userId == None: logging.error("bundleName, bundleId or userId is undefined") abort(make_response("bundleName, bundleId or userId is undefined", 404)) bundle = Bundle(bundleId, bundleName, userId) bundle.companyId = companyId bundle.description = bundleDescription config.bundleTable.insert(bundle.__dict__) requestResult = config.bundleTable.find_one({"bundleId": bundleId}) return mongodoc_jsonify(requestResult)
def testFUDI(): message = OSC.OSCMessage() message.setAddress("/foo/play") message.append(44) message.append(11) message.append(4.5) #message.append(True) #message.append(None) message.append("the white shiny cliffs of dover") print("org: %s" % (message)) for a in getFUDI(message): o=getOSC(a) print("%s -> %s" % (a,o)) bundle = OSCBundle() bundle.append(message) bundle+=message print("bundle: %s" % (bundle)) for a in getFUDI(bundle): o=getOSC(a) print("%s -> %s" % (a,o))
class BundleActivity(activity.Activity): zip_mime = ["application/x-zip", "application/zip", "application/x-zip-compressed"] _logger = None def __init__(self, handle): activity.Activity.__init__(self, handle) self._name = handle # Set up logging. We're sending messages to the default log directory, # which can be browsed with the Log activity. self._logger = logging.getLogger('bundle.BundleActivity') self._logger.setLevel(logging.DEBUG) # Show ALL messages # self._logger.setLevel(logging.WARNING) # Ignore DEBUG/INFO msgs self._logger.debug("Initializing BundleActivity.") # Set title for our Activity self.set_title('Bundle Activity') # Attach sugar toolbox (Share, ...) toolbox = activity.ActivityToolbox(self) self.set_toolbox(toolbox) #toolbox.show() self.activity_toolbar = toolbox.get_activity_toolbar() #create toolbar self.main_toolbar = gtk.Toolbar() #self.main_toolbar.show() toolbox.add_toolbar(_('Bundle'), self.main_toolbar) toolbox.set_current_toolbar(1) toolbox.show() # Create the main container self._main_view = gtk.VBox() # Import our class Bundle(): # Step 1: Load class, which creates Bundle.widget self.myBundle = Bundle(None) self._logger.debug("Bundle instance created.") self.myBundle.parent = self self.myGUI = GUI(self) self.myGUI.xid = handle self.myGUI.myBundle = self.myBundle self.myGUI.set_bundle(self.myBundle) #self.myGUI.parent = self # Step 3: We attach that widget to our window self._main_view.pack_start(self.myGUI.widget) # Display everything self.myGUI.widget.show() self._main_view.show() self.set_canvas(self._main_view) self.show_all() self.scratchDir = os.path.join(self.get_activity_root(), 'instance') self._logger.debug("Scratch dir is %s", self.scratchDir) self._logger.debug("__init__() finished") self.activityRegistry = ActivityRegistry() #self.myGUI.statusBar.set_text(self._logger.get_logs_dir()) def write_file(self, file_path): self._logger.debug("write_file() called with path = %s", file_path) if self.myBundle.status == self.myBundle.unpacked: # this means we have a list of items to save, so the mime-type # will be set to "application/x-zebra self.metadata['mime_type'] = "application/x-zebra" f = open(file_path, 'w') for (item) in self.myBundle.objList: f.write(item.object_id + "\n") f.close() elif self.myBundle.status == self.myBundle.packed: x = 1 def get_temp_files(self): self._logger.debug("get_temp_files called") for (item) in self.myBundle.objList: if item.status == self.myBundle.notInZip: self._logger.debug("Getting file for object = %s", item.object_id) jobject = datastore.get(item.object_id) filename = jobject.file_path self._logger.debug("Copying file %s", filename) ext = os.path.splitext(filename)[1] self._logger.debug("File extension = %s", ext) f, temp_file = tempfile.mkstemp(ext, prefix= jobject.metadata['title']+"_HASH", dir = self.scratchDir) # the changes to the line above should preserve and uniquify our filenames ~J #Might be more sensible to use the file name, but I think this'll work............... self._logger.debug("Copying %s", jobject.metadata['title']) if (os.path.exists(filename)): shutil.copy(filename, temp_file) self._logger.debug("Copying DONE"); self.myBundle.tempFileList.append((temp_file, jobject.metadata['title'])) else: self._logger.debug("Item %s does not have a file associated", jobject.metadata['title']) jobject.destroy() # this segment right here handles modified archives # basically modification is also handled when we click "Pack" (after adding new items) # just that here we unpack the existing files in the archive to put them in a new archive # file. Files flagged with the "to_delete" flag are not extracted if (self.myBundle.status == self.myBundle.packed): self._logger.debug("Attempting to re-pack the archive") # extract all the files that are not flagged as "TO DELETE" for (item) in self.myBundle.objList: self._logger.debug("Found item with title %s and to_delete %s", item.title, item.to_delete) if ((item.status == self.myBundle.inZip) and (item.to_delete == False)): try: f, temp_file = tempfile.mkstemp(item.ext, prefix= item.title+"_HASH", dir = self.scratchDir) del f; f = open(temp_file, 'wb') f.write(self.myBundle.extractOne(item)) f.close() self.myBundle.tempFileList.append((temp_file, " ")) except Exception, e: self._logger.error("EXCEPTION: %s", str(e))