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


Python tools.add_env_to_user函数代码示例

本文整理汇总了Python中umake.tools.add_env_to_user函数的典型用法代码示例。如果您正苦于以下问题:Python add_env_to_user函数的具体用法?Python add_env_to_user怎么用?Python add_env_to_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: post_install

 def post_install(self):
     """Add go necessary env variables"""
     add_env_to_user(
         self.name,
         {"PATH": {"value": os.path.join(self.install_path, "bin")}, "GOROOT": {"value": self.install_path}},
     )
     UI.delayed_display(DisplayMessage(_("You need to restart a shell session for your installation to work")))
开发者ID:fcole90,项目名称:ubuntu-make,代码行数:7,代码来源:go.py

示例2: post_install

 def post_install(self):
     """Add rust necessary env variables"""
     add_env_to_user(self.name, {"PATH": {"value": "{}:{}".format(os.path.join(self.install_path, "rustc", "bin"),
                                                                  os.path.join(self.install_path, "cargo", "bin"))},
                                 "LD_LIBRARY_PATH": {"value": os.path.join(self.install_path, "rustc", "lib")}})
     UI.delayed_display(DisplayMessage(_("You need to restart your current shell session for your {} installation "
                                         "to work properly").format(self.name)))
开发者ID:pombredanne,项目名称:ubuntu-make,代码行数:7,代码来源:rust.py

示例3: post_install

    def post_install(self):
        """Add necessary environment variables"""
        add_env_to_user(self.name, {"ANDROID_HOME": {"value": self.install_path, "keep": False}})
        # add "platform-tools" to PATH to ensure "adb" can be run once the platform tools are installed via
        # the SDK manager
        add_env_to_user(
            self.name,
            {
                "PATH": {
                    "value": [os.path.join("$ANDROID_HOME", "tools"), os.path.join("$ANDROID_HOME", "platform-tools")]
                }
            },
        )
        UI.delayed_display(
            DisplayMessage(
                _("You need to restart your current shell session for your {} installation " "to work properly").format(
                    self.name
                )
            )
        )

        # print wiki page message
        UI.delayed_display(
            DisplayMessage(
                "SDK installed in {}. More information on how to use it on {}".format(
                    self.install_path, "https://developer.android.com/sdk/installing/adding-packages.html"
                )
            )
        )
开发者ID:oijazsh,项目名称:ubuntu-make,代码行数:29,代码来源:android.py

示例4: post_install

 def post_install(self):
     """Add nodejs necessary env variables and move module folder"""
     subprocess.call([os.path.join(self.install_path, "bin", "npm"), "config", "set", "prefix", "~/.node_modules"])
     add_env_to_user(self.name, {"PATH": {"value": "{}:{}".format(os.path.join(self.install_path, "bin"),
                                                                  os.path.join(os.path.expanduser('~'),
                                                                               ".node_modules", "bin"))}})
     UI.delayed_display(DisplayMessage(_("You need to restart your current shell session for your {} installation "
                                         "to work properly").format(self.name)))
开发者ID:EdRondon,项目名称:ubuntu-make,代码行数:8,代码来源:nodejs.py

示例5: post_install

    def post_install(self):
        """Add necessary environment variables"""
        add_env_to_user(self.name, {"NDK_ROOT": {"value": self.install_path, "keep": False}})

        # print wiki page message
        UI.display(DisplayMessage("NDK installed in {}. More information on how to use it on {}".format(
                                  self.install_path,
                                  "https://developer.android.com/tools/sdk/ndk/index.html#GetStarted")))
开发者ID:jravetch,项目名称:ubuntu-make,代码行数:8,代码来源:android.py

示例6: test_add_env_to_user_empty_file

    def test_add_env_to_user_empty_file(self, expanderusermock):
        """Test that adding to user env append to an non existing .profile file"""
        expanderusermock.return_value = self.local_dir
        profile_file = os.path.join(self.local_dir, ".profile")
        tools.add_env_to_user("one path addition", {"FOOO": {"value": "/tmp/foo"}})

        expanderusermock.assert_called_with('~')
        profile_content = open(profile_file).read()
        self.assertTrue("export FOOO=/tmp/foo\n" in profile_content, profile_content)
        self.assertTrue("/tmp/foo" in os.environ["FOOO"], os.environ["FOOO"])
开发者ID:Ubuntu420,项目名称:ubuntu-make,代码行数:10,代码来源:test_tools.py

