当前位置: 首页>>代码示例>>Python>>正文


Python os.O_APPEND属性代码示例

本文整理汇总了Python中os.O_APPEND属性的典型用法代码示例。如果您正苦于以下问题:Python os.O_APPEND属性的具体用法?Python os.O_APPEND怎么用?Python os.O_APPEND使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在os的用法示例。


在下文中一共展示了os.O_APPEND属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: write_port_interface_file

# 需要导入模块: import os [as 别名]
# 或者: from os import O_APPEND [as 别名]
def write_port_interface_file(self, netns_interface, fixed_ips, mtu,
                                  interface_file_path, template_port):
        # write interface file

        # If we are using a consolidated interfaces file, just append
        # otherwise clear the per interface file as we are rewriting it
        # TODO(johnsom): We need a way to clean out old interfaces records
        if CONF.amphora_agent.agent_server_network_file:
            flags = os.O_WRONLY | os.O_CREAT | os.O_APPEND
        else:
            flags = os.O_WRONLY | os.O_CREAT | os.O_TRUNC

        # mode 00644
        mode = stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH

        with os.fdopen(os.open(interface_file_path, flags, mode),
                       'w') as text_file:
            text = self._generate_network_file_text(
                netns_interface, fixed_ips, mtu, template_port)
            text_file.write(text) 
开发者ID:openstack,项目名称:octavia,代码行数:22,代码来源:osutils.py

示例2: mode2flags

# 需要导入模块: import os [as 别名]
# 或者: from os import O_APPEND [as 别名]
def mode2flags(mode):
    """mode2flags(modestring)
    Converts a file mode in string form (e.g. "w+") to an integer flag value
    suitable for os.open().  """
    flags = os.O_LARGEFILE # XXX only when Python compiled with large file support
    if mode == "a":
        flags = flags | os.O_APPEND | os.O_WRONLY
    elif mode == "a+":
        flags = flags | os.O_APPEND | os.O_RDWR | os.O_CREAT
    elif mode == "w":
        flags = flags | os.O_WRONLY | os.O_CREAT
    elif mode == "w+":
        flags = flags | os.O_RDWR | os.O_CREAT
    elif mode == "r":
        pass # O_RDONLY is zero already
    elif mode == "r+":
        flags = flags | os.O_RDWR
    return flags


# precompute the O_ flag list, and stash it in the os module 
开发者ID:kdart,项目名称:pycopia,代码行数:23,代码来源:UserFile.py

示例3: _convert_pflags

# 需要导入模块: import os [as 别名]
# 或者: from os import O_APPEND [as 别名]
def _convert_pflags(self, pflags):
        "convert SFTP-style open() flags to python's os.open() flags"
        if (pflags & SFTP_FLAG_READ) and (pflags & SFTP_FLAG_WRITE):
            flags = os.O_RDWR
        elif pflags & SFTP_FLAG_WRITE:
            flags = os.O_WRONLY
        else:
            flags = os.O_RDONLY
        if pflags & SFTP_FLAG_APPEND:
            flags |= os.O_APPEND
        if pflags & SFTP_FLAG_CREATE:
            flags |= os.O_CREAT
        if pflags & SFTP_FLAG_TRUNC:
            flags |= os.O_TRUNC
        if pflags & SFTP_FLAG_EXCL:
            flags |= os.O_EXCL
        return flags 
开发者ID:iopsgroup,项目名称:imoocc,代码行数:19,代码来源:sftp_server.py

示例4: _convert_pflags

# 需要导入模块: import os [as 别名]
# 或者: from os import O_APPEND [as 别名]
def _convert_pflags(self, pflags):
        """convert SFTP-style open() flags to Python's os.open() flags"""
        if (pflags & SFTP_FLAG_READ) and (pflags & SFTP_FLAG_WRITE):
            flags = os.O_RDWR
        elif pflags & SFTP_FLAG_WRITE:
            flags = os.O_WRONLY
        else:
            flags = os.O_RDONLY
        if pflags & SFTP_FLAG_APPEND:
            flags |= os.O_APPEND
        if pflags & SFTP_FLAG_CREATE:
            flags |= os.O_CREAT
        if pflags & SFTP_FLAG_TRUNC:
            flags |= os.O_TRUNC
        if pflags & SFTP_FLAG_EXCL:
            flags |= os.O_EXCL
        return flags 
