本文整理汇总了Python中Base.Base类的典型用法代码示例。如果您正苦于以下问题:Python Base类的具体用法?Python Base怎么用?Python Base使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Base类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createSimpleTask
def createSimpleTask(phaseId, taskTypeValue, title, propertyMap):
"""
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
parenttaskType = Type.valueOf("xlrelease.CustomScriptTask")
parentTask = parenttaskType.descriptor.newInstance("nonamerequired")
parentTask.setTitle(title)
childTaskType = Type.valueOf(taskTypeValue)
childTask = childTaskType.descriptor.newInstance("nonamerequired")
for item in propertyMap:
if childTask.hasProperty(item):
childTask.setProperty(item, propertyMap[item])
else:
Base.info("dropped property: %s on %s because: not applicable" % (item, taskTypeValue))
parentTask.setPythonScript(childTask)
print str(parentTask)
taskApi.addTask(str(phaseId), parentTask)
示例2: resolve_xlr_template_variables_in_settings
def resolve_xlr_template_variables_in_settings(self, input_object, release_id):
'''
resolve xlr variables in dictionaries
:param release_id:
:param input_dictionary:
:return:
'''
output_list = []
output_dict = {}
# step through the dictionary
if type(input_object) == str or type(input_object) == unicode:
if '${' in input_object:
Base.info("found variable in %s" % input_object)
input_object = self.replace_xlr_variable_in_string(input_object, release_id)
return input_object
if isinstance(input_object, dict):
for k,v in input_object.items():
output_dict[k] = self.resolve_xlr_template_variables_in_settings(v, release_id)
return output_dict
if isinstance(input_object, list):
for v in input_object:
output_list.append(self.resolve_xlr_template_variables_in_settings(v, release_id))
return output_list
示例3: __init__
def __init__(self, core, package=None, password=None):
Base.__init__(self, core)
self.req = None
# load account if set
if self.USE_ACCOUNT:
self.account = self.core.accountManager.selectAccount(self.USE_ACCOUNT, self.user)
if self.account:
self.req = self.account.getAccountRequest()
if self.req is None:
self.req = core.requestFactory.getRequest()
# Package the plugin was initialized for, don't use this, its not guaranteed to be set
self.package = package
#: Password supplied by user
self.password = password
#: Propose a renaming of the owner package
self.rename = None
# For old style decrypter, do not use these!
self.packages = []
self.urls = []
self.pyfile = None
self.init()
示例4: __init__
def __init__(self, manager, loginname, password, options):
Base.__init__(self, manager.core)
if "activated" in options:
activated = from_string(options["activated"], "bool")
else:
activated = Account.activated
for opt in self.known_opt:
if opt not in options:
options[opt] = ""
for opt in options.keys():
if opt not in self.known_opt:
del options[opt]
# default account attributes
AccountInfo.__init__(self, self.__name__, loginname, Account.valid, Account.validuntil, Account.trafficleft,
Account.maxtraffic, Account.premium, activated, options)
self.manager = manager
self.lock = RLock()
self.timestamp = 0
self.login_ts = 0 # timestamp for login
self.cj = CookieJar(self.__name__)
self.password = password
self.error = None
self.init()
示例5: createSimpleTaskObject
def createSimpleTaskObject(self, taskTypeValue, title, propertyMap={}, parentTypeValue = None ):
"""
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:
"""
if parentTypeValue == None:
taskType = Type.valueOf(str(taskTypeValue))
Task = taskType.descriptor.newInstance("nonamerequired")
Task.setTitle(title)
for item in propertyMap:
if Task.hasProperty(item):
type = Task.getType()
desc = type.getDescriptor()
pd = desc.getPropertyDescriptor(item)
if str(pd.getKind()) == "CI":
Task.setProperty(item, self.find_ci_id(str(item), pd.getReferencedType()))
else:
Task.setProperty(item, propertyMap[item])
else:
Base.info("dropped property: %s on %s because: not applicable" % (item, taskTypeValue))
return Task
else:
# print propertyMap
parenttaskType = Type.valueOf(str(parentTypeValue))
parentTask = parenttaskType.descriptor.newInstance("nonamerequired")
parentTask.setTitle(title)
childTaskType = Type.valueOf(taskTypeValue)
childTask = childTaskType.descriptor.newInstance("nonamerequired")
for item in propertyMap:
if childTask.hasProperty(item):
type = childTask.getType()
desc = type.getDescriptor()
pd = desc.getPropertyDescriptor(item)
if str(pd.getKind()) == "CI":
childTask.setProperty(item, self.find_ci_id(str(item), pd.getReferencedType()))
else:
childTask.setProperty(item, propertyMap[item])
else:
Base.info("dropped property: %s on %s because: not applicable" % (item, taskTypeValue))
parentTask.setPythonScript(childTask)
return parentTask
示例6: handle_profile
def handle_profile(profile, targetPhase):
"""
parse the loaded profile and add a task for each item in it
:param profile: json or dict
:param targetPhase: phase to add the steps to
:return:
"""
loaded_profile = load_profile(profile)
phaseId = get_target_phase(targetPhase)
title_nr = 0
for type, data in loaded_profile.items():
if __type_step_dict.has_key(type):
taskTypeValue = __type_step_dict[type]
else:
taskTypeValue = type
for data_item in data:
final_data_items = dict(data_item.items() + __default_data_items.items())
title_nr += 1
title = get_title("dar_build_task_%s_%i" % (type, title_nr), taskTypeValue, data_item)
Base.info("creating step: %s" % title)
createSimpleTask(phaseId, taskTypeValue, title, final_data_items)
示例7: load_from_url
def load_from_url(self, url):
"""
reaches out to a url and loads the profile
:param url:
:return: dict: profile
"""
print type(url)
if type(url) == list:
# if we are fed a list of urls
# resolve each one and merge them with the later url taking precedence
outputDict = {}
for u in url :
Base.info("Attempting to fetch profile at: %s" % u)
response = requests.get(u, verify=False)
response.raise_for_status()
print json.loads(str(response.text))
outputDict = dict(self.merge_profiles(outputDict, json.loads(str(response.text))))
pprint.pprint(outputDict)
return outputDict
else:
response = requests.get(url, verify=False)
response.raise_for_status()
return json.loads(str(response.text))
示例8: __init__
def __init__(self, core, manager, user=None):
Base.__init__(self, core, user)
#: Provide information in dict here, usable by API `getInfo`
self.info = None
#: Callback of periodical job task, used by addonmanager
self.cb = None
#: `AddonManager`
self.manager = manager
#register events
if self.event_map:
for event, funcs in self.event_map.iteritems():
if type(funcs) in (list, tuple):
for f in funcs:
self.evm.addEvent(event, getattr(self,f))
else:
self.evm.addEvent(event, getattr(self,funcs))
#delete for various reasons
self.event_map = None
if self.event_list:
for f in self.event_list:
self.evm.addEvent(f, getattr(self,f))
self.event_list = None
self.initPeriodical()
self.init()
self.setup()
示例9: __init__
def __init__(self, spec):
Base.__init__(self)
self.spec = spec
self.tags = {}
self.macros = {}
self.subpackages = {}
self.changelogs = []
示例10: __init__
def __init__(self, manager, loginname, password, options):
Base.__init__(self, manager.core)
if "activated" in options:
self.activated = from_string(options["activated"], "bool")
else:
self.activated = Account.activated
for opt in self.known_opt:
if opt not in options:
options[opt] = ""
for opt in options.keys():
if opt not in self.known_opt:
del options[opt]
self.loginname = loginname
self.options = options
self.manager = manager
self.lock = RLock()
self.timestamp = 0
self.login_ts = 0 # timestamp for login
self.cj = CookieJar(self.__name__)
self.password = password
self.error = None
self.init()
示例11: __init__
def __init__(self, localDownloadQueue = "PendingDownloadQueue"):
Base.__init__(self)
self.download_queue = localDownloadQueue
self.ftp_sync = FileSyncer()
self.move_file_into_processing()
Extractor(self.local_directory_to_sync)
Cleaner(self.local_directory_to_sync)
示例12: OnInputChanged
def OnInputChanged(self, *args): #args just catches tkinter arguments. I don't need them
self.operand1 = (self.input_operand1.get(), Base.stringToBase(self.input_base1.get()))
self.operand2 = (self.input_operand2.get(), Base.stringToBase(self.input_base2.get()))
operator = Operator.stringToOperator(self.operator.get())
if self.canCalculate(operator):
operand1 = convert(self.operand1[0], self.operand1[1], Base.decimal)
# edge case not operation, operand2 could be invalid
if operator != Operator.NOT:
operand2 = convert(self.operand2[0], self.operand2[1], Base.decimal)
else:
operand2 = None
# edge case div by zero
if operator == Operator.DIV and float(operand2) == 0:
self.outputError('2', "Can't divide by 0")
self.outputResults('result', clear=True)
return
try:
self.result = (result(operand1, operand2, operator), Base.decimal)
self.outputResults('result')
except Exception as e:
print("Calculation: ", e)
else:
self.outputResults('result', clear=True)
示例13: __init__
def __init__(self, core, manager, user=None):
Base.__init__(self, core, user)
#: Callback of periodical job task, used by addonManager
self.cb = None
#: `AddonManager`
self.manager = manager
#register events
if self.event_map:
for event, funcs in self.event_map.iteritems():
if type(funcs) in (list, tuple):
for f in funcs:
self.evm.listenTo(event, getattr(self, f))
else:
self.evm.listenTo(event, getattr(self, funcs))
#delete for various reasons
self.event_map = None
self.init()
# start periodically if set
self.startPeriodical(self.interval, 0)
示例14: get_target_phase
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)
)
示例15: resolve_settings
def resolve_settings(self, inputDict, inputSettings):
'''
scan the inputDict for variable markers and look for resolution in the settings section of the template
:param inputDict: Dictionary to scan
:param inputSettings: settings that pertain to this input dictionary
:return: dictionary with resolution information
'''
vars_list = []
resolve_dict = {}
output_dict = {}
if inputSettings != None:
# find all the variables in the target dictionary
for k, v in inputDict.items():
if isinstance(v, unicode) or isinstance(v, str):
x = self.find_all_variables(str(v))
if x:
vars_list = vars_list + list(set(x) - set(vars_list))
# loop over the list with found variables
for v in vars_list:
# check if we can find a resolution in the settings for this app
if inputSettings.has_key(v):
# if we find a list in settings for this variable concatenate and dump
if type(inputSettings[v]) is list:
resolve_dict[v] = ",".join(inputSettings[v])
else:
resolve_dict[v] = inputSettings[v]
# loop over the resolve_dict and check it for stuff that could trigger a more specific set of variables
if inputSettings.has_key('specific_settings'):
specific_dict = inputSettings['specific_settings']
for k, v in resolve_dict.items():
if specific_dict.has_key(k):
if specific_dict[k].has_key(v):
resolve_dict.update(specific_dict[k][v])
# do one last loop over the dictionaries non list/dict objects and replace the placeholders/variables with te result
for k, v in inputDict.items():
if isinstance(v, unicode) or isinstance(v, str):
# loop over the keys of the resolve dict
for s in resolve_dict.keys():
ps = self.__variable_start_string + str(s) + self.__variable_end_string
v = v.replace(ps, resolve_dict[s])
output_dict[k] = v
for k, v in output_dict.items():
Base.info("Key: %s resolved to: %s" % (k, v))
return output_dict
else:
return inputDict