# HG changeset patch # User devi # Date 1140847345 -7200 # Node ID 2cb912bff2ea265549efce8f94770550b68c9015 # Parent bdc1f02d3f87028025d29e61e70f30c36fedba95 * В журнале выводится имя курса, а не только его код * Исправлена ошибка с фильтром при чтении журнала из XML-репозитория Теперь всё ок diff -r bdc1f02d3f87 -r 2cb912bff2ea l3-agent --- a/l3-agent Fri Feb 24 18:43:35 2006 +0200 +++ b/l3-agent Sat Feb 25 08:02:25 2006 +0200 @@ -279,6 +279,9 @@ #Загруженную информацию сразу же отправляем в поток print_session($Config{cache}, $local_session_id); } + else { + die "can't open session file"; + } } open (FILE, "$file"); @@ -581,10 +584,12 @@ @Command_Lines_Index = sort { defined($Command_Lines[$index[$a]]->{"time"}) ? $Command_Lines[$index[$a]]->{"time"} <=> $Command_Lines[$index[$b]]->{"time"} - : $Command_Lines[$index[$a]]->{"day"} cmp $Command_Lines[$index[$b]]->{"day"} + : defined($Command_Lines[$index[$a]]->{"day"}) + ? $Command_Lines[$index[$a]]->{"day"} cmp $Command_Lines[$index[$b]]->{"day"} || $Command_Lines[$index[$a]]->{"hour"} <=> $Command_Lines[$index[$b]]->{"hour"} || $Command_Lines[$index[$a]]->{"min"} <=> $Command_Lines[$index[$b]]->{"min"} || $Command_Lines[$index[$a]]->{"sec"} <=> $Command_Lines[$index[$b]]->{"sec"} + : 0 } @index; print "finished\n" if $Config{"verbose"} =~ /y/; @@ -738,12 +743,16 @@ my $local_session_id = $_[1]; return if not defined($Sessions{$local_session_id}); + print "printing session info. session id = ".$local_session_id."\n" + if $Config{verbose} =~ /y/; + open(OUT, ">>", $output_filename) or die "Can't open $output_filename for writing\n"; print OUT "\n"; my %session = %{$Sessions{$local_session_id}}; for my $key (keys %session) { - print OUT "<$key>".$session{$key}."\n" + print OUT "<$key>".$session{$key}."\n"; + print " ".$key,"\n"; } print OUT "\n"; close(OUT); diff -r bdc1f02d3f87 -r 2cb912bff2ea l3-cgi --- a/l3-cgi Fri Feb 24 18:43:35 2006 +0200 +++ b/l3-cgi Sat Feb 25 08:02:25 2006 +0200 @@ -6,16 +6,16 @@ use utf8; BEGIN { - chdir("/home/devi/cvs/lilalo"); - require l3config; - l3config::init_config(); + chdir("/home/devi/cvs/lilalo"); + require l3config; + l3config::init_config(); }; my %filter; for my $key (qw(login_from local_session_id)) { - $filter{$key} = param($key) if param($key); - $filter{$key} = $ENV{$key} if defined $ENV{$key}; + $filter{$key} = param($key) if param($key); + $filter{$key} = $ENV{$key} if defined $ENV{$key}; } my %Trainings; @@ -23,7 +23,7 @@ my %Machines; my $print = ""; -$l3config::Config{cgi2file} = $ENV{cgi2file} if defined($ENV{cgi2file}); +$l3config::Config{cgi2file} = $ENV{cgi2file} if defined($ENV{cgi2file}); $ENV{PATH_INFO} = $l3config::Config{cgi_path_info} if $l3config::Config{cgi_path_info}; my $is_not_cgi=""; @@ -39,87 +39,93 @@ sub load_training { my $training_file; - - $training_file = $l3config::Config{"path_classes"}.$_[0].$l3config::Config{"class_suffix"} if $_[0]; + + $training_file = $l3config::Config{"path_classes"}.$_[0].$l3config::Config{"class_suffix"} if $_[0]; $training_file ||= $l3config::Config{"classfile"} || $l3config::Config{"path_classes"}.$l3config::Config{"class"}.$l3config::Config{"class_suffix"}; my $XMLTraining = XMLin($training_file , ForceArray => [ 'student' ] ) or die "Can't open file of the training ",$training_file,"\n"; + my $course_file = $l3config::Config{"courses_path"}.$XMLTraining->{"course"}.".xml"; + my $XMLCourse; + if (eval{$XMLCourse = XMLin($course_file)}) { + $XMLTraining->{"course-name"} = $XMLCourse->{"fullname"}; + } + for my $student (@{$XMLTraining->{"student"}}) { - $XMLTraining->{host}->{$student->{"host"}}=$student; + $XMLTraining->{host}->{$student->{"host"}}=$student; } - return $XMLTraining; + return $XMLTraining; } if ($ENV{PATH_INFO} eq "/index") { - # Показываем индекс курсов - my @training_files = glob($l3config::Config{"path_classes"}."/2*".$l3config::Config{"class_suffix"}); - if (@training_files) { - for my $training_file (@training_files) { - $training_file =~ s@.*/@@; - $training_file =~ s@$l3config::Config{"class_suffix"}$@@; - my $training = load_training($training_file); - $Trainings{$training->{"date"}}=$training; - } - $print .= "\n"; - $print .= "\n"; - $print .= "Журналы лабораторных работ\n"; - $print .= "\n"; - $print .= "\n"; - $print .= "\n"; - for my $tdate (reverse sort keys %Trainings) { - my $t = $Trainings{$tdate}; - $print .= ""; - $print .= ""; - $print .= ""; - $print .= "\n"; - $print .= ""; - $print .= "\n"; - } - $print .= "
".$t->{date}."".$t->{course}."
"; - $print .= "
";
-			for my $host (sort keys %{$t->{host}}) {
-				my $h = $t->{host}->{$host};
-				$print .= "$host";
-				$print .= " ".$h->{firstname}." ".$h->{surname}." ";
-				$print .= " ".$h->{company}." ";
-				$print .= "root ";
-				$print .= "".$h->{user}." ";
-				$print .= "\n";
-			}
-			$print .= "
"; - $print .= "
\n"; - $print .= "\n"; - $print .= "\n"; - } - else { - $print .= "No training-files found
\n"; - $print .= "Template to load files: ".$l3config::Config{"path_classes"}."*".$l3config::Config{"class_suffix"}."\n" - } + # Показываем индекс курсов + my @training_files = glob($l3config::Config{"path_classes"}."/2*".$l3config::Config{"class_suffix"}); + if (@training_files) { + for my $training_file (@training_files) { + $training_file =~ s@.*/@@; + $training_file =~ s@$l3config::Config{"class_suffix"}$@@; + my $training = load_training($training_file); + $Trainings{$training->{"date"}}=$training; + } + $print .= "\n"; + $print .= "\n"; + $print .= "Журналы лабораторных работ\n"; + $print .= "\n"; + $print .= "\n"; + $print .= "\n"; + for my $tdate (reverse sort keys %Trainings) { + my $t = $Trainings{$tdate}; + $print .= ""; + $print .= ""; + $print .= ""; + $print .= "\n"; + $print .= ""; + $print .= "\n"; + } + $print .= "
".$t->{date}."".$t->{course}."
"; + $print .= "
";
+            for my $host (sort keys %{$t->{host}}) {
+                my $h = $t->{host}->{$host};
+                $print .= "$host";
+                $print .= " ".$h->{firstname}." ".$h->{surname}." ";
+                $print .= " ".$h->{company}." ";
+                $print .= "root ";
+                $print .= "".$h->{user}." ";
+                $print .= "\n";
+            }
+            $print .= "
"; + $print .= "
\n"; + $print .= "\n"; + $print .= "\n"; + } + else { + $print .= "No training-files found
\n"; + $print .= "Template to load files: ".$l3config::Config{"path_classes"}."*".$l3config::Config{"class_suffix"}."\n" + } } elsif ($ENV{PATH_INFO} eq "/current") { - open (FRONTEND, "./l3-frontend --output - --show_comments no --frontend_css $l3config::Config{frontend_css}|"); - binmode FRONTEND, ":utf8"; - while () { - $print .= $_; - } - close(FRONTEND); + open (FRONTEND, "./l3-frontend --output - --show_comments no --frontend_css $l3config::Config{frontend_css}|"); + binmode FRONTEND, ":utf8"; + while () { + $print .= $_; + } + close(FRONTEND); } else { - # Вызов производится по URL - $ENV{PATH_INFO} = "/".$ENV{PATH_INFO} unless $ENV{PATH_INFO} =~ m@^/@; - my ($skip, $training, $host, $user) = split /\//,$ENV{PATH_INFO},4; + # Вызов производится по URL + $ENV{PATH_INFO} = "/".$ENV{PATH_INFO} unless $ENV{PATH_INFO} =~ m@^/@; + my ($skip, $training, $host, $user) = split /\//,$ENV{PATH_INFO},4; - if (!$host || $host eq "index") { - # Нам неизвестен курс или явно указан просмотр индекса - # Просматриваем его + if (!$host || $host eq "index") { + # Нам неизвестен курс или явно указан просмотр индекса + # Просматриваем его - my $t = load_training($training); - $training ||= "current"; + my $t = load_training($training); + $training ||= "current"; my $prefix = "/cgi-bin/l3/$training/"; my $suffix = ""; @@ -130,52 +136,50 @@ my $path = $to_file; $path = "" unless $path =~ s@/[^/]*$@@; - $print .= "\n"; - $print .= "\n"; - $print .= "Журналы лабораторных работ\n"; + $print .= "\n"; + $print .= "\n"; + $print .= "Журналы лабораторных работ\n"; $print .= ""; - $print .= "\n"; - $print .= "\n"; - $print .= "\n"; - $print .= "

