本文整理汇总了Python中Base.Base.error方法的典型用法代码示例。如果您正苦于以下问题:Python Base.error方法的具体用法?Python Base.error怎么用?Python Base.error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Base.Base
的用法示例。
在下文中一共展示了Base.error方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_ci_to_repo
# 需要导入模块: from Base import Base [as 别名]
# 或者: from Base.Base import error [as 别名]
def update_ci_to_repo(storeName, data):
Base.info("writing ci: %s to repo" % storeName)
global StorageTimestamp
# get the store
store = load_ci_from_repo(storeName, __ciType)
# set the properties on the ci to be updated
for k, v in data.items():
store.setProperty(k, json.dumps(v))
store.setProperty('modTime', time_stamp())
# write back to xlr
if get_counter_timestamp(storeName) == StorageTimestamp:
try:
__repositoryService.update(store)
return True
except com.xebialabs.deployit.jcr.RuntimeRepositoryException as e:
Base.error('Error detected while saving %s' % storeName)
Base.error('Error: %s' % e)
return False
except com.xebialabs.deployit.repository.ItemConflictException as e:
Base.error('Error detected while saving %s' % storeName)
Base.error('Error: %s' % e)
return False
else:
Base.error('deadlock collision detected while saving %s' % storeName)
return False
示例2: get_path
# 需要导入模块: from Base import Base [as 别名]
# 或者: from Base.Base import error [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")
示例3: destroy_counter_store
# 需要导入模块: from Base import Base [as 别名]
# 或者: from Base.Base import error [as 别名]
def destroy_counter_store(storeName):
'''
Destroys a release counter store
:param storeName:
:return:
'''
if ci_exists(storeName, __ciType):
ci = load_ci_from_repo(storeName, __ciType )
__repositoryService.delete(ci.getId())
Base.info("Counter Store: %s destroyed.... BOOOM" % storeName)
else:
Base.error("Counter Store: %s did not exist... Moving on cuz that is how we roll" % storeName)
示例4: handle_phase
# 需要导入模块: from Base import Base [as 别名]
# 或者: from Base.Base import error [as 别名]
def handle_phase(self, phaseSettings, local_settings, release):
# resolve the settings in the phaseDict by doing a variable search and replace on the phase dict.
localPhaseDict = self.resolve_settings(phaseSettings, local_settings)
# create the phase
if localPhaseDict.has_key("title"):
self.get_target_phase(localPhaseDict["title"], release)
Base.info("phase: %s created with id %s" % (localPhaseDict["title"], localPhaseDict["title"]))
else:
Base.error("phase: not created title could not be retrieved")
if localPhaseDict.has_key("containers"):
self.handle_containers(localPhaseDict["title"], localPhaseDict["containers"], local_settings, release)
elif localPhaseDict.has_key("tasks"):
self.handle_tasks(localPhaseDict["title"], localPhaseDict["tasks"], local_settings, release)
else:
Base.info("no task found for this phase")
示例5: resolve_variable
# 需要导入模块: from Base import Base [as 别名]
# 或者: from Base.Base import error [as 别名]
def resolve_variable(self, **params):
"""
try to resolve the variable with the information specified
params can handle:
:default_value string: the default value to set in case no value could be retrieved
:collector dict: information used retrieve the value from an additional source
:param params:
:return: result for the resolve attempt
"""
# set our return value to None
ret_val = None
collector_val = None
# start by setting the default value if specified
if params.has_key('default_value'):
ret_val = params['default_value']
# act on the collector parameter
if params.has_key('collector'):
# if there is no type specified just pass it to the json collector, which is our default choice
# if not params['collector'].has_key('type'):
# collector_val = self.handle_json_collector(**params['collector'])
# if params['collector'].has_key('type'):
# collector_val = self.handle_json_collector(**params['collector'])
# else:
# print "collector type is not supported.... yet!!!"
# sys.exit(2)
# if there is no type specified just pass it to the json collector, which is our default choice
if not params['collector'].has_key('type'):
col_params = params['collector']
collector_val = JsonCollector(**col_params).resolve()
if params['collector'].has_key('type'):
col_params = params['collector']
collector_val = JsonCollector(**col_params).resolve()
else:
Base.error("collector type is not supported.... yet!!!")
pass
if collector_val:
ret_val = collector_val
return ret_val
示例6: create_ci
# 需要导入模块: from Base import Base [as 别名]
# 或者: from Base.Base import error [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)
示例7: load_json
# 需要导入模块: from Base import Base [as 别名]
# 或者: from Base.Base import error [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