lilalo

changeset 3:6c1d2b9f45e7

Добавил команду lm report.

Строит html-представление журналов
для заданного класса.
Нужно сделать поддержку опций GetOpt::Long
и тогда эту же команду можно будет использовать
для построения всех журналов в репозитории.
author devi
date Tue May 24 13:00:28 2005 +0300 (2005-05-24)
parents 787e9f11de51
children 774de5c1ad00
files lm
line diff
     1.1 --- a/lm	Sun May 22 16:31:54 2005 +0300
     1.2 +++ b/lm	Tue May 24 13:00:28 2005 +0300
     1.3 @@ -19,12 +19,17 @@
     1.4  our %Config = (
     1.5  	"show_host" 	=> "no",
     1.6  
     1.7 +	# Вспомогательные программы
     1.8 +	"l3-report"	=> "./lm-report",
     1.9 +
    1.10  	# Каталоги
    1.11  	"path_labmaker" => "/var/labmaker/",
    1.12  	"path_classes"	=> "/var/labmaker/classes/",
    1.13 -	"lablogs_path"	=> "/var/labmaker/lablogs/",
    1.14 +	"path_lablogs"	=> "/var/labmaker/lablogs/",
    1.15  	"courses_path"	=> "/var/labmaker/courses/",
    1.16  	"outpath"	=> "/var/labmaker/out/",
    1.17 +	"path_web"	=> "/var/www/l3",		# Путь к web-отчётам
    1.18 +	"path_share"	=> "./share/",		# Путь к web-отчётам
    1.19  
    1.20  	# Файлы
    1.21  	"runfile"	=> "lm.run", 
    1.22 @@ -263,7 +268,7 @@
    1.23  			my %myenv = ( %Config, 
    1.24  				host 	=>	$m,
    1.25  				dirs	=>	"/root /home/".$Machines{$m}->{"user"},
    1.26 -				lablogs =>	$Config{"lablogs_path"}."/".
    1.27 +				lablogs =>	$Config{"path_lablogs"}."/".
    1.28  						$XMLClass->{"course"}."/".
    1.29  						$XMLClass->{"date"}."/".
    1.30  						"$m",
    1.31 @@ -300,83 +305,47 @@
    1.32  }
    1.33  
    1.34  
    1.35 +
    1.36 +=cut comment
    1.37 +
    1.38 +lm report
    1.39 +
    1.40 +Построить html представление для журналов текущего класса.
    1.41 +Для построения используется скрипт l3-report.
    1.42 +
    1.43 +=cut
    1.44 +
    1.45  sub lm_report
    1.46  {
    1.47  
    1.48 -	print "Not implemented yet\n";
    1.49 -	exit(1);
    1.50 +	my $webdir = $Config{"path_web"};
    1.51 +	my $course=$XMLClass->{"course"};
    1.52 +	my $date=$XMLClass->{"date"};
    1.53 +	my $encoding=$XMLClass->{"charset"};
    1.54  
    1.55 -=cut comment
    1.56 +	print "date=$date\n";
    1.57  
    1.58 -Дальше идут скрипты, код которых нужно реализовать здесь.
    1.59 -Как минимум.
    1.60 +	for my $student (@{$XMLClass->{"student"}}) {
    1.61 +		my $user = $student->{"user"};
    1.62 +		my $hostname = $student->{"host"};
    1.63 +		my $encoding = $student->{"encoding"};
    1.64  
    1.65 -=cut 
    1.66 -
    1.67 -	my $lm_script_make_report_web = <<'SCRIPT';
    1.68 -
    1.69 -#!/bin/sh
    1.70 -
    1.71 -####cd /home/devi/lm
    1.72 -./lm do copy-lablogs
    1.73 -##./lm-report --input /home/murk/.labmaker --output /var/www/lm/murk.html
    1.74 -##exit
    1.75 -
    1.76 -COURSE=ug-h
    1.77 -DATE=2005-04-25
    1.78 -SUFF=".linux.nt"
    1.79 -#MACHINES="m01 m02 m03 m04 m05 m06 m07 m08 m09 m10 m11 m12 m13 m14 m15"
    1.80 -#MACHINES="m1 m2 m3 m4 m5 m6 m7 f1 f2 f3 f4 f5"
    1.81 -MACHINES="m01 m02 m03 m04 m05 m06 m07 m08"
    1.82 -#MACHINES="m1"
    1.83 -USERS="user root"
    1.84 -WEBDIR=/var/www/lm
    1.85 -
    1.86 -for u in $USERS
    1.87 -	do
    1.88 -		for m in $MACHINES
    1.89 -			do
    1.90 -				e=utf-8
    1.91 -				[ "${m##f}" = "$m" ] || e=koi8-r
    1.92 -				#e=koi8-r
    1.93 -				mkdir -p $WEBDIR/$DATE/$m
    1.94 -				cp share/*.ico share/*.css $WEBDIR/$m
    1.95 -				#echo Processing Lablogs/$COURSE/$DATE/$m$SUFF/$u/
    1.96 -				./lm-report\
    1.97 -					--input	Lablogs/$COURSE/$DATE/$m$SUFF/$u/ \
    1.98 -					--diffs "Lablogs/$COURSE/$DATE/$m$SUFF/$u/ Lablogs/$COURSE/$DATE/$m$SUFF/root/"\
    1.99 -					--output /var/www/lm/$DATE/$m/$u.html \
   1.100 -					--encoding $e
   1.101 -			done
   1.102 -	done
   1.103 -					
   1.104 -
   1.105 -SCRIPT
   1.106 -
   1.107 -	my $lm_script_make_report_all = <<'SCRIPT';
   1.108 -
   1.109 -#!/bin/sh
   1.110 -WEBDIR=/var/www/lm
   1.111 -
   1.112 -find . -type d -maxdepth 5 -mindepth 5 |\
   1.113 -	while read dir
   1.114 -	do
   1.115 -		subdir=${dir##Lablogs/}
   1.116 -		e=utf-8
   1.117 -		echo $dir | grep -qi bsd && e=koi8-r
   1.118 -		echo $dir | grep -qi /f && e=koi8-r
   1.119 -
   1.120 -		mkdir -p $WEBDIR/${subdir%/*}
   1.121 -		cp share/*.ico share/*.css $WEBDIR/${subdir%/*}
   1.122 -		#echo Processing Lablogs/$COURSE/$DATE/$m$SUFF/$u/
   1.123 -		./lm-report\
   1.124 -			--input $dir	 \
   1.125 -			--diffs "${dir%/user}/root $dir"\
   1.126 -			--output $WEBDIR/$subdir.html \
   1.127 -			--encoding $e
   1.128 -	done
   1.129 -
   1.130 -SCRIPT
   1.131 +		system("mkdir -p $webdir/$date/$hostname");
   1.132 +		system("cp ".$Config{"path_share"}."/*.{ico,css} $webdir/$date/$hostname");
   1.133 +		system($Config{"l3-report"}.
   1.134 +			" --input ".$Config{"path_lablogs"}."/$course/$date/$hostname/$user".
   1.135 +			" --diffs ".$Config{"path_lablogs"}."/$course/$date/$hostname/$user ".
   1.136 +				   $Config{"path_lablogs"}."/$course/$date/$hostname/root".
   1.137 +			" --output $webdir/$date/$hostname/$user.html".
   1.138 +			" --encoding $encoding"
   1.139 +		);
   1.140 +		system($Config{"l3-report"}.
   1.141 +			" --input ".$Config{"path_lablogs"}."/$course/$date/$hostname/root".
   1.142 +			" --diffs ".$Config{"path_lablogs"}."/$course/$date/$hostname/root ".
   1.143 +			" --output $webdir/$date/$hostname/root.html".
   1.144 +			" --encoding $encoding"
   1.145 +		);
   1.146 +	}
   1.147  }
   1.148  
   1.149  sub load_run