Beispiel #1
0
 def export(cls, filename, cube, options=None, progress=None):
     if options is None:
         options = dict()
     if 'interleave' not in options:
         root, ext = os.path.splitext(filename)
         if ext:
             options['interleave'] = ext[1:].lower()
     url = vfs.normalize(filename)
     dprint("writing cube to %s" % url)
     fh = vfs.open_write(url)
     cube.writeRawData(fh, options, progress)
     fh.close()
     
     headername = vfs.normalize(getCanonicalHeader(str(url)))
     dprint("writing header to %s" % headername)
     c = copy.copy(cube)
     for k, v in options.iteritems():
         setattr(c, k, v)
     c.data_offset = 0
     c.header_offset = 0
     c.file_offset = 0
     print c
     h = Header()
     h.getCubeAttributes(c)
     hfh = vfs.open_write(headername)
     hfh.write(str(h))
     hfh.close()
Beispiel #2
0
    def export(cls, filename, cube, options=None, progress=None):
        if options is None:
            options = dict()
        if 'interleave' not in options:
            root, ext = os.path.splitext(filename)
            if ext:
                options['interleave'] = ext[1:].lower()
        url = vfs.normalize(filename)
        dprint("writing cube to %s" % url)
        fh = vfs.open_write(url)
        cube.writeRawData(fh, options, progress)
        fh.close()

        headername = vfs.normalize(getCanonicalHeader(str(url)))
        dprint("writing header to %s" % headername)
        c = copy.copy(cube)
        for k, v in options.iteritems():
            setattr(c, k, v)
        c.data_offset = 0
        c.header_offset = 0
        c.file_offset = 0
        print c
        h = Header()
        h.getCubeAttributes(c)
        hfh = vfs.open_write(headername)
        hfh.write(str(h))
        hfh.close()
Beispiel #3
0
 def savePrefs(self):
     try:
         fh = vfs.open_write(self.project_config)
         text = self.configToText()
         fh.write(text)
     except:
         self.dprint("Failed writing project config file")
Beispiel #4
0
 def finishedCallback(self, job):
     """Callback from the JobOutputMixin when the job terminates."""
     del self.process
     fh = vfs.open_write(self.dot_output)
     fh.write(self.preview.getvalue())
     fh.close()
     self.frame.findTabOrOpen(self.dot_output)
Beispiel #5
0
 def savePrefs(self):
     try:
         fh = vfs.open_write(self.project_config)
         text = self.configToText()
         fh.write(text)
     except:
         self.dprint("Failed writing project config file")
Beispiel #6
0
 def action(self, index=-1, multiplier=1):
     url = ProjectPlugin.findProjectSettingsURL(self.mode)
     if url:
         locals = self.mode.classprefsDictFromLocals()
         fh = vfs.open_write(url)
         pickle.dump(locals, fh)
         fh.close()
Beispiel #7
0
 def action(self, index=-1, multiplier=1):
     base = ProjectPlugin.findProjectConfigDir(self.mode)
     if base:
         url = base.resolve2(ProjectPlugin.classprefs.default_settings_file_name)
         locals = self.mode.classprefsDictFromLocals()
         fh = vfs.open_write(url)
         pickle.dump(locals, fh)
         fh.close()
Beispiel #8
0
 def saveTemporaryCopy(self, temp_url):
     self.dprint(u"Saving backup copy to %s" % temp_url)
     try:
         self.stc.prepareEncoding()
         fh = vfs.open_write(temp_url)
         self.stc.writeTo(fh, temp_url)
         fh.close()
     except Exception, e:
         self.dprint(u"Failed autosaving to %s with %s" % (temp_url, e))
Beispiel #9
0
 def save(self, url):
     """Save this macro to the specified macro: url
     
     """
     dprint("Saving to %s" % url)
     self.rebuildMacroAndMetadata()
     fh = vfs.open_write(url)
     fh.write(self.data)
     fh.close()
Beispiel #10
0
 def saveTemporaryCopy(self, temp_url):
     self.dprint(u"Saving backup copy to %s" % temp_url)
     try:
         self.stc.prepareEncoding()
         fh = vfs.open_write(temp_url)
         self.stc.writeTo(fh, temp_url)
         fh.close()
     except Exception, e:
         self.dprint(u"Failed autosaving to %s with %s" % (temp_url, e))
Beispiel #11
0
 def save(self, url):
     dprint("Saving to %s" % url)
     fh = vfs.open_write(url)
     self.cube.scale_factor = self.scale
     self.cube.writeRawData(fh, options={'interleave': self.output_interleave})
     enviheader = ENVI.Header()
     enviheader.getCubeAttributes(self.cube)
     enviheader['interleave'] = self.output_interleave
     pathname = str(url) + ".hdr"
     enviheader.save(pathname)
Beispiel #12
0
 def save(cls, url):
     bytes = cls.packVersion1()
     fh = vfs.open_write(url)
     fh.write(bytes)
     fh.close()
Beispiel #13
0
 def openFileForWriting(self, url):
     return vfs.open_write(url)