added zip archive and in/out board assets
This commit is contained in:
parent
57eaa1f73f
commit
cb4729f7e7
15 changed files with 1674 additions and 34 deletions
136
sbin/changeIobStatus.pl
Normal file
136
sbin/changeIobStatus.pl
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
our ($webguiRoot);
|
||||
|
||||
BEGIN {
|
||||
$webguiRoot = "..";
|
||||
unshift (@INC, $webguiRoot."/lib");
|
||||
}
|
||||
|
||||
use Getopt::Long;
|
||||
use strict;
|
||||
use WebGUI::DateTime;
|
||||
use WebGUI::MessageLog;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
use WebGUI::User;
|
||||
|
||||
$|=1;
|
||||
|
||||
my $configFile;
|
||||
my $help;
|
||||
my $quiet;
|
||||
my $whatsHappening = "Automatically signed out.";
|
||||
my $newStatus = "Out";
|
||||
my $currentStatus = "In";
|
||||
my $userMessage = "You were logged out of the In/Out Board automatically.";
|
||||
my $userMessageFile;
|
||||
|
||||
|
||||
GetOptions(
|
||||
'configfile=s'=>\$configFile,
|
||||
'help'=>\$help,
|
||||
'quiet'=>\$quiet,
|
||||
'whatsHappening:s'=>\$whatsHappening,
|
||||
'userMessage:s'=>\$userMessage,
|
||||
'userMessageFile:s'=>\$userMessageFile,
|
||||
'currentStatus:s'=>\$currentStatus,
|
||||
'newStatus:s'=>\$newStatus
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
unless ($configFile && !$help) {
|
||||
print <<STOP;
|
||||
|
||||
|
||||
Usage: perl $0 --configfile=<webguiConfig>
|
||||
|
||||
--configFile WebGUI config file (with no path info).
|
||||
|
||||
Description: This utility allows you to automate the switching of status
|
||||
for users in the IOB. For instance, you may wish to
|
||||
automatically mark out all users each night that haven't
|
||||
already marked out.
|
||||
|
||||
Options:
|
||||
|
||||
--currentStatus The status to check for. Defaults to "$currentStatus".
|
||||
|
||||
--help Display this help message.
|
||||
|
||||
--newStatus The status to set the user to. Defaults to
|
||||
"$newStatus".
|
||||
|
||||
--quiet Disable output unless there's an error.
|
||||
|
||||
--userMessage A message to be sent to the user upon getting their
|
||||
status changed. Defaults to "$userMessage".
|
||||
|
||||
--userMessageFile A path to a filename to override the
|
||||
--userMessage with. This option will read the
|
||||
contents of the file and send that as the
|
||||
message.
|
||||
|
||||
--whatsHappening The message attached to the IOB when
|
||||
changing status. Defaults to
|
||||
"$whatsHappening".
|
||||
|
||||
STOP
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
print "Starting up...\n" unless ($quiet);
|
||||
WebGUI::Session::open($webguiRoot,$configFile);
|
||||
|
||||
if ($userMessageFile) {
|
||||
print "Opening message file.." unless ($quiet);
|
||||
if (open(FILE,"<".$userMessageFile)) {
|
||||
print "OK\n" unless ($quiet);
|
||||
my $contents;
|
||||
while (<FILE>) {
|
||||
$contents .= $_;
|
||||
}
|
||||
close(FILE);
|
||||
if (length($contents) == 0) {
|
||||
print "Message file empty, reverting to original message.\n";
|
||||
} else {
|
||||
$userMessage = $contents;
|
||||
}
|
||||
} else {
|
||||
print "Failed to open message file.\n";
|
||||
}
|
||||
}
|
||||
|
||||
print "Searching for users with a status of $currentStatus ...\n" unless ($quiet);
|
||||
my $userList;
|
||||
my $now = WebGUI::DateTime::time();
|
||||
my $sth = WebGUI::SQL->read("select userId,assetId from InOutBoard_status where status=".quote($currentStatus));
|
||||
while (my ($userId,$assetId) = $sth->array) {
|
||||
my $user = WebGUI::User->new($userId);
|
||||
print "\tFound user ".$user->username."\n" unless ($quiet);
|
||||
$userList .= $user->username." (".$userId.")\n";
|
||||
WebGUI::SQL->write("update InOutBoard_status set dateStamp=".$now.", message=".quote($whatsHappening).",
|
||||
status=".quote($newStatus)." where userId=".quote($userId)." and assetId=".quote($assetId));
|
||||
WebGUI::SQL->write("insert into InOutBoard_statusLog (userId, createdBy, dateStamp, message, status, assetId) values (
|
||||
".quote($userId).", ".quote(3).", ".$now.", ".quote($whatsHappening).", ".quote($newStatus).", ".quote($assetId).")");
|
||||
WebGUI::MessageLog::addEntry($userId,undef,"IOB Update",$userMessage);
|
||||
}
|
||||
$sth->finish;
|
||||
|
||||
if (length($userList) > 0) {
|
||||
print "Alerting admins of changes\n" unless ($quiet);
|
||||
my $message = "The following users had their status changed:\n\n".$userList;
|
||||
WebGUI::MessageLog::addEntry(undef,"3","IOB Update",$message);
|
||||
}
|
||||
|
||||
print "Cleaning up..." unless ($quiet);
|
||||
WebGUI::Session::end($session{var}{sessionId});
|
||||
WebGUI::Session::close();
|
||||
print "OK\n" unless ($quiet);
|
||||
|
||||
|
|
@ -53,6 +53,7 @@ use Storable;
|
|||
use XML::Simple ();
|
||||
use Compress::Zlib ();
|
||||
use Archive::Tar ();
|
||||
use Archive::Zip ();
|
||||
use IO::Zlib ();
|
||||
|
||||
####
|
||||
|
|
|
|||
108
sbin/spectre.pl
108
sbin/spectre.pl
|
|
@ -18,6 +18,7 @@ use POE qw(Session);
|
|||
use POE::Component::IKC::ClientLite;
|
||||
use POE::Component::IKC::Server;
|
||||
use POE::Component::IKC::Specifier;
|
||||
use POE::Component::JobQueue;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Workflow;
|
||||
|
||||
|
|
@ -67,27 +68,36 @@ fork and exit;
|
|||
|
||||
|
||||
create_ikc_server(
|
||||
port => 32133,
|
||||
name => 'Spectre',
|
||||
);
|
||||
port => 32133,
|
||||
name => 'Spectre',
|
||||
);
|
||||
|
||||
POE::Session->create(
|
||||
inline_states => {
|
||||
_start => \&initializeScheduler,
|
||||
_stop => \&shutdown,
|
||||
"shutdown" => \&shutdown,
|
||||
loadSchedule => \&loadSchedule,
|
||||
checkSchedule => \&checkSchedule,
|
||||
checkEvent => \&checkEvent,
|
||||
}
|
||||
);
|
||||
inline_states => {
|
||||
_start => \&initializeScheduler,
|
||||
_stop => \&shutdown,
|
||||
"shutdown" => \&shutdown,
|
||||
loadSchedule => \&loadSchedule,
|
||||
checkSchedule => \&checkSchedule,
|
||||
checkEvent => \&checkEvent,
|
||||
}
|
||||
);
|
||||
|
||||
POE::Session->create(
|
||||
inline_states => {
|
||||
_start => \&initializeJobQueue,
|
||||
_stop => \&shutdown,
|
||||
}
|
||||
);
|
||||
inline_states => {
|
||||
_start => \&initializeJobQueue,
|
||||
_stop => \&shutdown,
|
||||
}
|
||||
);
|
||||
|
||||
POE::Component::JobQueue->spawn (
|
||||
Alias => 'queuer',
|
||||
WorkerLimit => 10,
|
||||
Worker => \&spawnWorker,
|
||||
Passive => {
|
||||
Prioritizer => \&prioritizeJobs,
|
||||
},
|
||||
);
|
||||
|
||||
POE::Kernel->run();
|
||||
exit 0;
|
||||
|
|
@ -122,6 +132,9 @@ sub initializeJobQueue {
|
|||
$kernel->alias_set($serviceName);
|
||||
$kernel->call( IKC => publish => $serviceName, ["shutdown"] );
|
||||
print "OK\n";
|
||||
foreach my $config (keys %{WebGUI::Config::readAllConfigs("..")}) {
|
||||
$kernel->yield("loadJobs", $config);
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -138,6 +151,12 @@ sub initializeScheduler {
|
|||
$kernel->yield("checkSchedule");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub loadJobs {
|
||||
my ($heap, $config) = @_[HEAP, ARG0];
|
||||
sessionOpen($config);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub loadSchedule {
|
||||
my ($heap, $config) = @_[HEAP, ARG0];
|
||||
|
|
@ -147,14 +166,13 @@ sub loadSchedule {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub shutdown {
|
||||
my $kernel = $_[KERNEL];
|
||||
print "Stopping WebGUI Spectre...";
|
||||
if ($session{var}{userId}) {
|
||||
sessionClose();
|
||||
}
|
||||
print "OK\n";
|
||||
$kernel->stop;
|
||||
sub performJob {
|
||||
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub prioritizeJobs {
|
||||
return 1; # FIFO queue, but let's add priorities at some point
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -169,4 +187,44 @@ sub sessionClose {
|
|||
WebGUI::Session::close();
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub shutdown {
|
||||
my $kernel = $_[KERNEL];
|
||||
print "Stopping WebGUI Spectre...";
|
||||
if ($session{var}{userId}) {
|
||||
sessionClose();
|
||||
}
|
||||
print "OK\n";
|
||||
$kernel->stop;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub spawnWorker {
|
||||
my ($postback, @jobParams) = @_;
|
||||
POE::Session->create (
|
||||
inline_states => {
|
||||
_start => \&startWorker,
|
||||
_stop => \&stopWorker,
|
||||
performJob => \&performJob
|
||||
},
|
||||
args => [
|
||||
$postback,
|
||||
@jobParams,
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub startWorker {
|
||||
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub stopWorker {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ checkModule("DBI",1.40);
|
|||
checkModule("DBD::mysql",2.1021);
|
||||
checkModule("HTML::Parser",3.36);
|
||||
checkModule("Archive::Tar",1.05);
|
||||
checkModule("Archive::Zip",1.16);
|
||||
checkModule("IO::Zlib",1.01);
|
||||
checkModule("Compress::Zlib",1.34);
|
||||
checkModule("Net::SMTP",2.24);
|
||||
|
|
@ -61,7 +62,7 @@ checkModule("XML::Simple",2.09);
|
|||
checkModule("SOAP::Lite",0.60);
|
||||
checkModule("DateTime",0.2901);
|
||||
checkModule("Time::HiRes",1.38);
|
||||
checkModule("DateTime::Format::Strptime");
|
||||
checkModule("DateTime::Format::Strptime",1.0601);
|
||||
checkModule("DateTime::Cron::Simple",0.2);
|
||||
checkModule("Image::Magick",5.47,1);
|
||||
checkModule("Log::Log4perl",0.51);
|
||||
|
|
@ -71,8 +72,9 @@ checkModule("HTML::TagFilter",0.07);
|
|||
checkModule("HTML::Template",2.7);
|
||||
checkModule("Parse::PlainConfig",1.1);
|
||||
checkModule("XML::RSSLite",0.11);
|
||||
checkModule("POE",0.3202);
|
||||
checkModule("POE::Component::IKC::Server",0.18);
|
||||
#checkModule("POE",0.3202);
|
||||
#checkModule("POE::Component::IKC::Server",0.18);
|
||||
#checkModule("POE::Component::JobQueue",0.5402);
|
||||
checkModule("Apache2::Request",2.06);
|
||||
|
||||
###################################
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue