Esempio n. 1
0
 def save(self, filename, data, mode='wb', overwriteNewer=False):
     if filename != self.currentFilename():
         self.ftpObj.path = os.path.dirname(filename)
         self.ftpObj.name = os.path.basename(filename)
     try:
         self.ftpConn.save(self.ftpObj, data)
     except Exception, error:
         raise ExplorerNodes.TransportSaveError(error, self.ftpObj.whole_name())
Esempio n. 2
0
 def save(self, filename, data, mode='wb', overwriteNewer=False):
     if filename != self.resourcepath:
         self.name = os.path.basename(filename)
         self.resourcepath = filename
         self.initResource()
     try:
         self.checkResp(self.resource.put(data))
     except Exception, error:
         raise ExplorerNodes.TransportSaveError(error, self.resourcepath)
Esempio n. 3
0
 def save(self, filename, data, mode='wb', overwriteNewer=False):
     if self.resourcepath != filename:
         self.resourcepath = filename
         self.name = os.path.basename(self.resourcepath)
     try:
         if not overwriteNewer and self.fileIsNewer():
             raise ExplorerNodes.TransportModifiedSaveError(
                 _('This file has '
                   'been saved by someone else since it was loaded'),
                 self.resourcepath)
         open(self.resourcepath, mode).write(data)
     except IOError, error:
         raise ExplorerNodes.TransportSaveError(error, self.resourcepath)
Esempio n. 4
0
 def save(self, filename, data, mode='wb', overwriteNewer=False):
     from FileExplorer import FileSysNode
     import tempfile
     name = os.path.basename(self.resourcepath)
     fn = tempfile.mktemp()
     p, n = os.path.split(fn)
     fn = os.path.join(p, 'X'+n)
     try:
         open(fn, mode).write(data)
         try:
             parentDir = os.path.dirname(self.resourcepath)
             parentName = os.path.basename(parentDir)
             parentSSHNode = self.createChildNode(parentName, 1,
                   self.properties, parentDir)
             parentSSHNode.copyFromFS(FileSysNode('', fn, None, -1), name)
         finally:
             os.remove(fn)
     except Exception, error:
         raise ExplorerNodes.TransportSaveError(error, self.resourcepath)