Esempio n. 1
0
 def _format_reqs(self, req_list, result):
     req_string_list = ['other.GlueHostNetworkAdapterOutboundIP']
     for req_type, arg in req_list:
         if req_type == WMS.SOFTWARE:
             software_template_str = 'Member(%s, other.GlueHostApplicationSoftwareRunTimeEnvironment)'
             req_string_list.append(software_template_str %
                                    self._escape(arg))
         elif req_type == WMS.WALLTIME:
             if arg > 0:
                 req_string_list.append(
                     '(other.GlueCEPolicyMaxWallClockTime >= %d)' % int(
                         (arg + 59) / 60))
         elif req_type == WMS.CPUTIME:
             if arg > 0:
                 req_string_list.append(
                     '(other.GlueCEPolicyMaxCPUTime >= %d)' % int(
                         (arg + 59) / 60))
         elif req_type == WMS.MEMORY:
             if arg > 0:
                 req_string_list.append(
                     '(other.GlueHostMainMemoryRAMSize >= %d)' % arg)
         elif req_type == WMS.STORAGE:
             req_string_list.append(self._format_reqs_storage(arg))
         elif req_type == WMS.SITES:
             req_string_list.append(self._format_reqs_sites(arg))
         elif req_type == WMS.CPUS:
             pass  # Handle number of cpus in prepare
         else:
             raise APIError('Unknown requirement type %r or argument %r' %
                            (WMS.enum2str(req_type), arg))
     result['Requirements'] = str.join(' && ', iidfilter(req_string_list))
Esempio n. 2
0
	def _read_jobnum2pnum(self):
		fp = GZipTextFile(self._path_jobnum2pnum, 'r')
		try:
			def _translate_info(jobnum_pnum_info):
				return tuple(imap(lambda x: int(x.lstrip('!')), jobnum_pnum_info.split(':', 1)))

			int(fp.readline())  # max number of jobs
			jobnum_pnum_info_iter = iidfilter(imap(str.strip, fp.readline().split(',')))
			self._map_jobnum2pnum = dict(imap(_translate_info, jobnum_pnum_info_iter))
			self._can_submit_map = {}
		finally:
			fp.close()
	def _set_split_opt(self, config, name, work_unit_dict,
			target_partitions, target_partitions_by_nick):
		def _get_target_partitions(work_units, target):
			return str(max(1, int(work_units / float(target) + 0.5)))
		new_config_str = ''
		global_work_units = work_unit_dict.pop(None)
		if target_partitions > 0:
			new_config_str = _get_target_partitions(global_work_units, target_partitions)
		if target_partitions_by_nick > 0:
			for nick in iidfilter(sorted(work_unit_dict)):
				new_config_str += '\n\t%s => %s' % (nick,
					_get_target_partitions(work_unit_dict[nick], target_partitions_by_nick))
		try:
			config.set(name, new_config_str)
		except Exception:
			clear_current_exception()
Esempio n. 4
0
    def _set_split_opt(self, config, name, work_unit_dict, target_partitions,
                       target_partitions_by_nick):
        def _get_target_partitions(work_units, target):
            return str(max(1, int(work_units / float(target) + 0.5)))

        new_config_str = ''
        global_work_units = work_unit_dict.pop(None)
        if target_partitions > 0:
            new_config_str = _get_target_partitions(global_work_units,
                                                    target_partitions)
        if target_partitions_by_nick > 0:
            for nick in iidfilter(sorted(work_unit_dict)):
                new_config_str += '\n\t%s => %s' % (
                    nick,
                    _get_target_partitions(work_unit_dict[nick],
                                           target_partitions_by_nick))
        try:
            config.set(name, new_config_str)
        except Exception:
            clear_current_exception()
Esempio n. 5
0
	def _format_reqs(self, req_list, result):
		req_string_list = ['other.GlueHostNetworkAdapterOutboundIP']
		for req_type, arg in req_list:
			if req_type == WMS.SOFTWARE:
				software_template_str = 'Member(%s, other.GlueHostApplicationSoftwareRunTimeEnvironment)'
				req_string_list.append(software_template_str % self._escape(arg))
			elif req_type == WMS.WALLTIME:
				if arg > 0:
					req_string_list.append('(other.GlueCEPolicyMaxWallClockTime >= %d)' % int((arg + 59) / 60))
			elif req_type == WMS.CPUTIME:
				if arg > 0:
					req_string_list.append('(other.GlueCEPolicyMaxCPUTime >= %d)' % int((arg + 59) / 60))
			elif req_type == WMS.MEMORY:
				if arg > 0:
					req_string_list.append('(other.GlueHostMainMemoryRAMSize >= %d)' % arg)
			elif req_type == WMS.STORAGE:
				req_string_list.append(self._format_reqs_storage(arg))
			elif req_type == WMS.SITES:
				req_string_list.append(self._format_reqs_sites(arg))
			elif req_type in (WMS.CPUS, WMS.DISKSPACE):
				pass  # Handled outside of "requirement" directive or GlueCE attribute not available
			else:
				raise APIError('Unknown requirement type %r or argument %r' % (WMS.enum2str(req_type), arg))
		result['Requirements'] = str.join(' && ', iidfilter(req_string_list))
Esempio n. 6
0
def get_local_username():
	for username in iidfilter(imap(os.environ.get, ['LOGNAME', 'USER', 'LNAME', 'USERNAME'])):
		return username
	return ''
Esempio n. 7
0
def get_local_username():
    for username in iidfilter(
            imap(os.environ.get, ['LOGNAME', 'USER', 'LNAME', 'USERNAME'])):
        return username
    return ''