コード例 #1
0
ファイル: logging_setup.py プロジェクト: jolange/grid-control
    def _write_process_log(self, record):
        entry_time = time.strftime('%Y-%m-%d_%H:%M:%S',
                                   time.localtime(record.created))
        entry = '%s_%s.%03d' % (record.name, entry_time, int(record.msecs))
        files = record.files
        files['info'] = 'call=%s\nexit=%s\n' % (repr(
            record.proc.get_call()), record.proc.status(0))
        files['stdout'] = record.proc.stdout.read_log()
        files['stderr'] = record.proc.stderr.read_log()
        files['stdin'] = record.proc.stdin.read_log()

        def _log_tar():
            tar = tarfile.TarFile.open(self._fn, 'a')
            for key, value in record.files.items():
                if os.path.exists(value):
                    value = SafeFile(value).read_close()
                file_obj = VirtualFile(os.path.join(entry, key), [value])
                info, handle = file_obj.get_tar_info()
                tar.addfile(info, handle)
                handle.close()
            tar.close()

        rethrow(
            GCError('Unable to log results of external call "%s" to "%s"' %
                    (record.proc.get_call(), self._fn)), _log_tar)
コード例 #2
0
    def end_interface(
        self
    ):  # lots of try ... except .. finally - for clean console state restore
        def _end_interface():
            try:
                self._finish_drawing()
            finally:
                GCStreamHandler.set_global_lock()
                Console.reset_console()

        rethrow(GUIException('GUI shutdown exception'), _end_interface)
        self._exc.raise_any(GUIException('GUI drawing exception'))
コード例 #3
0
def convert_lumi_expr(opts, args):
	# Lumi filter manuipulation
	run_lumi_range_list = rethrow(NestedException('Could not parse: %s' % str.join(' ', args)),
		parse_lumi_filter, str.join(' ', args))

	if opts.gc:
		write_lumi_gc(run_lumi_range_list)
	if opts.json:
		write_lumi_json(run_lumi_range_list)
	if opts.full:
		write_lumi_ext(run_lumi_range_list)
コード例 #4
0
	def _write_process_log(self, record):
		entry_time = time.strftime('%Y-%m-%d_%H:%M:%S', time.localtime(record.created))
		entry = '%s_%s.%03d' % (record.name, entry_time, int(record.msecs))
		files = record.files
		files['info'] = 'call=%s\nexit=%s\n' % (repr(record.proc.get_call()), record.proc.status(0))
		files['stdout'] = record.proc.stdout.read_log()
		files['stderr'] = record.proc.stderr.read_log()
		files['stdin'] = record.proc.stdin.read_log()

		def _log_tar():
			tar = tarfile.TarFile.open(self._fn, 'a')
			for key, value in record.files.items():
				if os.path.exists(value):
					value = SafeFile(value).read_close()
				file_obj = VirtualFile(os.path.join(entry, key), [value])
				info, handle = file_obj.get_tar_info()
				tar.addfile(info, handle)
				handle.close()
			tar.close()
		rethrow(GCError('Unable to log results of external call "%s" to "%s"' % (
			record.proc.get_call(), self._fn)), _log_tar)
コード例 #5
0
def convert_lumi_expr(opts, args):
    # Lumi filter manuipulation
    run_lumi_range_list = rethrow(
        NestedException('Could not parse: %s' % str.join(' ', args)),
        parse_lumi_filter, str.join(' ', args))

    if opts.gc:
        write_lumi_gc(run_lumi_range_list)
    if opts.json:
        write_lumi_json(run_lumi_range_list)
    if opts.full:
        write_lumi_ext(run_lumi_range_list)
コード例 #6
0
def _var_rethrow(vn, msg, fun, *args, **kwargs):
    return rethrow(VarError(vn, msg), fun, *args, **kwargs)
コード例 #7
0
ファイル: pconfig.py プロジェクト: mschnepf/grid-control
def _var_rethrow(vn, msg, fun, *args, **kwargs):
	return rethrow(VarError(vn, msg), fun, *args, **kwargs)
コード例 #8
0
    def _write_process_log(self, record):
        entry_time = time.strftime('%Y-%m-%d_%H:%M:%S',
                                   time.localtime(record.created))
        entry = '%s_%s.%03d' % (record.name, entry_time, int(record.msecs))
        files = record.files
        files['info'] = 'call=%s\nexit=%s\n' % (repr(
            record.proc.get_call()), record.proc.status(0))
        files['stdout'] = record.proc.stdout.read_log()
        files['stderr'] = record.proc.stderr.read_log()
        files['stdin'] = record.proc.stdin.read_log()

        def _log_tar(only_print=False):
            # self._log.info('tar: %s' % self._fn)
            sleep_when_cannot_accept_jobs = False
            message = ""
            if not only_print:
                tar = tarfile.TarFile.open(self._fn, 'a')
            for key, value in record.files.items():
                if "The CREAM service cannot accept jobs at the moment" in value:
                    sleep_when_cannot_accept_jobs = True
                    message = "The CREAM service cannot accept jobs at the moment"
                elif "Unable to connect to" in value:
                    sleep_when_cannot_accept_jobs = True
                    message = value
                value = os.linesep.join([s for s in value.splitlines() if s])
                if only_print:
                    self._log.info('\n\tkey: "%s"\n\tvalue: "%s"' %
                                   (key, value))
                else:
                    if value.startswith('\n'):
                        value = value[1:]
                    if os.path.exists(value):
                        value = SafeFile(value).read_close()
                    # self._log.info('\tvirtual file: "%s"' % os.path.join(entry, key))
                    file_obj = VirtualFile(os.path.join(entry, key), [value])
                    info, handle = file_obj.get_tar_info()
                    # self._log.info('\tinfo: "%s"' % info)
                    # self._log.info('\thandle: "%s"' % handle)
                    tar.addfile(info, handle)
                    handle.close()
            if not only_print:
                tar.close()
            if sleep_when_cannot_accept_jobs:
                from grid_control.utils.activity import Activity
                activity = Activity(
                    message +
                    '. Waiting before trying to delegate proxy again...')
                time.sleep(900)
                activity.finish()

        # rethrow(GCError('Unable to log results of external call "%s" to "%s"' % (
        # 		record.proc.get_call(), self._fn)), _log_tar)
        try:
            rethrow(
                GCError('Unable to log results of external call "%s" to "%s"' %
                        (record.proc.get_call(), self._fn)), _log_tar)
        except:
            self._log.warning(
                'Unable to log results of external call "%s" to "%s"' %
                (record.proc.get_call(), self._fn))
            _log_tar(only_print=True)