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)
Exemplo n.º 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)
Exemplo n.º 3
0
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
Exemplo n.º 4
0
            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
Exemplo n.º 5
0
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)
 def os_chmod(path, mode):
   return os._chmod(longpathify(uni(path)), mode)
Exemplo n.º 7
0
def change_mod_conjugated(fp, subfp, mode):
    _chmod(_join(fp, subfp), mode)
    logger.info('Changed mod for %s to %s' % (_join(fp, subfp), mode))
Exemplo n.º 8
0
def change_mod(fp, mode):
    _chmod(fp, mode)
    logger.info('Changed mod for %s to %s' % (fp, mode))
Exemplo n.º 9
0
 def os_chmod(path, mode):
     return os._chmod(longpathify(uni(path)), mode)
Exemplo n.º 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
Exemplo n.º 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)