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


Python compat.get_exception方法代码示例

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


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

示例1: __init__

# 需要导入模块: from numpy.distutils import compat [as 别名]
# 或者: from numpy.distutils.compat import get_exception [as 别名]
def __init__(self):
        if self.info is not None:
            return
        info = [ {} ]
        ok, output = getoutput('uname -m')
        if ok:
            info[0]['uname_m'] = output.strip()
        try:
            fo = open('/proc/cpuinfo')
        except EnvironmentError:
            e = get_exception()
            warnings.warn(str(e), UserWarning, stacklevel=2)
        else:
            for line in fo:
                name_value = [s.strip() for s in line.split(':', 1)]
                if len(name_value) != 2:
                    continue
                name, value = name_value
                if not info or name in info[-1]: # next processor
                    info.append({})
                info[-1][name] = value
            fo.close()
        self.__class__.info = info 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:25,代码来源:cpuinfo.py

示例2: main

# 需要导入模块: from numpy.distutils import compat [as 别名]
# 或者: from numpy.distutils.compat import get_exception [as 别名]
def main():
    try:
        file = sys.argv[1]
    except IndexError:
        fid = sys.stdin
        outfile = sys.stdout
    else:
        fid = open(file, 'r')
        (base, ext) = os.path.splitext(file)
        newname = base
        outfile = open(newname, 'w')

    allstr = fid.read()
    try:
        writestr = process_str(allstr)
    except ValueError:
        e = get_exception()
        raise ValueError("In %s loop at %s" % (file, e))
    outfile.write(writestr) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:21,代码来源:conv_template.py

示例3: __init__

# 需要导入模块: from numpy.distutils import compat [as 别名]
# 或者: from numpy.distutils.compat import get_exception [as 别名]
def __init__(self):
        if self.info is not None:
            return
        info = [ {} ]
        ok, output = getoutput('uname -m')
        if ok:
            info[0]['uname_m'] = output.strip()
        try:
            fo = open('/proc/cpuinfo')
        except EnvironmentError:
            e = get_exception()
            warnings.warn(str(e), UserWarning)
        else:
            for line in fo:
                name_value = [s.strip() for s in line.split(':', 1)]
                if len(name_value) != 2:
                    continue
                name, value = name_value
                if not info or name in info[-1]: # next processor
                    info.append({})
                info[-1][name] = value
            fo.close()
        self.__class__.info = info 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:25,代码来源:cpuinfo.py

示例4: UnixCCompiler__compile

# 需要导入模块: from numpy.distutils import compat [as 别名]
# 或者: from numpy.distutils.compat import get_exception [as 别名]
def UnixCCompiler__compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
    """Compile a single source files with a Unix-style compiler."""
    # HP ad-hoc fix, see ticket 1383
    ccomp = self.compiler_so
    if ccomp[0] == 'aCC':
        # remove flags that will trigger ANSI-C mode for aCC
        if '-Ae' in ccomp:
            ccomp.remove('-Ae')
        if '-Aa' in ccomp:
            ccomp.remove('-Aa')
        # add flags for (almost) sane C++ handling
        ccomp += ['-AA']
        self.compiler_so = ccomp

    display = '%s: %s' % (os.path.basename(self.compiler_so[0]), src)
    try:
        self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
                   extra_postargs, display = display)
    except DistutilsExecError:
        msg = str(get_exception())
        raise CompileError(msg) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:23,代码来源:unixccompiler.py

示例5: new_compiler

# 需要导入模块: from numpy.distutils import compat [as 别名]
# 或者: from numpy.distutils.compat import get_exception [as 别名]
def new_compiler (plat=None,
                  compiler=None,
                  verbose=0,
                  dry_run=0,
                  force=0):
    # Try first C compilers from numpy.distutils.
    if plat is None:
        plat = os.name
    try:
        if compiler is None:
            compiler = get_default_compiler(plat)
        (module_name, class_name, long_description) = compiler_class[compiler]
    except KeyError:
        msg = "don't know how to compile C/C++ code on platform '%s'" % plat
        if compiler is not None:
            msg = msg + " with '%s' compiler" % compiler
        raise DistutilsPlatformError(msg)
    module_name = "numpy.distutils." + module_name
    try:
        __import__ (module_name)
    except ImportError:
        msg = str(get_exception())
        log.info('%s in numpy.distutils; trying from distutils',
                 str(msg))
        module_name = module_name[6:]
        try:
            __import__(module_name)
        except ImportError:
            msg = str(get_exception())
            raise DistutilsModuleError("can't compile C/C++ code: unable to load module '%s'" % \
                  module_name)
    try:
        module = sys.modules[module_name]
        klass = vars(module)[class_name]
    except KeyError:
        raise DistutilsModuleError(("can't compile C/C++ code: unable to find class '%s' " +
               "in module '%s'") % (class_name, module_name))
    compiler = klass(None, dry_run, force)
    log.debug('new_compiler returns %s' % (klass))
    return compiler 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:42,代码来源:ccompiler.py

示例6: getoutput

# 需要导入模块: from numpy.distutils import compat [as 别名]
# 或者: from numpy.distutils.compat import get_exception [as 别名]
def getoutput(cmd, successful_status=(0,), stacklevel=1):
    try:
        status, output = getstatusoutput(cmd)
    except EnvironmentError:
        e = get_exception()
        warnings.warn(str(e), UserWarning, stacklevel=stacklevel)
        return False, ""
    if os.WIFEXITED(status) and os.WEXITSTATUS(status) in successful_status:
        return True, output
    return False, output 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:12,代码来源:cpuinfo.py