开发者ID:iopsgroup,项目名称:imoocc,代码行数:19,代码来源:sftp_server.py

示例5: _start_by_conf

# 需要导入模块: import os [as 别名]
# 或者: from os import O_APPEND [as 别名]
def _start_by_conf(self, proc_conf):
        """
        Start subprocess using ProcConfiguration object
        :param proc_conf: 
        :return: Popen object instance
        """
        assert isinstance(proc_conf, config.ProcessConfiguration)

        args = list(proc_conf.cmd.split(' '))
        self.log.info("Starting: %s on %s", proc_conf.cmd, gpu.format_gpu_id(proc_conf.gpu_indices))
        if proc_conf.gpu_indices is not None:
            env = {"CUDA_VISIBLE_DEVICES": ",".join(map(str, sorted(proc_conf.gpu_indices)))}
        else:
            env = None
        if proc_conf.log is None:
            stdout = None
        else:
            stdout = os.open(proc_conf.log, os.O_APPEND if os.path.exists(proc_conf.log) else os.O_CREAT)
        p = subprocess.Popen(args, cwd=proc_conf.dir, env=env, stdout=stdout, stderr=subprocess.STDOUT)
        return p 
开发者ID:Shmuma,项目名称:gpu_mon,代码行数:22,代码来源:proc.py

示例6: _create_base_aws_cli_config_files_if_needed

# 需要导入模块: import os [as 别名]
# 或者: from os import O_APPEND [as 别名]
def _create_base_aws_cli_config_files_if_needed(adfs_config):
    def touch(fname, mode=0o600):
        flags = os.O_CREAT | os.O_APPEND
        with os.fdopen(os.open(fname, flags, mode)) as f:
            try:
                os.utime(fname, None)
            finally:
                f.close()

    aws_config_root = os.path.dirname(adfs_config.aws_config_location)

    if not os.path.exists(aws_config_root):
        os.mkdir(aws_config_root, 0o700)

    if not os.path.exists(adfs_config.aws_credentials_location):
        touch(adfs_config.aws_credentials_location)

    aws_credentials_root = os.path.dirname(adfs_config.aws_credentials_location)

    if not os.path.exists(aws_credentials_root):
        os.mkdir(aws_credentials_root, 0o700)

    if not os.path.exists(adfs_config.aws_config_location):
        touch(adfs_config.aws_config_location) 
开发者ID:venth,项目名称:aws-adfs,代码行数:26,代码来源:prepare.py

示例7: wtrf

# 需要导入模块: import os [as 别名]
# 或者: from os import O_APPEND [as 别名]
def wtrf():
    if sys.platform != "win32":
        wt = int(os.environ['MYHDL_TO_PIPE'])
        rf = int(os.environ['MYHDL_FROM_PIPE'])
    else:
        wt = msvcrt.open_osfhandle(int(os.environ['MYHDL_TO_PIPE']), os.O_APPEND | os.O_TEXT)
        rf = msvcrt.open_osfhandle(int(os.environ['MYHDL_FROM_PIPE']), os.O_RDONLY | os.O_TEXT)

    return wt, rf 
开发者ID:myhdl,项目名称:myhdl,代码行数:11,代码来源:test_Cosimulation.py

示例8: flags

