• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python python_compat.sorted函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中python_compat.sorted函数的典型用法代码示例。如果您正苦于以下问题:Python sorted函数的具体用法?Python sorted怎么用?Python sorted使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了sorted函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: jobs

	def jobs(self, *args, **kw):
		result = '<body>'
		result += str(CPProgressBar(0, min(100, self.counter), 100, 300))
		if 'job' in kw:
			jobNum = int(kw['job'])
			info = self.task.getJobConfig(jobNum)
			result += str(TabularHTML(zip(sorted(info), sorted(info)), [info], top = False))
		def getJobObjs():
			for jobNum in self.jobMgr.jobDB.getJobs():
				result = self.jobMgr.jobDB.get(jobNum).__dict__
				result['jobNum'] = jobNum
				result.update(result['dict'])
				yield result
		fmtTime = lambda t: time.strftime('%Y-%m-%d %T', time.localtime(t))
		result += str(TabularHTML([
				('jobNum', 'Job'), ('state', 'Status'), ('attempt', 'Attempt'),
				('wmsId', 'WMS ID'), ('dest', 'Destination'), ('submitted', 'Submitted')
			], getJobObjs(),
			fmt = {
				'jobNum': lambda x: '<a href="jobs?job=%s">%s</a>' % (x, x),
				'state': lambda s: Job.enum2str(s),
				'submitted': fmtTime
			}, top = True))
		result += '</body>'
		return result
开发者ID:gitter-badger,项目名称:grid-control,代码行数:25,代码来源:gui_cherrypy.py


示例2: write

	def write(self, stream, entries = None, printMinimal = False, printState = False,
			printUnused = True, printSource = False, printDefault = True, printTight = False):
		if not entries:
			entries = self.iterContent()
		config = {}
		for entry in entries:
			if printUnused or entry.accessed:
				if printDefault or not entry.source.startswith('<default'):
					if printState or not entry.option.startswith('#'):
						config.setdefault(entry.section, {}).setdefault(entry.option, []).append(entry)
		for section in sorted(config):
			if not printTight:
				stream.write('[%s]\n' % section)
			for option in sorted(config[section]):
				entryList = sorted(config[section][option], key = lambda e: e.order)
				if printMinimal:
					entryList = ConfigEntry.simplifyEntries(entryList)
				for entry in entryList:
					if printTight:
						stream.write('[%s] ' % section)
					for idx, line in enumerate(entry.format().splitlines()):
						if printSource and (idx == 0) and entry.source:
							if len(line) < 33:
								stream.write('%-35s; %s\n' % (line, entry.source))
							else:
								stream.write('; source: %s\n%s\n' % (entry.source, line))
						else:
							stream.write(line + '\n')
			if not printTight:
				stream.write('\n')
开发者ID:gitter-badger,项目名称:grid-control,代码行数:30,代码来源:cview_base.py


示例3: __init__

	def __init__(self, jobDB, task, jobs = None, configString = ''):
		Report.__init__(self, jobDB, task, jobs, configString)
		catJobs = {}
		catDescDict = {}
		# Assignment of jobs to categories (depending on variables and using datasetnick if available)
		for jobNum in self._jobs:
			jobConfig = task.getJobConfig(jobNum)
			varList = sorted(filter(lambda var: '!' not in repr(var), jobConfig.keys()))
			if 'DATASETSPLIT' in varList:
				varList.remove('DATASETSPLIT')
				varList.append('DATASETNICK')
			catKey = str.join('|', map(lambda var: '%s=%s' % (var, jobConfig[var]), varList))
			catJobs.setdefault(catKey, []).append(jobNum)
			if catKey not in catDescDict:
				catDescDict[catKey] = dict(map(lambda var: (var, jobConfig[var]), varList))
		# Kill redundant keys from description
		commonVars = dict(map(lambda var: (var, jobConfig[var]), varList)) # seed with last varList
		for catKey in catDescDict:
			for key in commonVars.keys():
				if key not in catDescDict[catKey].keys():
					commonVars.pop(key)
				elif commonVars[key] != catDescDict[catKey][key]:
					commonVars.pop(key)
		for catKey in catDescDict:
			for commonKey in commonVars:
				catDescDict[catKey].pop(commonKey)
		# Generate job-category map with efficient int keys - catNum becomes the new catKey
		self._job2cat = {}
		self._catDescDict = {}
		for catNum, catKey in enumerate(sorted(catJobs)):
			self._catDescDict[catNum] = catDescDict[catKey]
			self._job2cat.update(dict.fromkeys(catJobs[catKey], catNum))