示例7: post_install

    def post_install(self):
        """Add nodejs necessary env variables and move module folder"""
        if not self.prefix_set():
            with open(os.path.join(os.environ['HOME'], '.npmrc'), 'a+') as file:
                file.write("prefix = ${HOME}/.npm_modules\n")

        add_env_to_user(self.name, {"PATH": {"value": "{}:{}".format(os.path.join(self.install_path, "bin"),
                                                                     os.path.join(os.path.expanduser('~'),
                                                                                  ".npm_modules", "bin"))}})
        UI.delayed_display(DisplayMessage(self.RELOGIN_REQUIRE_MSG.format(self.name)))
开发者ID:ubuntu,项目名称:ubuntu-make,代码行数:10,代码来源:nodejs.py

示例8: post_install

 def post_install(self):
     """Create the Android Studio launcher"""
     add_env_to_user(self.name, {"ANDROID_HOME": {"value": self.install_path, "keep": False},
                                 "ANDROID_SDK": {"value": self.install_path, "keep": False}})
     create_launcher(self.desktop_filename, get_application_desktop_file(name=_("Android Studio"),
                     icon_path=os.path.join(self.install_path, "bin", "studio.png"),
                     try_exec=os.path.join(self.install_path, "bin", "studio.sh"),
                     exec=self.exec_link_name,
                     comment=_("Android Studio developer environment"),
                     categories="Development;IDE;",
                     extra="StartupWMClass=jetbrains-studio"))
开发者ID:ubuntu,项目名称:ubuntu-make,代码行数:11,代码来源:android.py

示例9: test_add_env_to_user

    def test_add_env_to_user(self, expanderusermock):
        """Test that adding to user env appending to an existing .profile file"""
        expanderusermock.return_value = self.local_dir
        profile_file = os.path.join(self.local_dir, ".profile")
        open(profile_file, 'w').write("Foo\nBar\n")
        tools.add_env_to_user("one path addition", {"FOOO": {"value": "bar"}})

        expanderusermock.assert_called_with('~')
        profile_content = open(profile_file).read()
        self.assertTrue("Foo\nBar\n" in profile_content, profile_content)  # we kept previous content
        self.assertTrue("export FOOO=bar\n" in profile_content, profile_content)
        self.assertTrue("bar" in os.environ["FOOO"], os.environ["FOOO"])
开发者ID:Ubuntu420,项目名称:ubuntu-make,代码行数:12,代码来源:test_tools.py

示例10: test_add_path_to_user

    def test_add_path_to_user(self, expanderusermock):
        """Test that adding to user path doesn't export as PATH is already exported"""
        expanderusermock.return_value = self.local_dir
        profile_file = os.path.join(self.local_dir, ".profile")
        open(profile_file, 'w').write("Foo\nBar\n")
        tools.add_env_to_user("one path addition", {"PATH": {"value": "/tmp/bar"}})

        expanderusermock.assert_called_with('~')
        profile_content = open(profile_file).read()
        self.assertTrue("Foo\nBar\n" in profile_content, profile_content)  # we kept previous content
        self.assertTrue("\nPATH=/tmp/bar:$PATH\n" in profile_content, profile_content)
        self.assertTrue("/tmp/bar" in os.environ["PATH"], os.environ["PATH"])
开发者ID:Ubuntu420,项目名称:ubuntu-make,代码行数:12,代码来源:test_tools.py

示例11: post_install

    def post_install(self):
        """Add rust necessary env variables"""
        add_env_to_user(self.name, {"PATH": {"value": "{}:{}".format(os.path.join(self.install_path, "rustc", "bin"),
                                                                     os.path.join(self.install_path, "cargo", "bin"))},
                                    "LD_LIBRARY_PATH": {"value": os.path.join(self.install_path, "rustc", "lib")}})

        # adjust for rust 1.5 some symlinks magic to have stdlib craft available
        os.chdir(os.path.join(self.install_path, "rustc", "lib"))
        os.rename("rustlib", "rustlib.init")
        os.symlink(glob(os.path.join('..', '..', 'rust-std-*', 'lib', 'rustlib'))[0], 'rustlib')
        os.symlink(os.path.join('..', 'rustlib.init', 'etc'), os.path.join('rustlib', 'etc'))

        UI.delayed_display(DisplayMessage(self.RELOGIN_REQUIRE_MSG.format(self.name)))
开发者ID:jravetch,项目名称:ubuntu-make,代码行数:13,代码来源:rust.py

