diff options
author | Robin H. Johnson <robbat2@gentoo.org> | 2010-06-28 01:59:22 +0000 |
---|---|---|
committer | Robin H. Johnson <robbat2@gentoo.org> | 2010-06-28 01:59:22 +0000 |
commit | 66e55afcb221e3a8b5143bbe0fd58ae130f37ee5 (patch) | |
tree | 923e6d9ccc8a922f4ac9fa8794731dd9fb1078d8 /listify | |
parent | Late change of officials. (diff) | |
download | elections-66e55afcb221e3a8b5143bbe0fd58ae130f37ee5.tar.gz elections-66e55afcb221e3a8b5143bbe0fd58ae130f37ee5.tar.bz2 elections-66e55afcb221e3a8b5143bbe0fd58ae130f37ee5.zip |
New script used for producing nice motd messages.
Diffstat (limited to 'listify')
-rwxr-xr-x | listify | 65 |
1 files changed, 65 insertions, 0 deletions
@@ -0,0 +1,65 @@ +#!/usr/bin/perl -w +# $Id: votify,v 1.5 2005/05/16 04:03:46 agriffis Exp $ +# +# Copyright 2005 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# +# votify: generate, verify and submit voting ballots for trustee elections +# + +#BEGIN { push @INC, (getpwnam 'fox2mike')[7].'/elections' } +BEGIN { push @INC, '/etc/elections/current' } + +use POSIX; +use Getopt::Long; +use List::Util; +use Votify 'user'; +use strict; + +###################################################################### +# Global vars +###################################################################### + +(my $zero = $0) =~ s,.*/,,; +(my $version = '$Revision: 1.5 $') =~ s/.*?(\d.*\d).*/$zero version $1\n/; +my (%opt, %elections); + +# Collect the open elections +my (@open_elections, $usage_elections); +opendir(D, "$Votify::datadir/") or die; +@open_elections = sort grep { + s/^start-// and do { + my ($name) = $_; + my ($starttime) = (stat _)[9] if stat("$Votify::datadir/start-$_"); + my ($stoptime) = (stat _)[9] if stat("$Votify::datadir/stop-$_"); + my $valid = ((not defined $starttime or $starttime < time) and + (not defined $stoptime or $stoptime > time)); + if($valid) { + $elections{$name} = {}; + $elections{$name}{starttime} = $starttime; + $elections{$name}{stoptime} = $stoptime; + } + $valid; + } +} readdir D; +closedir D; +my $datefmt = '%Y-%m-%d %H:%M UTC'; +if (@open_elections) { + $usage_elections = "Presently available elections:\n" . join('', map { + my ($name) = $_; + my ($start) = strftime($datefmt, localtime($elections{$name}{starttime})); + my ($stop) = strftime($datefmt, localtime($elections{$name}{stoptime})); + sprintf("\t%s: %s to %s\n", $name, $start, $stop) } @open_elections); + $usage_elections .= <<EOF +\nA handy tool called "votify" can be used to vote in the election. You can use +"votify --help" to get instructions on how to vote, verify, and submit your +ballot. +EOF +} else { + #$usage_elections = "No Gentoo elections are presently open.\n"; + $usage_elections = ""; +} + +print $usage_elections; +exit; +# vim:sw=4 et |