-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathneedsUpdateDatasetPresentersTT
More file actions
executable file
·74 lines (57 loc) · 1.88 KB
/
needsUpdateDatasetPresentersTT
File metadata and controls
executable file
·74 lines (57 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/perl
use strict;
use lib "$ENV{GUS_HOME}/lib/perl";
use Getopt::Long qw(GetOptions);
use Time::Local;
use EbrcModelCommon::Model::tmUtils;
use EbrcModelCommon::Model::DatasetPresenterTTUtils qw(getProjectListFromDb getPresenterFilePaths);
use DBI;
my ($propfile, $instance, $schema, $debug, $timestamp, $unixTimestamp);
Getopt::Long::Configure("pass_through");
GetOptions("propfile=s" => \$propfile,
"instance=s" => \$instance,
"schema=s" => \$schema,
"debug!" => \$debug,
"timestamp=s" => \$timestamp,
"unixtimestamp=s" => \$unixTimestamp,
);
die "required parameter missing" unless ($propfile && $instance && $timestamp && $unixTimestamp);
my $PROJECT_HOME = $ENV{PROJECT_HOME};
my $dbh = EbrcModelCommon::Model::tmUtils::getDbHandle($instance, $schema, $propfile);
$|=1;
# Get list of projects from database
my @projects = getProjectListFromDb($dbh, $instance, $PROJECT_HOME);
$dbh->disconnect();
# Get all resource file paths that would be read
my @filePaths = getPresenterFilePaths($PROJECT_HOME, \@projects);
# Check each file's modification time
my @newerFiles;
my @missingFiles;
foreach my $filePath (@filePaths) {
unless (-e $filePath) {
push @missingFiles, $filePath;
next;
}
my $gitTimestamp = EbrcModelCommon::Model::tmUtils::getGitTimestamp($filePath, $PROJECT_HOME);
if ($gitTimestamp > $unixTimestamp) {
push @newerFiles, $filePath;
if ($debug) {
my $mtime_str = localtime($gitTimestamp)->strftime('%Y-%m-%d %H:%M:%S');
print "Newer: $filePath (git commit: $mtime_str)\n";
}
}
}
# Warn about missing files
if (@missingFiles) {
print STDERR "Warning: The following files are missing:\n";
foreach my $missing (@missingFiles) {
print STDERR " $missing\n";
}
}
# Final output
if (@newerFiles || @missingFiles) {
print "out of date\n";
} else {
print "up to date\n";
}
exit 0;