开发者ID:gitter-badger,项目名称:grid-control,代码行数:32,代码来源:report_gui.py


示例4: get_plugin_list

def get_plugin_list(pname, inherit_prefix=False):
	alias_dict = {}
	inherit_map = {}
	cls = Plugin.get_class(pname)
	for entry in cls.get_class_info_list():
		depth = entry.pop('depth', 0)
		(alias, name) = entry.popitem()
		alias_dict.setdefault(name, []).append((depth, alias))

	def _process_child_map(mapping, prefix=''):
		for cls_name in mapping:
			inherit_map[cls_name] = _process_child_map(mapping[cls_name], prefix + '-' + cls_name)
		return prefix
	_process_child_map(cls.get_class_children(), pname)
	alias_dict.pop(pname, None)

	table_list = []
	for name in alias_dict:
		# sorted by length of name and depth
		by_len_depth = sorted(alias_dict[name], key=lambda d_a: (-len(d_a[1]), d_a[0]))
		# sorted by depth and name
		by_depth_name = sorted(alias_dict[name], key=lambda d_a: (d_a[0], d_a[1]))
		new_name = by_len_depth.pop()[1]
		depth = min(imap(lambda d_a: d_a[0], alias_dict[name]))
		alias_list = lmap(lambda d_a: d_a[1], by_depth_name)
		alias_list.remove(new_name)
		if inherit_prefix:
			new_name = ' | ' * (inherit_map[name].count('-') - 1) + new_name
		entry = {'Name': new_name, 'Alias': str.join(', ', alias_list),
			'Depth': '%02d' % depth, 'Inherit': inherit_map.get(name, '')}
		table_list.append(entry)
	return table_list
开发者ID:mschnepf,项目名称:grid-control,代码行数:32,代码来源:gc_scripts.py


示例5: DiffLists

def DiffLists(oldList, newList, cmpFkt, changedFkt, isSorted = False):
	(listAdded, listMissing, listChanged) = ([], [], [])
	if not isSorted:
		(newList, oldList) = (sorted(newList, cmpFkt), sorted(oldList, cmpFkt))
	(newIter, oldIter) = (iter(newList), iter(oldList))
	(new, old) = (next(newIter, None), next(oldIter, None))
	while True:
		if (new == None) or (old == None):
			break
		result = cmpFkt(new, old)
		if result < 0: # new[npos] < old[opos]
			listAdded.append(new)
			new = next(newIter, None)
		elif result > 0: # new[npos] > old[opos]
			listMissing.append(old)
			old = next(oldIter, None)
		else: # new[npos] == old[opos] according to *active* comparison
			changedFkt(listAdded, listMissing, listChanged, old, new)
			(new, old) = (next(newIter, None), next(oldIter, None))
	while new != None:
		listAdded.append(new)
		new = next(newIter, None)
	while old != None:
		listMissing.append(old)
		old = next(oldIter, None)
	return (listAdded, listMissing, listChanged)
开发者ID:mortenpi,项目名称:grid-control,代码行数:26,代码来源:utils.py


