summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoretienne2006-03-07 14:53:37 +0000
committeretienne2006-03-07 14:53:37 +0000
commitae445570a08145acf0bcc19fef4dc82ac76652b4 (patch)
tree99e28c73e5c0fe821a954adc3add8897c4808149
parentabcbe681fd0a2605769f3704e457490619c7a96a (diff)
downloadivymon-ae445570a08145acf0bcc19fef4dc82ac76652b4.zip
ivymon-ae445570a08145acf0bcc19fef4dc82ac76652b4.tar.gz
ivymon-ae445570a08145acf0bcc19fef4dc82ac76652b4.tar.bz2
ivymon-ae445570a08145acf0bcc19fef4dc82ac76652b4.tar.xz
*** empty log message ***
-rw-r--r--debian/changelog7
-rwxr-xr-xsrc/ivymon69
2 files changed, 50 insertions, 26 deletions
diff --git a/debian/changelog b/debian/changelog
index c7c67a7..786680e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+ivymon (1.13) unstable; urgency=low
+
+ * when receive the "Ivymon Output=<file>" message, set or update
+ the output filename.
+
+ -- Daniel Etienne <etienne@cena.fr> Tue, 7 Mar 2006 15:43:19 +0100
+
ivymon (1.12) unstable; urgency=low
* added in the "Messages to send" frame a field to display the
diff --git a/src/ivymon b/src/ivymon
index da6fb62..7a79b2e 100755
--- a/src/ivymon
+++ b/src/ivymon
@@ -92,7 +92,7 @@ use vars qw/$VERSION $opt_help $opt_b $opt_bus $opt_history @opt_bind @opt_send
$opt_undersize $opt_out $opt_loadingmode $opt_replayrepeat $opt_replaystartregexp
$opt_replaystopregexp $opt_replaytimegranularity/;
# **** VERSION ***
-$VERSION = '1.12';
+$VERSION = '1.13';
# options initialisation
$opt_loadingmode = 'replay-pause';
@@ -157,6 +157,8 @@ my $stopFlag = 0;
my $noMessageYet = 1;
my $jump_cnt = 0;
+my $outputfile;
+
my $noUpdateFlag = 0;
my $loadedFileFlag = 0;
my $loadingFlag = 0;
@@ -997,13 +999,6 @@ for my $bind (@effectivebind) {
# Options and arguments test
#
#=================================================================================
-# output file
-if ($opt_out) {
- unless (open(OUT, ">$opt_out")) {
- $mw->Tk::Error("Can't write to file '$opt_out' ($!)");
- $opt_out = undef;
- }
-}
# loading mode
$mw->Tk::Error("syntax error : -loadingmode accepts 'replay', 'replay-pause' ".
"or 'display' value")
@@ -1034,7 +1029,7 @@ if (@ARGV > 0) {
}
}
-
+$ivy->bindRegexp("Ivymon Output=(.*)", [sub { $outputfile = $_[1]; }]);
MainLoop;
#==================================================================================
@@ -1577,7 +1572,8 @@ sub newBinding {
# skip expressions between parenthesis
$msg =~ s/=\(.*?\)/= /g;
-
+ $msg =~ s/\s+$//;
+
# duplicate expressions containing the | character
my @expr;
my $msgsnum = 1;
@@ -2443,12 +2439,14 @@ sub savefile {
my ($d, $m, $y, $h, $M) = (localtime(time))[3,4,5,2,1];
$y =~ s/^\d// if $y >= 100;
$m++;
- my $default = 'ivylog'.$d.$m.$y."_".$h.":".$M.".ivy";
+ my $default = (defined $outputfile) ? $outputfile :
+ sprintf("ivylog%02s%02s%02s_%02s:%02s.ivy", $d, $m, $y, $h, $M);
my $file = $mw->getSaveFile(-initialfile => $default,
-filetypes => [['Ivy Files', '.ivy'],
['All Files', '*']],
);
return unless $file;
+ $outputfile = $file;
&showProgressbar();
# disable other buttons
my $jumpstate = $jumpButton->cget(-state);
@@ -2474,15 +2472,8 @@ sub savefile {
};
my $status = 0;
- # open file
- unless (open(OUT, ">$file")) {
+ if (&save < 0) {
$mw->Tk::Error("$!\n");
- &$restorestate;
- return;
- }
- unless (&save) {
- $mw->Tk::Error("$!\n");
- close(OUT);
&$restorestate;
return;
}
@@ -2492,8 +2483,37 @@ sub savefile {
} # end savefile
+sub openfile {
+
+ my $file = $outputfile;
+ $file = $opt_out unless defined $file;
+ return 0 unless defined $file;
+ if (open(OUT, ">$file")) {
+ return 1;
+ } else {
+ close(OUT);
+ $mw->Tk::messageBox(-icon => "warning",
+ -message =>
+ "Can't write to file $file ($!). ".
+ "Save data in ivymon-rescue.ivy",
+ -type => 'OK',
+ );
+ if (open(OUT, ">ivymon-rescue.ivy")) {
+ return 1;
+ } else {
+ close(OUT);
+ $mw->Tk::Error("Can't write to output file ($!)");
+ return -1;
+ }
+ }
+
+} # sub openfile
+
+
sub save {
+ my $of = &openfile();
+ return $of unless $of == 1;
my $tpl = $mw->Toplevel;
$tpl->Popup;
$tpl->title("Save");
@@ -2501,7 +2521,7 @@ sub save {
$tpl->Label(-text => "Saving data...")->pack(-expand => 1, -fill => 'both');
# save connected applications name
my @clients = $clientsListbox->get(0, 'end');
- print OUT "applications=", join(',', @clients),"\n" or return;
+ print OUT "applications=", join(',', @clients),"\n" or return -1;
my $nblines = $messagesText->index('end');
#print "nblines=$nblines\n";
@@ -2510,7 +2530,7 @@ sub save {
$progressbar->configure(-to => $nblines);
my $step = int($nblines/10);
#print "step=$step\n";
- print OUT "messages_number=$nblines\n" or return;
+ print OUT "messages_number=$nblines\n" or return -1;
# save messages 100 by 100, in order to reduce memory usage
my $index = "1.0";
my $counter = 0;
@@ -2522,7 +2542,7 @@ sub save {
$progressbar->update;
last;
}
- print OUT $messages or return;
+ print OUT $messages or return -1;
&setProgressbar($counter);
$counter += 100;
$progressbar->update if ($step == 0 or $counter % $step == 0);
@@ -2850,10 +2870,7 @@ sub warning3 {
sub quit {
print "Quit\n";
- if (defined $opt_out) {
- $mw->Tk::Error("$!\n") unless (&save);
- close(OUT);
- }
+ $mw->Tk::Error("$!\n") if &save < 0;
exit;
} # end quit