Exemplo n.º 1
0
def restore(trashed_file, path_exists, fs):
    if path_exists(trashed_file.path):
        raise IOError('Refusing to overwrite existing file "%s".' % os.path.basename(trashed_file.path))
    else:
        parent = os.path.dirname(trashed_file.path)
        fs.mkdirs(parent)

    fs.move(trashed_file.original_file, trashed_file.path)
    fs.remove_file(trashed_file.info_file)
Exemplo n.º 2
0
 def save(self):
     import fs
     try:
         BACKUP = "/tmp/new_settings.ini"
         #save to an alternate file to assure no data loss
         with open(BACKUP, "w") as configfile:
             self.config.write(configfile)
         fs.delete(self.name)
         fs.move(BACKUP,self.name)
         return True
     except:
         fs.delete(BACKUP)