示例6: _get_sandbox_file_list

	def _get_sandbox_file_list(self, task, sm_list):
		# Prepare all input files
		dep_list = set(ichain(imap(lambda x: x.get_dependency_list(), [task] + sm_list)))
		dep_fn_list = lmap(lambda dep: resolve_path('env.%s.sh' % dep,
			lmap(lambda pkg: get_path_share('', pkg=pkg), os.listdir(get_path_pkg()))), dep_list)
		task_config_dict = dict_union(self._remote_event_handler.get_mon_env_dict(),
			*imap(lambda x: x.get_task_dict(), [task] + sm_list))
		task_config_dict.update({'GC_DEPFILES': str.join(' ', dep_list),
			'GC_USERNAME': self._token.get_user_name(), 'GC_WMS_NAME': self._name})
		task_config_str_list = DictFormat(escape_strings=True).format(
			task_config_dict, format='export %s%s%s\n')
		vn_alias_dict = dict(izip(self._remote_event_handler.get_mon_env_dict().keys(),
			self._remote_event_handler.get_mon_env_dict().keys()))
		vn_alias_dict.update(task.get_var_alias_map())
		vn_alias_str_list = DictFormat(delimeter=' ').format(vn_alias_dict, format='%s%s%s\n')

		# Resolve wildcards in task input files
		def _get_task_fn_list():
			for fpi in task.get_sb_in_fpi_list():
				matched = glob.glob(fpi.path_abs)
				if matched != []:
					for match in matched:
						yield match
				else:
					yield fpi.path_abs
		return lchain([self._remote_event_handler.get_file_list(), dep_fn_list, _get_task_fn_list(), [
			VirtualFile('_config.sh', sorted(task_config_str_list)),
			VirtualFile('_varmap.dat', sorted(vn_alias_str_list))]])
开发者ID:mschnepf,项目名称:grid-control,代码行数:28,代码来源:wms.py


示例7: _match_entries

	def _match_entries(self, container, option_list=None):
		key_list = container.get_options()
		if option_list is not None:
			key_list = lfilter(key_list.__contains__, option_list)

		def _get_entry_key_ordered(entry):
			return (tuple(imap(_remove_none, _get_section_key_filtered(entry))), entry.order)

		def _get_section_key_filtered(entry):
			return self._get_section_key(entry.section.replace('!', '').strip())

		def _remove_none(key):
			if key is None:
				return -1
			return key

		def _select_sections(entry):
			return _get_section_key_filtered(entry) is not None

		result = []
		for key in key_list:
			(entries, entries_reverse) = ([], [])
			for entry in container.iter_config_entries(key, _select_sections):
				if entry.section.endswith('!'):
					entries_reverse.append(entry)
				else:
					entries.append(entry)
			result.extend(sorted(entries_reverse, key=_get_entry_key_ordered, reverse=True))
			result.extend(sorted(entries, key=_get_entry_key_ordered))
		return result
开发者ID:grid-control,项目名称:grid-control,代码行数:30,代码来源:cview_base.py


示例8: DiffLists

def DiffLists(oldList, newList, keyFun, changedFkt, isSorted = False):
	(listAdded, listMissing, listChanged) = ([], [], [])
	if not isSorted:
		(newList, oldList) = (sorted(newList, key = keyFun), sorted(oldList, key = keyFun))
	(newIter, oldIter) = (iter(newList), iter(oldList))
	(new, old) = (next(newIter, None), next(oldIter, None))
	while True:
		if (new is None) or (old is None):
			break
		keyNew = keyFun(new)
		keyOld = keyFun(old)
		if keyNew < keyOld: # new[npos] < old[opos]
			listAdded.append(new)
			new = next(newIter, None)
		elif keyNew > keyOld: # new[npos] > old[opos]
			listMissing.append(old)
			old = next(oldIter, None)
		else: # new[npos] == old[opos] according to *active* comparison
			changedFkt(listAdded, listMissing, listChanged, old, new)
			(new, old) = (next(newIter, None), next(oldIter, None))
	while new is not None:
		listAdded.append(new)
		new = next(newIter, None)
	while old is not None:
		listMissing.append(old)
		old = next(oldIter, None)
	return (listAdded, listMissing, listChanged)
开发者ID:Fra-nk,项目名称:grid-control,代码行数:27,代码来源:__init__.py


示例9: _get_workflow_graph

