Skip to content

Commit

Permalink
Merge pull request #557 from hollie/perltidy_run
Browse files Browse the repository at this point in the history
Perltidy run: cleanup of the codebase before releasing new stable.
  • Loading branch information
hollie committed Dec 5, 2015
2 parents e972923 + 7aef093 commit 8941197
Show file tree
Hide file tree
Showing 1,024 changed files with 162,466 additions and 131,433 deletions.
82 changes: 82 additions & 0 deletions bin/.perltidyrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Final parameter set for this run.
# See utility 'perltidyrc_dump.pl' for nicer formatting.
--add-newlines
--add-semicolons
--add-whitespace
--backup-file-extension="bak"
--backup-and-modify-in-place
--blank-lines-before-packages=1
--blank-lines-before-subs=1
--blanks-before-blocks
--blanks-before-comments
--block-brace-tightness=0
--block-brace-vertical-tightness=0
--nobrace-left-and-indent
--brace-tightness=1
--brace-vertical-tightness=0
--brace-vertical-tightness-closing=0
--break-at-old-attribute-breakpoints
--break-at-old-keyword-breakpoints
--break-at-old-logical-breakpoints
--break-at-old-ternary-breakpoints
--nocheck-syntax
--closing-brace-indentation=0
--closing-paren-indentation=0
--closing-side-comment-else-flag=0
--closing-side-comment-interval=6
--closing-side-comment-maximum-text=20
--closing-side-comments-balanced
--closing-square-bracket-indentation=0
--comma-arrow-breakpoints=1
--continuation-indentation=2
--nocuddled-else
--delete-old-newlines
--delete-old-whitespace
--delete-semicolons
--fixed-position-side-comment=0
--format="tidy"
--format-skipping
--fuzzy-line-length
--hanging-side-comments
--nohtml
--html-entities
--html-table-of-contents
--indent-block-comments
--indent-columns=4
--iterations=1
--keep-old-blank-lines=1
--nologfile
--long-block-line-count=8
--look-for-autoloader
--look-for-selfloader
--maximum-consecutive-blank-lines=1
--maximum-fields-per-table=0
--maximum-line-length=80
--minimum-space-to-comment=4
--noopening-anonymous-sub-brace-on-new-line
--noopening-brace-on-new-line
--noopening-sub-brace-on-new-line
--nooutdent-labels
--nooutdent-long-comments
--nooutdent-long-quotes
--paren-tightness=1
--paren-vertical-tightness=0
--paren-vertical-tightness-closing=0
--pass-version-line
--perl-syntax-check-flags="-c -T"
--pod2html
--preserve-line-endings
--noquiet
--recombine
--short-concatenation-item-length=8
--noshow-options
--nospace-for-semicolon
--nospace-terminal-semicolon
--square-bracket-tightness=1
--square-bracket-vertical-tightness=0
--square-bracket-vertical-tightness-closing=0
--static-block-comments
--nostatic-side-comments
--notabs
--trim-qw
--valign
213 changes: 116 additions & 97 deletions bin/alpha_page
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,32 @@

use strict;

my ($Pgm_Path, $Pgm_Name, $Version);
use vars '$Pgm_Root'; # So we can see it in eval var subs in read_parms
my ( $Pgm_Path, $Pgm_Name, $Version );
use vars '$Pgm_Root'; # So we can see it in eval var subs in read_parms

BEGIN {
($Version) = q$Revision$ =~ /: (\S+)/; # Note: revision number is auto-updated by cvs
($Pgm_Path, $Pgm_Name) = $0 =~ /(.*)[\\\/](.+)\.?/;
($Pgm_Name) = $0 =~ /([^.]+)/, $Pgm_Path = '.' unless $Pgm_Name;
$Pgm_Root = "$Pgm_Path/..";
eval "use lib '$Pgm_Path/../lib', '$Pgm_Path/../lib/site'"; # Use BEGIN eval to keep perl2exe happy
($Version) =
q$Revision$ =~ /: (\S+)/; # Note: revision number is auto-updated by cvs
( $Pgm_Path, $Pgm_Name ) = $0 =~ /(.*)[\\\/](.+)\.?/;
($Pgm_Name) = $0 =~ /([^.]+)/, $Pgm_Path = '.' unless $Pgm_Name;
$Pgm_Root = "$Pgm_Path/..";
eval "use lib '$Pgm_Path/../lib', '$Pgm_Path/../lib/site'"
; # Use BEGIN eval to keep perl2exe happy
}


