sys._getframe.f_back.f_code.co_name

Here are the examples of the python api sys._getframe.f_back.f_code.co_name taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

6 Examples 7

Example 1

Project: st2
Source File: resolvers.py
View license
    def _log(self, message, extra, level=stdlib_logging.DEBUG, **kwargs):
        """
        Custom logger method which prefix message with the class and caller method name.
        """
        class_name = self.__class__.__name__
        method_name = sys._getframe().f_back.f_code.co_name
        message_prefix = '%s.%s: ' % (class_name, method_name)
        message = message_prefix + message

        LOG.log(level, message, extra=extra, **kwargs)

Example 2

Project: acd_cli
Source File: acd_fuse.py
View license
    @staticmethod
    def convert(e: RequestError):
        """:raises: FuseOSError"""

        try:
            caller = sys._getframe().f_back.f_code.co_name + ': '
        except AttributeError:
            caller = ''
        logger.error(caller + e.__str__())

        try:
            exc = FuseOSError.code_mapping[e.status_code]
        except AttributeError:
            exc = FuseOSError(errno.EREMOTEIO)
        raise exc

Example 3

Project: updateHosts
Source File: updateHosts.py
View license
def get_cur_info():
    return (sys._getframe().f_back.f_code.co_name)

Example 4

Project: updateHosts
Source File: updateHosts.py
View license
def get_cur_info():
    return (sys._getframe().f_back.f_code.co_name)

Example 5

Project: spinalcordtoolbox
Source File: sct_utils.py
View license
def run(cmd, verbose=1, error_exit='error', raise_exception=False):
    if verbose==2:
        printv(sys._getframe().f_back.f_code.co_name, 1, 'process')
    if verbose:
        print(bcolors.blue+cmd+bcolors.normal)
    process = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
    output_final = ''
    while True:
        output = process.stdout.readline()
        if output == '' and process.poll() is not None:
            break
        if output:
            if verbose == 2:
                print output.strip()
            output_final += output.strip()+'\n'
    status_output = process.returncode
    # process.stdin.close()
    # process.stdout.close()
    # process.terminate()

    # need to remove the last \n character in the output -> return output_final[0:-1]
    if status_output:
        # from inspect import stack
        printv(output_final[0:-1], 1, error_exit)
        # printv('\nERROR in '+stack()[1][1]+'\n', 1, 'error')  # print name of parent function
        # sys.exit()
        if raise_exception:
            raise Exception(output_final[0:-1])
    else:
        # no need to output process.returncode (because different from 0)
        return status_output, output_final[0:-1]

Example 6

Project: spinalcordtoolbox
Source File: sct_utils.py
View license
def run(cmd, verbose=1, error_exit='error', raise_exception=False):
    if verbose==2:
        printv(sys._getframe().f_back.f_code.co_name, 1, 'process')
    if verbose:
        print(bcolors.blue+cmd+bcolors.normal)
    process = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
    output_final = ''
    while True:
        output = process.stdout.readline()
        if output == '' and process.poll() is not None:
            break
        if output:
            if verbose == 2:
                print output.strip()
            output_final += output.strip()+'\n'
    status_output = process.returncode
    # process.stdin.close()
    # process.stdout.close()
    # process.terminate()

    # need to remove the last \n character in the output -> return output_final[0:-1]
    if status_output:
        # from inspect import stack
        printv(output_final[0:-1], 1, error_exit)
        # printv('\nERROR in '+stack()[1][1]+'\n', 1, 'error')  # print name of parent function
        # sys.exit()
        if raise_exception:
            raise Exception(output_final[0:-1])
    else:
        # no need to output process.returncode (because different from 0)
        return status_output, output_final[0:-1]