# 需要导入模块: import os [as 别名]
# 或者: from os import O_APPEND [as 别名]
def flags(self, *which):
        import fcntl, os

        if which:
            if len(which) > 1:
                raise TypeError, 'Too many arguments'
            which = which[0]
        else: which = '?'

        l_flags = 0
        if 'n' in which: l_flags = l_flags | os.O_NDELAY
        if 'a' in which: l_flags = l_flags | os.O_APPEND
        if 's' in which: l_flags = l_flags | os.O_SYNC

        file = self._file_

        if '=' not in which:
            cur_fl = fcntl.fcntl(file.fileno(), fcntl.F_GETFL, 0)
            if '!' in which: l_flags = cur_fl & ~ l_flags
            else: l_flags = cur_fl | l_flags

        l_flags = fcntl.fcntl(file.fileno(), fcntl.F_SETFL, l_flags)

        if 'c' in which:
            arg = ('!' not in which)    # 0 is don't, 1 is do close on exec
            l_flags = fcntl.fcntl(file.fileno(), fcntl.F_SETFD, arg)

        if '?' in which:
            which = ''                  # Return current flags
            l_flags = fcntl.fcntl(file.fileno(), fcntl.F_GETFL, 0)
            if os.O_APPEND & l_flags: which = which + 'a'
            if fcntl.fcntl(file.fileno(), fcntl.F_GETFD, 0) & 1:
                which = which + 'c'
            if os.O_NDELAY & l_flags: which = which + 'n'
            if os.O_SYNC & l_flags: which = which + 's'
            return which 
开发者ID:glmcdona,项目名称:meddle,代码行数:38,代码来源:posixfile.py

示例9: test_send

# 需要导入模块: import os [as 别名]
# 或者: from os import O_APPEND [as 别名]
def test_send(self):
        d1 = "Come again?"
        d2 = "I want to buy some cheese."
        fd = os.open(TESTFN, os.O_WRONLY | os.O_APPEND)
        w = asyncore.file_wrapper(fd)
        os.close(fd)

        w.write(d1)
        w.send(d2)
        w.close()
        self.assertEqual(file(TESTFN).read(), self.d + d1 + d2) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:13,代码来源:test_asyncore.py

示例10: write_vip_interface_file

# 需要导入模块: import os [as 别名]
# 或者: from os import O_APPEND [as 别名]
def write_vip_interface_file(self, interface_file_path,
                                 primary_interface, vip, ip, broadcast,
                                 netmask, gateway, mtu, vrrp_ip, vrrp_version,
                                 render_host_routes, template_vip):
        # write interface file

        mode = stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH

        # If we are using a consolidated interfaces file, just append
        # otherwise clear the per interface file as we are rewriting it
        # TODO(johnsom): We need a way to clean out old interfaces records
        if CONF.amphora_agent.agent_server_network_file:
            flags = os.O_WRONLY | os.O_CREAT | os.O_APPEND
        else:
            flags = os.O_WRONLY | os.O_CREAT | os.O_TRUNC

        with os.fdopen(os.open(interface_file_path, flags, mode),
                       'w') as text_file:
            text = template_vip.render(
                consts=consts,
                interface=primary_interface,
                vip=vip,
                vip_ipv6=ip.version == 6,
                # For ipv6 the netmask is already the prefix
                prefix=(netmask if ip.version == 6
                        else utils.netmask_to_prefix(netmask)),
                broadcast=broadcast,
                netmask=netmask,
                gateway=gateway,
                network=utils.ip_netmask_to_cidr(vip, netmask),
                mtu=mtu,
                vrrp_ip=vrrp_ip,
                vrrp_ipv6=vrrp_version == 6,
                host_routes=render_host_routes,
                topology=CONF.controller_worker.loadbalancer_topology,
            )
            text_file.write(text) 
开发者ID:openstack,项目名称:octavia,代码行数:39,代码来源:osutils.py

示例11: write_static_routes_interface_file