def _get_workflow_graph(workflow):
	(graph, node_list) = _get_graph(workflow)

	# Process nodes
	node_str_list = []
	map_node2name = {}
	map_node2color = {}
	for node in sorted(node_list, key=lambda x: x.__class__.__name__):
		node_props = {
			'label': '"%s"' % _get_node_label(node),
			'fillcolor': '"%s"' % _get_node_color(node, map_node2color),
			'style': '"filled"',
		}
		if node == workflow:
			node_props['root'] = 'True'
		node_prop_str = str.join('; ', imap(lambda key: '%s = %s' % (key, node_props[key]), node_props))
		node_str_list.append('%s [%s];\n' % (_get_node_name(node, map_node2name), node_prop_str))

	# Process edges
	edge_str_list = []
	for entry in sorted(graph, key=lambda x: x.__class__.__name__):
		for child in sorted(set(graph[entry]), key=lambda x: x.__class__.__name__):
			edge_str_list.append('%s -> %s;\n' % (_get_node_name(entry, map_node2name),
				_get_node_name(child, map_node2name)))

	cluster_str_list = []

	dot_header = 'digraph mygraph {\nmargin=0;\nedge [len=2];\noverlap=compress;splines=True;\n'
	dot_format_string_list = [dot_header] + node_str_list + cluster_str_list + edge_str_list + ['}\n']
	return str.join('', dot_format_string_list)
开发者ID:grid-control,项目名称:grid-control,代码行数:30,代码来源:report_graph.py


示例10: getCMSFiles

	def getCMSFiles(self, blockPath):
		lumiDict = {}
		if self.selectedLumis: # Central lumi query
			lumiDict = self.getCMSLumisImpl(blockPath)
			lumiDict = QM(lumiDict, lumiDict, {})
		for (fileInfo, listLumi) in self.getCMSFilesImpl(blockPath, self.onlyValid, self.selectedLumis):
			if self.selectedLumis:
				if not listLumi:
					listLumi = lumiDict.get(fileInfo[DataProvider.URL], [])
				def acceptLumi():
					for (run, lumiList) in listLumi:
						for lumi in lumiList:
							if selectLumi((run, lumi), self.selectedLumis):
								return True
				if not acceptLumi():
					continue
				if self.includeLumi:
					(listLumiExt_Run, listLumiExt_Lumi) = ([], [])
					for (run, lumi_list) in sorted(listLumi):
						for lumi in lumi_list:
							listLumiExt_Run.append(run)
							listLumiExt_Lumi.append(lumi)
					fileInfo[DataProvider.Metadata] = [listLumiExt_Run, listLumiExt_Lumi]
				else:
					fileInfo[DataProvider.Metadata] = [list(sorted(set(map(lambda (run, lumi_list): run, listLumi))))]
			yield fileInfo
开发者ID:mortenpi,项目名称:grid-control,代码行数:26,代码来源:provider_cms.py


示例11: __init__

	def __init__(self, config, job_db, task):
		map_cat2jobs = {}
		map_cat2desc = {}
		job_config_dict = {}
		vn_list = []
		for jobnum in job_db.get_job_list():
			if task:
				job_config_dict = task.get_job_dict(jobnum)
			vn_list = lfilter(self._is_not_ignored_vn, sorted(job_config_dict.keys()))
			cat_key = str.join('|', imap(lambda vn: '%s=%s' % (vn, job_config_dict[vn]), vn_list))
			map_cat2jobs.setdefault(cat_key, []).append(jobnum)
			if cat_key not in map_cat2desc:
				map_cat2desc[cat_key] = dict(imap(lambda var: (var, job_config_dict[var]), vn_list))
		# Kill redundant keys from description - seed with last vn_list
		common_var_dict = dict(imap(lambda var: (var, job_config_dict[var]), vn_list))
		for cat_key in map_cat2desc:
			for key in list(common_var_dict.keys()):
				if key not in map_cat2desc[cat_key].keys():
					common_var_dict.pop(key)
				elif common_var_dict[key] != map_cat2desc[cat_key][key]:
					common_var_dict.pop(key)
		for cat_key in map_cat2desc:
			for common_key in common_var_dict:
				map_cat2desc[cat_key].pop(common_key)
		# Generate job-category map with efficient int keys - catNum becomes the new cat_key
		self._job2cat = {}
		self._map_cat2desc = {}
		for cat_num, cat_key in enumerate(sorted(map_cat2jobs)):
			self._map_cat2desc[cat_num] = map_cat2desc[cat_key]
			self._job2cat.update(dict.fromkeys(map_cat2jobs[cat_key], cat_num))
