當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。