本文整理汇总了Python中Base.Base.fatal方法的典型用法代码示例。如果您正苦于以下问题:Python Base.fatal方法的具体用法?Python Base.fatal怎么用?Python Base.fatal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Base.Base
的用法示例。
在下文中一共展示了Base.fatal方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: persist_variables_to_release
# 需要导入模块: from Base import Base [as 别名]
# 或者: from Base.Base import fatal [as 别名]
def persist_variables_to_release(self, releaseId):
"""
Handles resolving the variables and injecting them into the template
:return:
"""
release = self.__releaseApi.getRelease(releaseId)
self.set_variables_from_dict(self.resolve_xlr_template_variables(releaseId))
Base.info("resolved profile:")
print self.variables()
# handle variables inside the release first
newVariables = {}
# printing the variables for reporting
for k, v in self.variables().items():
Base.info("key: %s \t value: %s \n" % (k, v))
for key, value in self.variables().items():
if re.match(self.__variable_start_regex, key) is None:
key = "${%s}" % (key)
if type(value) is dict:
value = self.resolve_variable(**value)
if value == None:
Base.fatal("a value could not be generated for %s .. we are unable to keep the release valid" % key)
sys.exit(2)
newVariables[key] = value
release.setVariableValues(newVariables)
self.__releaseApi.updateRelease(releaseId, release)
示例2: get_path
# 需要导入模块: from Base import Base [as 别名]
# 或者: from Base.Base import fatal [as 别名]
def get_path(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 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" % (field))
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.fatal("Error encountered during resolution")
示例3: get_target_phase
# 需要导入模块: from Base import Base [as 别名]
# 或者: from Base.Base import fatal [as 别名]
def get_target_phase(self, targetPhase, release):
"""
search the release for the targetPhase by string name
for some stupid reason we can't address it by its name ..
:param targetPhase:string
:return:phaseId
"""
phaseList = self.__phaseApi.searchPhasesByTitle(str(targetPhase), release.id)
if len(phaseList) == 1:
return phaseList[0]
else:
print "Requested phase: %s not found. Creating it in the template first" % targetPhase
self.create_phase(targetPhase, release)
phaseList = self.__phaseApi.searchPhasesByTitle(str(targetPhase), release.id)
if len(phaseList) == 1:
return phaseList[0]
else:
Base.fatal(
"unable to create phase %s.. there is something seriously wrong with your installation"
% str(targetPhase)
)
示例4: handle_template
# 需要导入模块: from Base import Base [as 别名]
# 或者: from Base.Base import fatal [as 别名]
def handle_template(self, releaseId):
if self.template_plan() == None:
Base.fatal("no template plan found.. we can't continue")
if self.variables() != None:
self.handle_variables(releaseId)
if self.settings() != None:
self.set_settings_from_dict(self.resolve_xlr_template_variables_in_settings(self.settings(), releaseId))
if self.template_plan():
self.handle_template_plan(releaseId)
示例5: resolve_variables
# 需要导入模块: from Base import Base [as 别名]
# 或者: from Base.Base import fatal [as 别名]
def resolve_variables(self):
for key, val in self.variables():
if type(val) == dict:
solution = self.resolve_variable(val)
if solution == None:
Base.fatal("value for %s could not be found using the specified collector" % key)
sys.exit(2)
else:
Base.info("retrieved value: %s for %s" % (solution, key))
self.set_variable(key, solution)
示例6: load_ci_from_repo
# 需要导入模块: from Base import Base [as 别名]
# 或者: from Base.Base import fatal [as 别名]
def load_ci_from_repo(storeName, type):
sp = SearchParameters()
sp.setType(Type.valueOf(type))
for p in __repositoryService.listEntities(sp):
print p.getId()
if str(p.getTitle()) == storeName:
return p
Base.fatal("unable to find json data repository: %s" % storeName)
sys.exit(2)
示例7: get_target_phase
# 需要导入模块: from Base import Base [as 别名]
# 或者: from Base.Base import fatal [as 别名]
def get_target_phase(targetPhase):
"""
search the release for the targetPhase by string name
for some stupid reason we can't address it by its name ..
:param targetPhase:string
:return:phaseId
"""
phaseList = phaseApi.searchPhasesByTitle(targetPhase, release.id)
if len(phaseList) == 1:
return phaseList[0]
else:
Base.fatal("Requested phase: %s not found. Create it in the template first" % targetPhase)
示例8: download_json_profile
# 需要导入模块: from Base import Base [as 别名]
# 或者: from Base.Base import fatal [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)
示例9: create_ci
# 需要导入模块: from Base import Base [as 别名]
# 或者: from Base.Base import fatal [as 别名]
def create_ci(storeName):
'''
creates a ci in the xl-release repository under /Configuration/Custom of type rel.ReleaseCounterStore
:param storeName:
:return:
'''
Base.info("creating Counter Store: %s " % storeName)
ci = get_ci_object(__ciType, 'Configuration/Custom/%s' % storeName)
ci.setTitle(storeName)
check_ci_for_validations(ci)
try:
__repositoryService.create(ci)
Base.info("Counter Store: %s created")
except com.xebialabs.deployit.repository.ItemAlreadyExistsException as e:
Base.error(e)
Base.error("Counter Store already exists... moving on")
except Exception:
Base.fatal('an error occured while trying to create Counter Store: %s' % storeName)
sys.exit(2)
示例10: load_json
# 需要导入模块: from Base import Base [as 别名]
# 或者: from Base.Base import fatal [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
示例11:
# 需要导入模块: from Base import Base [as 别名]
# 或者: from Base.Base import fatal [as 别名]
{
"appName": appName,
"appVersion": appVersion,
"darBuildServer": __dar_build_server,
"xldeployServer": __xldeploy_server,
}
]
}
# both inputJson and inputJsonUrl cannot be None .
# we need input
if inputJson == None and inputJsonUrl == None:
Base.fatal("both inputJson and inputJsonUrl are empty: this can not be . existing step")
# inputJsonUrl takes precedence over inputJson ..
# BECAUSE I SAY SO ....Biatch
# Just checking if anyone ever really reads this ;-)
if inputJsonUrl:
if inputJsonUrl.startswith("http"):
inputJson = download_json_profile(inputJsonUrl)
if inputJson:
inputJson = inputJson.replace("\n", "").replace("\t", "").replace("\r", "")
handle_profile(__pre_build_steps, phaseName)
handle_profile(inputJson, phaseName)