Ensures that the private directory exists and is a directory.

    :param str app_name: the name of the app
438725
def ensure_private_dir_exists(app_name):
    
    path = private_dir_path(app_name)
    if not os.path.exists(path):
        os.makedirs(path)
    else:
        if not os.path.isdir(path):
            raise PrivateDirConflictError
905174
def _verify_app_source_dir(src_dir, mode, enforce=True):
    
    temp_dir = tempfile.mkdtemp(prefix='dx-build_tmp')
    try:
        _verify_app_source_dir_impl(src_dir, temp_dir, mode, enforce=enforce)
    finally:
        shutil.rmtree(temp_dir)
961902
def ensure_exists(self):
        """"""
        if not self.context.is_directory(self.directory):
            # This can also happen when we don't have permission to one of the
            # parent directories so we'll point that out in the error message
            # when it seems applicable (so as not to confuse users).
            if self.context.have_superuser_privileges:
                msg = "The directory %s doesn't exist!"
                raise ValueError(msg % self)
            else:
                raise ValueError(compact("""
                    The directory {location} isn't accessible, most likely
                    because it doesn't exist or because of permissions. If
                    you're sure the directory exists you can use the
                    --use-sudo option.
                """, location=self))
897216
def ensure_dir(path):
    
    dirpath = os.path.dirname(path)
    if dirpath and not os.path.exists(dirpath):
        os.makedirs(dirpath)
124089
def getAppDir():
    
    # Be sure the resource dir exists
    theDir = os.path.expanduser('~/.')+APP_NAME.lower()
    if not os.path.exists(theDir):
        try:
            os.mkdir(theDir)
        except OSError:
            print('Could not create "'+theDir+'" to save GUI settings.')
            theDir = "./"+APP_NAME.lower()
    return theDir
344285
def check_apps_permission(self, apps):
        
        for app in apps:
            if app in self.apps_dict:
                return True

        return False
353114
def find_applications_by_app_name(app_name)
      pids = []

      begin
        x = `ps auxw | grep -v grep | awk '{print $2, $11, $12}' | grep #{app_name}`
        if x && x.chomp!
          processes = x.split(/\n/).compact
          processes = processes.delete_if do |p|
            _pid, name, add = p.split(/\s/)
            # We want to make sure that the first part of the process name matches
            # so that app_name matches app_name_22

            app_name != name[0..(app_name.length - 1)] and not add.include?(app_name)
          end
          pids = processes.map { |p| p.split(/\s/)[0].to_i }
        end
        rescue ::Exception
      end

      pids.map do |f|
        app = Application.new(self, {}, PidMem.existing(f))
        setup_app(app)
        app
      end
    end
1199419
def private_path(self):
        
        path = os.path.join(self.path, '.hg', '.private')
        try:
            os.mkdir(path)
        except OSError as e:
            if e.errno != errno.EEXIST:
                raise
        return path
441675
def ensure_dir(dirname):
  
  try:
    # Tries to create the directory
    os.makedirs(dirname)
  except OSError:
    # Check that the directory exists
    if os.path.isdir(dirname): pass
    else: raise
538792
def get_app_key(self):
        
        if self.app_key is None:
            if os.environ.get(self.username):
                self.app_key = os.environ.get(self.username)
            else:
                raise AppKeyError(self.username)
912603
def ensure_dir(dir_path):
    
    exists = dir_exists(dir_path)
    if not exists:
        try:
            os.makedirs(dir_path)
        except(Exception,RuntimeError), e:
            raise Exception("Unable to create directory %s. Cause %s" %
                            (dir_path, e))
    return exists
843708
def mac_app_exists(app):
	'''
	'''

	APP_CHECK_APPLESCRIPT = '''try
	tell application "Finder"
		set appname to name of application file id "%s"
		return 0
	end tell
	on error err_msg number err_num
		return 1
	end try'''

	with open('/tmp/app_check.AppleScript', 'w') as f:
		f.write(APP_CHECK_APPLESCRIPT % app)

	app_check_proc = sp.Popen(
		['osascript', '-e', '/tmp/app_check.AppleScript'])

	if app_check_proc.wait() != 0:
		return False

	else:
		return True
928634
def add_usable_app(name, app):
    ''
    name = slugify(name)
    global usable_apps # pylint: disable=global-statement
    usable_apps[name] = app
    return name
799219
def get_permissions_app_name():
    
    global permissions_app_name

    if not permissions_app_name:
        permissions_app_name = getattr(settings, 'PERMISSIONS_APP', None)

        if not permissions_app_name:
            app_names_with_models = [a.name for a in apps.get_app_configs() if a.models_module is not None]
            if app_names_with_models:
                permissions_app_name = app_names_with_models[-1]

    return permissions_app_name
364616
def ensure_path_exists(dir_path):
    
    if not os.path.exists(dir_path):
        os.makedirs(dir_path)
        return True
    return False
303568
def ensure_dir(path):
    
    os.makedirs(os.path.abspath(os.path.dirname(path)), exist_ok=True)
592986
def distcheck(appname='',version='',subdir=''):
	''''''
	import tempfile,tarfile
	if not appname:appname=Utils.g_module.APPNAME
	if not version:version=Utils.g_module.VERSION
	waf=os.path.abspath(sys.argv[0])
	tarball=dist(appname,version)
	path=appname+'-'+version
	if os.path.exists(path):
		shutil.rmtree(path)
	t=tarfile.open(tarball)
	for x in t:t.extract(x)
	t.close()
	if subdir:
		build_path=os.path.join(path,subdir)
	else:
		build_path=path
	instdir=tempfile.mkdtemp('.inst','%s-%s'%(appname,version))
	ret=Utils.pproc.Popen([waf,'configure','build','install','uninstall','--destdir='+instdir],cwd=build_path).wait()
	if ret:
		raise Utils.WafError('distcheck failed with code %i'%ret)
	if os.path.exists(instdir):
		raise Utils.WafError('distcheck succeeded, but files were left in %s'%instdir)
	shutil.rmtree(path)