Журналы лабораторных работ

\n"; - $print .= "\n"; - $print .= "\n"; - $print .= ""; - $print .= ""; - $print .= ""; - $print .= "\n"; - for my $host (sort keys %{$t->{host}}) { + $print .= "\n"; + $print .= "\n"; + $print .= "\n"; + $print .= "

Журналы лабораторных работ

\n"; + $print .= "
"."Имя"."ХостПользователь
\n"; + $print .= "\n"; + $print .= ""; + $print .= ""; + $print .= ""; + $print .= "\n"; + for my $host (sort keys %{$t->{host}}) { + $print .= "\n"; + my $h = $t->{host}->{$host}; + $print .= ""; + $print .= ""; + $print .= ""; + $print .= ""; + $print .= "" if not $is_not_cgi; + $print .= "\n"; + $print .= "\n"; - - $print .= "\n"; - my $h = $t->{host}->{$host}; - $print .= ""; - $print .= ""; - $print .= ""; - $print .= ""; - $print .= "" if not $is_not_cgi; - $print .= "\n"; - $print .= "\n"; - - if ($is_not_cgi) { - # Это грязный хак - # Если мы чувствуем, что нас вызывают для генерения индексного файла, - # нам нужно создать и файлы, на которые он указывает - # Лучше было бы это сделать хотя бы через вызов функций + if ($is_not_cgi) { + # Это грязный хак + # Если мы чувствуем, что нас вызывают для генерения индексного файла, + # нам нужно создать и файлы, на которые он указывает + # Лучше было бы это сделать хотя бы через вызов функций # Такой же хак чуть ниже - mkdir("$path/$host"); - system("$0 --cgi2file $path/$prefix$host/root$suffix ". - "--cgi_path_info ".$training."/".$host."/root ". - "--frontend_css ../$l3config::Config{frontend_css}"); - system("$0 --cgi2file $path/$prefix$host/".$h->{user}."$suffix ". - "--cgi_path_info ".$training."/".$host."/".$h->{user}." ". - "--frontend_css ../$l3config::Config{frontend_css}"); - # system("$0 --cgi2file $path/$prefix$host$suffix ". - # "--cgi_path_info ".$training."/".$host." ". - # "--frontend_css ../$l3config::Config{frontend_css}"); - } - - } + mkdir("$path/$host"); + system("$0 --cgi2file $path/$prefix$host/root$suffix ". + "--cgi_path_info ".$training."/".$host."/root ". + "--frontend_css ../$l3config::Config{frontend_css}"); + system("$0 --cgi2file $path/$prefix$host/".$h->{user}."$suffix ". + "--cgi_path_info ".$training."/".$host."/".$h->{user}." ". + "--frontend_css ../$l3config::Config{frontend_css}"); + # system("$0 --cgi2file $path/$prefix$host$suffix ". + # "--cgi_path_info ".$training."/".$host." ". + # "--frontend_css ../$l3config::Config{frontend_css}"); + } + + } # Такой же хак был чуть выше if ($is_not_cgi) { # $print .= ""; @@ -191,42 +195,45 @@ $print .= ""; } - $print .= "\n"; - $print .= "
"."Имя"."ХостПользователь
".$h->{firstname}." ".$h->{surname}."$hostroot".$h->{user}."все
".$h->{firstname}." ".$h->{surname}."$hostroot".$h->{user}."все
все"; $print .= "все
\n"; - $print .= "\n"; - $print .= "\n"; - } - else { + $print .= "\n"; + $print .= "\n"; + $print .= "\n"; + $print .= "\n"; + } + else { - $l3config::Config{"class"}=$training if $training ne 'current'; - $XMLTraining = load_training; + $l3config::Config{"class"}=$training if $training ne 'current'; + $XMLTraining = load_training; - my @args=( - "--output" => "-", - "--show_comments" => "no", - "--course-center" => $XMLTraining->{center}, - "--course-trainer" => $XMLTraining->{instructor}->{firstname}." ".$XMLTraining->{instructor}->{surname}, - "--course-student" => $XMLTraining->{host}->{$host}->{firstname}." ".$XMLTraining->{host}->{$host}->{surname}, - "--course-code" => $XMLTraining->{course}, - "--course-date" => $XMLTraining->{date}, - "--encoding" => $XMLTraining->{host}->{$host}->{charset}, - ); - if ($training ne 'current') { - push @args, ("--backend_datafile" => "/var/lilalo/lablogs-xml/$training/$host/$user.xml"); - } else { - $filter{hostname} = $host if $host; - $filter{user} = $user if $user; - push @args, ("--filter" => join ("&", (map("$_=$filter{$_}", keys %filter)))); - ##push @args, ("--filter" => "hostname=".$host."&user=".$user); - } + my @args=( + "--output" => "-", + "--show_comments" => "no", + "--course-center" => $XMLTraining->{center}, + "--course-trainer" => $XMLTraining->{instructor}->{firstname}." ".$XMLTraining->{instructor}->{surname}, + "--course-student" => $XMLTraining->{host}->{$host}->{firstname}." ".$XMLTraining->{host}->{$host}->{surname}, + "--course-code" => $XMLTraining->{course}, + "--course-date" => $XMLTraining->{date}, + "--encoding" => $XMLTraining->{host}->{$host}->{charset}, + ); + if ($XMLTraining->{"course-name"}) { + push @args, ("--course-name" => $XMLTraining->{"course-name"}); + }; + if ($training ne 'current') { + push @args, ("--backend_datafile" => "/var/lilalo/lablogs-xml/$training/$host/$user.xml"); + } else { + $filter{hostname} = $host if $host; + $filter{user} = $user if $user; + } + push @args, ("--filter" => join ("&", (map("$_=$filter{$_}", keys %filter)))); - open (FRONTEND, "./l3-frontend --frontend_css $l3config::Config{frontend_css} ".join(" ",map("\"$_\"",@args))." |"); - binmode FRONTEND, ":utf8"; - while () { - $print .= $_; - } - close(FRONTEND); - } + #$print .= "./l3-frontend --frontend_css $l3config::Config{frontend_css} ".join(" ",map("\"$_\"",@args))." |
"; + open (FRONTEND, "./l3-frontend --frontend_css $l3config::Config{frontend_css} ".join(" ",map("\"$_\"",@args))." |"); + binmode FRONTEND, ":utf8"; + while () { + $print .= $_; + } + close(FRONTEND); + } } # Если задана переменная окружения l3_to_file, diff -r bdc1f02d3f87 -r 2cb912bff2ea l3-frontend --- a/l3-frontend Fri Feb 24 18:43:35 2006 +0200 +++ b/l3-frontend Sat Feb 25 08:02:25 2006 +0200 @@ -11,6 +11,7 @@ our %Args_Description; our $Mywi_Socket; our %Sessions; +our %filter; our %Files; @@ -255,12 +256,13 @@ my $data = ; close(CLASS); - for my $session ($data =~ m@(.*?)@sg) { - my %session; + my $i=0; + for my $session ($data =~ m@(.*?)@msg) { + my %session_hash; while ($session =~ m@<([^>]*?)>(.*?)@sg) { - $session{$1} = $2; + $session_hash{$1} = $2; } - $Sessions{$session{local_session_id}} = \%session; + $Sessions{$session_hash{local_session_id}} = \%session_hash; } } @@ -409,7 +411,6 @@ my @known_commands; - my %filter; if ($Config{filter}) { # Инициализация фильтра @@ -455,9 +456,9 @@ #$result .= "undefined local session id
\n" if !defined($cl->{local_session_id}); #$result .= "undefined filter key $filter_key
\n" if !defined($Sessions{$cl->{local_session_id}}->{$filter_key}); #$result .= $Sessions{$cl->{local_session_id}}->{$filter_key}." != ".$filter{$filter_key}; - next COMMAND_LINE if - defined($cl->{local_session_id}) - && defined($Sessions{$cl->{local_session_id}}->{$filter_key}) + next COMMAND_LINE + if defined($cl->{local_session_id}) + && defined($Sessions{$cl->{local_session_id}}->{$filter_key}) && $Sessions{$cl->{local_session_id}}->{$filter_key} ne $filter{$filter_key}; } @@ -688,7 +689,7 @@ my $hint = make_comment($cl->{"cline"}); my $cline; - $prompt_hint = join (" ", map("$_=$cl->{$_}", grep (!/^output$/, sort(keys(%{$cl}))))); + $prompt_hint = join (" ", map("$_=$cl->{$_}", grep (!/^(output|diff)$/, sort(keys(%{$cl}))))); $cline = "".$cl->{"prompt"}."".$cl->{"cline"}; $cline =~ s/\n//; @@ -836,6 +837,14 @@ my $files_section = print_files; $result = print_header($toc); + + +# $result.= join "
", keys %Sessions; +# for my $sess (keys %Sessions) { +# $result .= join " ", keys (%{$Sessions{$sess}}); +# $result .= "
"; +# } + $result.= "

Журнал

" . $command_lines; $result.= "

Файлы

" . $files_section if $files_section; $result.= "

Статистика

" . print_stat; @@ -944,6 +953,7 @@ $result .= "($course_code)" if $course_code; $result .= ", $course_date
" if $course_date; $result .= "Учебный центр $course_center
" if $course_center; + $result .= "Фильтр ".join(" ", map("$filter{$_}=$_", keys %filter))."
" if %filter; $result .= "

"; } diff -r bdc1f02d3f87 -r 2cb912bff2ea l3config.pm --- a/l3config.pm Fri Feb 24 18:43:35 2006 +0200 +++ b/l3config.pm Sat Feb 25 08:02:25 2006 +0200 @@ -94,7 +94,7 @@ "course-name" => "", "course-code" => "", - "course-date" => "", + "course-date" => "course-center" => "", "course-trainer" => "", "course-student" => "",