Esempio n. 1
0
def _yield_raw_scontrol_node_texts(NodeName=None):
    shv = ['scontrol', 'show', 'node', '--oneliner']
    if NodeName is not None:
        shv.append(NodeName)
    for line in util.runsh_i(shv):
        line = line.strip()
        if line != '': yield line
Esempio n. 2
0
def _yield_raw_scontrol_node_texts(NodeName=None):
	shv = ['scontrol', 'show', 'node', '--oneliner']
	if NodeName is not None:
		shv.append(NodeName)
	for line in util.runsh_i(shv):
		line = line.strip()
		if line!='': yield line
Esempio n. 3
0
def _yield_raw_sacct_job_lines(state='COMPLETED', starttime=None, endtime=None):
	"""Return an iterator that yields lines from sacct."""
	shv = ['sacct', '--allusers', '--noheader', '--parsable2', '--format', _sacct_format_parsable]
	if state is not None:
		shv.extend(['--state', state])
	if starttime is not None:
		shv.extend(['--starttime', starttime.strftime('%m/%d-%H:%M')])
	if endtime is not None:
		shv.extend(['--endtime', endtime.strftime('%m/%d-%H:%M')])
	return util.runsh_i(shv)
Esempio n. 4
0
def _yield_raw_sacct_job_lines(state='COMPLETED',
                               starttime=None,
                               endtime=None):
    """Return an iterator that yields lines from sacct."""
    shv = [
        'sacct', '--allusers', '--noheader', '--parsable2', '--format',
        _sacct_format_parsable
    ]
    if state is not None:
        shv.extend(['--state', state])
    if starttime is not None:
        shv.extend(['--starttime', starttime.strftime('%m/%d-%H:%M')])
    if endtime is not None:
        shv.extend(['--endtime', endtime.strftime('%m/%d-%H:%M')])
    return util.runsh_i(shv)
Esempio n. 5
0
	def test_runsh_list(self):
		"""That runsh_i() works on an argv list."""
		self.assertEqual(
			[line for line in u.runsh_i(['echo', '-e', 'foo\nbar'])],
			['foo\n', 'bar\n'],
		)
Esempio n. 6
0
	def test_runsh_i_string(self):
		"""That runsh_i() works on sh code as a string."""
		self.assertEqual(
			[line for line in u.runsh_i("echo -e 'foo\nbar'")],
			['foo\n', 'bar\n'],
		)