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


Python os.putenv方法代码示例

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


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

示例1: get_r2pipe

# 需要导入模块: import os [as 别名]
# 或者: from os import putenv [as 别名]
def get_r2pipe(filename, offset, options=None):
    """
    Get a r2pipe handle ready to analyse a flashair binary.
    """

    # Set the miasm architecture
    os.putenv("R2M2_ARCH", "mepl")

    # Use the r2m2 architecture
    default_options = ["-a", "r2m2"]

    # Map the binary at a given location
    default_options += ["-m", hex(offset)]

    # Decrease r2 verbosity
    default_options += ["-e", "bin.verbose=false"]

    # Add user specified options
    if isinstance(options, list):
        default_options += options

    return r2pipe.open(filename, default_options) 
开发者ID:guedou,项目名称:flashre,代码行数:24,代码来源:utils.py

示例2: __setitem__

# 需要导入模块: import os [as 别名]
# 或者: from os import putenv [as 别名]
def __setitem__(self, key, value):
        key = _norm_key(path2fsn(key))
        value = path2fsn(value)

        if is_win and PY2:
            # this calls putenv, so do it first and replace later
            try:
                os.environ[_fsn2legacy(key)] = _fsn2legacy(value)
            except OSError:
                raise ValueError

            try:
                set_windows_env_var(key, value)
            except WindowsError:
                # py3+win fails for invalid keys. try to do the same
                raise ValueError
        try:
            self._env[key] = value
        except OSError:
            raise ValueError 
开发者ID:bugatsinho,项目名称:bugatsinho.github.io,代码行数:22,代码来源:_environ.py

示例3: process_command

# 需要导入模块: import os [as 别名]
# 或者: from os import putenv [as 别名]
def process_command(test, params, env, command, command_timeout,
                    command_noncritical):
    """
    Pre- or post- custom commands to be executed before/after a test is run

    :param test: An Autotest test object.
    :param params: A dict containing all VM and image parameters.
    :param env: The environment (a dict-like object).
    :param command: Command to be run.
    :param command_timeout: Timeout for command execution.
    :param command_noncritical: If True test will not fail if command fails.
    """
    # Export environment vars
    for k in params:
        os.putenv("KVM_TEST_%s" % k, str(params[k]))
    # Execute commands
    try:
        a_process.system(
            "cd %s; %s" %
            (test.bindir, command), shell=True)
    except a_process.CmdError as e:
        if command_noncritical:
            logging.warn(e)
        else:
            raise 
开发者ID:avocado-framework,项目名称:avocado-vt,代码行数:27,代码来源:env_process.py

示例4: execute_command

# 需要导入模块: import os [as 别名]
# 或者: from os import putenv [as 别名]
def execute_command(self, cmd, timeout):
    ret = None
    if self.debugging_interface is None:
      cmd_obj = TimeoutCommand(cmd)
      ret = cmd_obj.run(timeout=self.timeout)
      if cmd_obj.stderr is not None:
        print cmd_obj.stderr
    else:
      self.iface.timeout = self.timeout
      if not has_pykd or self.iface != pykd_iface:
        if self.iface == asan_iface:
          crash = self.iface.main(asan_symbolizer_path=self.asan_symbolizer_path, args=cmd)
        else:
          crash = self.iface.main(cmd)
      else:
        # Avoid network timeouts and unnecessary delays when using pykd
        os.putenv("_NT_SYMBOL_PATH", "")
        crash = pykd_iface.main([cmd], timeout, mode=self.mode, windbg_path=self.windbg_path, exploitable_path=self.exploitable_path)

      if crash is not None:
        self.last_crash = crash
        ret = 0xC0000005 # Access violation in Windows

    return ret 
开发者ID:joxeankoret,项目名称:nightmare,代码行数:26,代码来源:minimize_bindiff.py

示例5: __init__