# 需要导入模块: import os [as 别名]
# 或者: from os import O_APPEND [as 别名]
def write_static_routes_interface_file(self, interface_file_path,
                                           interface, host_routes,
                                           template_routes, gateway,
                                           vip, netmask):
        # write static routes interface file

        mode = stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH

        # TODO(johnsom): We need a way to clean out old interfaces records
        if CONF.amphora_agent.agent_server_network_file:
            flags = os.O_WRONLY | os.O_CREAT | os.O_APPEND
        else:
            flags = os.O_WRONLY | os.O_CREAT | os.O_TRUNC

        with os.fdopen(os.open(interface_file_path, flags, mode),
                       'w') as text_file:
            text = template_routes.render(
                consts=consts,
                interface=interface,
                host_routes=host_routes,
                gateway=gateway,
                network=utils.ip_netmask_to_cidr(vip, netmask),
                vip=vip,
                topology=CONF.controller_worker.loadbalancer_topology,
            )
            text_file.write(text) 
开发者ID:openstack,项目名称:octavia,代码行数:28,代码来源:osutils.py

示例12: file_flags_to_mode

# 需要导入模块: import os [as 别名]
# 或者: from os import O_APPEND [as 别名]
def file_flags_to_mode(flags):
    """Convert file's open() flags into a readable string.
    Used by Process.open_files().
    """
    modes_map = {os.O_RDONLY: 'r', os.O_WRONLY: 'w', os.O_RDWR: 'w+'}
    mode = modes_map[flags & (os.O_RDONLY | os.O_WRONLY | os.O_RDWR)]
    if flags & os.O_APPEND:
        mode = mode.replace('w', 'a', 1)
    mode = mode.replace('w+', 'r+')
    # possible values: r, w, a, r+, a+
    return mode 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:13,代码来源:_pslinux.py

示例13: getFd

# 需要导入模块: import os [as 别名]
# 或者: from os import O_APPEND [as 别名]
def getFd(self, pio):
        "get file descriptor for given PInOut object"
        if self.fd is None:
            if isinstance(pio, PIn):
                self.fd = os.open(self.path, os.O_RDONLY)
            elif self.append:
                self.fd = os.open(self.path, os.O_WRONLY|os.O_CREAT|os.O_APPEND, 0o666)
            else:
                self.fd = os.open(self.path, os.O_WRONLY|os.O_CREAT|os.O_TRUNC, 0o666)
        return self.fd 
开发者ID:ComparativeGenomicsToolkit,项目名称:Comparative-Annotation-Toolkit,代码行数:12,代码来源:pipeline.py

示例14: touch

# 需要导入模块: import os [as 别名]
# 或者: from os import O_APPEND [as 别名]
def touch(fname, mode=0o666, dir_fd=None, **kwargs):
    ## After http://stackoverflow.com/questions/1158076/implement-touch-using-python
    if sys.version_info < (3, 3, 0):
        with open(fname, 'a'):
            os.utime(fname, None) # set to now
    else:
        flags = os.O_CREAT | os.O_APPEND
        with os.fdopen(os.open(fname, flags=flags, mode=mode, dir_fd=dir_fd)) as f:
            os.utime(f.fileno() if os.utime in os.supports_fd else fname,
                     dir_fd=None if os.supports_fd else dir_fd, **kwargs) 
开发者ID:GenealogyCollective,项目名称:gprime,代码行数:12,代码来源:generic.py

示例15: touch

# 需要导入模块: import os [as 别名]
# 或者: from os import O_APPEND [as 别名]
def touch(fname, mode=0o666, dir_fd=None, **kwargs):
    """Utility function for updating a file time stamp.

    Source:
        https://stackoverflow.com/questions/1158076/implement-touch-using-python
    """
    flags = os.O_CREAT | os.O_APPEND
    with os.fdopen(os.open(fname, flags=flags, mode=mode, dir_fd=dir_fd)) as f:
        os.utime(f.fileno() if os.utime in os.supports_fd else fname,
                 dir_fd=None if os.supports_fd else dir_fd, **kwargs) 
开发者ID:glotzerlab,项目名称:signac,代码行数:12,代码来源:test_sync.py


注:本文中的os.O_APPEND属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。