开发者ID:grid-control,项目名称:grid-control,代码行数:30,代码来源:cat_manager.py


示例12: get_list_difference

def get_list_difference(list_old, list_new, key_fun, on_matching_fun,
		is_sorted=False, key_fun_sort=None):
	(list_added, list_missing, list_matching) = ([], [], [])
	if not is_sorted:
		list_new = sorted(list_new, key=key_fun_sort or key_fun)
		list_old = sorted(list_old, key=key_fun_sort or key_fun)
	(iter_new, iter_old) = (iter(list_new), iter(list_old))
	(new, old) = (next(iter_new, None), next(iter_old, None))
	while True:
		if (new is None) or (old is None):
			break
		key_new = key_fun(new)
		key_old = key_fun(old)
		if key_new < key_old:  # new[npos] < old[opos]
			list_added.append(new)
			new = next(iter_new, None)
		elif key_new > key_old:  # new[npos] > old[opos]
			list_missing.append(old)
			old = next(iter_old, None)
		else:  # new[npos] == old[opos] according to *active* comparison
			on_matching_fun(list_added, list_missing, list_matching, old, new)
			(new, old) = (next(iter_new, None), next(iter_old, None))
	while new is not None:
		list_added.append(new)
		new = next(iter_new, None)
	while old is not None:
		list_missing.append(old)
		old = next(iter_old, None)
	return (list_added, list_missing, list_matching)
开发者ID:grid-control,项目名称:grid-control,代码行数:29,代码来源:algos.py


示例13: display_metadata

def display_metadata(dataset_list, block, metadata_key_list, metadata_list, base_header_list=None):
	header_list = [(DataProvider.BlockName, 'Block')] + (base_header_list or []) + \
		lzip(sorted(metadata_key_list), sorted(metadata_key_list))
	for metadata in metadata_list:
		metadata[DataProvider.Dataset] = block[DataProvider.Dataset]
		metadata[DataProvider.BlockName] = block.get(DataProvider.BlockName)
	title = get_title_update_header(dataset_list, header_list)
	ConsoleTable.create(header_list, metadata_list, title=title, pivot=True)
开发者ID:grid-control,项目名称:grid-control,代码行数:8,代码来源:dataset_info.py


示例14: getDisplayList

def getDisplayList(aliasDict):
	tableList = []
	for name in aliasDict:
		# sorted by length of name and depth
		by_len_depth = sorted(aliasDict[name], key = lambda d_a: (-len(d_a[1]), d_a[0]))
		# sorted by depth and name
		by_depth_name = sorted(aliasDict[name], key = lambda d_a: (d_a[0], d_a[1]))
		new_name = by_len_depth.pop()[1]
		aliasList = lmap(lambda d_a: d_a[1], by_depth_name)
		aliasList.remove(new_name)
		entry = {'Name': new_name, 'Alias': str.join(', ', aliasList)}
		if ('Multi' not in name) and ('Base' not in name):
			tableList.append(entry)
	return tableList
开发者ID:artus-analysis,项目名称:grid-control,代码行数:14,代码来源:plugins.py


示例15: _findCollision

	def _findCollision(self, tName, nameDict, varDict, hashKeys, keyFmt, nameFmt = identity):
		dupesDict = {}
		for (key, name) in nameDict.items():
			dupesDict.setdefault(nameFmt(name), []).append(keyFmt(name, key))
		ask = True
		for name, key_list in sorted(dupesDict.items()):
			if len(key_list) > 1:
				self._log.warn('Multiple %s keys are mapped to the name %s!', tName, repr(name))
				for key in sorted(key_list):
					self._log.warn('\t%s hash %s using:', tName, str.join('#', key))
					for var, value in self._getFilteredVarDict(varDict, key, hashKeys).items():
						self._log.warn('\t\t%s = %s', var, value)
				if ask and not utils.getUserBool('Do you want to continue?', False):
					sys.exit(os.EX_OK)
				ask = False
