本文整理汇总了Python中Base.Base.warning方法的典型用法代码示例。如果您正苦于以下问题:Python Base.warning方法的具体用法?Python Base.warning怎么用?Python Base.warning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Base.Base
的用法示例。
在下文中一共展示了Base.warning方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_path
# 需要导入模块: from Base import Base [as 别名]
# 或者: from Base.Base import warning [as 别名]
def get_path(self, json, path):
"""
traverses the dictionary derived from the json to look if it can satisfy the requested path
:param json:
:param path:
:return:
"""
if (type(path) is str) or (type(path) is unicode):
path = str(path).split('/')
field = path.pop(0)
try:
if json.has_key(field):
if type(json[field]) == dict:
return self.get_path(json[field], path)
elif type(json[field]) == list:
if len(json[field]) < 2:
Base.info("found %s" % (json[field][0]))
return str(json[field][0])
elif len(path) == 0:
Base.info("found %s using path %s" % (field, path))
return str(json[field])
else:
Base.warning("the requested path of %s could not be found in the json document. returning None instead")
return None
except Exception:
Base.error("Error encountered during resolution")
示例2: get_title
# 需要导入模块: from Base import Base [as 别名]
# 或者: from Base.Base import warning [as 别名]
def get_title(title, citype, data):
Base.info("GATHERING TITLE for %s" % citype)
if __type_title_dict.has_key(citype):
print __type_title_dict[citype]
new_title = []
for x in ["prefix", "data_fields", "postfix"]:
try:
out = __type_title_dict[citype][x]
if type(out) == list:
for e in out:
try:
new_title.append(str(data[e]))
except KeyError:
Base.warning("unable to retrieve %s from step data" % e)
else:
new_title.append(out)
except KeyError:
Base.warning("no data defined for field %s" % x)
return " ".join(new_title)
else:
return title
示例3: handle_toggles
# 需要导入模块: from Base import Base [as 别名]
# 或者: from Base.Base import warning [as 别名]
def handle_toggles(self, releaseId):
release = self.__releaseApi.getRelease(releaseId)
if self.toggles:
try:
for t in self.toggles:
task = self.get_task_by_phase_and_title(str(t["phase"]), str(t["task"]), release)
if task:
Base.info("removing task %s " % task)
self.__repositoryService.delete(str(task))
else:
Base.info("task not found")
except TypeError:
Base.warning("toggles not valid... moving on")
else:
Base.warning("no toggles found")
示例4: update_counter_storage
# 需要导入模块: from Base import Base [as 别名]
# 或者: from Base.Base import warning [as 别名]
def update_counter_storage(counterStoreTitle, key, value):
# get a timestamp.
# because we do not want two proccesses saving to the same store at the same time (data-loss is not a good thing)
Base.info("attempting to update counterStorage")
while True:
data = get_counter_storage(counterStoreTitle)
if type(data) == dict:
data[key] = value
else:
data = {key : value}
if update_ci_to_repo(counterStoreTitle, {'counterStorage': data} ) == True:
Base.info("Counter storage ci: %s saved succesfully" % counterStoreTitle)
return True
Base.warning("unable to save counter due to deadlock situation.... retrying")
示例5: download_json_profile
# 需要导入模块: from Base import Base [as 别名]
# 或者: from Base.Base import warning [as 别名]
def download_json_profile(url):
Base.info("downloading json from %s" % url)
error = 300
output = requests.get(url, verify=False)
# adding in retry to make all this stuff a little more robust
# if all else fails .. we are going to retry 10 times ..
retries = 10
nr_tries = 0
while True:
# increment trie counter
nr_tries += 1
Base.info("trying to fetch json from url %s , try nr: %i" % (url, nr_tries))
# try to fetch a response
response = requests.get(url, verify=False)
# if the status code is above 299 (which usually means that we have a problem) retry
if response.status_code > 299:
# if the number of retries exceeds 10 fail hard .. cuz that is how we roll
if nr_tries > retries:
Base.fatal("Unable to retrieve json from url after %i retries" % retries)
# warn the user
Base.warning("unable to retrieve json from url: %s" % url)
# it is good form to back off a failing remote system a bit .. every retry we are gonna wait 5 seconds longer . Coffee time !!!!
sleeptime = 5 * int(nr_tries)
Base.warning("timing out for: %i seconds" % sleeptime)
# sleep dammit .. i need it ..
time.sleep(sleeptime)
else:
Base.info("Download from %s : succesfull" % url)
Base.info(str(response.text))
return str(response.text)
示例6: handle_task
# 需要导入模块: from Base import Base [as 别名]
# 或者: from Base.Base import warning [as 别名]
def handle_task(self, phaseId, taskDict, taskSettings, release, containerId=None):
'''
handles a single task
:param phaseId: id of the phase to add the task to
:param taskDict: dictionary describing the task
:param taskSettings: settings to use when resolving variables in the inputdict
:param release: release to add the steps to
:param containerId: id of the container to add the task to if any
:return: none
'''
localTaskDict = self.resolve_settings(taskDict, taskSettings)
try:
parentTypeValue = localTaskDict['meta']['parent_task_type']
taskTitle = localTaskDict['title']
except KeyError:
parentTypeValue = None
taskTitle = "forgot to set one"
try:
if containerId != None:
if localTaskDict['meta']['task_type'] == "xlrelease.gateTask":
Base.Fatal("It is not allowed to create a gate task inside a container, failing")
self.createSimpleTaskInContainer(containerId, taskTitle, localTaskDict['meta']['task_type'], localTaskDict, parentTypeValue)
else:
if parentTypeValue == None:
self.createSimpleTask(phaseId, localTaskDict['meta']['task_type'], taskTitle, localTaskDict, release, parentTypeValue)
else:
self.createCustomScriptTask(phaseId, localTaskDict['meta']['task_type'], taskTitle, localTaskDict, release, parentTypeValue)
except Exception as e:
Base.warning(e.message)
print "Unable to create task"
示例7: load_json
# 需要导入模块: from Base import Base [as 别名]
# 或者: from Base.Base import warning [as 别名]
def load_json(self, url):
"""
loads json from a url and translates it into a dictionary
:param url:
:return:
"""
# adding in retry to make all this stuff a little more robust
# if all else fails .. we are going to retry 10 times ..
retries = 10
nr_tries = 0
output = None
while True:
# increment trie counter
nr_tries += 1
Base.info("trying to fetch json from url %s , try nr: %i" % (url, nr_tries))
# try to fetch a response
response = requests.get(url, verify=False, **self.requests_params)
# if the status code is above 299 (which usually means that we have a problem) retry
if response.status_code > 299:
# if the number of retries exceeds 10 fail hard .. cuz that is how we roll
if nr_tries > retries:
Base.fatal('Unable to retrieve json from url after %i retries' % retries)
sys.exit(2)
# warn the user
Base.warning("unable to retrieve json from url: %s" % url)
# it is good form to back off a failing remote system a bit .. every retry we are gonna wait 5 seconds longer . Coffee time !!!!
sleeptime = 5 * int(nr_tries)
Base.warning("timing out for: %i seconds" % sleeptime)
# sleep dammit .. i need it ..
time.sleep(sleeptime)
output = None
else:
# if we do get a proper response code .. break out of the loop
break
try:
Base.info("%s responded with:" % url)
print response.text
output = json.loads(str(response.text))
except Exception:
Base.warning("unable to decode information provided by %s" % url)
time.sleep(5)
output = None
except JSONDecodeError:
Base.warning("unable to decode output, not json formatted")
time.sleep(5)
output = None
if output == None:
Base.error("unable extract information from url: %s " % url)
return output
示例8: createSimpleTask
# 需要导入模块: from Base import Base [as 别名]
# 或者: from Base.Base import warning [as 别名]
def createSimpleTask(self, phaseId, taskTypeValue, title, propertyMap, release, parentTaskType):
"""
adds a custom task to a phase in the release
:param phaseId: id of the phase
:param taskTypeValue: type of task to add
:param title: title of the task
:param propertyMap: properties to add to the task
:return:
"""
# print propertyMap
Base.warning("createSimpleTask")
phaseName = self.get_target_phase(phaseId, release)
TaskType = Type.valueOf(taskTypeValue)
Task = TaskType.descriptor.newInstance("nonamerequired")
Task.setTitle(title)
vm = {}
for item in propertyMap:
Base.info("settings %s on task of type: %s" % (item, TaskType))
if Task.hasProperty(item):
type = Task.getType()
desc = type.getDescriptor()
pd = desc.getPropertyDescriptor(item)
Base.warning(pd.getKind())
if item == "dependencies":
Base.info("dependencies found, these will be set later")
elif item == "templateId" and "Application" not in propertyMap[item]:
Task.setProperty(item, self.find_template_id_by_name(str(propertyMap[item])))
elif str(pd.getKind()) == "CI":
Task.setProperty(item, self.find_ci_id(str(item), pd.getReferencedType()))
elif str(pd.getKind()) == "bool":
if propertyMap[item] == "false":
Task.setProperty(item, False)
else:
Task.setProperty(item, True)
else:
Task.setProperty(item, propertyMap[item])
else:
Base.info("dropped property: %s on %s because: not applicable" % (item, taskTypeValue))
print dir(Task.getType().getDescriptor().getPropertyDescriptor('templateVariables'))
taskId = self.__taskApi.addTask(str(phaseName), Task)
if propertyMap.has_key("dependencies"):
for dep in propertyMap["dependencies"]:
if dep.has_key("targetId"):
self.__taskApi.addDependency(str(taskId), dep["targetId"])
if dep.has_key("target"):
self.__taskApi.addDependency(str(taskId), dep['target'])