# 需要导入模块: import os [as 别名]
# 或者: from os import putenv [as 别名]
def __init__(self, *args, **kw):
      if hasattr(sys, 'frozen'):
        # We have to set original _MEIPASS2 value from sys._MEIPASS
        # to get --onefile mode working.
        os.putenv('_MEIPASS2', sys._MEIPASS)
      try:
        super(_Popen, self).__init__(*args, **kw)
      finally:
        if hasattr(sys, 'frozen'):
          # On some platforms (e.g. AIX) 'os.unsetenv()' is not
          # available. In those cases we cannot delete the variable
          # but only set it to the empty string. The bootloader
          # can handle this case.
          if hasattr(os, 'unsetenv'):
            os.unsetenv('_MEIPASS2')
          else:
            os.putenv('_MEIPASS2', '')

  # Second override 'Popen' class with our modified version. 
开发者ID:lanjelot,项目名称:patator,代码行数:21,代码来源:patator.py

示例6: __checkdeepquote_c

# 需要导入模块: import os [as 别名]
# 或者: from os import putenv [as 别名]
def __checkdeepquote_c(self, hAIK, vAIK, deepquoteFile, nonce):
        os.putenv('TPM_SERVER_PORT', '9999')
        os.putenv('TPM_SERVER_NAME', '9999')
        os.putenv('PATH', os.getenv('PATH') + ':/usr/local/bin')

        if common.STUB_TPM and common.TPM_CANNED_VALUES is not None:
            yamlIn = common.TPM_CANNED_VALUES
            if 'deepquote' in yamlIn:
                # YAML unicode-ifies strings, and C calls require byte strings (str)
                if 'nonce' in yamlIn['deepquote']:
                    nonce = str(yamlIn['deepquote']['nonce'])
            else:
                raise Exception("Could not get deepquote from canned YAML!")

        cmd = 'checkdeepquote -aik {0} -deepquote {1} -nonce {2} -vaik {3}'.format(hAIK, deepquoteFile, nonce, vAIK)
        #logger.info('Running cmd %r', cmd)

        retDict = self.__run(cmd,lock=False)
        return retDict['retout'] 
开发者ID:keylime,项目名称:keylime,代码行数:21,代码来源:tpm1.py

示例7: __check_quote_c

# 需要导入模块: import os [as 别名]
# 或者: from os import putenv [as 别名]
def __check_quote_c(self, aikFile, quoteFile, extData):
        os.putenv('TPM_SERVER_PORT', '9999')
        os.putenv('TPM_SERVER_NAME', '9999')
        os.putenv('PATH', os.getenv('PATH') + ':/usr/local/bin')

        if common.STUB_TPM and common.TPM_CANNED_VALUES is not None:
            yamlIn = common.TPM_CANNED_VALUES
            if 'tpmquote' in yamlIn and 'nonce' in yamlIn['tpmquote']:
                # YAML unicode-ifies strings, and C calls require byte strings (str)
                extData = str(yamlIn['tpmquote']['nonce'])
            else:
                raise Exception("Could not get quote nonce from canned YAML!")

        #print('Executing "%s"' % ("checkquote -aik %s -quote %s -nonce %s"%(aikFile, quoteFile, extData),))
        if common.USE_CLIME:
            import _cLime
            retout = _cLime.checkquote('-aik', aikFile, '-quote', quoteFile, '-nonce', extData)
            retout = [line + '\n' for line in retout.split('\n')]
            # Try and be transparent to tpm_quote.py
            return retout
        else:
            retDict = self.__run("checkquote -aik %s -quote %s -nonce %s"%(aikFile, quoteFile, extData),lock=False)
            return retDict['retout'] 
开发者ID:keylime,项目名称:keylime,代码行数:25,代码来源:tpm1.py

示例8: add_environment_variables