开发者ID:Fra-nk,项目名称:grid-control,代码行数:15,代码来源:provider_scan.py


示例16: list_parameters

def list_parameters(opts, psource):
	(result, needGCParam) = get_parameters(opts, psource)
	enabledOutput = opts.output.split(',')
	output = lfilter(lambda k: not opts.output or k in enabledOutput, psource.getJobKeys())
	stored = lfilter(lambda k: k.untracked == False, output)
	untracked = lfilter(lambda k: k.untracked == True, output)

	if opts.collapse > 0:
		result_old = result
		result = {}
		result_nicks = {}
		head = [('COLLATE_JOBS', '# of jobs')]
		if 'DATASETSPLIT' in stored:
			stored.remove('DATASETSPLIT')
			if opts.collapse == 1:
				stored.append('DATASETNICK')
				head.append(('DATASETNICK', 'DATASETNICK'))
			elif opts.collapse == 2:
				head.append(('COLLATE_NICK', '# of nicks'))
		for pset in result_old:
			if ('DATASETSPLIT' in pset) and (opts.collapse == 1):
				pset.pop('DATASETSPLIT')
			nickname = None
			if ('DATASETNICK' in pset) and (opts.collapse == 2):
				nickname = pset.pop('DATASETNICK')
			h = md5_hex(repr(lmap(pset.get, stored)))
			result.setdefault(h, []).append(pset)
			result_nicks.setdefault(h, set()).add(nickname)

		def doCollate(h):
			tmp = result[h][0]
			tmp['COLLATE_JOBS'] = len(result[h])
			tmp['COLLATE_NICK'] = len(result_nicks[h])
			return tmp
		result = lmap(doCollate, result)
	else:
		head = [('GC_JOB_ID', '#')]
		if needGCParam:
			head.append(('GC_PARAM', 'GC_PARAM'))
	if opts.active:
		head.append((ParameterInfo.ACTIVE, 'ACTIVE'))
	if opts.visible:
		stored = opts.visible.split(',')
	head.extend(sorted(izip(stored, stored)))
	if opts.untracked:
		head.extend(sorted(imap(lambda n: (n, '(%s)' % n), ifilter(lambda n: n not in ['GC_PARAM', 'GC_JOB_ID'], untracked))))
	utils.vprint('')
	utils.printTabular(head, result)
开发者ID:thomas-mueller,项目名称:grid-control,代码行数:48,代码来源:parameterList.py


示例17: dump_log_setup

def dump_log_setup(level):
	root = logging.getLogger()

	def display_logger(indent, logger, name):
		propagate_symbol = '+'
		if hasattr(logger, 'propagate') and not logger.propagate:
			propagate_symbol = 'o'
		desc = name
		if hasattr(logger, 'level'):
			desc += ' (level = %s)' % logging.getLevelName(logger.level)
		root.log(level, '%s%s %s', '|  ' * indent, propagate_symbol, desc)
		if hasattr(logger, 'filters'):
			for lf in logger.filters:
				root.log(level, '%s# %s', '|  ' * (indent + 1), lf.__class__.__name__)
		if hasattr(logger, 'handlers'):
			for handler in logger.handlers:
				root.log(level, '%s> %s', '|  ' * (indent + 1), handler.__class__.__name__)
				fmt = handler.formatter
				if fmt:
					desc = fmt.__class__.__name__
					if isinstance(fmt, ExceptionFormatter):
						desc = repr(fmt)
					elif isinstance(fmt, logging.Formatter):
						desc += '(%s, %s)' % (repr(getattr(fmt, '_fmt')), repr(fmt.datefmt))
					root.log(level, '%s|  %% %s', '|  ' * (indent + 1), desc)

	display_logger(0, root, '<root>')
	for key, logger in sorted(root.manager.loggerDict.items()):
		display_logger(key.count('.') + 1, logger, key)
开发者ID:thomas-mueller,项目名称:grid-control,代码行数:29,代码来源:logging_setup.py


