• Facebook
  • Twitter
  • Reddit
  • StumbleUpon
  • Digg
  • email

All Samples(8064)  |  Call(7565)  |  Derive(0)  |  Import(499)
Recursively delete a directory tree.

If ignore_errors is set, errors are ignored; otherwise, if onerror
is set, it is called to handle the error with arguments (func,
path, exc_info) where func is os.listdir, os.remove, or os.rmdir;
path is the argument to that function that caused it to fail; and
exc_info is a tuple returned by sys.exc_info().  If ignore_errors
is false and onerror is None, an exception is raised.

        def rmtree(path, ignore_errors=False, onerror=None):
    """Recursively delete a directory tree.

    If ignore_errors is set, errors are ignored; otherwise, if onerror
    is set, it is called to handle the error with arguments (func,
    path, exc_info) where func is os.listdir, os.remove, or os.rmdir;
    path is the argument to that function that caused it to fail; and
    exc_info is a tuple returned by sys.exc_info().  If ignore_errors
    is false and onerror is None, an exception is raised.

    """
    if ignore_errors:
        def onerror(*args):
            pass
    elif onerror is None:
        def onerror(*args):
            raise
    try:
        if os.path.islink(path):
            # symlinks to directories are forbidden, see bug #1669
            raise OSError("Cannot call rmtree on a symbolic link")
    except OSError:
        onerror(os.path.islink, path, sys.exc_info())
        # can't continue even if onerror hook returns
        return
    names = []
    try:
        names = os.listdir(path)
    except os.error, err:
        onerror(os.listdir, path, sys.exc_info())
    for name in names:
        fullname = os.path.join(path, name)
        try:
            mode = os.lstat(fullname).st_mode
        except os.error:
            mode = 0
        if stat.S_ISDIR(mode):
            rmtree(fullname, ignore_errors, onerror)
        else:
            try:
                os.remove(fullname)
            except os.error, err:
                onerror(os.remove, fullname, sys.exc_info())
    try:
        os.rmdir(path)
    except os.error:
        onerror(os.rmdir, path, sys.exc_info())
        


src/d/j/django-photos-0.2.9/src/photos/models.py   django-photos(Download)
from hashlib import sha224
import random
from django.db.models.signals import pre_delete, pre_save
from shutil import rmtree
 
def get_upload_to(instance, filename):
    dirs = datetime.datetime.now().strftime("photos/%y/%j/%H/%M/%S")
    except ValueError, e:
        pass # silently
    else:
        rmtree(path=abspath(dirname(path)), ignore_errors=True)
 
pre_delete.connect(pre_delete_photo, sender=Photo)
 

src/c/a/cargo-HEAD/src/python/cargo/io.py   cargo(Download)
def mkdtemp_scoped(*args, **kwargs):
    """
    Create a temporary directory, with support for cleanup.
    """
 
    from shutil   import rmtree
    from tempfile import mkdtemp
        yield path
    finally:
        if path is not None:
            rmtree(path, ignore_errors = True)
 
@contextmanager
def env_restored(unset = []):

src/f/u/fuzzpy-HEAD/setup.py   fuzzpy(Download)
 
from setuptools import setup
from distutils.cmd import Command
from shutil import rmtree
from glob import glob
import os
import sys
    def run(self):
        rmtree('doc', ignore_errors=True)
        os.mkdir('doc')
        # okay, this is a bit of a hack
        sys.argv = ['epydoc', '-v', '--name', NAME, '--url', URL, '-o', 'doc', PACKAGE]
        options, names = epydoc.cli.parse_arguments()
        epydoc.cli.main(options, names)

src/z/i/zicbee-0.9-rc5/zicbee/db/dbe.py   zicbee(Download)
        if  archive is not None:
            from tarfile import TarFile
            from tempfile import mkdtemp
            from shutil import rmtree
            tar = TarFile.open(archive)
            tmp = mkdtemp()
            try:
                        db.insert(**entry_dict)
                        yield '.'
            finally:
                rmtree(tmp, ignore_errors=True)
 
        db.commit()
 

src/e/z/ezgallery-HEAD/trunk/util/create_dist.py   ezgallery(Download)
import os
from os.path import join
import re
from shutil import copy, copytree, rmtree
import sys
import zipfile
 
    # copy the help directory
    #
    copytree('../help', join(prog_dir, 'help'), False)
    rmtree(join(prog_dir, 'help', 'CVS'), True)
    rmtree(join(prog_dir, 'help', 'images', 'CVS'), True)
 
    # copy any important text files