use Getopt::Long;
my %parms;
if (!&GetOptions(\%parms, "h", "help", "message=s", "name:s", "pin:i", "service:s") or
@ARGV or $parms{h} or $parms{help} or !$parms{message} or !$parms{service}) {
print<<eof;
if (
!&GetOptions( \%parms, "h", "help", "message=s", "name:s", "pin:i",
"service:s" )
or @ARGV
or $parms{h}
or $parms{help}
or !$parms{message}
or !$parms{service}
)
{
print <<eof;
$Pgm_Name (version $Version) sends alphanumeric page.
Expand All @@ -61,112 +70,122 @@ $Pgm_Name (version $Version) sends alphanumeric page.
eof

exit;
exit;
}

my (%pin_numbers);

&setup;

$parms{service} = "PageMart" unless $parms{service};
unless ( ($parms{service} eq "PageMart") | ($parms{service} eq "Arch1way") | ($parms{service} eq "Arch2way") ) {
print "\nParameter error: $parms{service}\n";
print "The only accepted values for -service are:\n";
print " PageMart\n";
print " Arch1way\n";
print " Arch2way\n";
print "(Note: not specifying -service will default to PageMart for backward compatibility.)\n";
exit;
unless ( ( $parms{service} eq "PageMart" ) | ( $parms{service} eq "Arch1way" ) |
( $parms{service} eq "Arch2way" ) )
{
print "\nParameter error: $parms{service}\n";
print "The only accepted values for -service are:\n";
print " PageMart\n";
print " Arch1way\n";
print " Arch2way\n";
print
"(Note: not specifying -service will default to PageMart for backward compatibility.)\n";
exit;
}

$parms{pin} = $pin_numbers{$parms{name}} unless $parms{pin};
unless ($parms{pin}) {
print "\nYou must specifies mh.ini parm alpha_page_NAME_pin and -name option\n";
print "or specify -pin option.\n";
exit;
$parms{pin} = $pin_numbers{ $parms{name} } unless $parms{pin};
unless ( $parms{pin} ) {
print
"\nYou must specifies mh.ini parm alpha_page_NAME_pin and -name option\n";
print "or specify -pin option.\n";
exit;
}
&send_page ($parms{service}, $parms{pin}, "$parms{message}");
&send_page( $parms{service}, $parms{pin}, "$parms{message}" );

use vars "%config_parms";

sub setup {

require 'handy_utilities.pl';
require 'handy_utilities.pl';

my $private_parms = $Pgm_Path . "/mh.private.ini";
&main::read_opts(\%config_parms, $Pgm_Path . "/mh.ini");
&main::read_opts(\%config_parms, $private_parms) if -e $private_parms;
my $private_parms = $Pgm_Path . "/mh.private.ini";
&main::read_opts( \%config_parms, $Pgm_Path . "/mh.ini" );
&main::read_opts( \%config_parms, $private_parms ) if -e $private_parms;

# Get pager parms
for my $parm (keys %config_parms) {
next unless $config_parms{$parm}; # Ingore blank parms
$pin_numbers{$1} = $config_parms{$parm} if $parm =~ /alpha_page_(\S+)_pin/;
}
# Get pager parms
for my $parm ( keys %config_parms ) {
next unless $config_parms{$parm}; # Ingore blank parms
$pin_numbers{$1} = $config_parms{$parm}
if $parm =~ /alpha_page_(\S+)_pin/;
}

for my $name (keys %pin_numbers) {
print "$name=$pin_numbers{$name}\n" if $config_parms{debug} eq 'page';
}
for my $name ( keys %pin_numbers ) {
print "$name=$pin_numbers{$name}\n" if $config_parms{debug} eq 'page';
}
}

sub send_page {
use LWP::UserAgent;
use HTTP::Request::Common;
my ($srv, $pin, $msg) = @_;

print "send page: ($srv) pin=$pin, $msg\n" if $config_parms{debug} eq 'page';

my $ua = new LWP::UserAgent;
$ua->timeout([60]); # Time out after 60 seconds
$ua->env_proxy(); # use proxy if defined

my $request;

if ( $srv eq "Arch2way" ) {
$request = POST 'http://www.Arch.com/cgi-bin/wwwtwoway.exe',
[ gw_pin => $pin,
MSSG => $msg,
Q1 => '0', # (No echo) or '1' (echo)
# The remaining fields have been tested and do work, but I am leaving commented out for now until I decide whether or not
# it is worth the effort to make them all config_parms and/or ARGS...
# ATM I am envisioning something like MH seeing a sensor above limit, sends page to 2way and then acts based on response.
# e.g. -message 'No motion detected in house for 2 hours - should all lights be set OFF?'
# -resp_a_string 'Yes'
# -resp_b_string 'No'
# -resp_c_string 'Just Inside Lights'
#resp_route => 'Email', # or 'Pager', (type of response)
#resp_addr => 'account@server.TLD', # address for response
# Note: All below fields require resp_route and resp_addr to be set
# confirm_receipt_str can only be 'confirm_page_delivery', so if confirmation not desired, leave it commented out
#confirm_receipt_str => 'confirm_page_delivery', # optional, (only option)
#resp_a_string => 'A', # Custom response option A
#resp_b_string => 'B', # Custom response option B
#resp_c_string => 'C', # Custom response option C
#resp_d_string => 'D', # Custom response option D
#resp_e_string => 'E', # Custom response option E
#resp_f_string => 'F', # Custom response option F
];
}
elsif ( $srv eq "Arch1way" ) {
$request = POST 'http://www.Arch.com/cgi-bin/wwwpage.exe',
[ PIN => $pin,
MSSG => $msg,
];
}
elsif ( $srv eq "PageMart" ) {
$request = POST 'http://www2.pagemart.com/cgi-bin/rbox/pglpage-cgi',
[ pin2 => $pin,
PAGELAUNCHERID => '2',
message1 => $msg,
];
}

my $response = $ua->request($request);

if ( $response ->is_success ) {
print "page sent\n" if $config_parms{debug} eq 'page';
}
else {
printf "page failed, %s\n", $response->status_line;
}
use LWP::UserAgent;
use HTTP::Request::Common;
my ( $srv, $pin, $msg ) = @_;

print "send page: ($srv) pin=$pin, $msg\n"
if $config_parms{debug} eq 'page';

my $ua = new LWP::UserAgent;
$ua->timeout( [60] ); # Time out after 60 seconds
$ua->env_proxy(); # use proxy if defined

my $request;

if ( $srv eq "Arch2way" ) {
$request = POST 'http://www.Arch.com/cgi-bin/wwwtwoway.exe', [
gw_pin => $pin,
MSSG => $msg,
Q1 => '0', # (No echo) or '1' (echo)

# The remaining fields have been tested and do work, but I am leaving commented out for now until I decide whether or not
# it is worth the effort to make them all config_parms and/or ARGS...
# ATM I am envisioning something like MH seeing a sensor above limit, sends page to 2way and then acts based on response.
# e.g. -message 'No motion detected in house for 2 hours - should all lights be set OFF?'
# -resp_a_string 'Yes'
# -resp_b_string 'No'
# -resp_c_string 'Just Inside Lights'
#resp_route => 'Email', # or 'Pager', (type of response)
#resp_addr => 'account@server.TLD', # address for response
# Note: All below fields require resp_route and resp_addr to be set
# confirm_receipt_str can only be 'confirm_page_delivery', so if confirmation not desired, leave it commented out
#confirm_receipt_str => 'confirm_page_delivery', # optional, (only option)
#resp_a_string => 'A', # Custom response option A
#resp_b_string => 'B', # Custom response option B
#resp_c_string => 'C', # Custom response option C
#resp_d_string => 'D', # Custom response option D
#resp_e_string => 'E', # Custom response option E
#resp_f_string => 'F', # Custom response option F
];
}
elsif ( $srv eq "Arch1way" ) {
$request = POST 'http://www.Arch.com/cgi-bin/wwwpage.exe',
[
PIN => $pin,
MSSG => $msg,
];
}
elsif ( $srv eq "PageMart" ) {
$request = POST 'http://www2.pagemart.com/cgi-bin/rbox/pglpage-cgi',
[
pin2 => $pin,
PAGELAUNCHERID => '2',
message1 => $msg,
];
}

my $response = $ua->request($request);

if ( $response->is_success ) {
print "page sent\n" if $config_parms{debug} eq 'page';
}
else {
printf "page failed, %s\n", $response->status_line;
}
}

#
Expand Down
Loading

0 comments on commit 8941197

Please sign in to comment.