示例7: _wrap_method

# 需要导入模块: from numpy.distutils import compat [as 别名]
# 或者: from numpy.distutils.compat import get_exception [as 别名]
def _wrap_method(self, mth, lang, args):
        from distutils.ccompiler import CompileError
        from distutils.errors import DistutilsExecError
        save_compiler = self.compiler
        if lang in ['f77', 'f90']:
            self.compiler = self.fcompiler
        try:
            ret = mth(*((self,)+args))
        except (DistutilsExecError, CompileError):
            str(get_exception())
            self.compiler = save_compiler
            raise CompileError
        self.compiler = save_compiler
        return ret 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:16,代码来源:config.py

示例8: _wrap_method

# 需要导入模块: from numpy.distutils import compat [as 别名]
# 或者: from numpy.distutils.compat import get_exception [as 别名]
def _wrap_method(self, mth, lang, args):
        from distutils.ccompiler import CompileError
        from distutils.errors import DistutilsExecError
        save_compiler = self.compiler
        if lang in ['f77', 'f90']:
            self.compiler = self.fcompiler
        try:
            ret = mth(*((self,)+args))
        except (DistutilsExecError, CompileError):
            msg = str(get_exception())
            self.compiler = save_compiler
            raise CompileError
        self.compiler = save_compiler
        return ret 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:16,代码来源:config.py

示例9: UnixCCompiler__compile

# 需要导入模块: from numpy.distutils import compat [as 别名]
# 或者: from numpy.distutils.compat import get_exception [as 别名]
def UnixCCompiler__compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
    """Compile a single source files with a Unix-style compiler."""
    # HP ad-hoc fix, see ticket 1383
    ccomp = self.compiler_so
    if ccomp[0] == 'aCC':
        # remove flags that will trigger ANSI-C mode for aCC
        if '-Ae' in ccomp:
            ccomp.remove('-Ae')
        if '-Aa' in ccomp:
            ccomp.remove('-Aa')
        # add flags for (almost) sane C++ handling
        ccomp += ['-AA']
        self.compiler_so = ccomp
    # ensure OPT environment variable is read
    if 'OPT' in os.environ:
        from distutils.sysconfig import get_config_vars
        opt = " ".join(os.environ['OPT'].split())
        gcv_opt = " ".join(get_config_vars('OPT')[0].split())
        ccomp_s = " ".join(self.compiler_so)
        if opt not in ccomp_s:
            ccomp_s = ccomp_s.replace(gcv_opt, opt)
            self.compiler_so = ccomp_s.split()
        llink_s = " ".join(self.linker_so)
        if opt not in llink_s:
            self.linker_so = llink_s.split() + opt.split()

    display = '%s: %s' % (os.path.basename(self.compiler_so[0]), src)
    try:
        self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
                   extra_postargs, display = display)
    except DistutilsExecError:
        msg = str(get_exception())
        raise CompileError(msg) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:35,代码来源:unixccompiler.py

示例10: calc_info

# 需要导入模块: from numpy.distutils import compat [as 别名]
# 或者: from numpy.distutils.compat import get_exception [as 别名]
def calc_info(self):
        which = None, None
        if os.getenv("NUMERIX"):
            which = os.getenv("NUMERIX"), "environment var"
        # If all the above fail, default to numpy.
        if which[0] is None:
            which = "numpy", "defaulted"
            try:
                import numpy
                which = "numpy", "defaulted"
            except ImportError:
                msg1 = str(get_exception())
                try:
                    import Numeric
                    which = "numeric", "defaulted"
                except ImportError:
                    msg2 = str(get_exception())
                    try:
                        import numarray
                        which = "numarray", "defaulted"
                    except ImportError:
                        msg3 = str(get_exception())
                        log.info(msg1)
                        log.info(msg2)
                        log.info(msg3)
        which = which[0].strip().lower(), which[1]
        if which[0] not in ["numeric", "numarray", "numpy"]:
            raise ValueError("numerix selector must be either 'Numeric' "
                             "or 'numarray' or 'numpy' but the value obtained"
                             " from the %s was '%s'." % (which[1], which[0]))
        os.environ['NUMERIX'] = which[0]
        self.set_info(**get_info(which[0])) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:34,代码来源:system_info.py

示例11: getoutput

# 需要导入模块: from numpy.distutils import compat [as 别名]
# 或者: from numpy.distutils.compat import get_exception [as 别名]
def getoutput(cmd, successful_status=(0,), stacklevel=1):
    try:
        status, output = getstatusoutput(cmd)
    except EnvironmentError:
        e = get_exception()
        warnings.warn(str(e), UserWarning, stacklevel=stacklevel)
        return False, output
    if os.WIFEXITED(status) and os.WEXITSTATUS(status) in successful_status:
        return True, output
    return False, output 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:12,代码来源:cpuinfo.py

示例12: process_file

# 需要导入模块: from numpy.distutils import compat [as 别名]
# 或者: from numpy.distutils.compat import get_exception [as 别名]
def process_file(source):
    lines = resolve_includes(source)
    sourcefile = os.path.normcase(source).replace("\\", "\\\\")
    try:
        code = process_str(''.join(lines))
    except ValueError:
        e = get_exception()
        raise ValueError('In "%s" loop at %s' % (sourcefile, e))
    return '#line 1 "%s"\n%s' % (sourcefile, code) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:11,代码来源:conv_template.py


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