Exemple #1
0
def main(argv, cfg):
	usage = "%(prog)s [-a | [workdir [workdir [...]]]"
	parser = ArgumentParser(usage=usage, prog=argv.pop(0))
	parser.add_argument('-a', '--all', action='store_true', help="list all workdirs")
	parser.add_argument('workdirs', nargs='*', default=[])
	args = parser.parse_args(argv)

	if args.all:
		args.workdirs.extend(sorted(cfg.workdirs))

	if not args.workdirs:
		for wd in sorted(cfg.workdirs):
			print(wd)
		return

	for name in args.workdirs:
		if name not in cfg.workdirs:
			print("No such workdir:", name, file=sys.stderr)
			continue
		known = call(cfg.url + '/workdir/' + url_quote(name))
		for jid in workdir_jids(cfg, name):
			show_job(known, jid)

		try:
			latest = os.readlink(os.path.join(cfg.workdirs[name], name + '-LATEST'))
		except OSError:
			latest = None
		if latest:
			show_job(known, jid, name + '-LATEST')
Exemple #2
0
def show(url, job, show_output):
    print(job.path)
    print('=' * len(job.path))
    setup = job.json_load('setup.json')
    setup.pop('_typing', None)
    setup.starttime = str(datetime.fromtimestamp(setup.starttime))
    if 'endtime' in setup:
        setup.endtime = str(datetime.fromtimestamp(setup.endtime))
    print(encode_setup(setup, as_str=True))
    try:
        with job.open('datasets.txt') as fh:
            print()
            print('datasets:')
            for line in fh:
                print('    %s/%s' % (
                    job,
                    line[:-1],
                ))
    except IOError:
        pass
    try:
        post = job.json_load('post.json')
    except FileNotFoundError:
        print('\x1b[31mWARNING: Job did not finish\x1b[m')
        post = None
    if post and post.subjobs:
        print()
        print('subjobs:')
        for sj in sorted(post.subjobs):
            print('   ', sj)
    if post and post.files:
        print()
        print('files:')
        for fn in sorted(post.files):
            print('   ', job.filename(fn))
    if post and not call(url + '/job_is_current/' + url_quote(job)):
        print('\x1b[34mJob is not current\x1b[m')
    print()
    out = job.output()
    if show_output:
        if out:
            print('output (use --just-output/-O to see only the output):')
            print(out)
            if not out.endswith('\n'):
                print()
        else:
            print(job, 'produced no output')
            print()
    elif out:
        print('%s produced %d bytes of output, use --output/-o to see it' % (
            job,
            len(out),
        ))
        print()
Exemple #3
0
 def resolve_path_part(path):
     if not path:
         return []
     if path == '/':
         return ['list']
     path = [url_quote(el) for el in path.split('/')]
     if path[-1] == '':
         path.pop()
         since = ['since', '0']
     elif len(path) > 2 and path[-2] == 'since':
         since = path[-2:]
         path = path[:-2]
     else:
         since = None
     if len(path) < 3 - bool(since):
         path.insert(0, user)
     if since:
         path.append(since[0])
         path.append(since[1] + '?captions')
     elif len(path) < 3:
         path.append('latest')
     return path
Exemple #4
0
	def get(count):
		url ='%s/method2job/%s/%s' % (cfg.url, method, count)
		if start_from:
			url += '?start_from=' + url_quote(start_from)
		return call(url)