# 需要导入模块: import os [as 别名]
# 或者: from os import putenv [as 别名]
def add_environment_variables(params, endpoint, record, temp_files, non_shared):
        # type: (KeeperParams, str, Record, [str], dict) -> [str]
        rs = []         # type: [str]
        key_prefix = 'connect:{0}:env:'.format(endpoint)
        for cf in record.custom_fields:
            cf_name = cf['name']        # type: str
            if cf_name.startswith(key_prefix):
                key_name = cf_name[len(key_prefix):]
                if not key_name:
                    continue
                cf_value = cf['value']  # type: str
                while True:
                    m = endpoint_parameter_pattern.search(cf_value)
                    if not m:
                        break
                    p = m.group(1)
                    val = ConnectCommand.get_parameter_value(params, record, p, temp_files, non_shared)
                    if not val:
                        raise Exception('Add environment variable. Failed to resolve key parameter: {0}'.format(p))
                    cf_value = cf_value[:m.start()] + val + cf_value[m.end():]
                if cf_value:
                    rs.append(key_name)
                    os.putenv(key_name, cf_value)
        return rs 
开发者ID:Keeper-Security,项目名称:Commander,代码行数:26,代码来源:utils.py

示例9: __init__

# 需要导入模块: import os [as 别名]
# 或者: from os import putenv [as 别名]
def __init__(self, *args, **kw):
            if hasattr(sys, 'frozen'):
                # We have to set original _MEIPASS2 value from sys._MEIPASS
                # to get --onefile mode working.
                os.putenv('_MEIPASS2', sys._MEIPASS)
            try:
                super(_Popen, self).__init__(*args, **kw)
            finally:
                if hasattr(sys, 'frozen'):
                    # On some platforms (e.g. AIX) 'os.unsetenv()' is not
                    # available. In those cases we cannot delete the variable
                    # but only set it to the empty string. The bootloader
                    # can handle this case.
                    if hasattr(os, 'unsetenv'):
                        os.unsetenv('_MEIPASS2')
                    else:
                        os.putenv('_MEIPASS2', '')

    # Second override 'Popen' class with our modified version. 
开发者ID:devgc,项目名称:EventMonkey,代码行数:21,代码来源:EventMonkey.py

示例10: set_verbosity

# 需要导入模块: import os [as 别名]
# 或者: from os import putenv [as 别名]
def set_verbosity(args):
    """determine the message level in the environment to set based on args.
    """
    level = "INFO"

    if args.debug:
        level = "DEBUG"
    elif args.quiet:
        level = "QUIET"

    os.environ["MESSAGELEVEL"] = level
    os.putenv("MESSAGELEVEL", level)
    os.environ["SINGULARITY_MESSAGELEVEL"] = level
    os.putenv("SINGULARITY_MESSAGELEVEL", level)

    # Import logger to set
    from spython.logger import bot

    bot.debug("Logging level %s" % level)
    import spython

    bot.debug("Singularity Python Version: %s" % spython.__version__) 
开发者ID:singularityhub,项目名称:singularity-cli,代码行数:24,代码来源:__init__.py

示例11: __init__

# 需要导入模块: import os [as 别名]
# 或者: from os import putenv [as 别名]
def __init__(self, level, visualize=False, frame_skip=1, fps=30):
        super().__init__()

        import ple

        if isinstance(level, str):
            assert level in PyGameLearningEnvironment.levels()
            level = getattr(ple.games, level)()

        if not visualize:
            os.putenv('SDL_VIDEODRIVER', 'fbcon')
            os.environ['SDL_VIDEODRIVER'] = 'dummy'

        self.environment = ple.PLE(
            game=level, fps=fps, frame_skip=frame_skip, display_screen=visualize
            # num_steps=1, reward_values={}, force_fps=True, add_noop_action=True, NOOP=K_F15,
            # state_preprocessor=None, rng=24
        )
        self.environment.init()

        self.has_game_state = self.environment.getGameStateDims() is not None
        self.available_actions = tuple(self.environment.getActionSet()) 
