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


Python DotXpra.sockdir方法代码示例

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


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

示例1: create_control_socket

# 需要导入模块: from xpra.dotxpra import DotXpra [as 别名]
# 或者: from xpra.dotxpra.DotXpra import sockdir [as 别名]
 def create_control_socket(self):
     dotxpra = DotXpra(self.socket_dir)
     name = "proxy-%s" % os.getpid()
     sockpath = dotxpra.norm_make_path(name, dotxpra.sockdir())
     state = dotxpra.get_server_state(sockpath)
     if state in (DotXpra.LIVE, DotXpra.UNKNOWN):
         log.warn("You already have a proxy server running at %s, the control socket will not be created!", sockpath)
         return False
     try:
         sock = create_unix_domain_socket(sockpath, None)
         sock.listen(5)
     except Exception, e:
         log.warn("failed to setup control socket %s: %s", sockpath, e)
         return False
开发者ID:svn2github,项目名称:Xpra,代码行数:16,代码来源:proxy_instance_process.py

示例2: create_control_socket

# 需要导入模块: from xpra.dotxpra import DotXpra [as 别名]
# 或者: from xpra.dotxpra.DotXpra import sockdir [as 别名]
 def create_control_socket(self):
     dotxpra = DotXpra(self.socket_dir)
     name = "proxy-%s" % os.getpid()
     sockpath = dotxpra.norm_make_path(name, dotxpra.sockdir())
     state = dotxpra.get_server_state(sockpath)
     if state in (DotXpra.LIVE, DotXpra.UNKNOWN):
         log.warn("You already have a proxy server running at %s, the control socket will not be created!", sockpath)
         return False
     try:
         sock = create_unix_domain_socket(sockpath, None, 0o600)
         sock.listen(5)
     except:
         log.warn("failed to setup control socket %s", sockpath, exc_info=True)
         return False
     self.control_socket = sock
     self.control_socket_path = sockpath
     log.info("proxy instance now also available using unix domain socket: %s", self.control_socket_path)
     return True
开发者ID:svn2github,项目名称:Xpra,代码行数:20,代码来源:proxy_instance_process.py

示例3: run_server

# 需要导入模块: from xpra.dotxpra import DotXpra [as 别名]
# 或者: from xpra.dotxpra.DotXpra import sockdir [as 别名]
def run_server(parser, opts, mode, xpra_file, extra_args):
    if len(extra_args) != 1:
        parser.error("need exactly 1 extra argument")
    if opts.encoding and opts.encoding=="help":
        from xpra.scripts.config import encodings_help
        from xpra.server.server_base import SERVER_ENCODINGS
        print("server supports the following encodings:\n * %s" % ("\n * ".join(encodings_help(SERVER_ENCODINGS))))
        return 0
    assert mode in ("start", "upgrade", "shadow")
    upgrading = mode == "upgrade"
    shadowing = mode == "shadow"
    display_name = extra_args.pop(0)
    if display_name.startswith(":") and not shadowing:
        n = display_name[1:]
        p = n.find(".")
        if p>0:
            n = n[:p]
        try:
            dno = int(n)
            if dno>=0 and dno<10:
                sys.stderr.write("WARNING: low display number: %s\n" % dno)
                sys.stderr.write("You are attempting to run the xpra server against what seems to be a default X11 display '%s'.\n" % display_name)
                sys.stderr.write("This is generally not what you want.\n")
                sys.stderr.write("You should probably use a higher display number just to avoid any confusion (and also this warning message).\n")
        except:
            pass

    if not shadowing and opts.exit_with_children and not opts.start_child:
        sys.stderr.write("--exit-with-children specified without any children to spawn; exiting immediately")
        return  1

    atexit.register(run_cleanups)
    signal.signal(signal.SIGINT, deadly_signal)
    signal.signal(signal.SIGTERM, deadly_signal)

    dotxpra = DotXpra(opts.socket_dir)

    # This used to be given a display-specific name, but now we give it a
    # single fixed name and if multiple servers are started then the last one
    # will clobber the rest.  This isn't great, but the tradeoff is that it
    # makes it possible to use bare 'ssh:hostname' display names and
    # autodiscover the proper numeric display name when only one xpra server
    # is running on the remote host.  Might need to revisit this later if
    # people run into problems or autodiscovery turns out to be less useful
    # than expected.
    scriptpath = os.path.join(dotxpra.confdir(), "run-xpra")

    # Save the starting dir now, because we'll lose track of it when we
    # daemonize:
    starting_dir = os.getcwd()

    # Daemonize:
    if opts.daemon:
        if opts.log_file:
            if os.path.isabs(opts.log_file):
                logpath = opts.log_file
            else:
                logpath = os.path.join(dotxpra.sockdir(), opts.log_file)
            logpath = logpath.replace("$DISPLAY", display_name)
        else:
            logpath = dotxpra.log_path(display_name) + ".log"
        sys.stderr.write("Entering daemon mode; "
                         + "any further errors will be reported to:\n"
                         + ("  %s\n" % logpath))
        # Do some work up front, so any errors don't get lost.
        if os.path.exists(logpath):
            os.rename(logpath, logpath + ".old")
        logfd = os.open(logpath, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, o0666)
        assert logfd > 2
        os.chdir("/")

        if os.fork():
            os._exit(0)
        os.setsid()
        if os.fork():
            os._exit(0)
        close_all_fds(exceptions=[logfd])
        fd0 = os.open("/dev/null", os.O_RDONLY)
        if fd0 != 0:
            os.dup2(fd0, 0)
            os.close(fd0)
        os.dup2(logfd, 1)
        os.dup2(logfd, 2)
        os.close(logfd)
        # Make these line-buffered:
        sys.stdout = os.fdopen(1, "w", 1)
        sys.stderr = os.fdopen(2, "w", 1)

    # Write out a shell-script so that we can start our proxy in a clean
    # environment:
    scriptfile = open(scriptpath, "w")
    # Unix is a little silly sometimes:
    umask = os.umask(0)
    os.umask(umask)
    if hasattr(os, "fchmod"):
        os.fchmod(scriptfile.fileno(), o0700 & ~umask)
    else:
        os.chmod(scriptpath, o0700 & ~umask)
    scriptfile.write(xpra_runner_shell_script(xpra_file, starting_dir, opts.socket_dir))
    scriptfile.close()
#.........这里部分代码省略.........
开发者ID:svn2github,项目名称:Xpra,代码行数:103,代码来源:server.py


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