src/e/z/ezgallery-HEAD/util/create_dist.py   ezgallery(Download)
import os
from os.path import join
import re
from shutil import copy, copytree, rmtree
import sys
import zipfile
 
    # copy the help directory
    #
    copytree('../help', join(prog_dir, 'help'), False)
    rmtree(join(prog_dir, 'help', 'CVS'), True)
    rmtree(join(prog_dir, 'help', 'images', 'CVS'), True)
 
    # copy any important text files

src/g/a/gajim-HEAD/setup_osx.py   gajim(Download)
from setuptools import setup
import sys, glob, os, commands, types
from os import system, unlink, symlink, getcwd, mkdir, utime
from shutil import move, copy, copytree, rmtree
 
###
### Globals
def cleanup():
	force(lambda:rmtree("build"))
	force(lambda:rmtree("dist"))
 
def stageInstall():
	check(system("make DATADIR=%s/build/inst LIBDIR=%s/build/inst prefix=%s/build/inst DOCDIR=%s/build/inst/share/doc install" % (PWD, PWD, PWD, PWD)))
	force(lambda:unlink("src/osx/growl/_growl.so"))
	# Nuke libs that are in the framework
	move("dist/Gajim.app/Contents/Frameworks/Python.framework",
		 "dist/Gajim.app/Contents/Python.framework")
	rmtree("dist/Gajim.app/Contents/Frameworks")
	mkdir("dist/Gajim.app/Contents/Frameworks")
	move("dist/Gajim.app/Contents/Python.framework",
		 "dist/Gajim.app/Contents/Frameworks/Python.framework")
def distApp():
	force(lambda:rmtree("dist/Gajim"))
	force(lambda:rmtree("dist/Gajim.tar.bz2"))
	mkdir("dist/Gajim")
	check(system("tar -cf - -C dist Gajim.app | tar -xf - -C dist/Gajim"))
	copy("README.osx", "dist/Gajim/README")
	copy("TODO.osx", "dist/Gajim/TODO")
	check(system("tar -C dist -jcf dist/Gajim-OSX-`date | awk '{printf(\"%s-%s-%s\", $6, $2, $3);}'`.tar.bz2 Gajim"))
	rmtree("dist/Gajim")

src/d/e/defis-HEAD/work/defis/ic/utils/ic_file.py   defis(Download)
from os.path import getatime as GetAccessFileTime
from os.path import getsize as GetFileSize
 
from shutil import rmtree as RemoveTreeDir
from shutil import copytree as CopyTreeDir
 
from sys import path as PATH
    try:
        to_dir=ToDir_+'/'+BaseName(Dir_)
        if Exists(to_dir) and ReWrite_:
            shutil.rmtree(to_dir, 1)
        if AddDir_:
            return addCopyDir(Dir_,to_dir)
        else:
        #print 'CloneDir >>>',Dir_,NewDir_
 
        if Exists(NewDir_) and ReWrite_:
            shutil.rmtree(NewDir_, 1)
        MakeDirs(NewDir_)
        for sub_dir in GetSubDirs(Dir_):
            shutil.copytree(sub_dir,NewDir_)

src/e/z/ezgallery-HEAD/trunk/create_win.py   ezgallery(Download)
# For questions or comments about the software contact: jakim@friant.org
import os
from os.path import join
from shutil import copy, copytree, rmtree
import sys
from libezg import debug
 
        #
        print "STATUS: removing old distribution directory"
        try:
            rmtree(join(root, "windows", "dist"))
        except Exception, val:
            print "No directory to remove [", val, "]"
        print "STATUS: running setup script."
        cmd = "c:\\python23\\python setup.py py2exe"
        debug.report("Debug", "create_win.main", "cmd", cmd)
        os.system(cmd)
        print "STATUS: cleaning up."
        try:
            rmtree("build")

src/o/p/openerp-server-5.0.0-3/bin/service/web_services.py   openerp-server(Download)
 
            zips = rc.retrieve_updates(rc.id, addons.get_modules_with_version())
 
            from shutil import rmtree, copytree, copy
 
            backup_directory = os.path.join(tools.config['root_path'], 'backup', time.strftime('%Y-%m-%d-%H-%M'))
            if zips and not os.path.isdir(backup_directory):
                        if os.path.islink(mp):
                            os.unlink(mp)
                        else:
                            rmtree(mp)
                    else:
                        copy(mp + 'zip', backup_directory)
                        os.unlink(mp + '.zip')
                            tools.extract_zip_file(zip_contents, tools.config['addons_path'] )
                        except:
                            l.notifyChannel('migration', netsvc.LOG_ERROR, 'unable to extract the module %s' % (module, ))
                            rmtree(module)
                            raise
                    finally:
                        zip_contents.close()

  1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9  Next