示例12: post_install

    def post_install(self):
        """Add rust necessary env variables"""
        add_env_to_user(self.name, {"PATH": {"value": "{}:{}".format(os.path.join(self.install_path, "rustc", "bin"),
                                                                     os.path.join(self.install_path, "cargo", "bin"))},
                                    "LD_LIBRARY_PATH": {"value": os.path.join(self.install_path, "rustc", "lib")}})

        # adjust for rust 1.5 some symlinks magic to have stdlib craft available
        os.chdir(os.path.join(self.install_path, "rustc", "lib"))
        os.rename("rustlib", "rustlib.init")
        os.symlink(glob(os.path.join('..', '..', 'rust-std-*', 'lib', 'rustlib'))[0], 'rustlib')
        os.symlink(os.path.join('..', 'rustlib.init', 'etc'), os.path.join('rustlib', 'etc'))

        UI.delayed_display(DisplayMessage(_("You need to restart your current shell session for your {} installation "
                                            "to work properly").format(self.name)))
开发者ID:EdRondon,项目名称:ubuntu-make,代码行数:14,代码来源:rust.py

示例13: test_add_env_to_user_multiple

    def test_add_env_to_user_multiple(self, expanderusermock):
        """Test that adding to user with multiple env for same framework appending to an existing .profile file"""
        expanderusermock.return_value = self.local_dir
        profile_file = os.path.join(self.local_dir, ".profile")
        open(profile_file, 'w').write("Foo\nBar\n")
        tools.add_env_to_user("one path addition", {"FOOO": {"value": "bar"}, "BAR": {"value": "foo"}})

        expanderusermock.assert_called_with('~')
        profile_content = open(profile_file).read()
        self.assertTrue("Foo\nBar\n" in profile_content, profile_content)  # we kept previous content
        self.assertTrue("export FOOO=bar\n" in profile_content, profile_content)
        self.assertTrue("export BAR=foo\n" in profile_content, profile_content)
        self.assertEqual(os.environ["FOOO"], "bar")
        self.assertEqual(os.environ["BAR"], "foo")
开发者ID:Ubuntu420,项目名称:ubuntu-make,代码行数:14,代码来源:test_tools.py

示例14: post_install

    def post_install(self):
        """Add rust necessary env variables"""
        add_env_to_user(self.name, {"PATH": {"value": "{}:{}".format(os.path.join(self.install_path, "rustc", "bin"),
                                                                     os.path.join(self.install_path, "cargo", "bin"))},
                                    "LD_LIBRARY_PATH": {"value": os.path.join(self.install_path, "rustc", "lib")}})

        # adjust for rust: some symlinks magic to have stdlib craft available
        arch_lib_folder = '{}-unknown-linux-gnu'.format(self.arch_trans[get_current_arch()])
        lib_folder = os.path.join(self.install_path, 'rust-std-{}'.format(arch_lib_folder),
                                  'lib', 'rustlib', arch_lib_folder, 'lib')
        for f in os.listdir(lib_folder):
            os.symlink(os.path.join(lib_folder, f),
                       os.path.join(self.install_path, 'rustc', 'lib', 'rustlib', arch_lib_folder, 'lib', f))

        UI.delayed_display(DisplayMessage(self.RELOGIN_REQUIRE_MSG.format(self.name)))
开发者ID:ubuntu,项目名称:ubuntu-make,代码行数:15,代码来源:rust.py

示例15: test_add_env_to_user_not_keep

    def test_add_env_to_user_not_keep(self, expanderusermock):
        """Test that adding to user env without keep replace an existing env"""
        os.environ["FOOO"] = "foo"
        expanderusermock.return_value = self.local_dir
        profile_file = os.path.join(self.local_dir, ".profile")
        open(profile_file, 'w').write("Foo\nBar\n")
        tools.add_env_to_user("one path addition", {"FOOO": {"value": "bar", "keep": False}})

        expanderusermock.assert_called_with('~')
        profile_content = open(profile_file).read()
        self.assertTrue("Foo\nBar\n" in profile_content, profile_content)  # we kept previous content
        self.assertTrue("export FOOO=bar\n" in profile_content, profile_content)
        self.assertTrue("bar" in os.environ["FOOO"], os.environ["FOOO"])
        self.assertFalse("foo" in os.environ["FOOO"], os.environ["FOOO"])
        self.assertEqual(os.environ["FOOO"], "bar")
开发者ID:Ubuntu420,项目名称:ubuntu-make,代码行数:15,代码来源:test_tools.py


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