xiaoyu_utils.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:astoptool 作者: zouliuyun 项目源码 文件源码
def tcp_port(self):
        """
        The tcp port used for the game server. Will try to get only once and save to self._tcp_port for later use.
        """

        def get_tcp_port():
            cmd = '''grep 'name="port" type="int"' conf.xml |awk -F[\<\>] '{print $3}' '''

            @hosts(self.int_ip)
            def _get_tcp_port():
                with cd('/app/{}/backend/apps'.format(self.name)):
                    result = run(cmd) 

                lines = result.splitlines()
                if len(lines) == 1:
                    return int(lines[0])
                else:
                    raise Exception("Can't get tcp port using cmd: {}".format(cmd))

            result = execute(_get_tcp_port)
            return result[self.int_ip]

        if not self._tcp_port:
            self._tcp_port = get_tcp_port()
        return self._tcp_port
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号