コード例 #1
0
def chmod(path, mode):
    from distutils import log
    log.debug("changing mode of %s to %o", path, mode)
    try:
        _chmod(path, mode)
    except os.error, e:
        log.debug("chmod failed: %s", e)
コード例 #2
0
def chmod(path, mode):
    from distutils import log
    log.debug("changing mode of %s to %o", path, mode)
    try:
        _chmod(path, mode)
    except os.error as e:
        log.debug("chmod failed: %s", e)
コード例 #3
0
ファイル: _common.py プロジェクト: JGoutin/accelpy
def set_cli_cache(name, obj, expiry_timestamp=None, expiry_seconds=30):
    """
    Add an object to disk cache. Mainly used to avoid repeated web server
    requests in CLI mode.

    Args:
        name (str): Cache name.
        obj (dict or list): Object to cache.
        expiry_timestamp (int): Expiry timestamp.
        expiry_seconds (int): Number of seconds before expiration.

    Returns:
        dict or list: obj
    """
    if not is_cli():
        return obj

    if expiry_timestamp is None:
        expiry_timestamp = int(_time()) + expiry_seconds

    path = _join(CACHE_DIR, f"{hash_cli_name(name)}_{int(expiry_timestamp)}")
    json_write(obj, path)
    _chmod(path, 0o600)

    return obj
コード例 #4
0
ファイル: usermgmt.py プロジェクト: sunfanwu/CloudStack
            Utils.pprint("GREEN",
                         "* setting owner of %s to UID %s" % (path, uid))
            _chown(path, uid, current_gid)
            current_uid = uid
        if current_gid != gid:
            Utils.pprint("GREEN",
                         "* setting group of %s to GID %s" % (path, gid))
            _chown(path, current_uid, gid)
            current_gid = gid
        if mode is not None:
            current_mode = stat.S_IMODE(os.stat(path).st_mode)
            if current_mode != mode:
                Utils.pprint(
                    "GREEN",
                    "* adjusting permissions on %s to mode %o" % (path, mode))
                _chmod(path, mode)
                current_mode = mode

    if ctx.is_install > 0:
        ctx.add_post_fun(lambda ctx: f(ctx, path, owner, group, mode))


Build.BuildContext.setownership = _setownership


def _createuser(ctx, user, homedir, shell):
    if Options.platform == 'win32': return
    if Options.platform == 'darwin': return
    if not hasattr(os, "getuid"): return
    if os.getuid() != 0: return
    if Options.options.NOUSERMGMT: return
コード例 #5
0
ファイル: utils.py プロジェクト: pombredanne/ensetuptools
def chmod(path, mode):
    log.debug("changing mode of %s to %o", path, mode)
    try:
        _chmod(path, mode)
    except os.error, e:
        log.debug("chmod failed: %s", e)
コード例 #6
0
 def os_chmod(path, mode):
   return os._chmod(longpathify(uni(path)), mode)
コード例 #7
0
ファイル: cxio.py プロジェクト: CeroProgramming/cxlibs
def change_mod_conjugated(fp, subfp, mode):
    _chmod(_join(fp, subfp), mode)
    logger.info('Changed mod for %s to %s' % (_join(fp, subfp), mode))
コード例 #8
0
ファイル: cxio.py プロジェクト: CeroProgramming/cxlibs
def change_mod(fp, mode):
    _chmod(fp, mode)
    logger.info('Changed mod for %s to %s' % (fp, mode))
コード例 #9
0
 def os_chmod(path, mode):
     return os._chmod(longpathify(uni(path)), mode)
コード例 #10
0
		
		path = bld.subst_add_destdir(path,bld)
		current_uid,current_gid = os.stat(path).st_uid,os.stat(path).st_gid
		if current_uid != uid:
			Utils.pprint("GREEN","* setting owner of %s to UID %s"%(path,uid))
			_chown(path,uid,current_gid)
			current_uid = uid
		if current_gid != gid:
			Utils.pprint("GREEN","* setting group of %s to GID %s"%(path,gid))
			_chown(path,current_uid,gid)
			current_gid = gid
		if mode is not None:
			current_mode = stat.S_IMODE(os.stat(path).st_mode)
			if current_mode != mode:
				Utils.pprint("GREEN","* adjusting permissions on %s to mode %o"%(path,mode))
				_chmod(path,mode)
				current_mode = mode
	
	if ctx.is_install > 0:
		ctx.add_post_fun(lambda ctx: f(ctx,path,owner,group,mode))
Build.BuildContext.setownership = _setownership

def _createuser(ctx,user,homedir,shell):
	if Options.platform == 'win32': return
	if Options.platform == 'darwin': return
	if not hasattr(os,"getuid"): return
	if os.getuid() != 0: return
	if Options.options.NOUSERMGMT: return
	
	def f(ctx,user,homedir,shell):
		import pwd
コード例 #11
0
try:
    # Use LibYAML if available
    from yaml import CSafeLoader as _Loader, CDumper as _Dumper
except ImportError:
    # Else use pure-Python library
    from yaml import SafeLoader as _Loader, Dumper as _Dumper
from yaml import dump as _yaml_dump, load as _yaml_load

from accelpy.exceptions import RuntimeException as _RuntimeException

#: User configuration directory
HOME_DIR = _expanduser('~/.accelize')

# Ensure directory exists and have restricted access rights
_makesdirs(HOME_DIR, exist_ok=True)
_chmod(HOME_DIR, 0o700)


def yaml_read(path):
    """
    Read a YAML file.

    Args:
        path (path-like object): Path to file to load.

    Returns:
        dict or list: Un-serialized content
    """
    with open(_fsdecode(path), 'rt') as file:
        return _yaml_load(file, Loader=_Loader)