9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov# Various functions
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov# Copyright (c) 2015 Red Hat, Inc.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov# Author: Nikolai Kondrashov <Nikolai.Kondrashov@redhat.com>
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov# This is free software; you can redistribute it and/or modify it
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov# under the terms of the GNU General Public License as published by
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov# the Free Software Foundation; version 2 only
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov# This program is distributed in the hope that it will be useful, but
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov# WITHOUT ANY WARRANTY; without even the implied warranty of
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov# General Public License for more details.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov# You should have received a copy of the GNU General Public License
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov# along with this program. If not, see <http://www.gnu.org/licenses/>.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai KondrashovUNINDENT_RE = re.compile("^ +", re.MULTILINE)
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov Unindent text by removing at most the number of spaces present in
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov the first non-empty line from the beginning of every line.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov Execute an interactive shell under "screen", preserving environment.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov For use as a breakpoint for debugging.
447d32b6f572e8ba3100668cb8677c19c0085be6Lukas Slebodnik # screen filter out LD_* evniroment varibles.
447d32b6f572e8ba3100668cb8677c19c0085be6Lukas Slebodnik # Back-up them and set them later in screenrc
447d32b6f572e8ba3100668cb8677c19c0085be6Lukas Slebodnik my_env["_LD_LIBRARY_PATH"] = os.getenv("LD_LIBRARY_PATH", "")
447d32b6f572e8ba3100668cb8677c19c0085be6Lukas Slebodnik my_env["_LD_PRELOAD"] = os.getenv("LD_PRELOAD", "")
447d32b6f572e8ba3100668cb8677c19c0085be6Lukas Slebodnik "screen", "-DAm", "-S", "sssd_cwrap_session", "-c",
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov """Return first argument that points to an existing directory."""
885da2c88a214eddd8c5ba16118debdf7e8f2666Fabiano Fidênciodef get_call_output(cmd, stderr_output=subprocess.PIPE):