allow annotating markers in explorer
This commit is contained in:
@ -8,6 +8,9 @@ use DateTime;
|
||||
|
||||
use feature 'say';
|
||||
|
||||
my $local_root = '/home/christoph/Notes/TU/MastersThesis/FailNix';
|
||||
my $local_archive_dir = "$local_root/injections";
|
||||
|
||||
my $ntfy_url = 'https://ntfy.vps.chriphost.de';
|
||||
my $ntfy_token = 'tk_rx8fd6hojuz4ekcb72j7juugkbmga'; # May be public
|
||||
my $ntfy_topic = 'fail-alerts';
|
||||
@ -187,4 +190,77 @@ sub get_section_name {
|
||||
return $name;
|
||||
}
|
||||
|
||||
sub read_experiment_info {
|
||||
my ($exp) = @_;
|
||||
|
||||
return unless ( -f "$local_archive_dir/$exp/0.info" );
|
||||
|
||||
open( my $fhandle, '<', "$local_archive_dir/$exp/0.info" )
|
||||
or die "Failed to open 0.info: $!";
|
||||
my $info = <$fhandle>;
|
||||
chomp $info;
|
||||
close($fhandle);
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
sub read_marker_info {
|
||||
my ( $experiment, $benchmark, $address ) = @_;
|
||||
|
||||
return ""
|
||||
unless (
|
||||
-f "$local_archive_dir/$experiment/markers/$benchmark-$address.info" );
|
||||
|
||||
open( my $fhandle, '<',
|
||||
"$local_archive_dir/$experiment/markers/$benchmark-$address.info" )
|
||||
or die "Failed to open $benchmark-$address.info: $!";
|
||||
my $info = <$fhandle>;
|
||||
chomp $info;
|
||||
close($fhandle);
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
sub overwrite_marker_info {
|
||||
my ( $experiment, $benchmark, $address, $info ) = @_;
|
||||
|
||||
system( 'mkdir', '-p', "$local_archive_dir/$experiment/markers" );
|
||||
|
||||
open( my $fhandle, '>',
|
||||
"$local_archive_dir/$experiment/markers/$benchmark-$address.info" )
|
||||
or die "Failed to open $benchmark-$address.info: $!";
|
||||
print $fhandle $info;
|
||||
close($fhandle);
|
||||
}
|
||||
|
||||
sub delete_marker_info {
|
||||
my ( $experiment, $benchmark, $address ) = @_;
|
||||
|
||||
system( 'rm',
|
||||
"$local_archive_dir/$experiment/markers/$benchmark-$address.info" );
|
||||
}
|
||||
|
||||
sub select_experiment {
|
||||
my ($multi) = @_;
|
||||
|
||||
my @experiments = find_subdirs($local_archive_dir);
|
||||
|
||||
my @exp_with_notes;
|
||||
foreach my $exp (@experiments) {
|
||||
my $info = read_experiment_info($exp);
|
||||
|
||||
push @exp_with_notes,
|
||||
defined $info ? sprintf( "%-50s (Note: %s)", $exp, $info ) : $exp;
|
||||
}
|
||||
|
||||
my @selected_experiments =
|
||||
TUI::select_from_list( "Select Archived Experiment to Open",
|
||||
$multi, @exp_with_notes );
|
||||
die "No experiment selected" unless @selected_experiments;
|
||||
|
||||
map { s/(.*?)\s+\(Note:.+\)$/$1/ } @selected_experiments;
|
||||
|
||||
return $multi == 1 ? @selected_experiments : $selected_experiments[0];
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
Reference in New Issue
Block a user