开发者ID:tensorforce,项目名称:tensorforce,代码行数:24,代码来源:pygame_learning_environment.py

示例12: test_env

# 需要导入模块: import os [as 别名]
# 或者: from os import putenv [as 别名]
def test_env(self):
        h = vanilla.Hub()

        VAR1 = 'VANILLA_%s_VAR1' % os.getpid()
        VAR2 = 'VANILLA_%s_VAR2' % os.getpid()

        os.putenv(VAR1, 'VAR1')

        child = h.process.execv(
            ['/usr/bin/env', 'sh', '-c', 'echo $%s $%s' % (VAR1, VAR2)])
        assert child.stdout.recv() == 'VAR1\n'

        child = h.process.execv(
            ['/usr/bin/env', 'sh', '-c', 'echo $%s $%s' % (VAR1, VAR2)],
            env={VAR2: 'VAR2'})
        assert child.stdout.recv() == 'VAR2\n' 
开发者ID:cablehead,项目名称:vanilla,代码行数:18,代码来源:test_process.py

示例13: __init__

# 需要导入模块: import os [as 别名]
# 或者: from os import putenv [as 别名]
def __init__(self, pid, current_path, executable, template_out_path):
        """
        Args:

            pid: numeric pid of the target
            current_path: the directory containing gdb_commands.py
            executable: the binary passed as the first arg to gdb
            template_out_path: the location that analysis.py rendered templates
                end up in.
        """
        self.pid = pid
        self.fifo = f"/tmp/memanz_pipe_{self.pid}"
        self.current_path = current_path
        # These should all be the same, so safe for threads.
        os.putenv("MEMORY_ANALYZER_TEMPLATES_PATH", template_out_path)
        self.executable = executable 
开发者ID:facebookincubator,项目名称:memory-analyzer,代码行数:18,代码来源:analysis_utils.py

示例14: sign

# 需要导入模块: import os [as 别名]
# 或者: from os import putenv [as 别名]
def sign(opts):
  """Tag the commit & sign it!"""
  # We use ! at the end of the key so that gpg uses this specific key.
  # Otherwise it uses the key as a lookup into the overall key and uses the
  # default signing key.  i.e. It will see that KEYID_RSA is a subkey of
  # another key, and use the primary key to sign instead of the subkey.
  cmd = ['git', 'tag', '-s', opts.tag, '-u', f'{opts.key}!',
         '-m', f'repo {opts.tag}', opts.commit]

  key = 'GNUPGHOME'
  print('+', f'export {key}="{opts.gpgdir}"')
  oldvalue = os.getenv(key)
  os.putenv(key, opts.gpgdir)
  util.run(opts, cmd)
  if oldvalue is None:
    os.unsetenv(key)
  else:
    os.putenv(key, oldvalue) 
开发者ID:GerritCodeReview,项目名称:git-repo,代码行数:20,代码来源:sign-tag.py

示例15: __init__

# 需要导入模块: import os [as 别名]
# 或者: from os import putenv [as 别名]
def __init__(self, *args, **kw):
        if hasattr(sys, 'frozen'):
            # We have to set original _MEIPASS2 value from sys._MEIPASS
            # to get --onefile mode working.
            # Last character is stripped in C-loader. We have to add
            # '/' or '\\' at the end.
            os.putenv('_MEIPASS2', sys._MEIPASS + os.sep)
        try:
            super(_Popen, self).__init__(*args, **kw)
        finally:
            if hasattr(sys, 'frozen'):
                # On some platforms (e.g. AIX) 'os.unsetenv()' is not
                # available. In those cases we cannot delete the variable
                # but only set it to the empty string. The bootloader
                # can handle this case.
                if hasattr(os, 'unsetenv'):
                    os.unsetenv('_MEIPASS2')
                else:
                    os.putenv('_MEIPASS2', '') 
开发者ID:SekoiaLab,项目名称:Fastir_Collector,代码行数:21,代码来源:mem.py


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