本文整理汇总了Python中inspect.stack方法的典型用法代码示例。如果您正苦于以下问题:Python inspect.stack方法的具体用法?Python inspect.stack怎么用?Python inspect.stack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类inspect
的用法示例。
在下文中一共展示了inspect.stack方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fnCall
# 需要导入模块: import inspect [as 别名]
# 或者: from inspect import stack [as 别名]
def fnCall():
"""
Prints filename:line:function for parent and grandparent.
"""
if not config.debug:
return
print(colors.OKGREEN + colors.BOLD + "=== DEBUG === | %s:%d:%s() called from %s:%d:%s()" % (
inspect.stack()[1][1].split(os.sep)[-1],
inspect.stack()[1][2],
inspect.stack()[1][3],
inspect.stack()[2][1].split(os.sep)[-1],
inspect.stack()[2][2],
inspect.stack()[2][3],
)+colors.RESET)
示例2: set_used
# 需要导入模块: import inspect [as 别名]
# 或者: from inspect import stack [as 别名]
def set_used(self, value, frame=None):
"""
Set used flag.
:Parameters:
#. value (boolean): True to use this constraint in stochastic
engine runtime.
#. frame (None, string): Target frame name. If None, engine used
frame is used. If multiframe is given, all subframes will be
targeted. If subframe is given, all other multiframe subframes
will be targeted.
"""
assert isinstance(value, bool), LOGGER.error("value must be boolean")
# get used frame
if self.engine is not None:
print(self.engine)
print(self.engine.usedFrame)
usedIncluded, frame, allFrames = get_caller_frames(engine=self.engine,
frame=frame,
subframeToAll=True,
caller="%s.%s"%(self.__class__.__name__,inspect.stack()[0][3]) )
if usedIncluded:
self.__used = value
for frm in allFrames:
self._dump_to_repository({'_Constraint__used' :value}, frame=frm)
示例3: transform_coordinates
# 需要导入模块: import inspect [as 别名]
# 或者: from inspect import stack [as 别名]
def transform_coordinates(self, coordinates, argument=None):
"""
Transform coordinates. This method is called to move atoms.
This method must be overloaded in all MoveGenerator sub-classes.
:Parameters:
#. coordinates (np.ndarray): The coordinates on which to apply
the move.
#. argument (object): Any other argument needed to perform the
move. In General it's not needed.
:Returns:
#. coordinates (np.ndarray): The new coordinates after applying
the move.
"""
raise Exception(LOGGER.impl("%s '%s' method must be overloaded"%(self.__class__.__name__,inspect.stack()[0][3])))
示例4: logging_config
# 需要导入模块: import inspect [as 别名]
# 或者: from inspect import stack [as 别名]
def logging_config(name=None, level=logging.DEBUG, console_level=logging.DEBUG):
if name is None:
name = inspect.stack()[1][1].split('.')[0]
folder = os.path.join(os.getcwd(), name)
if not os.path.exists(folder):
os.makedirs(folder)
logpath = os.path.join(folder, name + ".log")
print("All Logs will be saved to %s" %logpath)
logging.root.setLevel(level)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
logfile = logging.FileHandler(logpath)
logfile.setLevel(level)
logfile.setFormatter(formatter)
logging.root.addHandler(logfile)
#TODO Update logging patterns in other files
logconsole = logging.StreamHandler()
logconsole.setLevel(console_level)
logconsole.setFormatter(formatter)
logging.root.addHandler(logconsole)
return folder
示例5: install_words
# 需要导入模块: import inspect [as 别名]
# 或者: from inspect import stack [as 别名]
def install_words(game):
# stack()[0] is this; stack()[1] is adventure.play(); so, stack()[2]
namespace = inspect.stack()[2][0].f_globals
words = [ k for k in game.vocabulary if isinstance(k, str) ]
words.append('yes')
words.append('no')
for word in words:
identifier = ReprTriggeredPhrase(game, [ word ])
namespace[word] = identifier
if len(word) > 5:
namespace[word[:5]] = identifier
#__main__.py
示例6: create_resource_stack
# 需要导入模块: import inspect [as 别名]
# 或者: from inspect import stack [as 别名]
def create_resource_stack(cls, resource_stack_name):
try:
cls.logger.test("Creating test resources stack {}", resource_stack_name)
ami = Ec2(region()).latest_aws_linux_image["ImageId"]
resource_stack = Stack(resource_stack_name, region=region())
resource_stack.create_stack(template_file=template_path(__file__, TEST_RESOURCES_TEMPLATE),
timeout=1200,
iam_capability=True,
params={
"InstanceAmi": ami,
"InstanceType": TEST_INSTANCE_TYPES[0]
})
return resource_stack
except Exception as ex:
cls.logger.test("Error creating stack {}, {}", resource_stack_name, ex)
return None
示例7: create_resource_stack
# 需要导入模块: import inspect [as 别名]
# 或者: from inspect import stack [as 别名]
def create_resource_stack(cls, resource_stack_name):
try:
cls.logger.test("Creating test resources stack {}", resource_stack_name)
resource_stack = Stack(resource_stack_name, region=region())
default_vpc_id = cls.ec2.get_default_vpc()
assert default_vpc_id is not None
resource_stack.create_stack(template_file=template_path(__file__, TEST_RESOURCES_TEMPLATE),
timeout=1200,
iam_capability=True,
params={
"VpcId": default_vpc_id["VpcId"],
})
return resource_stack
except Exception as ex:
cls.logger.test("Error creating stack {}, {}", resource_stack_name, ex)
return None
示例8: create_resource_stack
# 需要导入模块: import inspect [as 别名]
# 或者: from inspect import stack [as 别名]
def create_resource_stack(cls, resource_stack_name):
try:
cls.logger.test("Creating test resources stack {}", resource_stack_name)
ami = Ec2(region()).latest_aws_linux_image["ImageId"]
resource_stack = Stack(resource_stack_name, region=region())
resource_stack.create_stack(template_file=template_path(__file__, TEST_RESOURCES_TEMPLATE), iam_capability=True,
params={
"InstanceAmi": ami,
"InstanceType": "t2.micro",
"TaskListTagName": tasklist_tagname(TESTED_ACTION),
"TaskListTagValue": ",".join(cls.get_methods())
})
return resource_stack
except Exception as ex:
cls.logger.test("Error creating stack {}, {}", resource_stack_name, ex)
return None
示例9: create_resource_stack
# 需要导入模块: import inspect [as 别名]
# 或者: from inspect import stack [as 别名]
def create_resource_stack(cls, resource_stack_name):
try:
cls.logger.test("Creating test resources stack {}", resource_stack_name)
ami = Ec2(region()).latest_aws_linux_image["ImageId"]
resource_stack = Stack(resource_stack_name, region=region())
stack_parameters = {
"InstanceAmi": ami, "InstanceType": "t2.micro",
"TaskListTagName": tasklist_tagname(TESTED_ACTION),
"TaskListTagValueNoCPULoad": "test_instance_no_cpu_load",
"TaskListTagValueCPULoad": "test_instance_cpu_load"
}
resource_stack.create_stack(template_file=template_path(__file__, TEST_RESOURCES_TEMPLATE),
iam_capability=True,
params=stack_parameters)
return resource_stack
except Exception as ex:
cls.logger.test("Error creating stack {}, {}", resource_stack_name, ex)
return None
示例10: whoami
# 需要导入模块: import inspect [as 别名]
# 或者: from inspect import stack [as 别名]
def whoami():
return '* ' + cur_time_msec() + ' ' + inspect.stack()[1][3] + ' '
示例11: whosdaddy
# 需要导入模块: import inspect [as 别名]
# 或者: from inspect import stack [as 别名]
def whosdaddy():
return '*' + cur_time_msec() + ' ' + inspect.stack()[2][3] + ' '
示例12: select_index
# 需要导入模块: import inspect [as 别名]
# 或者: from inspect import stack [as 别名]
def select_index(self):
"""
This method must be overloaded in every GroupSelector sub-class
:Returns:
#. index (integer): the selected group index in engine groups list.
"""
raise Exception(LOGGER.error("%s '%s' method must be overloaded"%(self.__class__.__name__,inspect.stack()[0][3])))
示例13: _codify__
# 需要导入模块: import inspect [as 别名]
# 或者: from inspect import stack [as 别名]
def _codify__(self, *args, **kwargs):
raise Exception(LOGGER.impl("'%s' method must be overloaded"%inspect.stack()[0][3]))
示例14: _apply_multiframe_prior
# 需要导入模块: import inspect [as 别名]
# 或者: from inspect import stack [as 别名]
def _apply_multiframe_prior(self, total):
raise Exception(LOGGER.impl("%s '%s' method must be overloaded"%(self.__class__.__name__,inspect.stack()[0][3])))
示例15: _apply_scale_factor
# 需要导入模块: import inspect [as 别名]
# 或者: from inspect import stack [as 别名]
def _apply_scale_factor(self, total, scaleFactor):
raise Exception(LOGGER.impl("%s '%s' method must be overloaded"%(self.__class__.__name__,inspect.stack()[0][3])))