示例18: write

	def write(self, stream, print_minimal=False, print_source=False, print_oneline=False, **kwarg):
		config = self._prepare_write(**kwarg)
		for section in sorted(config):
			if not print_oneline:
				stream.write('[%s]\n' % section)
			for option in sorted(config[section]):
				entry_list = sorted(config[section][option], key=lambda e: e.order)
				if print_minimal:
					entry_list = ConfigEntry.simplify_entries(entry_list)
				for entry in entry_list:
					source = ''
					if print_source:
						source = entry.source
					stream.write(entry.format(print_section=print_oneline, source=source) + '\n')
			if not print_oneline:
				stream.write('\n')
开发者ID:grid-control,项目名称:grid-control,代码行数:16,代码来源:cview_base.py


示例19: _readJobs

	def _readJobs(self, jobLimit):
		utils.ensureDirExists(self._dbPath, 'job database directory', JobError)

		candidates = []
		for jobFile in fnmatch.filter(os.listdir(self._dbPath), 'job_*.txt'):
			try: # 2xsplit is faster than regex
				jobNum = int(jobFile.split(".")[0].split("_")[1])
			except Exception:
				continue
			candidates.append((jobNum, jobFile))

		(jobMap, maxJobs) = ({}, len(candidates))
		activity = Activity('Reading job infos')
		idx = 0
		for (jobNum, jobFile) in sorted(candidates):
			idx += 1
			if (jobLimit >= 0) and (jobNum >= jobLimit):
				self._log.info('Stopped reading job infos at job #%d out of %d available job files, since the limit of %d jobs is reached',
					jobNum, len(candidates), jobLimit)
				break
			jobObj = self._load_job(os.path.join(self._dbPath, jobFile))
			jobMap[jobNum] = jobObj
			if idx % 100 == 0:
				activity.update('Reading job infos %d [%d%%]' % (idx, (100.0 * idx) / maxJobs))
		activity.finish()
		return jobMap
开发者ID:Fra-nk,项目名称:grid-control,代码行数:26,代码来源:job_db_text.py


示例20: _submit_get_jobs

	def _submit_get_jobs(self, task):
		# Get list of submittable jobs
		jobnum_list_ready = self.job_db.get_job_list(ClassSelector(JobClass.SUBMIT_CANDIDATES))
		(n_mod_ok, n_retry_ok, jobnum_list) = self._get_enabled_jobs(task, jobnum_list_ready)

		if self._show_blocker and jobnum_list_ready and not jobnum_list:  # No submission but ready jobs
			err_str_list = []
			if (n_retry_ok <= 0) or (n_mod_ok != 0):
				err_str_list.append('have hit their maximum number of retries')
			if (n_retry_ok != 0) and (n_mod_ok <= 0):
				err_str_list.append('are vetoed by the task module')
			err_delim = ' and '
			if n_retry_ok or n_mod_ok:
				err_delim = ' or '
			self._log.log_time(logging.WARNING, 'All remaining jobs %s!', str.join(err_delim, err_str_list))
		self._show_blocker = not (len(jobnum_list_ready) > 0 and len(jobnum_list) == 0)

		# Determine number of jobs to submit
		submit = len(jobnum_list)
		if self._njobs_inqueue > 0:
			submit = min(submit, self._njobs_inqueue - self.job_db.get_job_len(
				ClassSelector(JobClass.ATWMS)))
		if self._njobs_inflight > 0:
			submit = min(submit, self._njobs_inflight - self.job_db.get_job_len(
				ClassSelector(JobClass.PROCESSING)))
		if self._chunks_enabled and (self._chunks_submit > 0):
			submit = min(submit, self._chunks_submit)
		submit = max(submit, 0)

		if self._do_shuffle:
			return self._sample(jobnum_list, submit)
		return sorted(jobnum_list)[:submit]
开发者ID:mschnepf,项目名称:grid-control,代码行数:32,代码来源:job_manager.py



注:本文中的python_compat.sorted函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python python_digest.build_digest_challenge函数代码示例发布时间:2022-05-27
下一篇:
Python python_compat.set函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap