code stringlengths 2 1.05M | repo_name stringlengths 5 101 | path stringlengths 4 991 | language stringclasses 3 values | license stringclasses 5 values | size int64 2 1.05M |
|---|---|---|---|---|---|
package #
Date::Manip::Offset::off211;
# Copyright (c) 2008-2014 Sullivan Beck. All rights reserved.
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
# This file was automatically generated. Any changes to this file will
# be lost the next time 'tzdata' is run.
# Generated on: Fri Nov 21 11:03:45 EST 2014
# Data version: tzdata2014j
# Code version: tzcode2014j
# This module contains data from the zoneinfo time zone database. The original
# data was obtained from the URL:
# ftp://ftp.iana.orgtz
use strict;
use warnings;
require 5.010000;
our ($VERSION);
$VERSION='6.48';
END { undef $VERSION; }
our ($Offset,%Offset);
END {
undef $Offset;
undef %Offset;
}
$Offset = '+11:55:44';
%Offset = (
0 => [
'pacific/fiji',
],
);
1;
| nriley/Pester | Source/Manip/Offset/off211.pm | Perl | bsd-2-clause | 850 |
package #
Date::Manip::TZ::amindi00;
# Copyright (c) 2008-2014 Sullivan Beck. All rights reserved.
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
# This file was automatically generated. Any changes to this file will
# be lost the next time 'tzdata' is run.
# Generated on: Fri Nov 21 10:41:39 EST 2014
# Data version: tzdata2014j
# Code version: tzcode2014j
# This module contains data from the zoneinfo time zone database. The original
# data was obtained from the URL:
# ftp://ftp.iana.org/tz
use strict;
use warnings;
require 5.010000;
our (%Dates,%LastRule);
END {
undef %Dates;
undef %LastRule;
}
our ($VERSION);
$VERSION='6.48';
END { undef $VERSION; }
%Dates = (
1 =>
[
[ [1,1,2,0,0,0],[1,1,1,18,15,22],'-05:44:38',[-5,-44,-38],
'LMT',0,[1883,11,18,17,59,59],[1883,11,18,12,15,21],
'0001010200:00:00','0001010118:15:22','1883111817:59:59','1883111812:15:21' ],
],
1883 =>
[
[ [1883,11,18,18,0,0],[1883,11,18,12,0,0],'-06:00:00',[-6,0,0],
'CST',0,[1918,3,31,7,59,59],[1918,3,31,1,59,59],
'1883111818:00:00','1883111812:00:00','1918033107:59:59','1918033101:59:59' ],
],
1918 =>
[
[ [1918,3,31,8,0,0],[1918,3,31,3,0,0],'-05:00:00',[-5,0,0],
'CDT',1,[1918,10,27,6,59,59],[1918,10,27,1,59,59],
'1918033108:00:00','1918033103:00:00','1918102706:59:59','1918102701:59:59' ],
[ [1918,10,27,7,0,0],[1918,10,27,1,0,0],'-06:00:00',[-6,0,0],
'CST',0,[1919,3,30,7,59,59],[1919,3,30,1,59,59],
'1918102707:00:00','1918102701:00:00','1919033007:59:59','1919033001:59:59' ],
],
1919 =>
[
[ [1919,3,30,8,0,0],[1919,3,30,3,0,0],'-05:00:00',[-5,0,0],
'CDT',1,[1919,10,26,6,59,59],[1919,10,26,1,59,59],
'1919033008:00:00','1919033003:00:00','1919102606:59:59','1919102601:59:59' ],
[ [1919,10,26,7,0,0],[1919,10,26,1,0,0],'-06:00:00',[-6,0,0],
'CST',0,[1941,6,22,7,59,59],[1941,6,22,1,59,59],
'1919102607:00:00','1919102601:00:00','1941062207:59:59','1941062201:59:59' ],
],
1941 =>
[
[ [1941,6,22,8,0,0],[1941,6,22,3,0,0],'-05:00:00',[-5,0,0],
'CDT',1,[1941,9,28,6,59,59],[1941,9,28,1,59,59],
'1941062208:00:00','1941062203:00:00','1941092806:59:59','1941092801:59:59' ],
[ [1941,9,28,7,0,0],[1941,9,28,1,0,0],'-06:00:00',[-6,0,0],
'CST',0,[1942,2,9,7,59,59],[1942,2,9,1,59,59],
'1941092807:00:00','1941092801:00:00','1942020907:59:59','1942020901:59:59' ],
],
1942 =>
[
[ [1942,2,9,8,0,0],[1942,2,9,3,0,0],'-05:00:00',[-5,0,0],
'CWT',1,[1945,8,14,22,59,59],[1945,8,14,17,59,59],
'1942020908:00:00','1942020903:00:00','1945081422:59:59','1945081417:59:59' ],
],
1945 =>
[
[ [1945,8,14,23,0,0],[1945,8,14,18,0,0],'-05:00:00',[-5,0,0],
'CPT',1,[1945,9,30,6,59,59],[1945,9,30,1,59,59],
'1945081423:00:00','1945081418:00:00','1945093006:59:59','1945093001:59:59' ],
[ [1945,9,30,7,0,0],[1945,9,30,1,0,0],'-06:00:00',[-6,0,0],
'CST',0,[1946,4,28,7,59,59],[1946,4,28,1,59,59],
'1945093007:00:00','1945093001:00:00','1946042807:59:59','1946042801:59:59' ],
],
1946 =>
[
[ [1946,4,28,8,0,0],[1946,4,28,3,0,0],'-05:00:00',[-5,0,0],
'CDT',1,[1946,9,29,6,59,59],[1946,9,29,1,59,59],
'1946042808:00:00','1946042803:00:00','1946092906:59:59','1946092901:59:59' ],
[ [1946,9,29,7,0,0],[1946,9,29,1,0,0],'-06:00:00',[-6,0,0],
'CST',0,[1947,4,27,7,59,59],[1947,4,27,1,59,59],
'1946092907:00:00','1946092901:00:00','1947042707:59:59','1947042701:59:59' ],
],
1947 =>
[
[ [1947,4,27,8,0,0],[1947,4,27,3,0,0],'-05:00:00',[-5,0,0],
'CDT',1,[1947,9,28,6,59,59],[1947,9,28,1,59,59],
'1947042708:00:00','1947042703:00:00','1947092806:59:59','1947092801:59:59' ],
[ [1947,9,28,7,0,0],[1947,9,28,1,0,0],'-06:00:00',[-6,0,0],
'CST',0,[1948,4,25,7,59,59],[1948,4,25,1,59,59],
'1947092807:00:00','1947092801:00:00','1948042507:59:59','1948042501:59:59' ],
],
1948 =>
[
[ [1948,4,25,8,0,0],[1948,4,25,3,0,0],'-05:00:00',[-5,0,0],
'CDT',1,[1948,9,26,6,59,59],[1948,9,26,1,59,59],
'1948042508:00:00','1948042503:00:00','1948092606:59:59','1948092601:59:59' ],
[ [1948,9,26,7,0,0],[1948,9,26,1,0,0],'-06:00:00',[-6,0,0],
'CST',0,[1949,4,24,7,59,59],[1949,4,24,1,59,59],
'1948092607:00:00','1948092601:00:00','1949042407:59:59','1949042401:59:59' ],
],
1949 =>
[
[ [1949,4,24,8,0,0],[1949,4,24,3,0,0],'-05:00:00',[-5,0,0],
'CDT',1,[1949,9,25,6,59,59],[1949,9,25,1,59,59],
'1949042408:00:00','1949042403:00:00','1949092506:59:59','1949092501:59:59' ],
[ [1949,9,25,7,0,0],[1949,9,25,1,0,0],'-06:00:00',[-6,0,0],
'CST',0,[1950,4,30,7,59,59],[1950,4,30,1,59,59],
'1949092507:00:00','1949092501:00:00','1950043007:59:59','1950043001:59:59' ],
],
1950 =>
[
[ [1950,4,30,8,0,0],[1950,4,30,3,0,0],'-05:00:00',[-5,0,0],
'CDT',1,[1950,9,24,6,59,59],[1950,9,24,1,59,59],
'1950043008:00:00','1950043003:00:00','1950092406:59:59','1950092401:59:59' ],
[ [1950,9,24,7,0,0],[1950,9,24,1,0,0],'-06:00:00',[-6,0,0],
'CST',0,[1951,4,29,7,59,59],[1951,4,29,1,59,59],
'1950092407:00:00','1950092401:00:00','1951042907:59:59','1951042901:59:59' ],
],
1951 =>
[
[ [1951,4,29,8,0,0],[1951,4,29,3,0,0],'-05:00:00',[-5,0,0],
'CDT',1,[1951,9,30,6,59,59],[1951,9,30,1,59,59],
'1951042908:00:00','1951042903:00:00','1951093006:59:59','1951093001:59:59' ],
[ [1951,9,30,7,0,0],[1951,9,30,1,0,0],'-06:00:00',[-6,0,0],
'CST',0,[1952,4,27,7,59,59],[1952,4,27,1,59,59],
'1951093007:00:00','1951093001:00:00','1952042707:59:59','1952042701:59:59' ],
],
1952 =>
[
[ [1952,4,27,8,0,0],[1952,4,27,3,0,0],'-05:00:00',[-5,0,0],
'CDT',1,[1952,9,28,6,59,59],[1952,9,28,1,59,59],
'1952042708:00:00','1952042703:00:00','1952092806:59:59','1952092801:59:59' ],
[ [1952,9,28,7,0,0],[1952,9,28,1,0,0],'-06:00:00',[-6,0,0],
'CST',0,[1953,4,26,7,59,59],[1953,4,26,1,59,59],
'1952092807:00:00','1952092801:00:00','1953042607:59:59','1953042601:59:59' ],
],
1953 =>
[
[ [1953,4,26,8,0,0],[1953,4,26,3,0,0],'-05:00:00',[-5,0,0],
'CDT',1,[1953,9,27,6,59,59],[1953,9,27,1,59,59],
'1953042608:00:00','1953042603:00:00','1953092706:59:59','1953092701:59:59' ],
[ [1953,9,27,7,0,0],[1953,9,27,1,0,0],'-06:00:00',[-6,0,0],
'CST',0,[1954,4,25,7,59,59],[1954,4,25,1,59,59],
'1953092707:00:00','1953092701:00:00','1954042507:59:59','1954042501:59:59' ],
],
1954 =>
[
[ [1954,4,25,8,0,0],[1954,4,25,3,0,0],'-05:00:00',[-5,0,0],
'CDT',1,[1954,9,26,6,59,59],[1954,9,26,1,59,59],
'1954042508:00:00','1954042503:00:00','1954092606:59:59','1954092601:59:59' ],
[ [1954,9,26,7,0,0],[1954,9,26,1,0,0],'-06:00:00',[-6,0,0],
'CST',0,[1955,4,24,7,59,59],[1955,4,24,1,59,59],
'1954092607:00:00','1954092601:00:00','1955042407:59:59','1955042401:59:59' ],
],
1955 =>
[
[ [1955,4,24,8,0,0],[1955,4,24,3,0,0],'-05:00:00',[-5,0,0],
'EST',0,[1957,9,29,6,59,59],[1957,9,29,1,59,59],
'1955042408:00:00','1955042403:00:00','1957092906:59:59','1957092901:59:59' ],
],
1957 =>
[
[ [1957,9,29,7,0,0],[1957,9,29,1,0,0],'-06:00:00',[-6,0,0],
'CST',0,[1958,4,27,7,59,59],[1958,4,27,1,59,59],
'1957092907:00:00','1957092901:00:00','1958042707:59:59','1958042701:59:59' ],
],
1958 =>
[
[ [1958,4,27,8,0,0],[1958,4,27,3,0,0],'-05:00:00',[-5,0,0],
'EST',0,[1969,4,27,6,59,59],[1969,4,27,1,59,59],
'1958042708:00:00','1958042703:00:00','1969042706:59:59','1969042701:59:59' ],
],
1969 =>
[
[ [1969,4,27,7,0,0],[1969,4,27,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[1969,10,26,5,59,59],[1969,10,26,1,59,59],
'1969042707:00:00','1969042703:00:00','1969102605:59:59','1969102601:59:59' ],
[ [1969,10,26,6,0,0],[1969,10,26,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[1970,4,26,6,59,59],[1970,4,26,1,59,59],
'1969102606:00:00','1969102601:00:00','1970042606:59:59','1970042601:59:59' ],
],
1970 =>
[
[ [1970,4,26,7,0,0],[1970,4,26,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[1970,10,25,5,59,59],[1970,10,25,1,59,59],
'1970042607:00:00','1970042603:00:00','1970102505:59:59','1970102501:59:59' ],
[ [1970,10,25,6,0,0],[1970,10,25,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2006,4,2,6,59,59],[2006,4,2,1,59,59],
'1970102506:00:00','1970102501:00:00','2006040206:59:59','2006040201:59:59' ],
],
2006 =>
[
[ [2006,4,2,7,0,0],[2006,4,2,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2006,10,29,5,59,59],[2006,10,29,1,59,59],
'2006040207:00:00','2006040203:00:00','2006102905:59:59','2006102901:59:59' ],
[ [2006,10,29,6,0,0],[2006,10,29,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2007,3,11,6,59,59],[2007,3,11,1,59,59],
'2006102906:00:00','2006102901:00:00','2007031106:59:59','2007031101:59:59' ],
],
2007 =>
[
[ [2007,3,11,7,0,0],[2007,3,11,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2007,11,4,5,59,59],[2007,11,4,1,59,59],
'2007031107:00:00','2007031103:00:00','2007110405:59:59','2007110401:59:59' ],
[ [2007,11,4,6,0,0],[2007,11,4,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2008,3,9,6,59,59],[2008,3,9,1,59,59],
'2007110406:00:00','2007110401:00:00','2008030906:59:59','2008030901:59:59' ],
],
2008 =>
[
[ [2008,3,9,7,0,0],[2008,3,9,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2008,11,2,5,59,59],[2008,11,2,1,59,59],
'2008030907:00:00','2008030903:00:00','2008110205:59:59','2008110201:59:59' ],
[ [2008,11,2,6,0,0],[2008,11,2,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2009,3,8,6,59,59],[2009,3,8,1,59,59],
'2008110206:00:00','2008110201:00:00','2009030806:59:59','2009030801:59:59' ],
],
2009 =>
[
[ [2009,3,8,7,0,0],[2009,3,8,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2009,11,1,5,59,59],[2009,11,1,1,59,59],
'2009030807:00:00','2009030803:00:00','2009110105:59:59','2009110101:59:59' ],
[ [2009,11,1,6,0,0],[2009,11,1,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2010,3,14,6,59,59],[2010,3,14,1,59,59],
'2009110106:00:00','2009110101:00:00','2010031406:59:59','2010031401:59:59' ],
],
2010 =>
[
[ [2010,3,14,7,0,0],[2010,3,14,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2010,11,7,5,59,59],[2010,11,7,1,59,59],
'2010031407:00:00','2010031403:00:00','2010110705:59:59','2010110701:59:59' ],
[ [2010,11,7,6,0,0],[2010,11,7,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2011,3,13,6,59,59],[2011,3,13,1,59,59],
'2010110706:00:00','2010110701:00:00','2011031306:59:59','2011031301:59:59' ],
],
2011 =>
[
[ [2011,3,13,7,0,0],[2011,3,13,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2011,11,6,5,59,59],[2011,11,6,1,59,59],
'2011031307:00:00','2011031303:00:00','2011110605:59:59','2011110601:59:59' ],
[ [2011,11,6,6,0,0],[2011,11,6,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2012,3,11,6,59,59],[2012,3,11,1,59,59],
'2011110606:00:00','2011110601:00:00','2012031106:59:59','2012031101:59:59' ],
],
2012 =>
[
[ [2012,3,11,7,0,0],[2012,3,11,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2012,11,4,5,59,59],[2012,11,4,1,59,59],
'2012031107:00:00','2012031103:00:00','2012110405:59:59','2012110401:59:59' ],
[ [2012,11,4,6,0,0],[2012,11,4,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2013,3,10,6,59,59],[2013,3,10,1,59,59],
'2012110406:00:00','2012110401:00:00','2013031006:59:59','2013031001:59:59' ],
],
2013 =>
[
[ [2013,3,10,7,0,0],[2013,3,10,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2013,11,3,5,59,59],[2013,11,3,1,59,59],
'2013031007:00:00','2013031003:00:00','2013110305:59:59','2013110301:59:59' ],
[ [2013,11,3,6,0,0],[2013,11,3,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2014,3,9,6,59,59],[2014,3,9,1,59,59],
'2013110306:00:00','2013110301:00:00','2014030906:59:59','2014030901:59:59' ],
],
2014 =>
[
[ [2014,3,9,7,0,0],[2014,3,9,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2014,11,2,5,59,59],[2014,11,2,1,59,59],
'2014030907:00:00','2014030903:00:00','2014110205:59:59','2014110201:59:59' ],
[ [2014,11,2,6,0,0],[2014,11,2,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2015,3,8,6,59,59],[2015,3,8,1,59,59],
'2014110206:00:00','2014110201:00:00','2015030806:59:59','2015030801:59:59' ],
],
2015 =>
[
[ [2015,3,8,7,0,0],[2015,3,8,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2015,11,1,5,59,59],[2015,11,1,1,59,59],
'2015030807:00:00','2015030803:00:00','2015110105:59:59','2015110101:59:59' ],
[ [2015,11,1,6,0,0],[2015,11,1,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2016,3,13,6,59,59],[2016,3,13,1,59,59],
'2015110106:00:00','2015110101:00:00','2016031306:59:59','2016031301:59:59' ],
],
2016 =>
[
[ [2016,3,13,7,0,0],[2016,3,13,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2016,11,6,5,59,59],[2016,11,6,1,59,59],
'2016031307:00:00','2016031303:00:00','2016110605:59:59','2016110601:59:59' ],
[ [2016,11,6,6,0,0],[2016,11,6,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2017,3,12,6,59,59],[2017,3,12,1,59,59],
'2016110606:00:00','2016110601:00:00','2017031206:59:59','2017031201:59:59' ],
],
2017 =>
[
[ [2017,3,12,7,0,0],[2017,3,12,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2017,11,5,5,59,59],[2017,11,5,1,59,59],
'2017031207:00:00','2017031203:00:00','2017110505:59:59','2017110501:59:59' ],
[ [2017,11,5,6,0,0],[2017,11,5,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2018,3,11,6,59,59],[2018,3,11,1,59,59],
'2017110506:00:00','2017110501:00:00','2018031106:59:59','2018031101:59:59' ],
],
2018 =>
[
[ [2018,3,11,7,0,0],[2018,3,11,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2018,11,4,5,59,59],[2018,11,4,1,59,59],
'2018031107:00:00','2018031103:00:00','2018110405:59:59','2018110401:59:59' ],
[ [2018,11,4,6,0,0],[2018,11,4,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2019,3,10,6,59,59],[2019,3,10,1,59,59],
'2018110406:00:00','2018110401:00:00','2019031006:59:59','2019031001:59:59' ],
],
2019 =>
[
[ [2019,3,10,7,0,0],[2019,3,10,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2019,11,3,5,59,59],[2019,11,3,1,59,59],
'2019031007:00:00','2019031003:00:00','2019110305:59:59','2019110301:59:59' ],
[ [2019,11,3,6,0,0],[2019,11,3,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2020,3,8,6,59,59],[2020,3,8,1,59,59],
'2019110306:00:00','2019110301:00:00','2020030806:59:59','2020030801:59:59' ],
],
2020 =>
[
[ [2020,3,8,7,0,0],[2020,3,8,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2020,11,1,5,59,59],[2020,11,1,1,59,59],
'2020030807:00:00','2020030803:00:00','2020110105:59:59','2020110101:59:59' ],
[ [2020,11,1,6,0,0],[2020,11,1,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2021,3,14,6,59,59],[2021,3,14,1,59,59],
'2020110106:00:00','2020110101:00:00','2021031406:59:59','2021031401:59:59' ],
],
2021 =>
[
[ [2021,3,14,7,0,0],[2021,3,14,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2021,11,7,5,59,59],[2021,11,7,1,59,59],
'2021031407:00:00','2021031403:00:00','2021110705:59:59','2021110701:59:59' ],
[ [2021,11,7,6,0,0],[2021,11,7,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2022,3,13,6,59,59],[2022,3,13,1,59,59],
'2021110706:00:00','2021110701:00:00','2022031306:59:59','2022031301:59:59' ],
],
2022 =>
[
[ [2022,3,13,7,0,0],[2022,3,13,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2022,11,6,5,59,59],[2022,11,6,1,59,59],
'2022031307:00:00','2022031303:00:00','2022110605:59:59','2022110601:59:59' ],
[ [2022,11,6,6,0,0],[2022,11,6,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2023,3,12,6,59,59],[2023,3,12,1,59,59],
'2022110606:00:00','2022110601:00:00','2023031206:59:59','2023031201:59:59' ],
],
2023 =>
[
[ [2023,3,12,7,0,0],[2023,3,12,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2023,11,5,5,59,59],[2023,11,5,1,59,59],
'2023031207:00:00','2023031203:00:00','2023110505:59:59','2023110501:59:59' ],
[ [2023,11,5,6,0,0],[2023,11,5,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2024,3,10,6,59,59],[2024,3,10,1,59,59],
'2023110506:00:00','2023110501:00:00','2024031006:59:59','2024031001:59:59' ],
],
2024 =>
[
[ [2024,3,10,7,0,0],[2024,3,10,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2024,11,3,5,59,59],[2024,11,3,1,59,59],
'2024031007:00:00','2024031003:00:00','2024110305:59:59','2024110301:59:59' ],
[ [2024,11,3,6,0,0],[2024,11,3,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2025,3,9,6,59,59],[2025,3,9,1,59,59],
'2024110306:00:00','2024110301:00:00','2025030906:59:59','2025030901:59:59' ],
],
2025 =>
[
[ [2025,3,9,7,0,0],[2025,3,9,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2025,11,2,5,59,59],[2025,11,2,1,59,59],
'2025030907:00:00','2025030903:00:00','2025110205:59:59','2025110201:59:59' ],
[ [2025,11,2,6,0,0],[2025,11,2,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2026,3,8,6,59,59],[2026,3,8,1,59,59],
'2025110206:00:00','2025110201:00:00','2026030806:59:59','2026030801:59:59' ],
],
2026 =>
[
[ [2026,3,8,7,0,0],[2026,3,8,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2026,11,1,5,59,59],[2026,11,1,1,59,59],
'2026030807:00:00','2026030803:00:00','2026110105:59:59','2026110101:59:59' ],
[ [2026,11,1,6,0,0],[2026,11,1,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2027,3,14,6,59,59],[2027,3,14,1,59,59],
'2026110106:00:00','2026110101:00:00','2027031406:59:59','2027031401:59:59' ],
],
2027 =>
[
[ [2027,3,14,7,0,0],[2027,3,14,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2027,11,7,5,59,59],[2027,11,7,1,59,59],
'2027031407:00:00','2027031403:00:00','2027110705:59:59','2027110701:59:59' ],
[ [2027,11,7,6,0,0],[2027,11,7,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2028,3,12,6,59,59],[2028,3,12,1,59,59],
'2027110706:00:00','2027110701:00:00','2028031206:59:59','2028031201:59:59' ],
],
2028 =>
[
[ [2028,3,12,7,0,0],[2028,3,12,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2028,11,5,5,59,59],[2028,11,5,1,59,59],
'2028031207:00:00','2028031203:00:00','2028110505:59:59','2028110501:59:59' ],
[ [2028,11,5,6,0,0],[2028,11,5,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2029,3,11,6,59,59],[2029,3,11,1,59,59],
'2028110506:00:00','2028110501:00:00','2029031106:59:59','2029031101:59:59' ],
],
2029 =>
[
[ [2029,3,11,7,0,0],[2029,3,11,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2029,11,4,5,59,59],[2029,11,4,1,59,59],
'2029031107:00:00','2029031103:00:00','2029110405:59:59','2029110401:59:59' ],
[ [2029,11,4,6,0,0],[2029,11,4,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2030,3,10,6,59,59],[2030,3,10,1,59,59],
'2029110406:00:00','2029110401:00:00','2030031006:59:59','2030031001:59:59' ],
],
2030 =>
[
[ [2030,3,10,7,0,0],[2030,3,10,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2030,11,3,5,59,59],[2030,11,3,1,59,59],
'2030031007:00:00','2030031003:00:00','2030110305:59:59','2030110301:59:59' ],
[ [2030,11,3,6,0,0],[2030,11,3,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2031,3,9,6,59,59],[2031,3,9,1,59,59],
'2030110306:00:00','2030110301:00:00','2031030906:59:59','2031030901:59:59' ],
],
2031 =>
[
[ [2031,3,9,7,0,0],[2031,3,9,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2031,11,2,5,59,59],[2031,11,2,1,59,59],
'2031030907:00:00','2031030903:00:00','2031110205:59:59','2031110201:59:59' ],
[ [2031,11,2,6,0,0],[2031,11,2,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2032,3,14,6,59,59],[2032,3,14,1,59,59],
'2031110206:00:00','2031110201:00:00','2032031406:59:59','2032031401:59:59' ],
],
2032 =>
[
[ [2032,3,14,7,0,0],[2032,3,14,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2032,11,7,5,59,59],[2032,11,7,1,59,59],
'2032031407:00:00','2032031403:00:00','2032110705:59:59','2032110701:59:59' ],
[ [2032,11,7,6,0,0],[2032,11,7,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2033,3,13,6,59,59],[2033,3,13,1,59,59],
'2032110706:00:00','2032110701:00:00','2033031306:59:59','2033031301:59:59' ],
],
2033 =>
[
[ [2033,3,13,7,0,0],[2033,3,13,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2033,11,6,5,59,59],[2033,11,6,1,59,59],
'2033031307:00:00','2033031303:00:00','2033110605:59:59','2033110601:59:59' ],
[ [2033,11,6,6,0,0],[2033,11,6,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2034,3,12,6,59,59],[2034,3,12,1,59,59],
'2033110606:00:00','2033110601:00:00','2034031206:59:59','2034031201:59:59' ],
],
2034 =>
[
[ [2034,3,12,7,0,0],[2034,3,12,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2034,11,5,5,59,59],[2034,11,5,1,59,59],
'2034031207:00:00','2034031203:00:00','2034110505:59:59','2034110501:59:59' ],
[ [2034,11,5,6,0,0],[2034,11,5,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2035,3,11,6,59,59],[2035,3,11,1,59,59],
'2034110506:00:00','2034110501:00:00','2035031106:59:59','2035031101:59:59' ],
],
2035 =>
[
[ [2035,3,11,7,0,0],[2035,3,11,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2035,11,4,5,59,59],[2035,11,4,1,59,59],
'2035031107:00:00','2035031103:00:00','2035110405:59:59','2035110401:59:59' ],
[ [2035,11,4,6,0,0],[2035,11,4,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2036,3,9,6,59,59],[2036,3,9,1,59,59],
'2035110406:00:00','2035110401:00:00','2036030906:59:59','2036030901:59:59' ],
],
2036 =>
[
[ [2036,3,9,7,0,0],[2036,3,9,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2036,11,2,5,59,59],[2036,11,2,1,59,59],
'2036030907:00:00','2036030903:00:00','2036110205:59:59','2036110201:59:59' ],
[ [2036,11,2,6,0,0],[2036,11,2,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2037,3,8,6,59,59],[2037,3,8,1,59,59],
'2036110206:00:00','2036110201:00:00','2037030806:59:59','2037030801:59:59' ],
],
2037 =>
[
[ [2037,3,8,7,0,0],[2037,3,8,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2037,11,1,5,59,59],[2037,11,1,1,59,59],
'2037030807:00:00','2037030803:00:00','2037110105:59:59','2037110101:59:59' ],
[ [2037,11,1,6,0,0],[2037,11,1,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2038,3,14,6,59,59],[2038,3,14,1,59,59],
'2037110106:00:00','2037110101:00:00','2038031406:59:59','2038031401:59:59' ],
],
2038 =>
[
[ [2038,3,14,7,0,0],[2038,3,14,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2038,11,7,5,59,59],[2038,11,7,1,59,59],
'2038031407:00:00','2038031403:00:00','2038110705:59:59','2038110701:59:59' ],
[ [2038,11,7,6,0,0],[2038,11,7,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2039,3,13,6,59,59],[2039,3,13,1,59,59],
'2038110706:00:00','2038110701:00:00','2039031306:59:59','2039031301:59:59' ],
],
2039 =>
[
[ [2039,3,13,7,0,0],[2039,3,13,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2039,11,6,5,59,59],[2039,11,6,1,59,59],
'2039031307:00:00','2039031303:00:00','2039110605:59:59','2039110601:59:59' ],
[ [2039,11,6,6,0,0],[2039,11,6,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2040,3,11,6,59,59],[2040,3,11,1,59,59],
'2039110606:00:00','2039110601:00:00','2040031106:59:59','2040031101:59:59' ],
],
2040 =>
[
[ [2040,3,11,7,0,0],[2040,3,11,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2040,11,4,5,59,59],[2040,11,4,1,59,59],
'2040031107:00:00','2040031103:00:00','2040110405:59:59','2040110401:59:59' ],
[ [2040,11,4,6,0,0],[2040,11,4,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2041,3,10,6,59,59],[2041,3,10,1,59,59],
'2040110406:00:00','2040110401:00:00','2041031006:59:59','2041031001:59:59' ],
],
2041 =>
[
[ [2041,3,10,7,0,0],[2041,3,10,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2041,11,3,5,59,59],[2041,11,3,1,59,59],
'2041031007:00:00','2041031003:00:00','2041110305:59:59','2041110301:59:59' ],
[ [2041,11,3,6,0,0],[2041,11,3,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2042,3,9,6,59,59],[2042,3,9,1,59,59],
'2041110306:00:00','2041110301:00:00','2042030906:59:59','2042030901:59:59' ],
],
2042 =>
[
[ [2042,3,9,7,0,0],[2042,3,9,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2042,11,2,5,59,59],[2042,11,2,1,59,59],
'2042030907:00:00','2042030903:00:00','2042110205:59:59','2042110201:59:59' ],
[ [2042,11,2,6,0,0],[2042,11,2,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2043,3,8,6,59,59],[2043,3,8,1,59,59],
'2042110206:00:00','2042110201:00:00','2043030806:59:59','2043030801:59:59' ],
],
2043 =>
[
[ [2043,3,8,7,0,0],[2043,3,8,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2043,11,1,5,59,59],[2043,11,1,1,59,59],
'2043030807:00:00','2043030803:00:00','2043110105:59:59','2043110101:59:59' ],
[ [2043,11,1,6,0,0],[2043,11,1,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2044,3,13,6,59,59],[2044,3,13,1,59,59],
'2043110106:00:00','2043110101:00:00','2044031306:59:59','2044031301:59:59' ],
],
2044 =>
[
[ [2044,3,13,7,0,0],[2044,3,13,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2044,11,6,5,59,59],[2044,11,6,1,59,59],
'2044031307:00:00','2044031303:00:00','2044110605:59:59','2044110601:59:59' ],
[ [2044,11,6,6,0,0],[2044,11,6,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2045,3,12,6,59,59],[2045,3,12,1,59,59],
'2044110606:00:00','2044110601:00:00','2045031206:59:59','2045031201:59:59' ],
],
2045 =>
[
[ [2045,3,12,7,0,0],[2045,3,12,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2045,11,5,5,59,59],[2045,11,5,1,59,59],
'2045031207:00:00','2045031203:00:00','2045110505:59:59','2045110501:59:59' ],
[ [2045,11,5,6,0,0],[2045,11,5,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2046,3,11,6,59,59],[2046,3,11,1,59,59],
'2045110506:00:00','2045110501:00:00','2046031106:59:59','2046031101:59:59' ],
],
2046 =>
[
[ [2046,3,11,7,0,0],[2046,3,11,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2046,11,4,5,59,59],[2046,11,4,1,59,59],
'2046031107:00:00','2046031103:00:00','2046110405:59:59','2046110401:59:59' ],
[ [2046,11,4,6,0,0],[2046,11,4,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2047,3,10,6,59,59],[2047,3,10,1,59,59],
'2046110406:00:00','2046110401:00:00','2047031006:59:59','2047031001:59:59' ],
],
2047 =>
[
[ [2047,3,10,7,0,0],[2047,3,10,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2047,11,3,5,59,59],[2047,11,3,1,59,59],
'2047031007:00:00','2047031003:00:00','2047110305:59:59','2047110301:59:59' ],
[ [2047,11,3,6,0,0],[2047,11,3,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2048,3,8,6,59,59],[2048,3,8,1,59,59],
'2047110306:00:00','2047110301:00:00','2048030806:59:59','2048030801:59:59' ],
],
2048 =>
[
[ [2048,3,8,7,0,0],[2048,3,8,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2048,11,1,5,59,59],[2048,11,1,1,59,59],
'2048030807:00:00','2048030803:00:00','2048110105:59:59','2048110101:59:59' ],
[ [2048,11,1,6,0,0],[2048,11,1,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2049,3,14,6,59,59],[2049,3,14,1,59,59],
'2048110106:00:00','2048110101:00:00','2049031406:59:59','2049031401:59:59' ],
],
2049 =>
[
[ [2049,3,14,7,0,0],[2049,3,14,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2049,11,7,5,59,59],[2049,11,7,1,59,59],
'2049031407:00:00','2049031403:00:00','2049110705:59:59','2049110701:59:59' ],
[ [2049,11,7,6,0,0],[2049,11,7,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2050,3,13,6,59,59],[2050,3,13,1,59,59],
'2049110706:00:00','2049110701:00:00','2050031306:59:59','2050031301:59:59' ],
],
2050 =>
[
[ [2050,3,13,7,0,0],[2050,3,13,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2050,11,6,5,59,59],[2050,11,6,1,59,59],
'2050031307:00:00','2050031303:00:00','2050110605:59:59','2050110601:59:59' ],
[ [2050,11,6,6,0,0],[2050,11,6,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2051,3,12,6,59,59],[2051,3,12,1,59,59],
'2050110606:00:00','2050110601:00:00','2051031206:59:59','2051031201:59:59' ],
],
2051 =>
[
[ [2051,3,12,7,0,0],[2051,3,12,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2051,11,5,5,59,59],[2051,11,5,1,59,59],
'2051031207:00:00','2051031203:00:00','2051110505:59:59','2051110501:59:59' ],
[ [2051,11,5,6,0,0],[2051,11,5,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2052,3,10,6,59,59],[2052,3,10,1,59,59],
'2051110506:00:00','2051110501:00:00','2052031006:59:59','2052031001:59:59' ],
],
2052 =>
[
[ [2052,3,10,7,0,0],[2052,3,10,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2052,11,3,5,59,59],[2052,11,3,1,59,59],
'2052031007:00:00','2052031003:00:00','2052110305:59:59','2052110301:59:59' ],
[ [2052,11,3,6,0,0],[2052,11,3,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2053,3,9,6,59,59],[2053,3,9,1,59,59],
'2052110306:00:00','2052110301:00:00','2053030906:59:59','2053030901:59:59' ],
],
2053 =>
[
[ [2053,3,9,7,0,0],[2053,3,9,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2053,11,2,5,59,59],[2053,11,2,1,59,59],
'2053030907:00:00','2053030903:00:00','2053110205:59:59','2053110201:59:59' ],
[ [2053,11,2,6,0,0],[2053,11,2,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2054,3,8,6,59,59],[2054,3,8,1,59,59],
'2053110206:00:00','2053110201:00:00','2054030806:59:59','2054030801:59:59' ],
],
2054 =>
[
[ [2054,3,8,7,0,0],[2054,3,8,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2054,11,1,5,59,59],[2054,11,1,1,59,59],
'2054030807:00:00','2054030803:00:00','2054110105:59:59','2054110101:59:59' ],
[ [2054,11,1,6,0,0],[2054,11,1,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2055,3,14,6,59,59],[2055,3,14,1,59,59],
'2054110106:00:00','2054110101:00:00','2055031406:59:59','2055031401:59:59' ],
],
2055 =>
[
[ [2055,3,14,7,0,0],[2055,3,14,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2055,11,7,5,59,59],[2055,11,7,1,59,59],
'2055031407:00:00','2055031403:00:00','2055110705:59:59','2055110701:59:59' ],
[ [2055,11,7,6,0,0],[2055,11,7,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2056,3,12,6,59,59],[2056,3,12,1,59,59],
'2055110706:00:00','2055110701:00:00','2056031206:59:59','2056031201:59:59' ],
],
2056 =>
[
[ [2056,3,12,7,0,0],[2056,3,12,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2056,11,5,5,59,59],[2056,11,5,1,59,59],
'2056031207:00:00','2056031203:00:00','2056110505:59:59','2056110501:59:59' ],
[ [2056,11,5,6,0,0],[2056,11,5,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2057,3,11,6,59,59],[2057,3,11,1,59,59],
'2056110506:00:00','2056110501:00:00','2057031106:59:59','2057031101:59:59' ],
],
2057 =>
[
[ [2057,3,11,7,0,0],[2057,3,11,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2057,11,4,5,59,59],[2057,11,4,1,59,59],
'2057031107:00:00','2057031103:00:00','2057110405:59:59','2057110401:59:59' ],
[ [2057,11,4,6,0,0],[2057,11,4,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2058,3,10,6,59,59],[2058,3,10,1,59,59],
'2057110406:00:00','2057110401:00:00','2058031006:59:59','2058031001:59:59' ],
],
2058 =>
[
[ [2058,3,10,7,0,0],[2058,3,10,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2058,11,3,5,59,59],[2058,11,3,1,59,59],
'2058031007:00:00','2058031003:00:00','2058110305:59:59','2058110301:59:59' ],
[ [2058,11,3,6,0,0],[2058,11,3,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2059,3,9,6,59,59],[2059,3,9,1,59,59],
'2058110306:00:00','2058110301:00:00','2059030906:59:59','2059030901:59:59' ],
],
2059 =>
[
[ [2059,3,9,7,0,0],[2059,3,9,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2059,11,2,5,59,59],[2059,11,2,1,59,59],
'2059030907:00:00','2059030903:00:00','2059110205:59:59','2059110201:59:59' ],
[ [2059,11,2,6,0,0],[2059,11,2,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2060,3,14,6,59,59],[2060,3,14,1,59,59],
'2059110206:00:00','2059110201:00:00','2060031406:59:59','2060031401:59:59' ],
],
2060 =>
[
[ [2060,3,14,7,0,0],[2060,3,14,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2060,11,7,5,59,59],[2060,11,7,1,59,59],
'2060031407:00:00','2060031403:00:00','2060110705:59:59','2060110701:59:59' ],
[ [2060,11,7,6,0,0],[2060,11,7,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2061,3,13,6,59,59],[2061,3,13,1,59,59],
'2060110706:00:00','2060110701:00:00','2061031306:59:59','2061031301:59:59' ],
],
2061 =>
[
[ [2061,3,13,7,0,0],[2061,3,13,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2061,11,6,5,59,59],[2061,11,6,1,59,59],
'2061031307:00:00','2061031303:00:00','2061110605:59:59','2061110601:59:59' ],
[ [2061,11,6,6,0,0],[2061,11,6,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2062,3,12,6,59,59],[2062,3,12,1,59,59],
'2061110606:00:00','2061110601:00:00','2062031206:59:59','2062031201:59:59' ],
],
2062 =>
[
[ [2062,3,12,7,0,0],[2062,3,12,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2062,11,5,5,59,59],[2062,11,5,1,59,59],
'2062031207:00:00','2062031203:00:00','2062110505:59:59','2062110501:59:59' ],
[ [2062,11,5,6,0,0],[2062,11,5,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2063,3,11,6,59,59],[2063,3,11,1,59,59],
'2062110506:00:00','2062110501:00:00','2063031106:59:59','2063031101:59:59' ],
],
2063 =>
[
[ [2063,3,11,7,0,0],[2063,3,11,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2063,11,4,5,59,59],[2063,11,4,1,59,59],
'2063031107:00:00','2063031103:00:00','2063110405:59:59','2063110401:59:59' ],
[ [2063,11,4,6,0,0],[2063,11,4,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2064,3,9,6,59,59],[2064,3,9,1,59,59],
'2063110406:00:00','2063110401:00:00','2064030906:59:59','2064030901:59:59' ],
],
2064 =>
[
[ [2064,3,9,7,0,0],[2064,3,9,3,0,0],'-04:00:00',[-4,0,0],
'EDT',1,[2064,11,2,5,59,59],[2064,11,2,1,59,59],
'2064030907:00:00','2064030903:00:00','2064110205:59:59','2064110201:59:59' ],
[ [2064,11,2,6,0,0],[2064,11,2,1,0,0],'-05:00:00',[-5,0,0],
'EST',0,[2065,3,8,6,59,59],[2065,3,8,1,59,59],
'2064110206:00:00','2064110201:00:00','2065030806:59:59','2065030801:59:59' ],
],
);
%LastRule = (
'zone' => {
'dstoff' => '-04:00:00',
'stdoff' => '-05:00:00',
},
'rules' => {
'03' => {
'flag' => 'ge',
'dow' => '7',
'num' => '8',
'type' => 'w',
'time' => '02:00:00',
'isdst' => '1',
'abb' => 'EDT',
},
'11' => {
'flag' => 'ge',
'dow' => '7',
'num' => '1',
'type' => 'w',
'time' => '02:00:00',
'isdst' => '0',
'abb' => 'EST',
},
},
);
1;
| nriley/Pester | Source/Manip/TZ/amindi00.pm | Perl | bsd-2-clause | 36,979 |
=head1 ComputeD0
=over 13
=item ComputeD0 -
Compute the zonal space-concentration kernel of a spherical cap.
=back
=head1 SYNOPSIS
=over 23
=item SUBROUTINE ComputeD0 (
D0, LMAX, THETA0 )
=back
=over 4
=over 10
=item REAL*8
D0(LMAX+1, LMAX+1), THETA0
=item INTEGER
LMAX
=back
=back
=head1 DESCRIPTION
I<ComputeD0> will calculate the zonal space-concentration kernel for the spherical-cap concentration problem. The eigenfunctions of this matrix correspond to a family of orthogonal windowing functions, and the eigenvalues correspond to the window's concentration factor (i.e., the power of the window within THETA0 divided by the total power of the function). It is implicitly assumed that the employed spherical harmonic functions are normalized to the same value for all degrees and angular orders, which is the case for both the geodesy 4-pi and orthonormalized harmonics. This kernel is symmetric and is computed using the exact expressions presented in Appendix B of Wieczorek and Simons (2005).
=head1 ARGUMENTS
=over 10
=item D0
(output) REAL*8, DIMENSION (LMAX+1, LMAX+1)
The zonal space-concentration kernel.
=item LMAX
(input) INTEGER
The spherical harmonic bandwidth of the windows.
=item THETA0
(input) REAL*8
The angular radius of the spherical cap in RADIANS.
=back
=head1 SEE ALSO
computedg82(1), computedm(1), shreturntapers(1), shreturntapersm(1)
L<http://www.ipgp.jussieu.fr/~wieczor/SHTOOLS/SHTOOLS.html>
=head1 REFERENCES
Wieczorek, M. A. and F. J. Simons, Localized spectral analysis on the sphere,
I<Geophys. J. Int.>, 162, 655-675.
=head1 COPYRIGHT AND LICENSE
Copyright 2005, 2006 by Mark Wieczorek <wieczor@ipgp.fr>.
This is free software; you can distribute and modify it under the terms of the revised BSD license. | pletnes/SHTOOLS | src/doc/computed0.pod | Perl | bsd-3-clause | 1,789 |
# !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
# This file is machine-generated by lib/unicore/mktables from the Unicode
# database, Version 6.1.0. Any changes made here will be lost!
# !!!!!!! INTERNAL PERL USE ONLY !!!!!!!
# This file is for internal use by core Perl only. The format and even the
# name or existence of this file are subject to change without notice. Don't
# use it directly.
return <<'END';
062C 062E
0681 0687
06BF
0757 0758
076E 076F
0772
077C
08A2
END
| efortuna/AndroidSDKClone | ndk_experimental/prebuilt/linux-x86_64/lib/perl5/5.16.2/unicore/lib/Jg/Hah.pl | Perl | apache-2.0 | 491 |
package AI::MXNet::Module::Bucketing;
use Mouse;
use AI::MXNet::Function::Parameters;
use AI::MXNet::Base;
=encoding UTF-8
=head1 NAME
AI::MXNet::Module::Bucketing
=head1 SYNOPSIS
my $buckets = [10, 20, 30, 40, 50, 60];
my $start_label = 1;
my $invalid_label = 0;
my ($train_sentences, $vocabulary) = tokenize_text(
'./data/ptb.train.txt', start_label => $start_label,
invalid_label => $invalid_label
);
my ($validation_sentences) = tokenize_text(
'./data/ptb.test.txt', vocab => $vocabulary,
start_label => $start_label, invalid_label => $invalid_label
);
my $data_train = mx->rnn->BucketSentenceIter(
$train_sentences, $batch_size, buckets => $buckets,
invalid_label => $invalid_label
);
my $data_val = mx->rnn->BucketSentenceIter(
$validation_sentences, $batch_size, buckets => $buckets,
invalid_label => $invalid_label
);
my $stack = mx->rnn->SequentialRNNCell();
for my $i (0..$num_layers-1)
{
$stack->add(mx->rnn->LSTMCell(num_hidden => $num_hidden, prefix => "lstm_l${i}_"));
}
my $sym_gen = sub {
my $seq_len = shift;
my $data = mx->sym->Variable('data');
my $label = mx->sym->Variable('softmax_label');
my $embed = mx->sym->Embedding(
data => $data, input_dim => scalar(keys %$vocabulary),
output_dim => $num_embed, name => 'embed'
);
$stack->reset;
my ($outputs, $states) = $stack->unroll($seq_len, inputs => $embed, merge_outputs => 1);
my $pred = mx->sym->Reshape($outputs, shape => [-1, $num_hidden]);
$pred = mx->sym->FullyConnected(data => $pred, num_hidden => scalar(keys %$vocabulary), name => 'pred');
$label = mx->sym->Reshape($label, shape => [-1]);
$pred = mx->sym->SoftmaxOutput(data => $pred, label => $label, name => 'softmax');
return ($pred, ['data'], ['softmax_label']);
};
my $contexts;
if(defined $gpus)
{
$contexts = [map { mx->gpu($_) } split(/,/, $gpus)];
}
else
{
$contexts = mx->cpu(0);
}
my $model = mx->mod->BucketingModule(
sym_gen => $sym_gen,
default_bucket_key => $data_train->default_bucket_key,
context => $contexts
);
$model->fit(
$data_train,
eval_data => $data_val,
eval_metric => mx->metric->Perplexity($invalid_label),
kvstore => $kv_store,
optimizer => $optimizer,
optimizer_params => {
learning_rate => $lr,
momentum => $mom,
wd => $wd,
},
initializer => mx->init->Xavier(factor_type => "in", magnitude => 2.34),
num_epoch => $num_epoch,
batch_end_callback => mx->callback->Speedometer($batch_size, $disp_batches),
($chkp_epoch ? (epoch_end_callback => mx->rnn->do_rnn_checkpoint($stack, $chkp_prefix, $chkp_epoch)) : ())
);
=head1 DESCRIPTION
Implements the AI::MXNet::Module::Base API, and allows multiple
symbols to be used depending on the `bucket_key` provided by each different
mini-batch of data
=cut
=head2 new
Parameters
----------
$sym_gen : subref or any perl object that overloads &{} op
A sub when called with a bucket key, returns a list with triple
of ($symbol, $data_names, $label_names).
$default_bucket_key : str or anything else
The key for the default bucket.
$logger : Logger
$context : AI::MXNet::Context or array ref of AI::MXNet::Context objects
Default is cpu(0)
$work_load_list : array ref of Num
Default is undef, indicating uniform workload.
$fixed_param_names: arrayref of str
Default is undef, indicating no network parameters are fixed.
$state_names : arrayref of str
states are similar to data and label, but not provided by data iterator.
Instead they are initialized to 0 and can be set by set_states()
=cut
extends 'AI::MXNet::Module::Base';
has '_sym_gen' => (is => 'ro', init_arg => 'sym_gen', required => 1);
has '_default_bucket_key' => (is => 'rw', init_arg => 'default_bucket_key', required => 1);
has '_context' => (
is => 'ro', isa => 'AI::MXNet::Context|ArrayRef[AI::MXNet::Context]',
lazy => 1, default => sub { AI::MXNet::Context->cpu },
init_arg => 'context'
);
has '_work_load_list' => (is => 'rw', init_arg => 'work_load_list', isa => 'ArrayRef[Num]');
has '_curr_module' => (is => 'rw', init_arg => undef);
has '_curr_bucket_key' => (is => 'rw', init_arg => undef);
has '_buckets' => (is => 'rw', init_arg => undef, default => sub { +{} });
has '_fixed_param_names' => (is => 'rw', isa => 'ArrayRef[Str]', init_arg => 'fixed_param_names');
has '_state_names' => (is => 'rw', isa => 'ArrayRef[Str]', init_arg => 'state_names');
has '_params_dirty' => (is => 'rw', init_arg => undef);
sub BUILD
{
my ($self, $original_params) = @_;
$self->_fixed_param_names([]) unless defined $original_params->{fixed_param_names};
$self->_state_names([]) unless defined $original_params->{state_names};
$self->_params_dirty(0);
my ($symbol, $data_names, $label_names) = &{$self->_sym_gen}($self->_default_bucket_key);
$self->_check_input_names($symbol, $data_names//[], "data", 1);
$self->_check_input_names($symbol, $label_names//[], "label", 0);
$self->_check_input_names($symbol, $self->_state_names, "state", 1);
$self->_check_input_names($symbol, $self->_fixed_param_names, "fixed_param", 1);
}
method _reset_bind()
{
$self->binded(0);
$self->_buckets({});
$self->_curr_module(undef);
$self->_curr_bucket_key(undef);
}
method data_names()
{
if($self->binded)
{
return $self->_curr_module->data_names;
}
else
{
return (&{$self->_sym_gen}($self->_default_bucket_key))[1];
}
}
method output_names()
{
if($self->binded)
{
return $self->_curr_module->ouput_names;
}
else
{
my ($symbol) = &{$self->_sym_gen}($self->_default_bucket_key);
return $symbol->list_ouputs;
}
}
method data_shapes()
{
assert($self->binded);
return $self->_curr_module->data_shapes;
}
method label_shapes()
{
assert($self->binded);
return $self->_curr_module->label_shapes;
}
method output_shapes()
{
assert($self->binded);
return $self->_curr_module->output_shapes;
}
method get_params()
{
assert($self->binded and $self->params_initialized);
$self->_curr_module->_p->_params_dirty($self->_params_dirty);
my ($arg_params, $aux_params) = $self->_curr_module->get_params;
$self->_params_dirty(0);
return ($arg_params, $aux_params);
}
method set_params(
HashRef[AI::MXNet::NDArray] $arg_params,
HashRef[AI::MXNet::NDArray] $aux_params,
Bool $allow_missing=0,
Bool $force_init=1,
Bool $allow_extra=0
)
{
if(not $allow_missing)
{
$self->init_params(
arg_params => $arg_params, aux_params => $aux_params,
allow_missing => $allow_missing, force_init => $force_init,
allow_extra => $allow_extra
);
return;
}
if($self->params_initialized and not $force_init)
{
AI::MXNet::Logging->warning(
"Parameters already initialized and force_init=False. "
."set_params call ignored."
);
return;
}
$self->_curr_module->set_params(
$arg_params, $aux_params,
allow_missing => $allow_missing,
force_init => $force_init,
allow_extra => $allow_extra
);
# because we didn't update self._arg_params, they are dirty now.
$self->_params_dirty(1);
$self->params_initialized(1);
}
method init_params(
AI::MXNet::Initializer :$initializer=AI::MXNet::Initializer->Uniform(scale => 0.01),
Maybe[HashRef[AI::MXNet::NDArray]] :$arg_params=,
Maybe[HashRef[AI::MXNet::NDArray]] :$aux_params=,
Bool :$allow_missing=0,
Bool :$force_init=0,
Bool :$allow_extra=0
)
{
return if($self->params_initialized and not $force_init);
assert($self->binded, 'call bind before initializing the parameters');
$self->_curr_module->init_params(
initializer => $initializer,
arg_params => $arg_params,
aux_params => $aux_params,
allow_missing => $allow_missing,
force_init => $force_init,
allow_extra => $allow_extra
);
$self->_params_dirty(0);
$self->params_initialized(1);
}
method get_states(Bool $merge_multi_context=1)
{
assert($self->binded and $self->params_initialized);
$self->_curr_module->get_states($merge_multi_context);
}
method set_states(:$states=, :$value=)
{
assert($self->binded and $self->params_initialized);
$self->_curr_module->set_states(states => $states, value => $value);
}
=head2 bind
Binding for a AI::MXNet::Module::Bucketing means setting up the buckets and bind the
executor for the default bucket key. Executors corresponding to other keys are
binded afterwards with switch_bucket.
Parameters
----------
:$data_shapes : ArrayRef[AI::MXNet::DataDesc|NameShape]
This should correspond to the symbol for the default bucket.
:$label_shapes= : Maybe[ArrayRef[AI::MXNet::DataDesc|NameShape]]
This should correspond to the symbol for the default bucket.
:$for_training : Bool
Default is 1.
:$inputs_need_grad : Bool
Default is 0.
:$force_rebind : Bool
Default is 0.
:$shared_module : AI::MXNet::Module::Bucketing
Default is undef. This value is currently not used.
:$grad_req : str, array ref of str, hash ref of str to str
Requirement for gradient accumulation. Can be 'write', 'add', or 'null'
(defaults to 'write').
Can be specified globally (str) or for each argument (array ref, hash ref).
:$bucket_key : str
bucket key for binding. by default is to use the ->default_bucket_key
=cut
method bind(
ArrayRef[AI::MXNet::DataDesc|NameShape] :$data_shapes,
Maybe[ArrayRef[AI::MXNet::DataDesc|NameShape]] :$label_shapes=,
Bool :$for_training=1,
Bool :$inputs_need_grad=0,
Bool :$force_rebind=0,
Maybe[AI::MXNet::BaseModule] :$shared_module=,
Str|ArrayRef[Str]|HashRef[Str] :$grad_req='write',
Maybe[Str] :$bucket_key=
)
{
# in case we already initialized params, keep it
my ($arg_params, $aux_params);
if($self->params_initialized)
{
($arg_params, $aux_params) = $self->get_params;
}
# force rebinding is typically used when one want to switch from
# training to prediction phase.
$self->_reset_bind if $force_rebind;
if($self->binded)
{
$self->logger->warning('Already binded, ignoring bind()');
return;
}
assert((not defined $shared_module), 'shared_module for BucketingModule is not supported');
$self->for_training($for_training);
$self->inputs_need_grad($inputs_need_grad);
$self->binded(1);
my ($symbol, $data_names, $label_names) = &{$self->_sym_gen}($bucket_key//$self->_default_bucket_key);
my $module = AI::MXNet::Module->new(
symbol => $symbol,
data_names => $data_names,
label_names => $label_names,
logger => $self->logger,
context => $self->_context,
work_load_list => $self->_work_load_list,
state_names => $self->_state_names,
fixed_param_names => $self->_fixed_param_names
);
$module->bind(
data_shapes => $data_shapes,
label_shapes => $label_shapes,
for_training => $for_training,
inputs_need_grad => $inputs_need_grad,
force_rebind => 0,
shared_module => undef,
grad_req => $grad_req
);
$self->_curr_module($module);
$self->_curr_bucket_key($self->_default_bucket_key);
$self->_buckets->{ $self->_default_bucket_key } = $module;
# copy back saved params, if already initialized
if($self->params_initialized)
{
$self->set_params($arg_params, $aux_params);
}
}
=head2 switch_bucket
Switch to a different bucket. This will change $self->_curr_module.
Parameters
----------
:$bucket_key : str (or any perl object that overloads "" op)
The key of the target bucket.
:$data_shapes : Maybe[ArrayRef[AI::MXNet::DataDesc|NameShape]]
Typically $data_batch->provide_data.
:$label_shapes : Maybe[ArrayRef[AI::MXNet::DataDesc|NameShape]]
Typically $data_batch->provide_label.
=cut
method switch_bucket(
Maybe[ArrayRef[AI::MXNet::DataDesc|NameShape]] :$data_shapes=,
Maybe[ArrayRef[AI::MXNet::DataDesc|NameShape]] :$label_shapes=,
:$bucket_key
)
{
assert($self->binded, 'call bind before switching bucket');
if(not exists $self->_buckets->{ $bucket_key })
{
my ($symbol, $data_names, $label_names) = &{$self->_sym_gen}($bucket_key);
my $module = AI::MXNet::Module->new(
symbol => $symbol,
data_names => $data_names,
label_names => $label_names,
logger => $self->logger,
context => $self->_context,
work_load_list => $self->_work_load_list
);
$module->bind(
data_shapes => $data_shapes,
label_shapes => $label_shapes,
for_training => $self->_curr_module->for_training,
inputs_need_grad => $self->_curr_module->inputs_need_grad,
force_rebind => 0,
shared_module => $self->_buckets->{ $self->_default_bucket_key },
);
$self->_buckets->{ $bucket_key } = $module;
}
$self->_curr_module($self->_buckets->{ $bucket_key });
$self->_curr_bucket_key($bucket_key);
}
method init_optimizer(
Str :$kvstore='local',
Optimizer :$optimizer='sgd',
HashRef :$optimizer_params={ learning_rate => 0.01 },
Bool :$force_init=0
)
{
assert($self->binded and $self->params_initialized);
if($self->optimizer_initialized and not $force_init)
{
$self->logger->warning('optimizer already initialized, ignoring.');
return;
}
$self->_curr_module->init_optimizer(
kvstore => $kvstore,
optimizer => $optimizer,
optimizer_params => $optimizer_params,
force_init => $force_init
);
for my $mod (values %{ $self->_buckets })
{
if($mod ne $self->_curr_module)
{
$mod->borrow_optimizer($self->_curr_module);
}
}
$self->optimizer_initialized(1);
}
method prepare(AI::MXNet::DataBatch $data_batch)
{
assert($self->binded and $self->params_initialized);
## perform bind if have not done so yet
my $original_bucket_key = $self->_curr_bucket_key;
$self->switch_bucket(
bucket_key => $data_batch->bucket_key,
data_shapes => $data_batch->provide_data,
label_shapes => $data_batch->provide_label
);
# switch back
$self->switch_bucket(bucket_key => $original_bucket_key);
}
method forward(
AI::MXNet::DataBatch $data_batch,
Bool :$is_train=
)
{
assert($self->binded and $self->params_initialized);
$self->switch_bucket(
bucket_key => $data_batch->bucket_key,
data_shapes => $data_batch->provide_data,
label_shapes => $data_batch->provide_label
);
$self->_curr_module->forward($data_batch, is_train => $is_train);
}
method backward(Maybe[ArrayRef[AI::MXNet::NDArray]|AI::MXNet::NDArray] $out_grads=)
{
assert($self->binded and $self->params_initialized);
$self->_curr_module->backward($out_grads);
}
method update()
{
assert($self->binded and $self->params_initialized and $self->optimizer_initialized);
$self->_params_dirty(1);
$self->_curr_module->update;
}
method get_outputs(Bool $merge_multi_context=1)
{
assert($self->binded and $self->params_initialized);
return $self->_curr_module->get_outputs($merge_multi_context);
}
method get_input_grads(Bool $merge_multi_context=1)
{
assert($self->binded and $self->params_initialized and $self->inputs_need_grad);
return $self->_curr_module->get_input_grads($merge_multi_context);
}
method update_metric(
AI::MXNet::EvalMetric $eval_metric,
ArrayRef[AI::MXNet::NDArray] $labels
)
{
assert($self->binded and $self->params_initialized);
$self->_curr_module->update_metric($eval_metric, $labels);
}
method symbol()
{
assert($self->binded);
return $self->_curr_module->symbol;
}
method get_symbol()
{
assert($self->binded);
return $self->_buckets->{ $self->_default_bucket_key }->symbol;
}
method install_monitor(AI::MXNet::Monitor $mon)
{
assert($self->binded);
for my $mod (values %{ $self->_buckets })
{
$mod->install_monitor($mon);
}
}
1;
| hotpxl/mxnet | perl-package/AI-MXNet/lib/AI/MXNet/Module/Bucketing.pm | Perl | apache-2.0 | 17,817 |
#!/usr/bin/perl
use warnings;
use FindBin;
use lib "$FindBin::Bin/lib";
use Module::Load::Conditional 'can_load';
$nicfile = $ARGV[0] if($ARGV[0]);
$outputdir = $ARGV[1];
if(!$nicfile || !$outputdir) {
exitWithError("Syntax: $0 nicfile outputdir");
}
### LOAD THE NICFILE! ###
open(my $nichandle, "<", $nicfile);
my $line = <$nichandle>;
my $nicversion = 1;
if($line =~ /^nic (\w+)$/) {
$nicversion = $1;
}
seek($nichandle, 0, 0);
my $NICPackage = "NIC$nicversion";
exitWithError("I don't understand NIC version $nicversion!") if(!can_load(modules => {"NIC::Formats::$NICPackage" => undef}));
my $NIC = "NIC::Formats::$NICPackage"->new();
$NIC->load($nichandle);
$NIC->addConstraint("package");
close($nichandle);
### YAY! ###
$NIC->build($outputdir);
$NIC->dumpPreamble("pre.NIC");
sub exitWithError {
my $error = shift;
print STDERR "[error] ", $error, $/;
exit 1;
}
| mandy04/FLEXLoader | theos/bin/denicify.pl | Perl | bsd-3-clause | 881 |
# Part of get-flash-videos. See get_flash_videos for copyright.
package FlashVideo::Site::Scivee; # horrible casing :(
# for use with Scivee.tv
#
use strict;
use FlashVideo::Utils;
use HTML::Entities;
sub find_video {
# print title_to_filename(decode_entities("The+Algorithmic+Lens%3A+How+the+Computational+Perspective+is+Transforming+the+Sciences.mp3"));
# also /asset/audio/$vid
my ($self, $browser) = @_;
my $title;
if ($browser->content =~ /title\>([^\|]+)/) {
$title = $1;
}
else {
#$title = extract_info($browser)->{meta_title};
$title = extract_info($browser)->{title};
}
my $filename = title_to_filename($title);
# since I can't figure how to get the request url
my $vid;
if ($browser->content =~ /\/ratings\/(\d+)/) {
$vid = $1;
}
elsif ($browser->content =~ /flashvars="id=(\d+)/) {
$vid = $1;
}
else {
# print $browser->content;
die "Could not find video!";
}
my $url = "http://www.scivee.tv/asset/video/$vid";
return $url, $filename;
}
1;
| monsieurvideo/get-flash-videos | lib/FlashVideo/Site/Scivee.pm | Perl | apache-2.0 | 1,016 |
do 'samba-lib.pl';
# backup_config_files()
# Returns files and directories that can be backed up
sub backup_config_files
{
local @rv = ( $config{'smb_conf'} );
push(@rv, $config{'smb_passwd'}) if ($config{'smb_passwd'});
&get_share("global");
local $umap = &getval("username map");
push(@rv, $umap) if ($umap);
return @rv;
}
# pre_backup(&files)
# Called before the files are actually read
sub pre_backup
{
return undef;
}
# post_backup(&files)
# Called after the files are actually read
sub post_backup
{
return undef;
}
# pre_restore(&files)
# Called before the files are restored from a backup
sub pre_restore
{
return undef;
}
# post_restore(&files)
# Called after the files are restored from a backup
sub post_restore
{
return undef;
}
1;
| rcuvgd/Webmin22.01.2016 | samba/backup_config.pl | Perl | bsd-3-clause | 752 |
#!/usr/bin/perl -wT
print "Content-Type: image/svg+xml\r\n";
print "Expires: Thu, 01 Dec 2003 16:00:00 GMT\r\n";
print "Cache-Control: no-store, no-cache, must-revalidate\r\n";
print "Pragma: no-cache\r\n";
print "\r\n";
open(FILE, "embedded.svg");
while (<FILE>) {
print $_;
}
close(FILE);
| nwjs/chromium.src | third_party/blink/web_tests/http/tests/misc/resources/svg-no-store.pl | Perl | bsd-3-clause | 295 |
package CorrTableEntry;
use strict;
#
# This is a SAS component
#
sub new
{
my($class, $line) = @_;
my $l = $line;
chomp $l;
return bless [split(/\t/, $l)], $class;
}
# Column-1
sub id1
{
return $_[0]->[0];
}
# Column-2
sub id2
{
return $_[0]->[1];
}
# Column-3
sub npairs
{
return $_[0]->[2];
}
# Column-4
sub pairs
{
my @pairs = split(/,/, $_[0]->[3]);
return map { [split(/:/, $_)] } @pairs;
}
# Column-5
sub func1
{
return $_[0]->[4];
}
# Column-6
sub func2
{
return $_[0]->[5];
}
# Column-7
sub aliases1
{
return $_[0]->[6];
}
# Column-8
sub aliases2
{
return $_[0]->[7];
}
# Column-9
sub hitinfo
{
return $_[0]->[8];
}
# Column-10
sub iden
{
return $_[0]->[9];
}
# Column-11
sub psc
{
return $_[0]->[10];
}
# Column-12
sub beg1
{
return $_[0]->[11];
}
# Column-13
sub end1
{
return $_[0]->[12];
}
# Column-14
sub ln1
{
return $_[0]->[13];
}
# Column-14
sub len1
{
return $_[0]->[13];
}
# Column-15
sub beg2
{
return $_[0]->[14];
}
# Column-16
sub end2
{
return $_[0]->[15];
}
# Column-17
sub ln2
{
return $_[0]->[16];
}
# Column-17
sub len2
{
return $_[0]->[16];
}
# Column-18
sub bsc
{
return $_[0]->[17];
}
# Column-19
sub num_matching_functions
{
return $_[0]->[18];
}
# Column-20
sub clear_bbh
{
return $_[0]->[19];
}
1;
| kbase/kb_seed | lib/CorrTableEntry.pm | Perl | mit | 1,364 |
#! perl -w
#
# parseraydata.pl file
#
# Retrieves table from a PRINT RAYS command and saves it to the temporary
# file rays#.temp. This program is called by cassrayread.m.
#
# Copyright 2005 Kelly Kearney
use strict;
#---------------------------
# Get ray table
#---------------------------
my $cassoutFile = $ARGV[0];
open (CASSOUT, "$cassoutFile") or die "Cannot open cassout file: $!";
my $tableCount = 0;
FILELOOP: while (1) { # (<CASSOUT>) {
my $fileLine = <CASSOUT>;
last FILELOOP if (! defined($fileLine));
if ($fileLine =~ /RANGE DEPTH ANGLE TIME/) {
$tableCount++;
<CASSOUT>;<CASSOUT>;<CASSOUT>;
open(RAY, "> rays${tableCount}.temp") or die "Cannot open ray table file: $!";
TABLELOOP: while (1) {
chomp(my $tableLine = <CASSOUT>);
if (($tableLine =~ /Elapsed time =/) || ($tableLine =~ /^\s*$/)) {
close(RAY);
next FILELOOP;
} else {
my @rayData = split ' ', $tableLine;
if (@rayData == 11) {
if ($rayData[10] eq 'SRC') {
pop @rayData;
print RAY "@rayData 1\n";
} elsif ($rayData[10] eq 'MAX') {
pop @rayData;
print RAY "@rayData 2\n";
} elsif ($rayData[10] eq 'BTM') {
pop @rayData;
print RAY "@rayData 3\n";
} elsif ($rayData[10] eq 'SRF') {
pop @rayData;
print RAY "@rayData 4\n";
}
} elsif (@rayData == 10) {
print RAY "@rayData 0\n";
} else {
die "Wrong number of columns found in table\n";
}
}
}
}
}
| kakearney/cass-pkg | Cass/parseraydata.pl | Perl | mit | 1,986 |
package Note::File::RDF;
use strict;
use warnings;
no warnings 'uninitialized';
use Moose;
use RDF::Trine::Model;
use RDF::Trine::Store;
use RDF::Trine::Store::DBI::SQLite;
use Note::File;
use Note::RDF::Sparql;
use base 'Note::File';
has 'type' => (
'is' => 'rw',
'isa' => 'Str',
'default' => sub { return 'Store::DBI::SQLite'; },
);
has 'rdf' => (
'is' => 'rw',
'isa' => 'Note::RDF::Sparql',
'lazy' => 1,
'default' => sub {
my $obj = shift;
my $spq = new Note::RDF::Sparql(
'storage' => $obj->store(),
);
},
);
has 'model' => (
'isa' => 'RDF::Trine::Model',
'is' => 'rw',
'lazy' => 1,
'default' => sub {
my $obj = shift;
return new RDF::Trine::Model($obj->store());
},
);
has 'store' => (
'is' => 'rw',
'isa' => 'RDF::Trine::Store',
'lazy' => 1,
'default' => sub {
my ($obj) = @_;
my $type = $obj->type();
if ($type eq 'Store::DBI::SQLite')
{
my $file = $obj->file();
my $store = new RDF::Trine::Store({
'storetype' => 'DBI',
'name' => 'model',
'dsn' => "dbi:SQLite:dbname=$file",
'username' => '',
'password' => '',
});
return $store;
}
die(qq|Invalid store type: '$type'|);
},
);
1;
| mfrager/note | File/RDF.pm | Perl | mit | 1,171 |
package App::Sqitch::Command::target;
use 5.010;
use strict;
use warnings;
use utf8;
use Moo;
use Types::Standard qw(Str Int HashRef);
use Locale::TextDomain qw(App-Sqitch);
use App::Sqitch::X qw(hurl);
use URI::db;
use Try::Tiny;
use Path::Class qw(file dir);
use List::Util qw(max);
use namespace::autoclean;
extends 'App::Sqitch::Command';
our $VERSION = '0.997';
has verbose => (
is => 'ro',
isa => Int,
default => 0,
);
has properties => (
is => 'ro',
isa => HashRef,
default => sub { {} },
);
sub options {
return qw(
set|s=s%
registry|r=s
client|c=s
verbose|v+
);
}
my %normalizer_for = (
top_dir => sub { $_[0] ? dir($_[0])->cleanup : undef },
plan_file => sub { $_[0] ? file($_[0])->cleanup : undef },
client => sub { $_[0] },
);
$normalizer_for{"$_\_dir"} = $normalizer_for{top_dir} for qw(deploy revert verify);
$normalizer_for{$_} = $normalizer_for{client} for qw(registry extension);
sub configure {
my ( $class, $config, $options ) = @_;
# Handle deprecated options.
for my $key (qw(registry client)) {
my $val = delete $options->{$key} or next;
App::Sqitch->warn(__x(
'Option --{key} has been deprecated; use "--set {key}={val}" instead',
key => $key,
val => $val
));
my $set = $options->{set} ||= {};
$set->{$key} = $val;
}
$options->{properties} = delete $options->{set}
if $options->{set};
# No config; target config is actually targets.
return $options;
}
sub execute {
my ( $self, $action ) = (shift, shift);
$action ||= 'list';
$action =~ s/-/_/g;
my $meth = $self->can($action) or $self->usage(__x(
'Unknown action "{action}"',
action => $action,
));
return $self->$meth(@_);
}
sub list {
my $self = shift;
my $sqitch = $self->sqitch;
my %targets = $sqitch->config->get_regexp(key => qr/^target[.][^.]+[.]uri$/);
my $format = $self->verbose ? "%1\$s\t%2\$s" : '%1$s';
for my $key (sort keys %targets) {
my ($target) = $key =~ /target[.]([^.]+)/;
$sqitch->emit(sprintf $format, $target, $targets{$key});
}
return $self;
}
sub add {
my ($self, $name, $uri) = @_;
$self->usage unless $name && $uri;
my $key = "target.$name";
my $config = $self->sqitch->config;
hurl target => __x(
'Target "{target}" already exists',
target => $name
) if $config->get( key => "$key.uri");
my @vars = ({
key => "$key.uri",
value => URI::db->new($uri, 'db:')->as_string,
});
# Collect properties.
my $props = $self->properties;
while (my ($prop, $val) = each %{ $props } ) {
my $normalizer = $normalizer_for{$prop} or $self->usage(__x(
'Unknown property "{property}"',
property => $prop,
));
push @vars => {
key => "$key.$prop",
value => $normalizer->($val),
};
}
# Make it so.
$config->group_set( $config->local_file, \@vars );
return $self;
}
sub _set {
my ($self, $key, $name, $value) = @_;
$self->usage unless $name && $value;
my $config = $self->sqitch->config;
my $target = "target.$name";
hurl target => __x(
'Unknown target "{target}"',
target => $name
) unless $config->get( key => "$target.uri");
$config->set(
key => "$target.$key",
value => $value,
filename => $config->local_file,
);
return $self;
}
sub set_url { shift->set_uri(@_) };
sub set_uri {
my ($self, $name, $uri) = @_;
$self->_set(
'uri',
$name,
$uri ? URI::db->new($uri, 'db:')->as_string : undef
);
}
sub set_registry { shift->_set('registry', @_) }
sub set_client { shift->_set('client', @_) }
sub set_extension { shift->_set('extension', @_) }
sub _set_dir {
my ($self, $key, $name, $dir) = @_;
$self->_set( $key, $name, $normalizer_for{top_dir}->($dir) );
}
sub set_top_dir { shift->_set_dir('top_dir', @_) }
sub set_deploy_dir { shift->_set_dir('deploy_dir', @_) }
sub set_revert_dir { shift->_set_dir('revert_dir', @_) }
sub set_verify_dir { shift->_set_dir('verify_dir', @_) }
sub set_plan_file {
my ($self, $name, $file) = @_;
$self->_set( 'plan_file', $name, $normalizer_for{plan_file}->($file) );
}
sub rm { shift->remove(@_) }
sub remove {
my ($self, $name) = @_;
$self->usage unless $name;
if ( my @deps = $self->_dependencies($name) ) {
hurl target => __x(
q{Cannot rename target "{target}" because it's refereneced by: {engines}},
target => $name,
engines => join ', ', @deps
);
}
$self->_rename($name);
}
sub rename {
my ($self, $old, $new) = @_;
$self->usage unless $old && $new;
if ( my @deps = $self->_dependencies($old) ) {
hurl target => __x(
q{Cannot rename target "{target}" because it's refereneced by: {engines}},
target => $old,
engines => join ', ', @deps
);
}
$self->_rename($old, $new);
}
sub _dependencies {
my ($self, $name) = @_;
my %depends = $self->sqitch->config->get_regexp(
key => qr/^(?:core|engine[.][^.]+)[.]target$/
);
return grep { $depends{$_} eq $name } sort keys %depends;
}
sub _rename {
my ($self, $old, $new) = @_;
my $config = $self->sqitch->config;
try {
$config->rename_section(
from => "target.$old",
($new ? (to => "target.$new") : ()),
filename => $config->local_file,
);
} catch {
die $_ unless /No such section/;
hurl target => __x(
'Unknown target "{target}"',
target => $old,
);
};
return $self;
}
sub show {
my ($self, @names) = @_;
return $self->list unless @names;
my $sqitch = $self->sqitch;
my $config = $sqitch->config;
# Set up labels.
my $len = max map { length } (
__ 'URI',
__ 'Registry',
__ 'Client',
__ 'Top Directory',
__ 'Plan File',
__ 'Deploy Directory',
__ 'Revert Directory',
__ 'Verify Directory',
__ 'Extension',
);
my %label_for = (
uri => __('URI') . ': ' . ' ' x ($len - length __ 'URI'),
registry => __('Registry') . ': ' . ' ' x ($len - length __ 'Registry'),
client => __('Client') . ': ' . ' ' x ($len - length __ 'Client'),
top_dir => __('Top Directory') . ': ' . ' ' x ($len - length __ 'Top Directory'),
plan_file => __('Plan File') . ': ' . ' ' x ($len - length __ 'Plan File'),
deploy_dir => __('Deploy Directory') . ': ' . ' ' x ($len - length __ 'Deploy Directory'),
revert_dir => __('Revert Directory') . ': ' . ' ' x ($len - length __ 'Revert Directory'),
verify_dir => __('Verify Directory') . ': ' . ' ' x ($len - length __ 'Verify Directory'),
extension => __('Extension') . ': ' . ' ' x ($len - length __ 'Extension'),
);
require App::Sqitch::Target;
for my $name (@names) {
my $target = App::Sqitch::Target->new(
sqitch => $sqitch,
name => $name,
);
$self->emit("* $name");
$self->emit(' ', $label_for{uri}, $target->uri->as_string);
$self->emit(' ', $label_for{registry}, $target->registry);
$self->emit(' ', $label_for{client}, $target->client);
$self->emit(' ', $label_for{top_dir}, $target->top_dir);
$self->emit(' ', $label_for{plan_file}, $target->plan_file);
$self->emit(' ', $label_for{deploy_dir}, $target->deploy_dir);
$self->emit(' ', $label_for{revert_dir}, $target->revert_dir);
$self->emit(' ', $label_for{verify_dir}, $target->verify_dir);
$self->emit(' ', $label_for{extension}, $target->extension);
}
return $self;
}
1;
__END__
=head1 Name
App::Sqitch::Command::target - Add, modify, or list Sqitch target databases
=head1 Synopsis
my $cmd = App::Sqitch::Command::target->new(%params);
$cmd->execute;
=head1 Description
Manages Sqitch targets, which are stored in the local configuration file.
=head1 Interface
=head2 Instance Methods
=head2 Attributes
=head3 C<properties>
Hash of property values to set.
=head3 C<verbose>
Verbosity.
=head3 C<execute>
$target->execute($command);
Executes the C<target> command.
=head3 C<add>
Implements the C<add> action.
=head3 C<list>
Implements the C<list> action.
=head3 C<remove>
=head3 C<rm>
Implements the C<remove> action.
=head3 C<rename>
Implements the C<rename> action.
=head3 C<set_client>
Implements the C<set-client> action.
=head3 C<set_registry>
Implements the C<set-registry> action.
=head3 C<set_uri>
=head3 C<set_url>
Implements the C<set-uri> action.
=head3 C<set_top_dir>
Implements the C<set-top-dir> action.
=head3 C<set_plan_file>
Implements the C<set-plan-file> action.
=head3 C<set_deploy_dir>
Implements the C<set-deploy-dir> action.
=head3 C<set_revert_dir>
Implements the C<set-revert-dir> action.
=head3 C<set_verify_dir>
Implements the C<set-verify-dir> action.
=head3 C<set_extension>
Implements the C<set-extension> action.
=head3 C<show>
Implements the C<show> action.
=head1 See Also
=over
=item L<sqitch-target>
Documentation for the C<target> command to the Sqitch command-line client.
=item L<sqitch>
The Sqitch command-line client.
=back
=head1 Author
David E. Wheeler <david@justatheory.com>
=head1 License
Copyright (c) 2012-2014 iovation Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
=cut
| gitpan/App-Sqitch | lib/App/Sqitch/Command/target.pm | Perl | mit | 10,782 |
#=======================================================================
# ____ ____ _____ _ ____ ___ ____
# | _ \| _ \| ___| _ _ / \ | _ \_ _| |___ \
# | |_) | | | | |_ (_) (_) / _ \ | |_) | | __) |
# | __/| |_| | _| _ _ / ___ \| __/| | / __/
# |_| |____/|_| (_) (_) /_/ \_\_| |___| |_____|
#
# A Perl Module Chain to faciliate the Creation and Modification
# of High-Quality "Portable Document Format (PDF)" Files.
#
# Copyright 1999-2005 Alfred Reibenschuh <areibens@cpan.org>.
#
#=======================================================================
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
#
# $Id: ExtGState.pm,v 2.0 2005/11/16 02:16:04 areibens Exp $
#
#=======================================================================
package PDF::API2::Resource::ExtGState;
BEGIN {
use strict;
use PDF::API2::Resource;
use PDF::API2::Basic::PDF::Utils;
use Math::Trig;
use PDF::API2::Util;
use vars qw(@ISA $VERSION);
@ISA = qw(PDF::API2::Resource);
( $VERSION ) = sprintf '%i.%03i', split(/\./,('$Revision: 2.0 $' =~ /Revision: (\S+)\s/)[0]); # $Date: 2005/11/16 02:16:04 $
}
no warnings qw[ deprecated recursion uninitialized ];
=head1 NAME
PDF::API2::Resource::ExtGState - extgate support for PDF::API2
=item $egs = PDF::API2::Resource::ExtGState->new @parameters
Returns a new extgstate object (called from $pdf->extgstate).
=cut
sub new {
my ($class,$pdf,$key)=@_;
my $self = $class->SUPER::new($pdf,$key);
$self->{Type}=PDFName('ExtGState');
return($self);
}
=item $font = PDF::API2::Resource::ExtGState->new_api $api, $name
Returns a egstate-font object. This method is different from 'new' that
it needs an PDF::API2-object rather than a Text::PDF::File-object.
=cut
sub new_api {
my ($class,$api,@opts)=@_;
my $obj=$class->new($api->{pdf},@opts);
$self->{' api'}=$api;
return($obj);
}
=item $egs->strokeadjust $boolean
=cut
sub strokeadjust {
my ($self,$var)=@_;
$self->{SA}=PDFBool($var);
return($self);
}
=item $egs->strokeoverprint $boolean
=cut
sub strokeoverprint {
my ($self,$var)=@_;
$self->{OP}=PDFBool($var);
return($self);
}
=item $egs->filloverprint $boolean
=cut
sub filloverprint {
my ($self,$var)=@_;
$self->{op}=PDFBool($var);
return($self);
}
=item $egs->overprintmode $num
=cut
sub overprintmode {
my ($self,$var)=@_;
$self->{OPM}=PDFNum($var);
return($self);
}
=item $egs->blackgeneration $obj
=cut
sub blackgeneration {
my ($self,$obj)=@_;
$self->{BG}=$obj;
return($self);
}
=item $egs->blackgeneration2 $obj
=cut
sub blackgeneration2 {
my ($self,$obj)=@_;
$self->{BG2}=$obj;
return($self);
}
=item $egs->undercolorremoval $obj
=cut
sub undercolorremoval {
my ($self,$obj)=@_;
$self->{UCR}=$obj;
return($self);
}
=item $egs->undercolorremoval2 $obj
=cut
sub undercolorremoval2 {
my ($self,$obj)=@_;
$self->{UCR2}=$obj;
return($self);
}
=item $egs->transfer $obj
=cut
sub transfer {
my ($self,$obj)=@_;
$self->{TR}=$obj;
return($self);
}
=item $egs->transfer2 $obj
=cut
sub transfer2 {
my ($self,$obj)=@_;
$self->{TR2}=$obj;
return($self);
}
=item $egs->halftone $obj
=cut
sub halftone {
my ($self,$obj)=@_;
$self->{HT}=$obj;
return($self);
}
=item $egs->halftonephase $obj
=cut
sub halftonephase {
my ($self,$obj)=@_;
$self->{HTP}=$obj;
return($self);
}
=item $egs->smoothness $num
=cut
sub smoothness {
my ($self,$var)=@_;
$self->{SM}=PDFNum($var);
return($self);
}
=item $egs->font $font, $size
=cut
sub font {
my ($self,$font,$size)=@_;
$self->{Font}=PDFArray(PDFName($font->{' apiname'}),PDFNum($size));
return($self);
}
=item $egs->linewidth $size
=cut
sub linewidth {
my ($self,$var)=@_;
$self->{LW}=PDFNum($var);
return($self);
}
=item $egs->linecap $cap
=cut
sub linecap {
my ($self,$var)=@_;
$self->{LC}=PDFNum($var);
return($self);
}
=item $egs->linejoin $join
=cut
sub linejoin {
my ($self,$var)=@_;
$self->{LJ}=PDFNum($var);
return($self);
}
=item $egs->meterlimit $limit
=cut
sub meterlimit {
my ($self,$var)=@_;
$self->{ML}=PDFNum($var);
return($self);
}
=item $egs->dash @dash
=cut
sub dash {
my ($self,@dash)=@_;
$self->{ML}=PDFArray( map { PDFNum($_); } @dash );
return($self);
}
=item $egs->flatness $flat
=cut
sub flatness {
my ($self,$var)=@_;
$self->{FL}=PDFNum($var);
return($self);
}
=item $egs->renderingintent $intentName
=cut
sub renderingintent {
my ($self,$var)=@_;
$self->{FL}=PDFName($var);
return($self);
}
=item $egs->strokealpha $alpha
The current stroking alpha constant, specifying the
constant shape or constant opacity value to be used
for stroking operations in the transparent imaging model.
=cut
sub strokealpha {
my ($self,$var)=@_;
$self->{CA}=PDFNum($var);
return($self);
}
=item $egs->fillalpha $alpha
Same as strokealpha, but for nonstroking operations.
=cut
sub fillalpha {
my ($self,$var)=@_;
$self->{ca}=PDFNum($var);
return($self);
}
=item $egs->blendmode $blendname
=item $egs->blendmode $blendfunctionobj
The current blend mode to be used in the transparent
imaging model.
=cut
sub blendmode {
my ($self,$var)=@_;
if(ref($var)) {
$self->{BM}=$var;
} else {
$self->{BM}=PDFName($var);
}
return($self);
}
=item $egs->alphaisshape $boolean
The alpha source flag (alpha is shape), specifying
whether the current soft mask and alpha constant
are to be interpreted as shape values (true) or
opacity values (false).
=cut
sub alphaisshape {
my ($self,$var)=@_;
$self->{AIS}=PDFBool($var);
return($self);
}
=item $egs->textknockout $boolean
The text knockout flag, which determines the behavior
of overlapping glyphs within a text object in the
transparent imaging model.
=cut
sub textknockout {
my ($self,$var)=@_;
$self->{TK}=PDFBool($var);
return($self);
}
=item $egs->transparency $t
The graphics tranparency , with 0 being fully opaque and 1 being fully transparent.
This is a convenience method setting proper values for strokeaplha and fillalpha.
=cut
sub transparency {
my ($self,$var)=@_;
$self->strokealpha(1-$var);
$self->fillalpha(1-$var);
return($self);
}
=item $egs->opacity $op
The graphics opacity , with 1 being fully opaque and 0 being fully transparent.
This is a convenience method setting proper values for strokeaplha and fillalpha.
=cut
sub opacity {
my ($self,$var)=@_;
$self->strokealpha($var);
$self->fillalpha($var);
return($self);
}
sub outobjdeep {
my ($self, @opts) = @_;
foreach my $k (qw/ api apipdf /) {
$self->{" $k"}=undef;
delete($self->{" $k"});
}
$self->SUPER::outobjdeep(@opts);
}
1;
__END__
=head1 AUTHOR
alfred reibenschuh
=head1 HISTORY
$Log: ExtGState.pm,v $
Revision 2.0 2005/11/16 02:16:04 areibens
revision workaround for SF cvs import not to screw up CPAN
Revision 1.2 2005/11/16 01:27:48 areibens
genesis2
Revision 1.1 2005/11/16 01:19:25 areibens
genesis
Revision 1.10 2005/06/17 19:44:03 fredo
fixed CPAN modulefile versioning (again)
Revision 1.9 2005/06/17 18:53:34 fredo
fixed CPAN modulefile versioning (dislikes cvs)
Revision 1.8 2005/03/14 22:01:06 fredo
upd 2005
Revision 1.7 2004/12/16 00:30:53 fredo
added no warn for recursion
Revision 1.6 2004/06/15 09:14:41 fredo
removed cr+lf
Revision 1.5 2004/06/07 19:44:36 fredo
cleaned out cr+lf for lf
Revision 1.4 2003/12/08 13:05:33 Administrator
corrected to proper licencing statement
Revision 1.3 2003/11/30 17:28:55 Administrator
merged into default
Revision 1.2.2.1 2003/11/30 16:56:35 Administrator
merged into default
Revision 1.2 2003/11/30 11:44:49 Administrator
added CVS id/log
=cut
| carlgao/lenga | images/lenny64-peon/usr/share/perl5/PDF/API2/Resource/ExtGState.pm | Perl | mit | 9,244 |
# This file is auto-generated by the Perl DateTime Suite time zone
# code generator (0.07) This code generator comes with the
# DateTime::TimeZone module distribution in the tools/ directory
#
# Generated from debian/tzdata/antarctica. Olson data version 2008c
#
# Do not edit this file directly.
#
package DateTime::TimeZone::Antarctica::Rothera;
use strict;
use Class::Singleton;
use DateTime::TimeZone;
use DateTime::TimeZone::OlsonDB;
@DateTime::TimeZone::Antarctica::Rothera::ISA = ( 'Class::Singleton', 'DateTime::TimeZone' );
my $spans =
[
[
DateTime::TimeZone::NEG_INFINITY,
62353929600,
DateTime::TimeZone::NEG_INFINITY,
62353929600,
0,
0,
'zzz'
],
[
62353929600,
DateTime::TimeZone::INFINITY,
62353918800,
DateTime::TimeZone::INFINITY,
-10800,
0,
'ROTT'
],
];
sub olson_version { '2008c' }
sub has_dst_changes { 0 }
sub _max_year { 2018 }
sub _new_instance
{
return shift->_init( @_, spans => $spans );
}
1;
| carlgao/lenga | images/lenny64-peon/usr/share/perl5/DateTime/TimeZone/Antarctica/Rothera.pm | Perl | mit | 952 |
package Genesis::BOSH;
use Genesis;
sub _bosh {
my @args = @_;
die "Unable to determine where the bosh CLI lives. This is a bug, please report it.\n"
unless $ENV{GENESIS_BOSH_COMMAND};
my $opts = (ref($args[0]) eq 'HASH') ? shift @args : {};
$opts->{env} ||= {};
# Clear out the BOSH env vars unless we shouldn't
unless ($ENV{GENESIS_HONOR_ENV}) {
$opts->{env}{HTTPS_PROXY} = ''; # bosh dislikes this env var
$opts->{env}{https_proxy} = ''; # bosh dislikes this env var
$opts->{env}{BOSH_ENVIRONMENT} ||= ''; # ensure using ~/.bosh/config via alias
$opts->{env}{BOSH_CA_CERT} ||= '';
$opts->{env}{BOSH_CLIENT} ||= '';
$opts->{env}{BOSH_CLIENT_SECRET} ||= '';
}
if ($args[0] =~ m/^bosh(\s|$)/) {
# ('bosh', 'do', 'things') or 'bosh do things'
$args[0] =~ s/^bosh/$ENV{GENESIS_BOSH_COMMAND}/;
} elsif ($args[0] =~ /\$\{?[\@0-9]/) {
# ('deploy "$1" | jq -r .whatever', $d)
$args[0] = "$ENV{GENESIS_BOSH_COMMAND} $args[0]";
} else {
# ('deploy', $d)
unshift @args, $ENV{GENESIS_BOSH_COMMAND};
}
return run($opts, @args);
}
sub config {
my ($class, $alias) = @_;
return {} unless -f "$ENV{HOME}/.bosh/config";
my $bosh = load_yaml_file("$ENV{HOME}/.bosh/config")
or return {};
for my $e (@{ $bosh->{environments} || [] }) {
return $e if $e->{alias} eq $alias;
}
return {};
}
sub environment_variables {
my ($class, $alias) = @_;
my $e = $class->config($alias);
return {} unless %$e;
return {
BOSH_ENVIRONMENT => $ENV{BOSH_ENVIRONMENT} || $e->{url},
BOSH_CA_CERT => $ENV{BOSH_CA_CERT} || $e->{ca_cert},
BOSH_CLIENT => $ENV{BOSH_CLIENT} || $e->{username},
BOSH_CLIENT_SECRET => $ENV{BOSH_CLIENT_SECRET} || $e->{password},
} if (envset('GENESIS_HONOR_ENV'));
return {
BOSH_ENVIRONMENT => $e->{url},
BOSH_CA_CERT => $e->{ca_cert},
BOSH_CLIENT => $e->{username},
BOSH_CLIENT_SECRET => $e->{password},
};
}
my $reping;
sub ping {
my ($class, $env) = @_;
return 1 if $ENV{GENESIS_BOSH_VERIFIED} eq $env;
# TODO: once using vault-stored bosh targetting, we don't need to do this anymore
debug "Checking BOSH at '$env' for connectivity";
my $waiting=0;
unless ($reping || in_callback || envset "GENESIS_TESTING") {;
waiting_on STDERR "Checking availability of the '#M{$env}' BOSH director...";
$waiting=1;
}
$reping = 1;
my ($host,$port);
if ($env =~ qr(^http(s?)://(.*?)(?::([0-9]*))?$)) {
$host = $2;
$port = $3 || 25555;
} else {
my $config = $class->config($env);
bail("#R{error!}\n\nCannot find bosh environment '#M{$env}' in the local ~/.bosh/config\n")
unless %$config;
$config->{url} =~ qr(^http(s?)://(.*?)(?::([0-9]*))?$) or
bail("#R{error!}\n\nInvalid BOSH director URL #C{%s}: expecting http(s)://ip-or-domain(:port)\n", $config->{url});
$host = $2;
$port = $3 || 25555;
}
my $status = tcp_listening($host,$port);
unless ($status eq 'ok') {
error "#R{unreachable - $status!}\n" if $waiting;
return 0;
}
my ($out,$rc) = read_json_from(_bosh('bosh', '-e', $env, 'env', '--json'));
if ($rc) {
error "#R{error!}\n\n$out\n" if $waiting;
return 0;
}
my $user = $out->{Tables}[0]{Rows}[0]{user};
if ($user eq "(not logged in)") {
# Just because it says not logged in, doesn't mean you're not. It only
# checks the access token, not the refresh token. So try something that
# does refresh the access token, then get the user after that.
($out,$rc) = _bosh('bosh', '-e', $env, 'stemcells', '--json');
($out,$rc) = read_json_from(_bosh('bosh', '-e', $env, 'env', '--json'));
$user = $out->{Tables}[0]{Rows}[0]{user};
}
if ($user eq "(not logged in)") {
error "#R{unauthenticated!}" if $waiting;
return 0;
}
explain STDERR "#G{ok - authenticated as $user}" if $waiting;
$ENV{GENESIS_BOSH_VERIFIED} = $env;
return 1;
}
sub env {
my ($class, $env) = @_;
return _bosh({ interactive => 1, passfail => 1 },
'bosh', '-e', $env, 'env');
}
sub create_env {
my ($class, $manifest, %opts) = @_;
bug("Missing deployment manifest in call to create_env()!!")
unless $manifest;
bug("Missing 'state' option in call to create_env()!!")
unless $opts{state};
$opts{flags} ||= [];
push(@{$opts{flags}}, '--state', $opts{state});
push(@{$opts{flags}}, '-l', $opts{vars_file}) if ($opts{vars_file});
return _bosh({ interactive => 1, passfail => 1 },
'bosh', $ENV{BOSH_NON_INTERACTIVE} ? '-n' : (),
'create-env', @{$opts{flags}}, $manifest);
}
sub download_config {
my ($class, $env, $path, $type, $name) = @_;
$name ||= '*';
my @configs;
if ($name eq '*') {
my ($configs_list,$rc,$err) = read_json_from(_bosh(
{interactive => 0, stderr => 0},
'bosh -e "$1" configs -r=1 --type="$2" --json | jq -r \'.Tables[0].Rows[]| {"type": .type, "name": .name}\' | jq -sMc',
$env, $type
));
if ($rc || ! scalar(@$configs_list)) {
$err ||= "No configurations found on BOSH director" unless scalar(@$configs_list);
bail "#R{[ERROR]} Could not load #C{$type} configurations: $err";
}
for (@$configs_list) {
my $label = $_->{name} eq "default" ? "base $_->{type} config" : "$_->{type} config '$_->{name}'";
push @configs, {type => $_->{type}, name => $_->{name}, label => $label};
}
} else {
my $label = $name eq "default" ? "$type config" : "$type config '$name'";
push @configs, {type => $type, name => $name, label => $label};
}
my @config_contents;
for (@configs) {
my ($out,$rc,$err) = _bosh(
{ interactive => 0},
'bosh -e "$1" config --type "$2" --name "$3" --json',
$env, $_->{type}, $_->{name}
);
my $json = eval {JSON::PP::decode_json($out)};
my $json_err = $@;
if ($json_err) {
chomp $json_err;
$json_err =~ s/ at lib\/Genesis\/BOSH.*//sm;
}
if ($rc || $json_err) {
my $msg = $err;
$msg = "#R{$json_err:}\n\n[36m$out[0m" if ($json_err && !$msg);
$msg ||= join("\n", grep {$_ !~ /^Exit code/} grep {$_ !~ /^Using environment/} @{$json->{Lines}});
$msg ||= "Could not understand 'BOSH config' json output:\n\n[36m$out[0m";
$msg = "No $label found" if $msg eq 'No config';
die $msg."\n";
}
bug("BOSH returned multiple entries for $label - Genesis doesn't know how to process this")
if (@{$json->{Tables}} != 1 || @{$json->{Tables}[0]{Rows}} != 1);
my $config = $json->{Tables}[0]{Rows}[0]{content};
die "No $label contents\n" unless defined($config);
push @config_contents, $config;
}
my $config;
if (scalar(@config_contents) > 1) {
($config, my $rc, my $err) = run(
{interactive => 0, stderr=>0},
'spruce merge --multi-doc --go-patch <(echo "$1")',
join("\n---\n", @config_contents)
);
bail("Failed to converge the active $type configurations: $err") if $rc;
} else {
$config = $config_contents[0]
}
mkfile_or_fail($path,$config);
return \@configs;
}
sub download_cloud_config {
my ($class, $env, $path,) = @_;
waiting_on STDERR "Downloading cloud config from '#M{$env}' BOSH director...";
my $configs = $class->download_config($env,$path,"cloud","default");
bail "#R{error!} No cloud-config defined on '#M{$env}' BOSH director\n" unless (-s $path);
explain STDERR "#G{ok}";
return $configs;
}
sub deploy {
my ($class, $env, %opts) = @_;
bug("Missing BOSH environment name in call to deploy()!!")
unless $env;
for my $o (qw(manifest deployment)) {
bug("Missing '$o' option in call to deploy()!!")
unless $opts{$o};
}
$opts{flags} ||= [];
push(@{$opts{flags}}, "-l", $opts{vars_file}) if ($opts{vars_file});
return _bosh({ interactive => 1, passfail => 1 },
'bosh', '-e', $env, '-d', $opts{deployment},
$ENV{BOSH_NON_INTERACTIVE} ? '-n' : (),
'deploy', @{$opts{flags}}, $opts{manifest});
}
sub alias {
my ($class, $alias) = @_;
_bosh({ interactive => 1, onfailure => "Could not create BOSH alias for '$_[0]'" },
'bosh', 'alias-env', $alias);
}
sub run_errand {
my ($class, $env, %opts) = @_;
bug("Missing BOSH environment name in call to run_errand()!!")
unless $env;
for my $o (qw(deployment errand)) {
bug("Missing '$o' option in call to run_errand()!!")
unless $opts{$o};
}
_bosh({ interactive => 1, onfailure => "Failed to run errand '$opts{errand}' ($opts{deployment} deployment on $env BOSH director)" },
'bosh', '-n', '-e', $env, '-d', $opts{deployment}, 'run-errand', $opts{errand});
return 1;
}
sub stemcells {
my ($class, $env) = @_;
return lines(_bosh(
q<bosh -e "$1" stemcells --json | jq -r '.Tables[0].Rows[] | "\(.os)@\(.version)" | sub("[^0-9]+$";"")'>,
$env
));
}
1;
=head1 NAME
Genesis::BOSH
=head1 DESCRIPTION
This module provides (namespaced) wrapper functions for running commands
against a BOSH director, with the appropriate error and environment
handling.
All of these functions should be called as class methods, like so:
use Genesis::BOSH;
Genesis::BOSH->ping('https://10.0.0.4:25555')
or die "Unable to talk to BOSH!\n";
Most of these functions will die() if they encounter any issues running the
given BOSH command (with C<ping()> being a notable exception!)
=head1 CLASS METHODS
=head2 environment_variables($alias)
Returns a hash ref of environment variables and values corresponding to the
BOSH Director matching the specified alias name. Returns an empty hash ref if
no alias matches or if the ~/.bosh/config file is unreadable.
=head2 ping($env)
Try to contact the BOSH director at C<$env>, and report success or failure.
=head2 env($env)
Similar to C<ping>, this tries to contact the BOSH director at C<$env>, and
reports success or failure. However, this function prints its output to the
user, so it is useful in presenting the environment's details.
=head2 create_env($manifest, %opts)
Run a C<bosh create-env> of the given manifest. The only supported option
is B<state>, which holds the path to the persistent state file, and is
required. If the C<$BOSH_NON_INTERACTIVE> environment variable is set, this
will run with a C<-n> flag as well, to avoid prompting the user.
=head2 download_cloud_config($env, $file)
Downloads the current cloud-config from the BOSH director, and stores it in
the given C<$file>.
=head2 deploy($manifest, %opts)
Deploy the given C<$manfiest> to a BOSH director. Supported options are:
=over
=item target
The name or URL of the BOSH director to deploy to. This option is required.
=item deployment
The name of the deployment to deploy. This option is required, and must
match the C<name> property in C<$manifest>.
=item options
An arrayref of flags and their values, to pass through to the underlying
C<bosh> command invocation.
=back
=head2 alias($env)
Creates a new BOSH alias via C<bosh alias-env>. This function takes no
arguments, and expects all of the settings for things like IP, CA
certificate, etc. to be found in the environment variables.
This is probably bad and we should change it. (FIXME)
=head2 run_errand($env, $deployment, $errand)
Runs the named C<$errand> against the given C<$deployment>, and bails if the
errand doesn't succeed.
=head1 INTERNAL FUNCTIONS
These functions are implementation details of this module, and should not
concern anyone else, ever.
=head2 _bosh(...)
This is a wrapper function to Genesis::Utils's C<run()> function. It
does things that are useful if you are running the C<bosh> CLI, and not
anything else. Specifically, it:
=over
=item 1.
Clears the https proxy environment variables because this does bad things to
BOSH. It clears out both the lowercase (https_proxy) and upercase
(HTTPS_PROXY) versions.
=item 2.
Clears the BOSH_ENVIRONENT, BOSH_CA_CERT, BOSH_CLIENT, and
BOSH_CLIENT_SECRET unless explicitly sent in via the C<env> option. This
allows B<Genesis> to specify these values when needed, but removes any
exposure to these set from the caller's environment.
=item 3.
Runs the command with the correct version of the BOSH CLI executable. The
command may or may not be provided with C<bosh> as the first item; if it
does, it is replaced with the correct path, if not, the correct path is
prepended to the command before it is called.
=back
Otherwise it is exactly the same as the C<run> command, and supports all the
same syntax and options -- see C<run>'s documentation for more details.
Note that you can leave off the actual "bosh" token in your command, and
C<_bosh()> will do what you mean:
# this:
_bosh('bosh deploy -d concourse manifest.yml');
# is equivalent to:
_bosh('deploy -d concourse manifest.yml');
This comes in handy because sometimes it looks weird to omit the leading
C<bosh> token, as in:
_bosh({ onfailure => 'oops; stuff broke' },
'-e', $env, '-n', @etc);
=cut
| starkandwayne/genesis | lib/Genesis/BOSH.pm | Perl | mit | 12,640 |
#!/usr/bin/perl
#use strict;
use warnings;
=begin comment
author bupton
This file is still broken, because hackathon, but the project moved on without it. Still, does do some good, fast parsing
and searches through files to match up data and turns it into a JSON format. I stopped right at the end, when it just needed
another layer of data structure, so it would be able to output a five position array of gene data, instead of one big string.
=end comment
=cut
use JSON; #Dependency: This needs a module installed from the CPAN
#Declare variables, because I might like Perl, but I'm not a savage
my $fhIn = undef;
my $fhOut = undef;
my $inputFile = "./GSE40705_Pancreas_gene.txt"; #Should shift argv rather than hard code
my $compareFile = "./gene_lookup_GRCh38.tsv"; #The input for the second file that needs to be compared to line up symbol with insertion
my $outputFile = "./filterOutput.txt"; #Give user option to name file?
my $errOut = "./errorLog.txt"; #error logs are only for people that make mistakes
my %dataSet; #the hash to hold every row of data
my %chrSet; #the hash that holds the compared data, keyed by chromosome
my @index;
#Prepare file handles
open $fhIn, '<', $inputFile or die "Sorry, I couldn't open '$inputFile': $!\n";
open $fhOut, '>', $outputFile or die "Sorry, I couldn't create another file here\n";
while (my $row = <$fhIn>){
if($row =~ /^[\d]/){
$row =~ /([\S]+)\t(\S*)\t(\S*)\t(\S*)\t(\S*)\t(\S*)/;
if ($1 ne ""){ #just checking to be sure I caught a valid line
my $cluster = $1; #creating these variables in a loop is inefficient, but clarifies the code
my $isoForms = $2; #These variables are holding the values under the actual name in the table that Im reading in.
my $geneSymbol = $3;
my $rnaSeh = $4;
my $riboZero = $5;
my $total = $6;
# $dataSet{$geneSymbol}[0] = "$count"; #unused data field
# $dataSet{$geneSymbol}[1] = "$cluster"; #unused data field
# $dataSet{$geneSymbol}[2] = "$isoForms"; #unused data field
$dataSet{$geneSymbol}[0] = "$geneSymbol";
$dataSet{$geneSymbol}[3] = "$rnaSeh";
$dataSet{$geneSymbol}[4] = "$riboZero";
}
}
}
close $fhIn or die "Input close failed."; #now that ive built the hash, close to keep them from getting mixed up with stray inputs
open $fhIn, '<', $compareFile or die "Sorry, I couldn't open '$compareFile': $!\n";
while (my $row = <$fhIn>) #read line by line
{
if($row =~ /^Symbol/)
{ #catch the first line of this file and do nothing
}elsif($row =~ /^\w/)
{ #use a regex to parse the text and put it into separate variables, like an explode or split method
$row =~ /(\w+)\t(\w+)\t(\d*)\t(\d*)/;
if ( length $4 )
{ #check to see if we have all five data fields populated, take no action if they aren't
my $chromosome;
my $geneSymbol = $1; #this is local and is not the same as earlier variable, but its the same data field
$chromosome = "$2"; #save the value to a local variable for clarity, not efficiency
$dataSet{$geneSymbol}[1] = "$3"; #start
$dataSet{$geneSymbol}[2] = "$4"; #length
if (!exists $chrSet{$chromosome})
{ #identifies the hash to the chromosome name 1-19, x, y so we can identify all data to the owning chromosome
$chrSet{$chromosome} = [];
}
my @annot; #create local variable to store all data associated with each line from both files
# This pushes the set of data into the basic array, that can be formatted neatly for JSON output
push (@annot, ($dataSet{$geneSymbol}[0], $dataSet{$geneSymbol}[1], $dataSet{$geneSymbol}[2], $dataSet{$geneSymbol}[3]));
push (@annot, ($dataSet{$geneSymbol}[4]));
# push (@index, (@annot)); #this is a key area to fix, the data structure isn't layered enough and needs another array
push ($chrSet{$chromosome}, (@annot));
}
}
}
my $JSON;
$JSON = JSON->new->allow_nonref; #requires JSON module from CPAN archive
my $json_text = $JSON->encode( $chrSet{'1'} ); #this should iterate through each chromosome number, needs a for loop
print $fhOut "$json_text\n";
close $fhIn or die "Input close failed.";
close $fhOut or die "Output close failed";
| NCBI-Hackathons/rnaseqview | JSONTool.pl | Perl | cc0-1.0 | 4,130 |
=head1 LICENSE
Copyright [1999-2016] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=head1 CONTACT
Please email comments or questions to the public Ensembl
developers list at <http://lists.ensembl.org/mailman/listinfo/dev>.
Questions may also be sent to the Ensembl help desk at
<http://www.ensembl.org/Help/Contact>.
=head1 NAME
=head1 SYNOPSIS
=head1 DESCRIPTION
=cut
package Bio::EnsEMBL::Funcgen::ReadFile;
use strict;
use warnings;
use Bio::EnsEMBL::Utils::Exception qw( throw deprecate );
use Bio::EnsEMBL::Funcgen::GenericGetSetFunctionality qw(
_generic_get_or_set
_generic_set
_generic_get
_generic_fetch
);
use Role::Tiny::With;
with 'Bio::EnsEMBL::Funcgen::GenericConstructor';
sub _constructor_parameters {
return {
dbID => 'dbID',
adaptor => 'adaptor',
name => 'name',
is_paired_end => 'is_paired_end',
file_size => 'file_size',
number_of_reads => 'number_of_reads',
read_length => 'read_length',
md5sum => 'md5sum',
file => 'file',
notes => 'notes',
analysis_id => '_analysis_id',
analysis => 'set_Analysis',
};
}
sub dbID { return shift->_generic_get_or_set('dbID', @_); }
sub adaptor {return shift->_generic_get_or_set('adaptor', @_);}
=head2 name
Example : my $name = $peak_calling->name;
Description: Accessor for the name of the read file.
Returntype : String
Exceptions : None
Caller : general
Status : Stable
=cut
sub name { return shift->_generic_get_or_set('name', @_); }
sub is_paired_end { return shift->_generic_get_or_set('is_paired_end', @_); }
=head2 file_size
Example : my $file_size = $peak_calling->file_size;
Description: Accessor for the file_size of the read file.
Returntype : Int
Exceptions : None
Caller : general
Status : Stable
=cut
sub file_size { return shift->_generic_get_or_set('file_size', @_); }
=head2 read_length
Example : my $read_length = $read_file->read_length;
Description: Accessor for the read_length of the read file.
Returntype : Int
Exceptions : None
Caller : general
Status : Stable
=cut
sub read_length { return shift->_generic_get_or_set('read_length', @_); }
=head2 md5sum
Example : my $md5sum = $read_file->md5sum;
Description: Accessor for the md5sum of the data file.
Returntype : String
Exceptions : None
Caller : general
Status : Stable
=cut
sub md5sum { return shift->_generic_get_or_set('md5sum', @_); }
sub file { return shift->_generic_get_or_set('file', @_); }
sub number_of_reads { return shift->_generic_get_or_set('number_of_reads', @_); }
sub notes { return shift->_generic_get_or_set('notes', @_); }
sub _analysis_id { return shift->_generic_get_or_set('_analysis_id', @_); }
sub paired_end_tag {
my $self = shift;
if (! $self->is_paired_end) {
throw("Not a paired end read file!");
}
my $read_file_experimental_configuration = $self->get_ReadFileExperimentalConfiguration;
my $paired_end_tag = $read_file_experimental_configuration->paired_end_tag;
return $paired_end_tag;
}
sub get_mate_ReadFile {
my $self = shift;
if (! $self->is_paired_end) {
throw("Not a paired end read file!");
}
my $paired_end_tag = $self->paired_end_tag;
my $mate_paired_end_tag = 3 - $paired_end_tag;
my $read_file_experimental_configuration = $self->get_ReadFileExperimentalConfiguration;
my $pairs_read_file_experimental_configuration
= Bio::EnsEMBL::Funcgen::ReadFileExperimentalConfiguration->new(
-technical_replicate => $read_file_experimental_configuration->technical_replicate,
-biological_replicate => $read_file_experimental_configuration->biological_replicate,
-paired_end_tag => $mate_paired_end_tag,
-multiple => $read_file_experimental_configuration->multiple,
-experiment_id => $read_file_experimental_configuration->experiment_id,
);
my $read_file_adaptor
= $self->adaptor->db->get_ReadFileAdaptor;
my $read_file_mate
= $read_file_adaptor
->fetch_by_ReadFileExperimentalConfiguration(
$pairs_read_file_experimental_configuration
);
if (! defined $read_file_mate) {
throw("Couldn't find pair!");
}
return $read_file_mate;
}
sub get_FastQC {
my $self = shift;
my $fastqc_adaptor = $self->adaptor->db->get_FastQCAdaptor;
if (! defined $fastqc_adaptor) {
throw("Couldn't get an FastQCAdaptor!");
}
my $fastqc = $fastqc_adaptor->fetch_by_ReadFile($self);
return $fastqc;
}
=head2 get_Analysis
Example : my $analysis = $read_file->get_Analysis;
Description: Getter for the analysis of the read file. This is not an in
silico analysis, but the the protocol that was used to
generate the reads.
Returntype : Bio::EnsEMBL::Analysis
Exceptions : None
Caller : general
Status : Stable
=cut
sub get_Analysis {
return shift->_generic_get('analysis');
}
=head2 get_Analysis
Example : $read_file->set_Analysis($analysis);
Description: Setter for the analysis of the read file. The analysis should
represent the protocol that was used to generate the reads.
Returntype : None
Exceptions : None
Caller : general
Status : Stable
=cut
sub set_Analysis {
my $self = shift;
my $obj = shift;
return $self->_generic_set('analysis', 'Bio::EnsEMBL::Analysis', $obj);
}
=head2 get_ReadFileExperimentalConfiguration
Example : my $read_file_experimental_configuration
= $read_file->get_ReadFileExperimentalConfiguration;
Description: Getter for the ReadFileExperimentalConfiguration object.
Returntype : Bio::EnsEMBL::Funcgen::ReadFileExperimentalConfiguration
Exceptions : None
Caller : general
Status : Stable
=cut
sub get_ReadFileExperimentalConfiguration {
my $self = shift;
my $read_file_experimental_configuration_adaptor
= $self->adaptor->db->get_ReadFileExperimentalConfigurationAdaptor;
my $read_file_experimental_configurations
= $read_file_experimental_configuration_adaptor
->fetch_all_by_read_file_id(
$self->dbID
);
return $read_file_experimental_configurations->[0];
}
=head2 set_ReadFileExperimentalConfiguration
Example : $read_file->fetch_ReadFileExperimentalConfiguration(
$read_file_experimental_configuration
);
Description: Setter for the ReadFileExperimentalConfiguration object.
Returntype : None
Exceptions : None
Caller : general
Status : Stable
=cut
sub set_ReadFileExperimentalConfiguration {
my $self = shift;
my $obj = shift;
return $self->_generic_set(
'read_file_experimental_configuration',
'Bio::EnsEMBL::Funcgen::ReadFileExperimentalConfiguration',
$obj
);
}
=head2 summary_as_hash
Example : $summary = $read_file->summary_as_hash;
Description : Returns summary in a hash reference.
Returns : Hashref of descriptive strings
Status : Intended for internal use (REST)
=cut
sub summary_as_hash {
my $self = shift;
# Optional parameter to avoid infinite recursions when two objects
# reference each other.
#
my $suppress_link = shift;
$suppress_link = '' if (! defined $suppress_link);
my $summary = {
name => $self->name,
};
if ($suppress_link ne 'fastqc') {
my $fastqc = $self->get_FastQC;
if (defined $fastqc) {
$summary->{'fastqc'} = $fastqc->summary_as_hash('read_file');
}
}
return $summary;
}
1;
| Ensembl/ensembl-funcgen | modules/Bio/EnsEMBL/Funcgen/ReadFile.pm | Perl | apache-2.0 | 8,288 |
#
# Copyright 2016 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package centreon::common::cisco::standard::snmp::mode::environment;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
my %map_type_mon = (
1 => 'oldAgs',
2 => 'ags',
3 => 'c7000',
4 => 'ci',
6 => 'cAccessMon',
7 => 'cat6000',
8 => 'ubr7200',
9 => 'cat4000',
10 => 'c10000',
11 => 'osr7600',
12 => 'c7600',
13 => 'c37xx',
14 => 'other'
);
my $thresholds = {
fan => [
['unknown', 'UNKNOWN'],
['down', 'CRITICAL'],
['up', 'OK'],
['normal', 'OK'],
['warning', 'WARNING'],
['critical', 'CRITICAL'],
['shutdown', 'CRITICAL'],
['not present', 'OK'],
['not functioning', 'WARNING'],
],
psu => [
['^off*', 'WARNING'],
['failed', 'CRITICAL'],
['onButFanFail|onButInlinePowerFail', 'WARNING'],
['on', 'OK'],
['normal', 'OK'],
['warning', 'WARNING'],
['critical', 'CRITICAL'],
['shutdown', 'CRITICAL'],
['not present', 'OK'],
['not functioning', 'WARNING'],
],
temperature => [
['normal', 'OK'],
['warning', 'WARNING'],
['critical', 'CRITICAL'],
['shutdown', 'CRITICAL'],
['not present', 'OK'],
['not functioning', 'WARNING'],
],
voltage => [
['normal', 'OK'],
['warning', 'WARNING'],
['critical', 'CRITICAL'],
['shutdown', 'CRITICAL'],
['not present', 'OK'],
['not functioning', 'WARNING'],
],
module => [
['unknown|mdr', 'UNKNOWN'],
['disabled|okButDiagFailed|missing|mismatchWithParent|mismatchConfig|dormant|outOfServiceAdmin|outOfServiceEnvTemp|powerCycled|okButPowerOverWarning|okButAuthFailed|fwMismatchFound|fwDownloadFailure', 'WARNING'],
['failed|diagFailed|poweredDown|powerDenied|okButPowerOverCritical', 'CRITICAL'],
['boot|selfTest|poweredUp|syncInProgress|upgrading|fwDownloadSuccess|ok', 'OK'],
],
physical => [
['other', 'UNKNOWN'],
['incompatible|unsupported', 'CRITICAL'],
['supported', 'OK'],
],
sensor => [
['ok', 'OK'],
['unavailable', 'OK'],
['nonoperational', 'CRITICAL'],
],
};
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"exclude:s" => { name => 'exclude' },
"absent-problem:s" => { name => 'absent' },
"component:s" => { name => 'component', default => '.*' },
"no-component:s" => { name => 'no_component' },
"threshold-overload:s@" => { name => 'threshold_overload' },
"warning:s@" => { name => 'warning' },
"critical:s@" => { name => 'critical' },
});
$self->{components} = {};
$self->{no_components} = undef;
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (defined($self->{option_results}->{no_component})) {
if ($self->{option_results}->{no_component} ne '') {
$self->{no_components} = $self->{option_results}->{no_component};
} else {
$self->{no_components} = 'critical';
}
}
$self->{overload_th} = {};
foreach my $val (@{$self->{option_results}->{threshold_overload}}) {
next if (!defined($val) || $val eq '');
my @values = split (/,/, $val);
if (scalar(@values) < 3) {
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'.");
$self->{output}->option_exit();
}
my ($section, $instance, $status, $filter);
if (scalar(@values) == 3) {
($section, $status, $filter) = @values;
$instance = '.*';
} else {
($section, $instance, $status, $filter) = @values;
}
if ($section !~ /^(temperature|fan|psu)$/) {
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload section '" . $val . "'.");
$self->{output}->option_exit();
}
if ($self->{output}->is_litteral_status(status => $status) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload status '" . $val . "'.");
$self->{output}->option_exit();
}
$self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section}));
push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status, instance => $instance };
}
$self->{numeric_threshold} = {};
foreach my $option (('warning', 'critical')) {
foreach my $val (@{$self->{option_results}->{$option}}) {
if ($val !~ /^(.*?),(.*?),(.*)$/) {
$self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'.");
$self->{output}->option_exit();
}
my ($section, $regexp, $value) = ($1, $2, $3);
if ($section !~ /(temperature|voltage|sensor)/i) {
$self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "' (type must be: temperature, voltage or sensor).");
$self->{output}->option_exit();
}
my $position = 0;
if (defined($self->{numeric_threshold}->{$section})) {
$position = scalar(@{$self->{numeric_threshold}->{$section}});
}
if (($self->{perfdata}->threshold_validate(label => $option . '-' . $section . '-' . $position, value => $value)) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong $option threshold '" . $value . "'.");
$self->{output}->option_exit();
}
$self->{numeric_threshold}->{$section} = [] if (!defined($self->{numeric_threshold}->{$section}));
push @{$self->{numeric_threshold}->{$section}}, { label => $option . '-' . $section . '-' . $position, threshold => $option, regexp => $regexp };
}
}
}
sub run {
my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
my $oid_entPhysicalDescr = '.1.3.6.1.2.1.47.1.1.1.1.2';
my $oid_ciscoEnvMonPresent = ".1.3.6.1.4.1.9.9.13.1.1";
my $snmp_request = [ { oid => $oid_entPhysicalDescr }, { oid => $oid_ciscoEnvMonPresent } ];
my @components = ('fan', 'psu', 'temperature', 'voltage', 'module', 'physical', 'sensor');
foreach (@components) {
if (/$self->{option_results}->{component}/) {
my $mod_name = "centreon::common::cisco::standard::snmp::mode::components::$_";
centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $mod_name,
error_msg => "Cannot load module '$mod_name'.");
my $func = $mod_name->can('load');
$func->(request => $snmp_request);
}
}
if (scalar(@{$snmp_request}) == 2) {
$self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'.");
$self->{output}->option_exit();
}
$self->{results} = $self->{snmp}->get_multiple_table(oids => $snmp_request);
$self->{output}->output_add(long_msg => sprintf("Environment type: %s",
defined($self->{results}->{$oid_ciscoEnvMonPresent}->{$oid_ciscoEnvMonPresent . '.0'}) && defined($map_type_mon{$self->{results}->{$oid_ciscoEnvMonPresent}->{$oid_ciscoEnvMonPresent . '.0'}} ) ?
$map_type_mon{$self->{results}->{$oid_ciscoEnvMonPresent}->{$oid_ciscoEnvMonPresent . '.0'}} : 'unknown'));
foreach (@components) {
if (/$self->{option_results}->{component}/) {
my $mod_name = "centreon::common::cisco::standard::snmp::mode::components::$_";
my $func = $mod_name->can('check');
$func->($self);
}
}
my $total_components = 0;
my $display_by_component = '';
my $display_by_component_append = '';
foreach my $comp (sort(keys %{$self->{components}})) {
# Skipping short msg when no components
next if ($self->{components}->{$comp}->{total} == 0 && $self->{components}->{$comp}->{skip} == 0);
$total_components += $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip};
my $count_by_components = $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip};
$display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . '/' . $count_by_components . ' ' . $self->{components}->{$comp}->{name};
$display_by_component_append = ', ';
}
$self->{output}->output_add(severity => 'OK',
short_msg => sprintf("All %s components are ok [%s].",
$total_components,
$display_by_component)
);
if (defined($self->{option_results}->{no_component}) && $total_components == 0) {
$self->{output}->output_add(severity => $self->{no_components},
short_msg => 'No components are checked.');
}
$self->{output}->display();
$self->{output}->exit();
}
sub check_exclude {
my ($self, %options) = @_;
if (defined($options{instance})) {
if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) {
$self->{components}->{$options{section}}->{skip}++;
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance."));
return 1;
}
} elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) {
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section."));
return 1;
}
return 0;
}
sub absent_problem {
my ($self, %options) = @_;
if (defined($self->{option_results}->{absent}) &&
$self->{option_results}->{absent} =~ /(^|\s|,)($options{section}(\s*,|$)|${options{section}}[^,]*#\Q$options{instance}\E#)/) {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => sprintf("Component '%s' instance '%s' is not present",
$options{section}, $options{instance}));
}
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance (not present)"));
$self->{components}->{$options{section}}->{skip}++;
return 1;
}
sub get_severity_numeric {
my ($self, %options) = @_;
my $status = 'OK'; # default
my $thresholds = { warning => undef, critical => undef };
my $checked = 0;
if (defined($self->{numeric_threshold}->{$options{section}})) {
my $exits = [];
foreach (@{$self->{numeric_threshold}->{$options{section}}}) {
if ($options{instance} =~ /$_->{regexp}/i) {
push @{$exits}, $self->{perfdata}->threshold_check(value => $options{value}, threshold => [ { label => $_->{label}, exit_litteral => $_->{threshold} } ]);
$thresholds->{$_->{threshold}} = $self->{perfdata}->get_perfdata_for_output(label => $_->{label});
$checked = 1;
}
}
$status = $self->{output}->get_most_critical(status => $exits) if (scalar(@{$exits}) > 0);
}
return ($status, $thresholds->{warning}, $thresholds->{critical}, $checked);
}
sub get_severity {
my ($self, %options) = @_;
my $status = 'UNKNOWN'; # default
if (defined($self->{overload_th}->{$options{section}})) {
foreach (@{$self->{overload_th}->{$options{section}}}) {
if ($options{value} =~ /$_->{filter}/i &&
(!defined($options{instance}) || $options{instance} =~ /$_->{instance}/)) {
$status = $_->{status};
return $status;
}
}
}
my $label = defined($options{label}) ? $options{label} : $options{section};
foreach (@{$thresholds->{$label}}) {
if ($options{value} =~ /$$_[0]/i) {
$status = $$_[1];
return $status;
}
}
return $status;
}
1;
__END__
=head1 MODE
Check environment (Power Supplies, Fans, Temperatures, Voltages, Modules, Physical Entities).
=over 8
=item B<--component>
Which component to check (Default: '.*').
Can be: 'fan', 'psu', 'temperature', 'voltage', 'module', 'physical', 'sensor'.
=item B<--exclude>
Exclude some parts (comma seperated list) (Example: --exclude=fan)
Can also exclude specific instance: --exclude=fan#1#,psu#3#
=item B<--absent-problem>
Return an error if an entity is not 'present' (default is skipping) (comma seperated list)
Can be specific or global: --absent-problem=fan#1#
=item B<--no-component>
Return an error if no compenents are checked.
If total (with skipped) is 0. (Default: 'critical' returns).
=item B<--threshold-overload>
Set to overload default threshold values (syntax: section,status,regexp)
It used before default thresholds (order stays).
Example: --threshold-overload='fan,CRITICAL,^(?!(up|normal)$)'
=item B<--warning>
Set warning threshold for temperatures, voltages, sensors (syntax: type,regexp,threshold)
Example: --warning='temperature,.*,30'
=item B<--critical>
Set critical threshold for temperatures, voltages, sensors (syntax: type,regexp,threshold)
Example: --critical='temperature,.*,40'
=back
=cut
| bcournaud/centreon-plugins | centreon/common/cisco/standard/snmp/mode/environment.pm | Perl | apache-2.0 | 14,982 |
package KinoSearch::Util::MemoryPool;
use KinoSearch;
1;
__END__
__BINDING__
Clownfish::Binding::Perl::Class->register(
parcel => "KinoSearch",
class_name => "KinoSearch::Util::MemoryPool",
bind_constructors => ["new"],
);
__COPYRIGHT__
Copyright 2005-2011 Marvin Humphrey
This program is free software; you can redistribute it and/or modify
under the same terms as Perl itself.
| gitpan/KinoSearch | lib/KinoSearch/Util/MemoryPool.pm | Perl | apache-2.0 | 407 |
=head1 LICENSE
Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
Copyright [2016-2020] EMBL-European Bioinformatics Institute
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=cut
package XrefParser::RFAMParser;
use strict;
use warnings;
use Carp;
use DBI;
use base qw( XrefParser::BaseParser );
use Bio::EnsEMBL::Registry;
sub run_script {
my ($self, $ref_arg) = @_;
my $source_id = $ref_arg->{source_id};
my $species_id = $ref_arg->{species_id};
my $species_name = $ref_arg->{species};
my $file = $ref_arg->{file};
my $verbose = $ref_arg->{verbose};
my $core_db = $ref_arg->{dba};
my $dbi = $ref_arg->{dbi};
$dbi = $self->dbi unless defined $dbi;
if((!defined $source_id) or (!defined $species_id) or (!defined $file) ){
croak "Need to pass source_id, species_id and file as pairs";
}
$verbose |=0;
my $wget;
my $user = "ensro";
my $host;
my $port = 3306;
my $dbname;
my $pass;
if($file =~ /wget[=][>](\S+?)[,]/){
$wget = $1;
}
if($file =~ /host[=][>](\S+?)[,]/){
$host = $1;
}
if($file =~ /port[=][>](\S+?)[,]/){
$port = $1;
}
if($file =~ /dbname[=][>](\S+?)[,]/){
$dbname = $1;
}
if($file =~ /pass[=][>](\S+?)[,]/){
$pass = $1;
}
if($file =~ /user[=][>](\S+?)[,]/){
$user = $1;
}
#get direct RFAM xrefs from core
my $registry = "Bio::EnsEMBL::Registry";
my $dba;
#get the species name
my %id2name = $self->species_id2name($dbi);
if (defined $species_name) { push @{$id2name{$species_id}}, $species_name; }
if (!defined $id2name{$species_id}) { next; }
$species_name = $id2name{$species_id}[0];
if ($host) {
$dba = Bio::EnsEMBL::DBSQL::DBAdaptor->new(
'-host' => $host,
'-user' => $user,
'-pass' => $pass,
'-dbname' => $dbname,
'-port' => $port,
'-species' => $species_name,
'-group' => 'core',
);
} elsif (defined $core_db) {
$dba = $core_db;
} else {
$registry->load_registry_from_multiple_dbs(
{
'-host' => 'mysql-ens-sta-1',
'-port' => 4519,
'-user' => 'ensro',
},
);
$dba = $registry->get_DBAdaptor($species_name, 'core');
}
my $rfam_sql = "select distinct t.stable_id, hit_name from analysis a join transcript t on (a.analysis_id = t.analysis_id and a.logic_name like 'ncrna%' and t.biotype != 'miRNA') join exon_transcript et on (t.transcript_id = et.transcript_id) join supporting_feature sf on (et.exon_id = sf.exon_id and sf.feature_type = 'dna_align_feature' ) join dna_align_feature df on (sf.feature_id = df.dna_align_feature_id) order by hit_name";
my $sth = $dba->dbc->prepare($rfam_sql);
$sth->execute();
#hash keyed on RFAM accessions, value is an array of ensembl transcript stable_ids
my %rfam_transcript_stable_ids;
while (my ($stable_id, $hit_name) = $sth->fetchrow_array ) {
my $rfam_id;
if ($hit_name =~ /^(RF\d+)/) {
$rfam_id = $1;
}
if ($rfam_id) {
push @{$rfam_transcript_stable_ids{$rfam_id}}, $stable_id;
}
}
$sth->finish;
my @lines;
if (defined $wget) {
my $ua = LWP::UserAgent->new();
$ua->timeout(10);
$ua->env_proxy();
my $request = HTTP::Request->new(GET => $wget);
my $response = $ua->request($request);
if ( !$response->is_success() ) {
warn($response->status_line);
return 1;
}
@lines = split(/\n\n\n/, $response->decoded_content);
} else {
my $file_io = $self->get_filehandle($file);
if ( !defined $file_io ) {
print "ERROR: Can't open RFAM file $file\n";
return 1;
}
my $temp_line;
while (my $line = $file_io->getline()) {
if ($line =~ /\/\//) {
push @lines, $temp_line;
$temp_line = '';
} else {
$temp_line .= $line . "\n";
}
}
}
my @xrefs;
my $xref_count = 0;
my $direct_count = 0;
while (my $entry = shift @lines) {
my $xref;
chomp $entry;
next if (!$entry);
my ($accession) = $entry =~ /#=GF\sAC\s+(\w+)/ ;
my ($label) = $entry =~ /#=GF\sID\s+([^\n]+)/;
my ($description) = $entry =~ /#=GF\sDE\s+([^\n]+)/;
if ($accession) {
if (exists($rfam_transcript_stable_ids{$accession})){
#add xref
my $xref_id = $self->add_xref({ acc => $accession,
version => 0,
label => $label || $accession ,
desc => $description,
source_id => $source_id,
species_id => $species_id,
dbi => $dbi,
info_type => "DIRECT"} );
my @transcript_stable_ids = @{$rfam_transcript_stable_ids{$accession}};
foreach my $stable_id (@transcript_stable_ids){
$self->add_direct_xref($xref_id, $stable_id, "Transcript", "", $dbi);
$direct_count++;
}
$xref_count++;
}
}
}
print "Added $xref_count RFAM xrefs and $direct_count direct xrefs\n" if($verbose);
return 0; # successfull
}
1;
| james-monkeyshines/ensembl | misc-scripts/xref_mapping/XrefParser/RFAMParser.pm | Perl | apache-2.0 | 5,597 |
# Copyright 2020, Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
package Google::Ads::GoogleAds::V10::Resources::DynamicSearchAdsSearchTermView;
use strict;
use warnings;
use base qw(Google::Ads::GoogleAds::BaseEntity);
use Google::Ads::GoogleAds::Utils::GoogleAdsHelper;
sub new {
my ($class, $args) = @_;
my $self = {
hasMatchingKeyword => $args->{hasMatchingKeyword},
hasNegativeKeyword => $args->{hasNegativeKeyword},
hasNegativeUrl => $args->{hasNegativeUrl},
headline => $args->{headline},
landingPage => $args->{landingPage},
pageUrl => $args->{pageUrl},
resourceName => $args->{resourceName},
searchTerm => $args->{searchTerm}};
# Delete the unassigned fields in this object for a more concise JSON payload
remove_unassigned_fields($self, $args);
bless $self, $class;
return $self;
}
1;
| googleads/google-ads-perl | lib/Google/Ads/GoogleAds/V10/Resources/DynamicSearchAdsSearchTermView.pm | Perl | apache-2.0 | 1,402 |
#
# Copyright 2022 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package network::viptela::snmp::mode::components::led;
use strict;
use warnings;
sub load {}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking led");
$self->{components}->{led} = { name => 'led', total => 0, skip => 0 };
return if ($self->check_filter(section => 'led'));
my ($exit, $warn, $crit, $checked);
foreach (@{$self->{results}}) {
next if ($_->{type} ne 'led');
my $instance = 'led.' . $_->{name};
next if ($self->check_filter(section => 'led', instance => $instance));
$self->{components}->{led}->{total}++;
$self->{output}->output_add(
long_msg => sprintf(
"led '%s' status is '%s' [instance: %s]",
$_->{name},
$_->{status},
$instance
)
);
$exit = $self->get_severity(label => 'default', section => 'led', value => $_->{status});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf("led '%s' status is '%s'", $_->{name}, $_->{status})
);
}
}
}
1;
| centreon/centreon-plugins | network/viptela/snmp/mode/components/led.pm | Perl | apache-2.0 | 1,998 |
package Hanjie::GridController;
use strict;
use integer;
use Carp;
use Data::Dumper;
use Hanjie::Grid;
use Hanjie::DrawSimple;
use Hanjie::Row;
use Hanjie::Column;
sub new { my ($proto) = @_;
my ($self, $class);
$class = ref($proto) || $proto;
$self = { _rows => [],
_columns => []
};
bless($self, $class);
return $self;
}
sub width { my ($self) = @_;
return scalar @{$self->{_columns}};
}
sub height { my ($self) = @_;
return scalar @{$self->{_rows}};
}
sub get { my ($self, $i, $j) = @_;
return $self->{_grid}{$i}{$j};
}
sub set { my ($self, $i, $j, $value) = @_;
$self->{_grid}{$i}{$j} = $value;
}
sub grid { my ($self) = @_;
return $self->{_grid};
}
sub addRow { my ($self, @clue) = @_;
push @{$self->{_rows}}, Hanjie::Row->new(1 + scalar @{$self->{_rows}}, @clue);
}
sub addCol { my ($self, @clue) = @_;
push @{$self->{_columns}}, Hanjie::Column->new(1 + scalar @{$self->{_columns}}, @clue);
}
sub OneScan { my ($self) = @_;
my ($result, $r, $c);
$result = 0;
foreach $r (@{$self->{_rows}}) {
$result += $r->solve($self->grid());
}
foreach $c (@{$self->{_columns}}) {
$result += $c->solve($self->grid());
}
if ($result > 0) {
drawGrid($self->grid());
}
return $result;
}
sub solve { my ($self) = @_;
my ($result);
$self->{_grid} = Hanjie::Grid->new($self->width(), $self->height());
$result = $self->OneScan();
while ($result > 0) {
$result = $self->OneScan();
}
}
1;
| gavilancomun/hanjie-perl | GridController.pm | Perl | apache-2.0 | 1,474 |
package Search::Elasticsearch::Client::Direct::Indices;
$Search::Elasticsearch::Client::Direct::Indices::VERSION = '1.17';
use Moo;
with 'Search::Elasticsearch::Role::API';
with 'Search::Elasticsearch::Role::Client::Direct';
__PACKAGE__->_install_api('indices');
1;
=pod
=encoding UTF-8
=head1 NAME
Search::Elasticsearch::Client::Direct::Indices - A client for running index-level requests
=head1 VERSION
version 1.17
=head1 DESCRIPTION
This module provides methods to make index-level requests, such as
creating and deleting indices, managing type mappings, index settings,
warmers, index templates and aliases.
It does L<Search::Elasticsearch::Role::Client::Direct>.
=head1 INDEX METHODS
=head2 C<create()>
$result = $e->indices->create(
index => 'my_index' # required
body => { # optional
index settings
mappings
warmers
}
);
The C<create()> method is used to create an index. Optionally, index
settings, type mappings and index warmers can be added at the same time.
Query string parameters:
C<master_timeout>,
C<timeout>
See the L<create index docs|http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-create-index.html>
for more information.
=head2 C<get()>
$response = $e->indices->get(
index => 'index' | \@indices # optional
feature => 'feature' | \@features # optional
);
Returns the aliases, settings, mappings, and warmers for the specified indices.
The C<feature> parameter can be set to none or more of: C<_settings>, C<_mappings>,
C<_warmers> and C<_aliases>.
See the L<get index docs|http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-get-index.html>.
Query string parameters:
C<allow_no_indices>,
C<expand_wildcards>,
C<ignore_unavailable>,
C<local>
=head2 C<exists()>
$bool = $e->indices->exists(
index => 'index' | \@indices # required
);
The C<exists()> method returns C<1> or the empty string to indicate
whether the specified index or indices exist.
Query string parameters:
C<allow_no_indices>,
C<expand_wildcards>,
C<ignore_unavailable>,
C<local>
See the L<index exists docs|http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-indices-exists.html>
for more information.
=head2 C<delete()>
$response = $e->indices->delete(
index => 'index' | \@indices # required
);
The C<delete()> method deletes the specified indices.
Query string parameters:
C<allow_no_indices>,
C<expand_wildcards>,
C<ignore_unavailable>,
C<master_timeout>,
C<timeout>
See the L<delete index docs|http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-delete-index.html>
for more information.
=head2 C<close()>
$response = $e->indices->close(
index => 'index' | \@indices # required
);
The C<close()> method closes the specified indices, reducing resource usage
but allowing them to be reopened later.
Query string parameters:
C<allow_no_indices>,
C<expand_wildcards>,
C<ignore_unavailable>
C<master_timeout>,
C<timeout>
See the L<close index docs|http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-open-close.html>
for more information.
=head2 C<open()>
$response = $e->indices->open(
index => 'index' | \@indices # required
);
The C<open()> method opens closed indices.
Query string parameters:
C<allow_no_indices>,
C<expand_wildcards>,
C<ignore_unavailable>
C<master_timeout>,
C<timeout>
See the L<open index docs|http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-open-close.html>
for more information.
=head2 C<clear_cache()>
$response = $e->indices->clear_cache(
index => 'index' | \@indices # optional
);
The C<clear_cache()> method is used to clear the in-memory filter, fielddata,
or id cache for the specified indices.
Query string parameters:
C<allow_no_indices>,
C<expand_wildcards>,
C<fielddata>,
C<fields>,
C<filter>,
C<filter_cache>,
C<filter_keys>,
C<id>,
C<id_cache>,
C<ignore_unavailable>,
C<query_cache>,
C<recycler>
See the L<clear_cache docs|http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-clearcache.html>
for more information.
=head2 C<refresh()>
$response = $e->indices->refresh(
index => 'index' | \@indices # optional
);
The C<refresh()> method refreshes the specified indices (or all indices),
allowing recent changes to become visible to search. This process normally
happens automatically once every second by default.
Query string parameters:
C<allow_no_indices>,
C<expand_wildcards>,
C<force>,
C<ignore_unavailable>
See the L<refresh index docs|http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-refresh.html>
for more information.
=head2 C<flush()>
$response = $e->indices->flush(
index => 'index' | \@indices # optional
);
The C<flush()> method causes the specified indices (or all indices) to be
written to disk with an C<fsync>, and clears out the transaction log.
This process normally happens automatically.
Query string parameters:
C<allow_no_indices>,
C<expand_wildcards>,
C<force>,
C<full>,
C<ignore_unavailable>,
C<wait_if_ongoing>
See the L<flush index docs|http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-flush.html>
for more information.
=head2 C<optimize()>
$response = $e->indices->optimize(
index => 'index' | \@indices # optional
);
The C<optimize()> method rewrites all the data in an index into at most
C<max_num_segments>. This is a very heavy operation and should only be run
with care, and only on indices that are no longer being updated.
Query string parameters:
C<allow_no_indices>,
C<expand_wildcards>,
C<flush>,
C<ignore_unavailable>,
C<max_num_segments>,
C<only_expunge_deletes>,
C<wait_for_merge>
See the L<optimize index docs|http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-optimize.html>
for more information.
=head2 C<get_upgrade()>
$response = $e->indices->get_upgrade(
index => 'index' | \@indices # optional
);
The C<get_upgrade()> method returns information about which indices need to be
upgraded, which can be done with the C<upgrade()> method.
Query string parameters:
C<allow_no_indices>,
C<expand_wildcards>,
C<human>,
C<ignore_unavailable>
See the L<upgrade docs|http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-upgrade.html>
for more information.
=head2 C<upgrade()>
$response = $e->indices->upgrade(
index => 'index' | \@indices # optional
);
The C<upgrade()> method upgrades all segments in the specified indices to the latest format.
Query string parameters:
C<allow_no_indices>,
C<expand_wildcards>,
C<ignore_unavailable>,
C<wait_for_completion>
See the L<upgrade docs|http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-upgrade.html>
for more information.
=head1 MAPPING METHODS
=head2 C<put_mapping()>
$response = $e->indices->put_mapping(
index => 'index' | \@indices # optional,
type => 'type', # required
body => { mapping } # required
)
The C<put_mapping()> method is used to create or update a type
mapping on an existing index. Mapping updates are allowed to add new
fields, but not to overwrite or change existing fields.
For instance:
$response = $e->indices->put_mapping(
index => 'users',
type => 'user',
body => {
user => {
properties => {
name => { type => 'string' },
age => { type => 'integer' }
}
}
}
);
Query string parameters:
C<allow_no_indices>,
C<expand_wildcards>,
C<ignore_unavailable>,
C<ignore_conflicts>,
C<master_timeout>,
C<timeout>
See the L<put_mapping docs|http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-put-mapping.html>
for more information.
=head2 C<get_mapping()>
$result = $e->indices->get_mapping(
index => 'index' | \@indices # optional,
type => 'type' | \@types # optional
);
The C<get_mapping()> method returns the type definitions for one, more or
all types in one, more or all indices.
Query string parameters:
C<allow_no_indices>,
C<expand_wildcards>,
C<ignore_unavailable>,
C<local>
See the L<get_mapping docs|http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-get-mapping.html>
for more information.
=head2 C<get_field_mapping()>
$result = $e->indices->get_field_mapping(
index => 'index' | \@indices # optional,
type => 'type' | \@types # optional,
field => 'field' | \@fields # required
include_defaults => 0 | 1
);
The C<get_field_mapping()> method returns the field definitions for one, more or
all fields in one, more or all types and indices.
Query string parameters:
C<allow_no_indices>,
C<expand_wildcards>,
C<ignore_unavailable>,
C<include_defaults>,
C<local>
See the L<get_mapping docs|http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-get-field-mapping.html>
for more information.
=head2 C<exists_type()>
$bool = $e->indices->exists_type(
index => 'index' | \@indices # required,
type => 'type' | \@types # required
);
The C<exists_type()> method checks for the existence of all specified types
in all specified indices, and returns C<1> or the empty string.
Query string parameters:
C<allow_no_indices>,
C<expand_wildcards>,
C<ignore_unavailable>,
C<local>
See the L<exists_type docs|http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-types-exists.html>
for more information.
=head2 C<delete_mapping()>
$response = $e->indices->delete_mapping(
index => 'index' | \@indices # required,
type => 'type' | \@types # required
);
The C<delete_mapping()> method deletes the type mappings (and all documents of
that type) in all specified indices.
Query string parameters:
C<master_timeout>
See the L<delete_mapping docs|http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-delete-mapping.html>
for more information.
=head1 ALIAS METHODS
=head2 C<update_aliases()>
$response = $e->indices->update_aliases(
body => { actions } # required
);
The C<update_aliases()> method changes (by adding or removing) multiple
index aliases atomically. For instance:
$response = $e->indices->update_aliases(
body => {
actions => [
{ add => { alias => 'current', index => 'logs_2013_09' }},
{ remove => { alias => 'current', index => 'logs_2013_08' }}
]
}
);
Query string parameters:
C<master_timeout>,
C<timeout>
See the L<update_aliases docs|http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-aliases.html>
for more information.
=head2 C<get_aliases()>
$result = $e->indices->get_aliases(
index => 'index' | \@indices, # optional
alias => 'alias' | \@aliases # optional
);
The C<get_aliases()> method returns a list of aliases per index for all
the specified indices.
Query string parameters:
C<local>,
C<timeout>
See the L<get_aliases docs|http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-aliases.html>
for more information.
=head2 C<put_alias()>
$response = $e->indices->put_alias(
index => 'index' | \@indices, # required
name => 'alias', # required
body => { alias defn } # optional
);
The C<put_alias()> method creates an index alias. For instance:
$response = $e->indices->put_alias(
index => 'my_index',
name => 'twitter',
body => {
filter => { term => { user_id => 'twitter' }}
}
);
Query string parameters:
C<master_timeout>,
C<timeout>
See the L<put_alias docs|http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-aliases.html>
for more information.
=head2 C<get_alias()>
$result = $e->indices->get_alias(
index => 'index' | \@indices, # optional
name => 'alias' | \@aliases # optional
);
The C<get_alias()> method returns the alias definitions for the specified
aliases in the specified indices.
Query string parameters:
C<allow_no_indices>,
C<expand_wildcards>,
C<ignore_unavailable>,
C<local>
See the L<get_alias docs|http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-aliases.html>
for more information.
=head2 C<exists_alias()>
$bool = $e->indices->exists_alias(
index => 'index' | \@indices, # optional
name => 'alias' | \@aliases # optional
);
The C<exists_alias()> method returns C<1> or the empty string depending on
whether the specified aliases exist in the specified indices.
Query string parameters:
C<allow_no_indices>,
C<expand_wildcards>,
C<ignore_unavailable>,
C<local>
See the L<exists_alias docs|http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-aliases.html>
for more information.
=head2 C<delete_alias()>
$response = $e->indices->delete_alias(
index => 'index' | \@indices # required,
name => 'alias' | \@aliases # required
);
The C<delete_alias()> method deletes one or more aliases from one or more
indices.
Query string parameters:
C<master_timeout>,
C<timeout>
See the L<delete_alias docs|http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-aliases.html>
for more information.
=head1 SETTINGS METHODS
=head2 C<put_settings()>
$response = $e->indices->put_settings(
index => 'index' | \@indices # optional
body => { settings }
);
The C<put_settings()> method sets the index settings for the specified
indices or all indices. For instance:
$response = $e->indices->put_settings(
body => {
"index.refresh_interval" => -1
}
);
Query string parameters:
C<allow_no_indices>,
C<expand_wildcards>,
C<flat_settings>,
C<ignore_unavailable>,
C<master_timeout>
See the L<put_settings docs|http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-update-settings.html>
for more information.
=head2 C<get_settings()>
$result = $e->indices->get_settings(
index => 'index' | \@indices # optional
name => 'name' | \@names # optional
);
The C<get_settings()> method retrieves the index settings for the specified
indices or all indices.
Query string parameters:
C<allow_no_indices>,
C<expand_wildcards>,
C<flat_settings>,
C<ignore_unavailable>,
C<local>
See the L<get_settings docs|http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-get-settings.html>
for more information.
=head1 TEMPLATE METHODS
=head2 C<put_template()>
$response = $e->indices->put_template(
name => 'template' # required
body => { template defn } # required
);
The C<put_template()> method is used to create or update index templates.
Query string parameters:
C<create>,
C<flat_settings>,
C<master_timeout>,
C<op_type>,
C<order>,
C<timeout>,
C<version>,
C<version_type>
See the L<put_template docs|http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-templates.html>
for more information.
=head2 C<get_template()>
$result = $e->indices->get_template(
name => 'template' # optional
);
The C<get_template()> method is used to retrieve a named template.
Query string parameters:
C<flat_settings>,
C<local>
See the L<get_template docs|http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-templates.html>
for more information.
=head2 C<exists_template()>
$result = $e->indices->exists_template(
name => 'template' # required
);
The C<exists_template()> method is used to check whether the named template exists.
Query string parameters:
C<local>
See the L<get_template docs|http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-templates.html>
for more information.
=head2 C<delete_template()>
$response = $e->indices->delete_template(
name => 'template' # required
);
The C<delete_template()> method is used to delete a named template.
Query string parameters:
C<master_timeout>,
C<timeout>,
C<version>,
C<version_type>
See the L<delete_template docs|http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-templates.html>
for more information.
=head1 WARMER METHODS
=head2 C<put_warmer()>
$response = $e->indices->put_warmer(
index => 'index' | \@indices, # optional
type => 'type' | \@types, # optional
name => 'warmer', # required
body => { warmer defn } # required
);
The C<put_warmer()> method is used to create or update named warmers which
are used to I<warm up> new segments in the index before they are exposed
to user searches. For instance:
$response = $e->indices->put_warmer(
index => 'my_index',
name => 'date_field_warmer',
body => {
sort => 'date'
}
);
Query string parameters:
C<allow_no_indices>,
C<expand_wildcards>,
C<ignore_unavailable>,
C<master_timeout>
See the L<put_warmer docs|http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-warmers.html>
for more information.
=head2 C<get_warmer()>
$response = $e->indices->get_warmer(
index => 'index' | \@indices, # optional
type => 'type' | \@types, # optional
name => 'warmer' | \@warmers, # optional
);
The C<get_warmer()> method is used to retrieve warmers by name.
Query string parameters:
C<allow_no_indices>,
C<expand_wildcards>,
C<ignore_unavailable>,
C<local>
See the L<get_warmer docs|http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-warmers.html>
for more information.
=head2 C<delete_warmer()>
$response = $e->indices->get_warmer(
index => 'index' | \@indices, # required
name => 'warmer' | \@warmers, # required
);
The C<delete_warmer()> method is used to delete warmers by name.
Query string parameters:
C<master_timeout>
See the L<delete_warmer docs|http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-warmers.html>
for more information.
=head1 STATS METHODS
=head2 C<stats()>
$result = $e->indices->stats(
index => 'index' | \@indices # optional
metric => 'metric' | \@metrics # optional
);
The C<stats()> method returns statistical information about one, more or all
indices. By default it returns all metrics, but you can limit which metrics
are returned by specifying the C<metric>.
Allowed metrics are:
C<_all>,
C<completion>
C<docs>,
C<fielddata>,
C<filter_cache>,
C<flush>,
C<get>,
C<id_cache>,
C<indexing>,
C<merge>,
C<percolate>,
C<query_cache>,
C<refresh>,
C<search>,
C<segments>,
C<store>,
C<warmer>
Query string parameters:
C<completion_fields>,
C<fielddata_fields>,
C<fields>,
C<groups>,
C<human>,
C<level>,
C<types>
See the L<stats docs|http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-stats.html>
for more information.
=head2 C<recovery()>
$result = $e->indices->recovery(
index => 'index' | \@indices # optional
);
Provides insight into on-going shard recoveries.
Query string parameters:
C<active_only>,
C<detailed>,
C<human>
See the L<recovery docs|http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-recovery.html>
for more information.
=head2 C<segments()>
$result = $e->indices->segments(
index => 'index' | \@indices # optional
);
The C<segments()> method is used to return information about the segments
that an index contains.
Query string parameters:
C<allow_no_indices>,
C<expand_wildcards>,
C<human>,
C<ignore_unavailable>
See the L<segments docs|http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-segments.html>
for more information.
=head1 QUERY AND ANALYSIS METHODS
=head2 C<analyze()>
$result = $e->indices->analyze(
index => 'index' # optional,
body => 'text to analyze'
);
The C<analyze()> method passes the text in the C<body> through the specified
C<analyzer>, C<tokenizer> or token C<filter> - which may be global, or associated
with a particular index or field - and returns the tokens. Very useful
for debugging analyzer configurations.
Query string parameters:
C<analyzer>,
C<char_filters>,
C<field>,
C<filters>,
C<format>,
C<prefer_local>,
C<text>,
C<tokenizer>
See the L<analyze docs|http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-analyze.html>
for more information.
=head2 C<validate_query()>
$result = $e->indices->validate_query(
index => 'index' | \@indices, # optional
type => 'type' | \@types, # optional
body => { query }
);
The C<validate_query()> method accepts a query in the C<body> and checks
whether the query is valid or not. Most useful when C<explain> is set
to C<true>, in which case it includes an execution plan in the output.
Query string parameters:
C<allow_no_indices>,
C<expand_wildcards>,
C<explain>,
C<ignore_unavailable>,
C<q>,
C<source>
See the L<validate_query docs|http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-validate.html>
for more information.
=head1 AUTHOR
Clinton Gormley <drtech@cpan.org>
=head1 COPYRIGHT AND LICENSE
This software is Copyright (c) 2014 by Elasticsearch BV.
This is free software, licensed under:
The Apache License, Version 2.0, January 2004
=cut
__END__
# ABSTRACT: A client for running index-level requests
| gitpan/Search-Elasticsearch | lib/Search/Elasticsearch/Client/Direct/Indices.pm | Perl | apache-2.0 | 22,980 |
#
# Copyright 2021 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package storage::hitachi::standard::snmp::mode::components::dkc;
use strict;
use warnings;
my %map_status = (
1 => 'noError',
2 => 'acute',
3 => 'serious',
4 => 'moderate',
5 => 'service',
);
my $mapping = {
dkcHWProcessor => { oid => '.1.3.6.1.4.1.116.5.11.4.1.1.6.1.2', map => \%map_status, type => 'processor' },
dkcHWCSW => { oid => '.1.3.6.1.4.1.116.5.11.4.1.1.6.1.3', map => \%map_status, type => 'bus' },
dkcHWCache => { oid => '.1.3.6.1.4.1.116.5.11.4.1.1.6.1.4', map => \%map_status, type => 'cache' },
dkcHWSM => { oid => '.1.3.6.1.4.1.116.5.11.4.1.1.6.1.5', map => \%map_status, type => 'memory' },
dkcHWPS => { oid => '.1.3.6.1.4.1.116.5.11.4.1.1.6.1.6', map => \%map_status, type => 'psu' },
dkcHWBattery => { oid => '.1.3.6.1.4.1.116.5.11.4.1.1.6.1.7', map => \%map_status, type => 'battery' },
dkcHWFan => { oid => '.1.3.6.1.4.1.116.5.11.4.1.1.6.1.8', map => \%map_status, type => 'fan' },
dkcHWEnvironment => { oid => '.1.3.6.1.4.1.116.5.11.4.1.1.6.1.9', map => \%map_status, type => 'environment' },
};
my $oid_raidExMibDKCHWEntry = '.1.3.6.1.4.1.116.5.11.4.1.1.6.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_raidExMibDKCHWEntry };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking controller chassis");
$self->{components}->{dkc} = {name => 'dkc', total => 0, skip => 0};
return if ($self->check_filter(section => 'dkc'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_raidExMibDKCHWEntry}})) {
next if ($oid !~ /^$mapping->{dkcHWProcessor}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_raidExMibDKCHWEntry}, instance => $instance);
$self->{components}->{dkc}->{total}++;
foreach (keys %{$mapping}) {
next if ($self->check_filter(section => 'dkc', instance => $1 . '.' . $mapping->{$_}->{type}));
$self->{output}->output_add(long_msg => sprintf("dkc '%s' %s status is '%s' [instance: %s].",
$instance, $mapping->{$_}->{type}, $result->{$_},
$instance . '.' . $mapping->{$_}->{type}
));
my $exit = $self->get_severity(label => 'dk', section => 'dkc', instance => $1 . '.' . $mapping->{$_}->{type}, value => $result->{$_});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("DKC '%s' %s status is '%s'",
$instance, $mapping->{$_}->{type}, $result->{$_}));
}
}
}
}
1; | Tpo76/centreon-plugins | storage/hitachi/standard/snmp/mode/components/dkc.pm | Perl | apache-2.0 | 3,745 |
=head1 LICENSE
Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
Copyright [2016] EMBL-European Bioinformatics Institute
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=cut
# Module to ease mysql schema conversion
# Usage:
# Make a schema_converter with new ( source_dbh, target_dbh )
# source database should be filled, target is empty schema
# For each target table there will be a transfer
# Either with a self specified transfer function
# with a custom select
# from a renamed source table
# from the same name source table
# configure the transfer (and the order) with
# table_rename( "oldname", "newname" )
# table_skip( "tablename" )
# do_first( "newtable1", "newtable2", "newtable3" )
# Each standard table transfer
# Either do a custom select statement
# or transfer columns with same name or renamed into each other
# specify columns to omit in target or get error
# column_rename( "tablename", "oldcolname", "newcolname" )
# column_skip( $targetdb, "table", "column" )
# custom_select( $targetdb, "tablename",
# Each row may be modified (custom select or standard select)
# specify a row_modifier function for the target table
# It takes a list ref and returns a list ref with the modified values
# ( you have to know the order of columns which come in have to go out db )
# set_row_modifier( "tablename", function_reference )
#
# potentially large (target) tables should be declared with
# big_table( "newtablename" );
package SchemaConverter;
use strict;
use DBI;
use Data::Dumper;
sub new {
my ( $class, @args ) = @_;
my $self = {};
bless $self, $class;
$self->source_dbh( $args[0] );
$self->target_dbh( $args[1] );
$self->read_dbs();
return $self;
}
sub tmp_dir {
my ( $self, $arg ) = @_;
( defined $arg ) &&
( $self->{'tmp_dir'} = $arg );
return $self->{'tmp_dir'};
}
sub source_dbh {
my ( $self, $arg ) = @_;
( defined $arg ) &&
( $self->{'source_dbh'} = $arg );
return $self->{'source_dbh'};
}
sub target_dbh {
my ( $self, $arg ) = @_;
( defined $arg ) &&
( $self->{'target_dbh'} = $arg );
return $self->{'target_dbh'};
}
sub close_dbh {
my $self = shift;
$self->source_dbh()->disconnect();
$self->target_dbh()->disconnect();
}
sub transfer {
my $self = shift;
local *FH;
my $tmpdir;
if( ! defined $self->tmp_dir() ) {
$self->close_dbh();
die( "No tmp_dir specified" );
} else {
$tmpdir = $self->tmp_dir();
}
# first we should check if all standard trnasfers can go
# otherwise testing this is a pain
$self->check_possible_transfer();
my @ordered_tables = $self->{targetdb}{dofirst};
my %all_tables = %{$self->{targetdb}{tables}};
for my $tablename ( @ordered_tables ) {
delete $all_tables{$tablename};
}
for my $tablename ( keys %all_tables ) {
push( @ordered_tables, $tablename );
}
for my $tablename ( @ordered_tables ) {
my $skip = 0;
print STDERR "Transfer $tablename ";
open( FH, ">$tmpdir/$tablename.txt" ) or die "cant open dumpfile";
if( exists $self->{targetdb}{tables}{$tablename}{transfer} ) {
my $transfunc = $self->{targetdb}{tables}{$tablename}{transfer};
&$transfunc( $self->source_dbh(), $self->target_dbh(), $tablename, \*FH );
} else {
my $sourcetable;
if( exists $self->{targetdb}{tables}{$tablename}{link} ) {
$sourcetable = $self->{targetdb}{tables}{$tablename}{link};
if( $sourcetable eq "" ) {
# skip this table
$skip = 1;
}
} else {
# find the sourcetable
if( exists $self->{targetdb}{tables}{$tablename}{select} ) {
# if we have custom select, sourcetable doesnt make sense
$sourcetable = undef;
} elsif( ! exists $self->{sourcedb}{tables}{$tablename} ) {
die "Couldnt find source for $tablename. Enter empty sourcetable.";
} else {
$sourcetable = $tablename;
}
}
if( ! $skip ) {
$self->standard_table_transfer( $sourcetable, $tablename, \*FH );
}
}
close FH;
if( ! $skip ) {
$self->target_dbh->do( "load data infile '$tmpdir/$tablename.txt' into table $tablename" );
}
# upload ?
unlink "$tmpdir/$tablename.txt";
print STDERR " finished\n";
}
# close databases
}
# this function checks if a standard transfer is possible.
# custom selects and custom transfer functions are not checked
# it will only return if it can do the transfer otherwise die
sub check_possible_transfer {
my $self = shift;
for my $tablename ( keys %{$self->{targetdb}{tables}} ) {
my $sourcetable;
if( exists $self->{targetdb}{tables}{$tablename}{transfer} ) {
next;
}
if( exists $self->{targetdb}{tables}{$tablename}{link} ) {
$sourcetable = $self->{targetdb}{tables}{$tablename}{link};
if( $sourcetable eq "" ) {
# skip this table
next;
}
} else {
# find the sourcetable
if( exists $self->{targetdb}{tables}{$tablename}{select} ) {
# custom select, no check
next;
} elsif( ! exists $self->{sourcedb}{tables}{$tablename} ) {
die "Couldnt find source for $tablename. Enter empty sourcetable.";
} else {
$sourcetable = $tablename;
}
}
my @newcols = @{$self->{targetdb}{tables}{$tablename}{columns}};
my @oldcols = @{$self->{sourcedb}{tables}{$sourcetable}{columns}};
my %rename;
if( exists $self->{targetdb}{tables}{$tablename}{columnrename} ) {
%rename = %{$self->{targetdb}{tables}{$tablename}{columnrename}};
} else {
%rename = ();
}
# find all source columns and build select statement
for my $colname ( @newcols ) {
my $selname;
if( exists $rename{$colname} ) {
$selname = $rename{$colname};
if( $selname eq "" ) {
$selname = "NULL";
}
} else {
my $colExists = 0;
for my $oldcol ( @oldcols ) {
if( $oldcol eq $colname ) {
$selname = $colname;
$colExists = 1;
last;
}
}
if( ! $colExists ) {
die "Couldnt fill $tablename.$colname\n";
}
}
}
}
}
sub standard_table_transfer {
my ( $self, $sourcetable, $targettable, $tmpfile ) = @_;
my $sourcedb = $self->source_dbh();
my $targetdb = $self->target_dbh();
# look for custom select
my $select = "";
if( exists $self->{targetdb}{tables}{$targettable}{select} ) {
$select = $self->{targetdb}{tables}{$targettable}{select};
} else {
# check if all columns have matching names
my @newcols = @{$self->{targetdb}{tables}{$targettable}{columns}};
my @oldcols = @{$self->{sourcedb}{tables}{$sourcetable}{columns}};
my %rename;
if( exists $self->{targetdb}{tables}{$targettable}{columnrename} ) {
%rename = %{$self->{targetdb}{tables}{$targettable}{columnrename}};
} else {
%rename = ();
}
# find all source columns and build select statement
for my $colname ( @newcols ) {
my $selname;
if( exists $rename{$colname} ) {
$selname = $rename{$colname};
if( $selname eq "" ) {
$selname = "NULL";
}
} else {
my $colExists = 0;
for my $oldcol ( @oldcols ) {
if( $oldcol eq $colname ) {
$selname = $colname;
$colExists = 1;
last;
}
}
if( ! $colExists ) {
die "Couldnt fill $targettable.$colname\n";
}
}
$select .= " $selname,";
}
chop( $select );
$select = "SELECT $select from $sourcetable";
}
# MySQL specific ...
# DBD doesn't use cursors; loads whole table during execute()
# problem for large tables - "mysql_use_result" gets around this
my $sth;
if (defined $self->{targetdb}{tables}{$targettable}{its_a_big_un}) {
$sth = $self->source_dbh()->prepare( $select , { mysql_use_result => 1 } );
}
else {
$sth = $self->source_dbh()->prepare( $select );
}
$sth->execute();
my $row;
if( exists $self->{targetdb}{tables}{$targettable}{row_modify} ) {
my $rowmod = $self->{targetdb}{tables}{$targettable}{row_modify};
while( my $arref = $sth->fetchrow_arrayref() ) {
$row = &{$rowmod}($arref);
print $tmpfile ( join( "\t",@{$row} ),"\n" );
}
} else {
while( my $arref = $sth->fetchrow_arrayref() ) {
$row = join( "\t", @$arref );
print $tmpfile "$row\n";
}
}
}
sub read_dbs {
my $self = shift;
my $dbh;
for my $db_name ('targetdb', 'sourcedb' ) {
if( $db_name eq 'targetdb' ) {
$dbh = $self->target_dbh();
} else {
$dbh = $self->source_dbh();
}
my $sth = $dbh->prepare( "show tables" );
$sth->execute();
while( my $arref = $sth->fetchrow_arrayref() ) {
$self->{$db_name}{tables}{$arref->[0]} = {};
}
my @tables = keys %{$self->{$db_name}{tables}};
for my $table ( @tables ) {
$sth = $dbh->prepare( "show columns from $table" );
$sth->execute();
while( my $arref = $sth->fetchrow_arrayref () ) {
push( @{$self->{$db_name}{tables}{$table}{columns}}, $arref->[0] );
}
}
}
}
sub table_rename {
my ( $self, $oldtable, $newtable ) = @_;
$self->{targetdb}{tables}{$newtable}{link} = $oldtable;
}
sub table_skip {
my ( $self, $newtable ) = @_;
$self->{targetdb}{tables}{$newtable}{link} = "";
}
sub column_rename {
my ( $self, $newtable, $oldcol, $newcol ) = @_;
$self->{targetdb}{tables}{$newtable}{columnrename}{$newcol} = $oldcol;
}
sub column_skip {
my ( $self, $newtable, $newcol ) = @_;
$self->{targetdb}{tables}{$newtable}{columnrename}{$newcol} = "";
}
sub custom_select {
my ( $self, $newtable, $select ) = @_;
$self->{targetdb}{tables}{$newtable}{select} = $select;
}
sub set_row_modifier {
my ( $self, $newtable, $row_modifier ) = @_;
$self->{targetdb}{tables}{$newtable}{row_modify} = $row_modifier;
}
sub clear_target {
my $self = shift;
for my $tablename ( keys %{$self->{targetdb}{tables}} ) {
$self->target_dbh()->do( "delete from $tablename" );
}
}
sub big_table {
my ( $self, $table ) = @_;
$self->{targetdb}{tables}{$table}{its_a_big_un} = 1;
}
sub do_first {
my $self = shift;
my @ordered_table_list= @_;
$self->{targetdb}{dofirst} = \@ordered_table_list;
}
1;
| danstaines/ensembl | misc-scripts/surgery/SchemaConverter.pm | Perl | apache-2.0 | 10,609 |
=head1 LICENSE
Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
Copyright [2016-2021] EMBL-European Bioinformatics Institute
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=cut
package EnsEMBL::Web::ViewConfig::Gene::TranscriptsImage;
use strict;
use warnings;
use parent qw(EnsEMBL::Web::ViewConfig);
sub init_cacheable {
## Abstract method implementation
my $self = shift;
$self->image_config_type('gene_summary');
$self->title('Summary');
}
sub form_fields { } # No default fields
sub field_order { } # No default fields
1;
| Ensembl/ensembl-webcode | modules/EnsEMBL/Web/ViewConfig/Gene/TranscriptsImage.pm | Perl | apache-2.0 | 1,074 |
=head1 LICENSE
Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
Copyright [2016-2021] EMBL-European Bioinformatics Institute
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=cut
package XrefMapper::sars_cov_2;
use XrefMapper::BasicMapper;
use vars '@ISA';
@ISA = qw{ XrefMapper::BasicMapper };
use strict;
sub transcript_names_from_gene {
my $self = shift;
my $core_dbi = $self->core->dbc;
my $reset_sth = $core_dbi->prepare("UPDATE transcript SET display_xref_id = null");
$reset_sth->execute();
$reset_sth->finish;
my $del_xref_sth = $core_dbi->prepare("DELETE x FROM xref x, object_xref ox, external_db e WHERE x.xref_id = ox.xref_id AND ensembl_object_type = 'Transcript' AND e.external_db_id = x.external_db_id AND e.db_name like '%_trans_name'");
my $del_ox_sth = $core_dbi->prepare("DELETE ox FROM object_xref ox LEFT JOIN xref x ON x.xref_id = ox.xref_id WHERE isnull(x.xref_id)");
my $xref_id_sth = $core_dbi->prepare("SELECT max(xref_id) FROM xref");
my $ox_id_sth = $core_dbi->prepare("SELECT max(object_xref_id) FROM object_xref");
my $ins_xref_sth = $core_dbi->prepare("INSERT IGNORE into xref (xref_id, external_db_id, dbprimary_acc, display_label, version, description, info_type, info_text) values(?, ?, ?, ?, 0, ?, 'MISC', ?)");
my $ins_ox_sth = $core_dbi->prepare("INSERT into object_xref (object_xref_id, ensembl_id, ensembl_object_type, xref_id) values(?, ?, 'Transcript', ?)");
my $update_tran_sth = $core_dbi->prepare("UPDATE transcript t SET t.display_xref_id= ? WHERE t.transcript_id=?");
my $get_genes = $core_dbi->prepare("SELECT g.gene_id, e.db_name, x.dbprimary_acc, x.display_label, x.description FROM gene g, xref x, external_db e where g.display_xref_id = x.xref_id and e.external_db_id = x.external_db_id");
my $get_transcripts = $core_dbi->prepare("SELECT transcript_id FROM transcript WHERE gene_id = ? ORDER BY seq_region_start, seq_region_end");
my $get_source_id = $core_dbi->prepare("SELECT external_db_id FROM external_db WHERE db_name like ?");
$get_genes->execute();
my ($gene_id, $external_db, $external_db_id, $acc, $label, $description, $transcript_id, $xref_id, $ox_id, $ext, $reuse_xref_id, $info_text);
$get_genes->bind_columns(\$gene_id, \$external_db, \$acc, \$label, \$description);
$xref_id_sth->execute();
$xref_id_sth->bind_columns(\$xref_id);
$xref_id_sth->fetch();
$ox_id_sth->execute();
$ox_id_sth->bind_columns(\$ox_id);
$ox_id_sth->fetch();
$del_xref_sth->execute();
while ($get_genes->fetch()) {
$get_source_id->execute($external_db . "_trans_name");
$get_source_id->bind_columns(\$external_db_id);
$get_source_id->fetch();
$get_transcripts->execute($gene_id);
$get_transcripts->bind_columns(\$transcript_id);
while ($get_transcripts->fetch) {
$xref_id++;
$ox_id++;
$info_text = 'via gene ' . $acc;
$ins_xref_sth->execute($xref_id, $external_db_id, $label, $label, $description, $info_text);
$ins_ox_sth->execute($ox_id, $transcript_id, $xref_id);
$update_tran_sth->execute($xref_id, $transcript_id);
}
}
$del_ox_sth->execute();
$del_ox_sth->finish();
$del_xref_sth->finish();
$xref_id_sth->finish();
$ox_id_sth->finish();
$get_genes->finish();
$get_source_id->finish();
$get_transcripts->finish();
$ins_xref_sth->finish();
$ins_ox_sth->finish();
$update_tran_sth->finish();
}
1;
| Ensembl/ensembl | misc-scripts/xref_mapping/XrefMapper/sars_cov_2.pm | Perl | apache-2.0 | 3,926 |
=head1 LICENSE
Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
Copyright [2016-2021] EMBL-European Bioinformatics Institute
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=cut
#TODO
package EnsEMBL::Web::ViewConfig::Location::MultiBottom;
use strict;
use base qw(EnsEMBL::Web::ViewConfig);
sub init {
my $self = shift;
$self->set_default_options({
show_bottom_panel => 'yes'
});
$self->image_config_type('MultiBottom');
$self->title('Comparison Image');
$self->set_default_options({
opt_pairwise_blastz => 'normal',
opt_pairwise_tblat => 'normal',
opt_pairwise_lpatch => 'normal',
opt_join_genes_bottom => 'off',
opt_pairwise_cactus_hal_pw => 'compact'
});
}
sub extra_tabs {
my $self = shift;
my $hub = $self->hub;
return [
'Select species or regions',
$hub->url('MultiSelector', {
action => 'MultiSpeciesSelector',
multiselect => 1,
referer_action => $hub->action,
%{$hub->multi_params}
})
];
}
sub init_form {
my $self = shift;
$self->add_fieldset('Comparative features');
foreach ([ 'blastz', 'BLASTz/LASTz net pairwise alignments' ], [ 'tblat', 'Translated BLAT net pairwise alignments' ], [ 'lpatch', 'LASTz patch alignments' ], ['cactus_hal_pw', 'Cactus HAL alignments']) {
$self->add_form_element({
type => 'DropDown',
select => 'select',
name => "opt_pairwise_$_->[0]",
label => $_->[1],
values => [
{ value => 0, caption => 'Off' },
{ value => 'normal', caption => 'Normal' },
{ value => 'compact', caption => 'Compact' },
],
});
}
$self->add_form_element({
type => 'CheckBox',
label => 'Join genes',
name => 'opt_join_genes_bottom',
value => 'on',
});
$self->add_fieldset('Display options');
$self->add_form_element({ type => 'YesNo', name => 'show_bottom_panel', select => 'select', label => 'Show panel' });
}
1;
| Ensembl/ensembl-webcode | modules/EnsEMBL/Web/ViewConfig/Location/MultiBottom.pm | Perl | apache-2.0 | 2,510 |
package Search::Elasticsearch::Util::API::QS;
use strict;
use warnings;
use Sub::Exporter -setup => { exports => ['qs_init'] };
our %Handler = (
string => sub {"$_[0]"},
list => sub {
ref $_[0] eq 'ARRAY'
? join( ',', @{ shift() } )
: shift();
},
bool => sub { $_[0] ? 1 : 0 },
enum => sub {
ref $_[0] eq 'ARRAY'
? join( ',', @{ shift() } )
: shift();
},
number => sub { 0 + $_[0] },
datetime => sub {"$_[0]"},
duration => sub {"$_[0]"},
);
our %Params = (
active_only => { type => 'bool' },
all => { type => 'bool' },
allow_no_indices => { type => 'bool' },
analyze_wildcard => { type => 'bool' },
analyzer => { type => 'string' },
boost_terms => { type => 'number' },
bytes => { type => 'enum', options => [ 'b', 'k', 'm', 'g' ] },
char_filters => { type => 'list' },
clear => { type => 'bool' },
completion => { type => 'bool' },
completion_fields => { type => 'list' },
consistency => {
options => [ 'one', 'quorum', 'all' ],
type => 'enum'
},
create => { type => 'bool' },
default_operator => {
default => 'OR',
options => [ 'AND', 'OR' ],
type => 'enum'
},
delay => { type => 'duration' },
detailed => { type => 'bool' },
df => { type => 'string' },
dfs => { type => 'bool' },
docs => { type => 'bool' },
dry_run => { type => 'bool' },
exit => { type => 'bool' },
expand_wildcards => {
type => 'enum',
options => [ 'open', 'closed', 'none', 'all' ]
},
explain => { type => 'bool' },
field => { type => 'string' },
field_statistics => { type => 'bool' },
fielddata => { type => 'bool' },
fielddata_fields => { type => 'list' },
fields => { type => 'list' },
filter => { type => 'bool' },
filter_blocks => { type => 'bool' },
filter_cache => { type => 'bool' },
filter_index_templates => { type => 'bool' },
filter_indices => { type => 'list' },
filter_keys => { type => 'bool' },
filter_path => { type => 'list' },
filter_metadata => { type => 'bool' },
filter_nodes => { type => 'bool' },
filter_routing_table => { type => 'bool' },
filters => { type => 'list' },
flat_settings => { type => 'bool' },
flush => { type => 'bool' },
force => { type => 'bool' },
format => {
default => 'detailed',
options => [ 'detailed', 'text' ],
type => 'enum'
},
from => { type => 'number' },
fs => { type => 'bool' },
full => { type => 'bool' },
full_id => { type => 'bool' },
get => { type => 'bool' },
groups => { type => 'list' },
http => { type => 'bool' },
h => { type => 'list' },
help => { type => 'bool' },
human => { type => 'bool' },
id => { type => 'string' },
id_cache => { type => 'bool' },
ids => { type => 'list' },
ignore_conflicts => { type => 'bool' },
ignore_indices => {
default => 'none',
options => [ 'none', 'missing' ],
type => 'enum'
},
ignore => { type => 'list', },
ignore_idle_threads => { type => 'bool' },
ignore_unavailable => { type => 'bool' },
include_defaults => { type => 'bool' },
index => { type => 'list' },
index_templates => { type => 'list' },
indexing => { type => 'bool' },
indices => { type => 'bool' },
interval => { type => 'duration' },
jvm => { type => 'bool' },
lang => { type => 'string' },
lenient => { type => 'bool' },
level => {
options => [ 'cluster', 'node', 'indices', 'shards' ],
type => 'enum'
},
local => { type => 'bool' },
lowercase_expanded_terms => { type => 'bool' },
master_timeout => { type => 'duration' },
max_doc_freq => { type => 'number' },
max_num_segments => { type => 'number' },
max_query_terms => { type => 'number' },
max_word_len => { type => 'number' }, # depr 0.90
max_word_length => { type => 'number' },
metric => {
type => 'enum',
options => [
"_all", "blocks", "metadata", "nodes",
"routing_table", "master_node", "version"
]
},
merge => { type => 'bool' },
min_doc_freq => { type => 'number' },
min_score => { type => 'number' },
min_term_freq => { type => 'number' },
min_word_len => { type => 'number' }, # depr 0.90
min_word_length => { type => 'number' },
mlt_fields => { type => 'list' },
name => { type => 'list' },
network => { type => 'bool' },
offsets => { type => 'bool' },
only_ancient_segments => { type => 'bool' },
only_expunge_deletes => { type => 'bool' },
op_type => {
default => 'index',
options => [ 'index', 'create' ],
type => 'enum'
},
order => { type => 'number' },
os => { type => 'bool' },
parent => { type => 'string' },
payloads => { type => 'bool' },
percent_terms_to_match => { type => 'number' },
percolate => { type => 'string' },
percolate_format => { type => 'string' },
percolate_index => { type => 'string' },
percolate_preference => { type => 'string' },
percolate_routing => { type => 'list' },
percolate_type => { type => 'string' },
plugin => { type => 'bool' },
positions => { type => 'bool' },
prefer_local => { type => 'bool' },
preference => { type => 'string' },
pri => { type => 'bool' },
process => { type => 'bool' },
q => { type => 'string' },
query => { type => 'bool' },
query_cache => { type => 'bool' },
realtime => { type => 'bool' },
recovery => { type => 'bool' },
recycler => { type => 'bool' },
refresh => { type => 'bool' },
replication => {
default => 'sync',
options => [ 'sync', 'async' ],
type => 'enum'
},
request => { type => 'bool' },
request_cache => { type => 'bool' },
retry_on_conflict => { type => 'number' },
rewrite => { type => 'bool' },
routing => { type => 'string' },
script => { type => 'string' },
script_id => { type => 'string' },
scripted_upsert => { type => 'bool' },
scroll => { type => 'duration' },
scroll_id => { type => 'string' },
search => { type => 'bool' },
search_from => { type => 'number' },
search_indices => { type => 'list' },
search_scroll => { type => 'string' },
search_size => { type => 'number' },
search_source => { type => 'string' },
search_type => {
options => [
'query_then_fetch', 'query_and_fetch',
'dfs_query_then_fetch', 'dfs_query_and_fetch',
'count', 'scan'
],
type => 'enum'
},
search_types => { type => 'list' },
settings => { type => 'bool' },
size => { type => 'number' },
snapshot => { type => 'bool' },
snapshots => { type => 'number' },
sort => { type => 'list' },
source => { type => 'string' },
_source => { type => 'list', },
_source_exclude => { type => 'list', },
_source_include => { type => 'list', },
stats => { type => 'list' },
stop_words => { type => 'list' },
store => { type => 'bool' },
suggest_field => { type => 'string' },
suggest_mode => {
default => 'missing',
options => [ 'missing', 'popular', 'always' ],
type => 'enum'
},
suggest_size => { type => 'number' },
suggest_text => { type => 'string' },
term_statistics => { type => 'bool' },
terminate_after => { type => 'number' },
text => { type => 'string' },
thread_pool => { type => 'bool' },
threads => { type => 'number' },
timeout => { type => 'duration' },
timestamp => { type => 'datetime' },
tokenizer => { type => 'string' },
track_scores => { type => 'bool' },
transport => { type => 'bool' },
ts => { type => 'bool' },
ttl => { type => 'duration' },
type => { type => 'string' },
types => { type => 'list' },
v => { type => 'bool' },
verbose => { type => 'bool' },
verify => { type => 'bool' },
version => { type => 'number' },
version_type => {
type => 'enum',
options => [ 'internal', 'external' ]
},
wait_for_active_shards => { type => 'number' },
wait_for_completion => { type => 'bool' },
wait_for_merge => { type => 'bool' },
wait_for_nodes => { type => 'string' },
wait_for_relocating_shards => { type => 'number' },
wait_for_status => {
default => undef,
options => [ 'green', 'yellow', 'red' ],
type => 'enum'
},
wait_if_ongoing => { type => 'bool' },
warmer => { type => 'bool' }
);
#===================================
sub qs_init {
#===================================
no warnings 'uninitialized';
my %qs;
for (@_) {
my $defn = $Params{$_} || die("Unknown query-string param ($_)\n");
$defn->{handler} ||= $Handler{ $defn->{type} }
|| die "Unknown query-string parameter type ($defn->{type})\n";
$qs{$_} = $defn;
}
return \%qs;
}
1;
__END__
# ABSTRACT: A utility class for query string parameters in the API
=head1 DESCRIPTION
This class contains a definition of each query string parameter that
can be accepted by actions in the L<API|Search::Elasticsearch::Role::API>.
=head1 EXPORTS
=head2 C<qs_init()>
use Search::Elasticsearch::Util::API::QS qw(qs_init);
$handler = qs_init( @qs_params );
$qs_hash = $handler->($params);
The C<qs_init()> sub accepts a list of query string parameter names,
and returns a handler which can extract those parameters from C<\%params>
and return a hash of values to be passed as a query string.
For instance:
$handler = qs_init(qw(fields size from));
$params = { fields =>['foo','bar'], size => 10, query=>\%query };
$qs_hash = $handler->($params);
Would result in:
$qs_hash: { fields => 'foo,bar', size => 10};
$params: { query => \%query }
| jeteve/elasticsearch-perl | lib/Search/Elasticsearch/Util/API/QS.pm | Perl | apache-2.0 | 11,687 |
package Bio::EnsEMBL::Funcgen::RunnableDB::ProbeMapping::DumpUnmappedSeqs;
use strict;
use base ('Bio::EnsEMBL::Hive::Process');
use Hash::Util qw( lock_keys );
sub run {
my $self = shift;
my $unmapped_sequences_file = $self->param('unmapped_sequences_file');
my $species = $self->param('species');
my $funcgen_adaptor = Bio::EnsEMBL::Registry->get_DBAdaptor($species, 'funcgen');
my $dbc_tracking = $funcgen_adaptor->dbc;
my $helper = Bio::EnsEMBL::Utils::SqlHelper->new(
-DB_CONNECTION => $dbc_tracking
);
my $unmapped_sequences_count =
$helper->execute_single_result(
-SQL => 'select count(*) from probe_seq',
);
use Bio::EnsEMBL::Utils::Logger;
my $logger = Bio::EnsEMBL::Utils::Logger->new();
$logger->info("There are $unmapped_sequences_count unmapped probe sequences in the database.\n");
if ($unmapped_sequences_count==0) {
die("There are no unmapped probes in the database.");
}
my $sth = $dbc_tracking->prepare('select probe_seq_id, sequence from probe_seq');
$sth->execute;
use Bio::Seq;
use Bio::SeqIO;
my $out = Bio::SeqIO->new(
-file => '>' . $unmapped_sequences_file,
-format => 'Fasta'
);
my $progressbar_id = $logger->init_progress($unmapped_sequences_count, 100);
$logger->info("Writing unmapped sequences to $unmapped_sequences_file\n");
my $skipped_sequences = 0;
my $num_sequence_written=0;
PROBE_SEQUENCE:
while (my $data = $sth->fetchrow_hashref) {
lock_keys(%$data);
if (!$data->{sequence}) {
use Data::Dumper;
warn("This probe had no sequence!\n" . Dumper($data));
$skipped_sequences++;
next PROBE_SEQUENCE;
}
my $seq_obj = Bio::Seq->new(
-id => $data->{probe_seq_id},
-seq => $data->{sequence},
-alphabet => 'dna',
);
$out->write_seq($seq_obj);
$num_sequence_written++;
$logger->log_progressbar($progressbar_id, $num_sequence_written);
}
$logger->info("Done writing $num_sequence_written sequences.");
if ($num_sequence_written + $skipped_sequences != $unmapped_sequences_count) {
my $msg = "$unmapped_sequences_count sequences had to be written, but only wrote $num_sequence_written sequences and skipped $skipped_sequences sequences!";
$logger->error($msg);
die($msg)
}
}
1;
| Ensembl/ensembl-funcgen | modules/Bio/EnsEMBL/Funcgen/RunnableDB/ProbeMapping/DumpUnmappedSeqs.pm | Perl | apache-2.0 | 2,445 |
package HyperGlossary::Controller::Hg;
use strict;
use warnings;
use parent 'Catalyst::Controller';
use WWW::HyperGlossary::Model;
use WWW::HyperGlossary;
use DBI;
use DBIx::MySperql qw(DBConnect SQLExec SQLFetch $dbh);
use LWP::Simple;
#use Chemistry::OpenBabel;
use MIME::Base64::Perl;
use XML::Simple;
use URI;
use Encode;
use Data::Dumper;
use JSON::XS;
use HTML::TreeBuilder;
our ($category_id, $definition_type, $language_id, $mysperql_pdb, $hg_model);
=head1 NAME
HyperGlossary::Controller::Root - Root Controller for HyperGlossary
=head1 DESCRIPTION
Main Hyperglossary controller
=head1 METHODS
=cut
sub auto : Private {
my ($self, $c) = @_;
my $path = $c->request->path(); $path =~ s/\d+$//;
$c->stash->{template} = $path . '.tt2';
$dbh = $c->controller('Root')->_connect( $c->config->{hgdb} );
if($c->user_exists){
warn $c->model('hgDB::HgRoles') . $c->user->get('user_name') . " : " . $c->user->get('user_id');
}
if(exists $c->session->{category_id}){$c->stash->{category_id} = $c->session->{category_id}; warn "category_id is already set ".$c->session->{category_id};}else{ $c->session->{category_id} = 34;}
if(exists $c->session->{language_id}){$c->stash->{language_id} = $c->session->{language_id};}else{ $c->session->{language_id} = 25;}
if(exists $c->session->{category}){$c->stash->{category} = $c->session->{category};warn "YESYESYESYESYESYES";}else{ $c->session->{category} = 'General Chemistry';warn "NONONONONONONONONONO";}
$mysperql_pdb = DBIx::MySperqlOO->new({ db=>'gene_pdb', user=>'root', pass=>'K16Tut' });
$hg_model = WWW::HyperGlossary::Model->new();
}
#preferences: Get the users preferences for a particular session form/controller
sub preferences : Local {
my ( $self, $c ) = @_;
$c->stash->{action_url} = $c->config->{rootURL} . 'hg/save_preferences';
my $hg3 = WWW::HyperGlossary->new();
my $sql = "select category_id, category FROM hg_categories;";
my ($categories) = SQLExec( $sql, '\@@' );
$c->stash->{category_options} = $hg3->_build_html_select_options( $categories, $c->stash->{category_id} );
$c->stash->{definition_type_options} = $hg3->_build_html_select_options( $c->config->{hg_definition_types}, $c->stash->{definition_type_id} );
$c->stash->{language_options} = $hg3->_build_html_select_options( $c->config->{hg_languages}, $c->stash->{language_id} );
}
#url: URL input/form controller
sub url : Local {
my ( $self, $c ) = @_;
my $hg3 = WWW::HyperGlossary->new();
$c->stash->{path} = $c->request->path;
$c->stash->{action_url} = $c->config->{rootURL} . 'hg/start_url';
$c->stash->{exampleURL} = 'http://www.science.uwaterloo.ca/~cchieh/cact/applychem/atmosphere.html';
my $sql = "select category_id, category FROM hg_categories;";
my ($categories) = SQLExec( $sql, '\@@' );
$c->stash->{category_options} = $hg3->_build_html_select_options( $categories, $c->session->{category_id} );
$c->stash->{set_cat_url} = $c->config->{rootURL} . 'hg/save_preferences';
}
#text: Text input/form controller
sub text : Local {
my ( $self, $c ) = @_;
$c->stash->{action_url} = $c->config->{rootURL} . 'hg/text_process';
$c->stash->{path} = $c->request->path;
my $hg3 = WWW::HyperGlossary->new();
$c->stash->{jsFiles} = ['/static/js/tiny_mce/tiny_mce_src.js'];
$c->stash->{readonly} = 'false';
my $sql = "select category_id, category FROM hg_categories;";
my ($categories) = SQLExec( $sql, '\@@' );
$c->stash->{category_options} = $hg3->_build_html_select_options( $categories, $c->session->{category_id} );
$c->stash->{set_cat_url} = $c->config->{rootURL} . 'hg/save_preferences';
}
#about: Displays the about information. Content in template
sub about : Local {
my ( $self, $c ) = @_;
$c->stash->{about} = 'WikiHyperGlossary is a tool for chemical education.';
}
#text_process: Submit text to be processed
sub text_process : Local {
my ( $self, $c ) = @_;
my $plaintext = $c->request->param('editor');
# Get and parse text for first return
my $hg = WWW::HyperGlossary->new();
my ($head,$body,$page_id) = $hg->start_text({ text => $plaintext,
category_id => $c->session->{category_id} });
$c->session->{page_id} = $page_id;
$c->session->{flag} = 1;
$c->stash->{head} = $head;
$c->stash->{jsFiles} = ['/static/js/hg3.js','/static/js/jas.js'];
$c->stash->{page_id} = $page_id;
$c->stash->{body} = $body;
$c->stash->{urlpage} = 1;
$c->stash->{controller_url} = $c->config->{rootURL}.'hg/next_set';
}
#save_preferences: Save the users preferences for a particular session
sub save_preferences : Local {
my ( $self, $c ) = @_;
$c->stash->{template} = '';
$c->session->{category_id} = $c->request->param('category');
$c->session->{definition_type} = $c->request->param('definition_type');
$c->session->{language_id} = $c->request->param('language');
my $sql = "SELECT category FROM hg_categories WHERE category_id=" . $c->session->{category_id};
($c->session->{category}) = SQLExec( $sql, '@' );
$c->response->status(204);
$c->response->body("\n\n");
}
#start_url: Submit URL to get processed
sub start_url : Local {
my ( $self, $c ) = @_;
$c->session->{url} = $c->request->param('url');
my $category_id = $c->flash->{category_id};
warn "START_CITY: ".$c->session->{url};
# Get and parse html for first return
my $hg = WWW::HyperGlossary->new();
my ($head,$body,$page_id) = $hg->start_url({ url => $c->session->{url},
category_id => $c->session->{category_id} });
$c->session->{page_id} = $page_id;
$c->session->{flag} = 1;
$c->stash->{jsFiles} = ['static/js/hg3.js','static/js/jas.js'];
$c->stash->{head} = $head;
$c->stash->{page_id} = $page_id;
$c->stash->{body} = $body;
$c->stash->{urlpage} = 1;
$c->stash->{controller_url} = $c->config->{rootURL}.'hg/next_set';
}
#next_set: Return the page as each word set is processed
sub next_set : LocalRegex('next_set(\d+)$') {
my ($self, $c) = @_;
my $page_id = $c->req->captures->[0];
my $text;
# Process the next set
my $hg = WWW::HyperGlossary->new();
if($c->session->{flag} == 2){
$text = $hg->get_cached_page({ page_id => $page_id });
}
else{
$c->session->{flag}++;
$text = $hg->next_set({ page_id => $page_id, hg_words => $c->config->{hg_words}, current_set => $c->session->{flag} });
}
# Return special page
$c->stash->{template} = '';
$c->response->body( $text );
}
#export_page: Build the a page that has been processed to exported and used independent of the local server
sub export_page : Local {
my ( $self, $c ) = @_;
my $export;
my $page_id = $c->session->{page_id};
my $sql = "SELECT url, body FROM hg_pages WHERE page_id = '$page_id'";
my ( $url,$body ) = SQLExec( $sql, '@' );
#Build the head an direct link to javascript on server
$export .= "<head>\n";
$export .= '<link rel="icon" type="image/png" href="'.$c->config->{rootURL}.'static/images/HG.png" />'."\n";
$export .= '<link rel="stylesheet" type="text/css" href="'.$c->config->{rootURL}.'static/js/ext/resources/css/ext-all.css" />'."\n";
$export .= '<link rel="stylesheet" type="text/css" href="'.$c->config->{rootURL}.'static/js/ext/resources/css/xtheme-gray.css" />'."\n";
$export .= '<link rel="stylesheet" type="text/css" href="'.$c->config->{rootURL}.'static/js/livegrid/build/resources/css/ext-ux-livegrid.css" />'."\n";
$export .= '<link rel="stylesheet" type="text/css" href="'.$c->config->{rootURL}.'static/js/ext/resources/css/fileuploadfield.css" />'."\n";
$export .= '<script type="text/javascript"> var base_url = "'.$c->config->{rootURL}.'";</script>'."\n";
$export .= '<script type="text/javascript" src="'.$c->config->{rootURL}.'static/js/ext/adapter/ext/ext-base.js"></script>'."\n";
$export .= '<script type="text/javascript" src="'.$c->config->{rootURL}.'static/js/ext/ext-all.js"></script>'."\n";
$export .= '<script type="text/javascript" src="'.$c->config->{rootURL}.'static/js/ext/Ext.ux.ColorField.js"></script>'."\n";
$export .= '<script type="text/javascript" src="'.$c->config->{rootURL}.'static/js/ext/basex/ext-basex.js"></script>'."\n";
$export .= '<script type="text/javascript" src="'.$c->config->{rootURL}.'static/js/ext/mif/uxvismode.js"></script>'."\n";
$export .= '<script type="text/javascript" src="'.$c->config->{rootURL}.'static/js/ext/mif/multidom.js"></script>'."\n";
$export .= '<script type="text/javascript" src="'.$c->config->{rootURL}.'static/js/ext/mif/mif.js"></script>'."\n";
$export .= '<script type="text/javascript" src="'.$c->config->{rootURL}.'static/js/jmol/Jmol.js"></script>'."\n";
$export .= '<script type="text/javascript" src="'.$c->config->{rootURL}.'static/js/ext/examples/ux/FileUploadField.js"></script>'."\n";
$export .= '<script type="text/javascript" src="'.$c->config->{rootURL}.'static/js/jas.js"></script>'."\n";
my $javascript = &export_javascript($c->config->{rootURL}, $c->session->{category_id});
$export .= '<script type="text/javascript">'.$javascript.'</script>'."\n";
$export .= "<base href='$url'></base>"."\n";
$export .= "</head>\n";
$export .= $body;
my $filename = 'hg_page_export.html';
# Return special page
$c->stash->{template} = '';
$c->response->header('Content-Disposition',qq[attachment; filename="$filename"]);
$c->response->body( $export );
}
#getCount: Get the count of the number of words in a glossary
sub getCount : Local {
my ($self, $c) = @_;
my $category_id = $c->session->{category_id};
my $sql = "SELECT COUNT(*) FROM hg_category_words ";
$sql .= "WHERE category_id = '$category_id'";
my ($count) = SQLExec( $sql, '@' );
$c->response->body( $count );
}
#chemEdArticle: Get chenEddl articles
sub chemEdArticle : Local{
my ( $self, $c ) = @_;
my $term = $c->req->param('name');
$c->stash->{nowrap} = 1;
$c->stash->{term} = $term;
my $rootURL = 'http://www.chemeddl.org:8080/';
my $service = 'alfresco/service/custom/articles/search/';
my $query = '?year=2000&month=october&author=&audience=&domain=&element=&topic=&pedagogy=&text='.$term;
my $auth = $self->_get_chemEd_auth();
my $articles = get($rootURL . $service . $query . $auth);
$articles =~ m/<body(.*?)>(.*)<\/body>/six;
$articles =~ s/href="\//href="http:\/\/chemeddl.org:8080\//g;
$c->stash->{articles} = $articles;
}
sub searchChemEdDL : Local {
my ( $self, $c ) = @_;
my $term = $c->req->param('term');
my $content = get('http://www.chemeddl.org/resources/models360/files/searchlist.php?q='.$term);
return
}
#jmol: Get jmol and display applet (now set to use Jsmol)
sub jmol : Local{
my ( $self, $c ) = @_;
my $term = $c->req->param('term');
my $category_id;
$c->stash->{template} = 'hg/jsmol.tt2';
if($c->req->param('category_id')){$category_id = $c->req->param('category_id');}else{ $category_id = $c->session->{category_id};}
my $smile;
my $url;
my $inchi_key;
my $sql = "SELECT word_id FROM hg_words WHERE word='$term'";
my($word_id) = SQLExec($sql, '@');
$sql = "SELECT category_word_id, word_type_id FROM hg_category_words WHERE word_id = $word_id AND category_id = $category_id";
my($category_word_id, $word_type_id) = SQLExec($sql, '@');
if($word_type_id == 2){
$sql = "SELECT identifier FROM hg_word_identifiers WHERE category_word_id = $category_word_id ";
$sql .= "AND word_type_identifier_id = 1";
my($inchi) = SQLExec($sql, '@');
warn "INCHI^^^^^^^ $inchi\n";
$inchi_key = $self->_inchiToOther({inchi => $inchi, operation => 'InChIToInChIKey'});
#my $content = get('http://144.92.39.69/resources/models360/modelsJmol.php?inchikey='.$inchi_key);
#$url = 'http://144.92.39.69/resources/models360/modelsJmol.php?inchikey='.$inchi_key;
my $content = get('http://www.chemeddl.org/resources/models360/modelsJmol.php?inchikey='.$inchi_key);
$url = 'http://www.chemeddl.org/resources/models360/modelsJmol.php?inchikey='.$inchi_key;
warn "URL: $content";
my $base = '<base href="http://www.chemeddl.org/resources/models360/" />';
#my $logo = '<a href="/"><img src="img/logoChemEdDL.gif" style="border: 0pt none;"></a><span id="headerText">Models 360</span>';
#$content =~ s/\"\/(tools\/jmol)\"/\"http:\/\/144\.92\.39\.69\/$1\"/;
#$content =~ s/(load)\s(files)/$1 http:\/\/144\.92\.39\.69\/resources\/models360\/$2/g;
#my $info = 'Info0 = {'."\n";
#$info .= 'use: "HTML5", '."\n";
#$info .= 'width: 380, height: 380,'."\n";
#$info .= 'color: "black",'."\n";
#$info .= 'isSigned: false,'."\n";
#$info .= 'jarFile: "JmolApplet0.jar",'."\n";
#$info .= 'serverURL: "http://www.chemeddl.org/tools/jsmol/"'."\n";
#$info .= 'serverURL: "http://hyperglossary.org/static/js/jsmol/php/jsmol.php",'."\n";
#$info .= 'jarPath: "http://www.chemeddl.org/tools/jsmol/java",'."\n";
#$info .= 'j2sPath: "http://www.chemeddl.org/tools/jsmol/j2s" };'."\n";
#$info .= 'disableJ2SLoadMonitor: false,'."\n";
#$info .= 'disableInitialConsole: true'."\n";
#$info .= '}'."\n";
#$info .= 'Jmol._alertNoBinary = false;';
#$content =~ s/Info0.*?}/$info/ms;
#$content =~ s/\.\.\/\.\.\/(tools\/jsmol.*)/http:\/\/www\.chemeddl\.org\/$1/g;
#$content =~ s/(files.*\.js)/http:\/\/www\.chemeddl\.org\/resources\/models360\/$1/g;
#$content =~ s/(library.*\.[js|css])/http:\/\/www\.chemeddl\.org\/resources\/models360\/$1/g;
#$content =~ s/(load)\s(files)/$1 http:\/\/www\.chemeddl\.org\/resources\/models360\/$2/g;
# warn "CONTENT: $content";
# my $html = HTML::TreeBuilder->new;
# my $root = $html->parse($content);
# warn $1. "<====================---------";
#my $baselink = HTML::Element->new(
# 'base',
# 'href' => 'http://www.chemeddl.org/resources/models360/',
# );
#unshift(@{$root->find('head')->content_array_ref},$base);
#$root->find('head')->insert_element($baselink);
#unshift(@{$root->find('head')->content_array_ref},$logo);
#$content = $root->as_HTML;
my $error = 'gave no results';
#my $error = 'load';
if($content =~ /.*$error.*/){
$c->stash->{local} = 1;
my $filename = $term;
$filename=~s/[\W]//g;
$filename = $filename .'.mol2';
my $file = $c->config->{staticPATH}.'jmolFile/'.$filename;
warn "FILE 000000> $file\n";
unless(-e $file){
#$smile = $self->_openBabelWebService({what => $inchi, fromFormat => 'inchi', toFormat => 'smiles' });
$smile = $self->_inchiToOther({inchi=> $inchi, operation => 'InChIToSMILES'});
$self->_smileToMol2({smile => $smile, filename => $filename, staticPATH => $c->config->{staticPATH}});
}
$c->stash->{jmolFile} = $c->config->{rootURL} .'static/jmolFile/'.$filename;
$c->stash->{jsFiles} = [$c->config->{rootURL} .'static/js/jmol/Jmol.js'];
}
else{
#$c->stash->{chemeddl} = 'http://www.chemeddl.org/resources/models360/models.php?inchikey='.$inchi_key;
$c->stash->{chemeddl} = 'http://chemdata.umr.umn.edu/acs_chemeddl/LAMP/resources/models360/models.php?inchikey='.$inchi_key;
$c->stash->{SHIT} = 1;
}
}
$c->stash->{nowrap} = 1;
}
#jchempaint: Get 2D structure (SMILE structure)
sub jchempaint : Local{
my ( $self, $c ) = @_;
my $term = $c->req->param('term');
#my $category_id = $c->session->{category_id};
my $category_id;
if($c->req->param('category_id')){$category_id = $c->req->param('category_id');}else{ $category_id = $c->session->{category_id};}
my $smile;
my $sql = "SELECT word_id FROM hg_words WHERE word='$term'";
my($word_id) = SQLExec($sql, '@');
$sql = "SELECT category_word_id, word_type_id FROM hg_category_words WHERE word_id = $word_id AND category_id = $category_id";
my($category_word_id, $word_type_id) = SQLExec($sql, '@');
if($word_type_id == 2){
$sql = "SELECT identifier FROM hg_word_identifiers WHERE category_word_id = $category_word_id ";
$sql .= "AND word_type_identifier_id = 1";
my($inchi) = SQLExec($sql, '@');
#$smile = $self->_inchiToSmile({inchi => $inchi});
$smile = $self->_cactusConverter({fromFormat=> $inchi, toFormat => 'JME'});
warn "$smile <---------------------------------";
}
$c->stash->{template} = 'hg/jsme.tt2';
$c->stash->{jme} = $smile;
$c->stash->{nowrap} = 1;
}
#chemSpider: Get ChemSpider Content
sub chemSpider : Local{
my ( $self, $c ) = @_;
my $term = $c->req->param('term');
#my $category_id = $c->session->{category_id};
my $inchi;
my $spider_id_array;
my $category_id;
if($c->req->param('category_id')){$category_id = $c->req->param('category_id');}else{ $category_id = $c->session->{category_id};}
my $token = 'f0cc0b75-342a-4e72-853a-9784c821d552';
my $spider_thumbnail_service = 'http://www.chemspider.com/Search.asmx/GetCompoundThumbnail';
my $sql = "SELECT word_id FROM hg_words WHERE word='$term'";
my($word_id) = SQLExec($sql, '@');
$sql = "SELECT category_word_id, word_type_id FROM hg_category_words WHERE word_id = $word_id AND category_id = $category_id";
warn "GET WORD TYPE: $sql";
my($category_word_id, $word_type_id) = SQLExec($sql, '@');
if($word_type_id == 2){
$spider_id_array = $self->_chemSpiderThumbnailSearch({term => $term, staticPath => $c->config->{staticPATH}});
}
$c->stash->{chemspider} = \@$spider_id_array;
$c->stash->{word_type} = $word_type_id;
}
#Display proteins that have a pdb file
sub uniprotJmol : Local {
my ($self, $c) = @_;
my $word = $c->req->param('term');
my $category_id = $c->session->{category_id};
my($word_id) = $hg_model->get_word_id({word => $word});
my($category_word_id, $word_type_id) = $hg_model->get_category_word_id({word => $word, category_id => $category_id});
my($word_identifier_id, $identifier) = $hg_model->get_word_identifier_id({category_word_id => $category_word_id});
my $sql = "SELECT pdb_id FROM uniprot_to_pdb WHERE uniprotkb_id = '$identifier' LIMIT 0,1";
my($pdb) = $mysperql_pdb->sqlexec($sql, '@');
$c->stash->{jmolFile} = $c->config->{rootURL} . 'pdb/'.$pdb.'.pdb.gz';
$c->stash->{jsFiles} = [$c->config->{rootURL} .'static/js/jmol/Jmol.js'];
$c->stash->{nowrap} = 1;
}
#chemSpider: Get ChemSpider Content
sub jChemPaintToChemSpider : Local{
my ( $self, $c ) = @_;
my $smiles = $c->req->param('smiles');
warn "SMILES: $smiles";
$c->stash->{template} = 'hg/chemSpider.tt2';
my $path = $c->config->{staticPATH};
my $inchi_key;
if($smiles){
warn $smiles."<---------";
my $inchi = $self->_smilesToInchi({smiles=> $smiles});
$inchi_key = $self->_inchiToOther({inchi => $inchi, operation => 'InChIToInChIKey'});
}
my $spider_id_array = $self->_chemSpiderThumbnailSearch({term => $inchi_key, staticPath => $path});
if(@$spider_id_array){
$c->stash->{chemspider} = \@$spider_id_array;
}
else{$c->stash->{spider_message} = "No results found for the query using the smile string: \n $smiles";}
$c->stash->{word_type} = 2;
}
sub _chemSpiderThumbnailSearch{
my ( $self, $arg_refs) = @_;
my @spider_id_array;
my $token = 'f0cc0b75-342a-4e72-853a-9784c821d552';
my $spider_thumbnail_service = 'http://www.chemspider.com/Search.asmx/GetCompoundThumbnail';
my $browser = LWP::UserAgent->new;
my $xml = new XML::Simple;
my $spider_simple_service = 'http://www.chemspider.com/Search.asmx/SimpleSearch';
#Get thumbnail image of chemical word
my $simple_url = URI->new( $spider_simple_service );
$simple_url->query_form(
'query' => $arg_refs->{term},
'token' => $token,
);
my $spider_simple_content = $browser->get($simple_url);
my $chemspider_simple_data = $xml->XMLin($spider_simple_content->content,ForceArray => 1);
my $chemspider_ref = $chemspider_simple_data->{int};
foreach my $chemspider_id (@$chemspider_ref){
#Get thumbnail image of chemical word
my $thumbnail_url = URI->new( $spider_thumbnail_service );
$thumbnail_url->query_form(
'id' => $chemspider_id,
'token' => $token,
);
my $spider_thumbnail_content = $browser->get($thumbnail_url);
#Get XML thumbnail content and decode 64bit string
my $data = $xml->XMLin($spider_thumbnail_content->content);
my $decoded_64 = decode_base64($data->{content});
open(FILE, '>' . $arg_refs->{staticPath} . 'files/' . $chemspider_id . '.png');
print FILE $decoded_64;
close(FILE);
push(@spider_id_array,$chemspider_id);
}
return \@spider_id_array;
}
#chemEdMovie: Get ChemEdDL video
sub chemEdMovie : Local{
my ( $self, $c ) = @_;
my $term = $c->req->param('term');
$c->stash->{jsFile} = ['/static/js/QTP_Library.js','/static/js/AC_Quicktime.js'];
my $rootURL = 'http://www.chemeddl.org:8080/';
my $service = 'alfresco/service/custom/video/';
my $query = '?name='.$term;
my $auth = $self->_get_chemEd_auth();
my $video = get($rootURL . $service . $query . $auth);
$video =~ m/<body.*?>(.*)<\/body>/six;
$video =~ s/\/alfresco/http:\/\/www.chemeddl.org:8080\/alfresco/g;
$c->stash->{video} = $video;
}
#_get_chemEd_auth: Get authorization ticket from chemeddl
sub _get_chemEd_auth : Private{
my ( $self) = @_;
my $rootURL = 'http://www.chemeddl.org:8080/';
my $ticketXML = get($rootURL . 'alfresco/service/api/login?u=mabauer&pw=chemeddl1MAB');
$ticketXML =~ /<ticket>(.*)<\/ticket>/g;
my $ticket = $1;
my $auth = '&alf_ticket=' . $ticket;
return $auth
}
#Build definiton page popup window
sub definition : Local{
my ( $self, $c ) = @_;
my $term = $c->req->param('term');
my ($word_id, $category_id, $definition_type_id, $definition) = $self->_get_def( {term => $term} );
$c->stash->{nowrap} = 1;
$c->stash->{definition} = $definition;
$c->stash->{term} = $term;
}
#defTran: Using google translate application to translate the definition
sub defTran : Local{
my ( $self, $c ) = @_;
my $word = $c->req->param('term');
my $category_id = $c->session->{category_id};
my $sql = "SELECT word_id FROM hg_words WHERE word='$word'";
my($word_id) = SQLExec($sql, '@');
$sql = "SELECT citation,image_icon,bgcolor,fgcolor FROM hg_category_citations WHERE category_id = '$category_id'";
my($citation,$image_icon,$bgcolor,$fgcolor) = SQLExec($sql, '@');
my ($definition) = $self->_get_def( {word_id => $word_id, category_id => $category_id} );
$c->stash->{template} = 'hg/hg_definition.tt2';
$c->stash->{nowrap} = 1;
$c->stash->{definition} = $definition;
$c->stash->{term} = $word;
$c->stash->{citation} = $citation;
$c->stash->{iconImage} = $image_icon;
$c->stash->{bgcolor} = $bgcolor;
$c->stash->{fgcolor} = $fgcolor;
}
#_get_def: Pulls definition from database and returns it to definiton controller
sub _get_def : Private {
my ( $self, $arg_ref ) = @_;
my $word_id = $arg_ref->{'word_id'};
my $category_id = $arg_ref->{'category_id'};
my %definition;
my @def_array;
my $sql ="SELECT a.category_word_id from hg_category_words a INNER JOIN hg_words b ON a.word_id=b.word_id WHERE b.word_id=$word_id AND a.category_id=$category_id";
my($category_word_id) = SQLExec($sql, '@');
warn "SQL CATEGORY_WORD_ID: $sql =--> $category_word_id";
$sql = "SELECT definition_field_id, field_label FROM hg_definition_fields WHERE category_id=$category_id ORDER BY definition_field_id";
my $data_ref = SQLExec($sql, '\@@');
foreach my $chunk (@$data_ref){
my ($label_id,$label) = @$chunk;
$sql = "SELECT b.data FROM hg_definition_data b INNER JOIN hg_category_words_has_definition_data a ON b.definition_data_id=a.definition_data_id WHERE a.category_word_id=$category_word_id AND b.definition_field_id=$label_id";
my($data) = SQLExec($sql, '@');
$data =~ s/\\\"/\"/g;
$data = WWW::HyperGlossary::Base->_html_unescape( $data );
#decode the string from database
$data = decode("utf8",$data);
push(@def_array,{$label => $data});
}
return \@def_array;
}
#view_def: View defintion including older versions
sub view_def : Local {
my ($self, $c) = @_;
my $term;
$c->req->param('word') ? ($term = $c->req->param('word')) : ($term = $c->flash->{term});
my $definition_id = $c->req->param('def_id');
my ($word_id, $category_id, $definition_type_id, $definition) = $self->_get_def( {term => $term, def_id => $definition_id} );
my $html = $self->_buildSelect( {term => $term} );
$c->stash->{action_url} = $c->config->{rootURL} . 'hg/view_def';
$c->stash->{definition} = $definition;
$c->stash->{term} = $term;
$c->stash->{versionSelect} = $html;
}
#_buildSelect: Dynamically build the select
sub _buildSelect
{
my ($self, $argref) = @_;
my ($html, $selected, $current_id);
my $sql = "select definition_id, revision_date FROM hg_definitions, hg_words WHERE ";
$sql .= "hg_words.word_id=hg_definitions.word_id AND word='$argref->{term}' ORDER BY revision_date DESC;";
warn 'HTML SELELCT SQL: '.$sql;
my ($definition_ids) = SQLExec( $sql, '\@@' );
$html .= "<select name='def_id'>\n";
if (! $current_id) { $current_id = 0; $html .= " <option value=''> "; }
foreach my $datum (@{ $definition_ids }) {
my ($id, $label) = @$datum;
if ($id == $current_id) { $selected = ' selected'; } else { $selected = ''; }
$html .= " <option value='$id' $selected> $label ";
}
$html .= "</select>\n";
return $html;
}
#uses ChemSpiders open Babel Web Service to convert between different chemical identifiers
sub _openBabelWebService {
my ($self, $arg_refs) = @_;
my $spider_openbabel_service = 'http://www.chemspider.com/OpenBabel.asmx/Convert';
my $browser = LWP::UserAgent->new;
my $xml = new XML::Simple;
my $simple_url = URI->new( $spider_openbabel_service );
$simple_url->query_form(
'what' => $arg_refs->{what},
'fromFormat' => $arg_refs->{fromFormat},
'toFormat' => $arg_refs->{toFormat}
);
my $spider_simple_content = $browser->get($simple_url);
my $to_format= $xml->XMLin($spider_simple_content->content);
return $to_format->{content};
}
sub _cactusConverter {
my ($self, $arg_refs) = @_;
my $cactus_service = 'http://cactus.nci.nih.gov/chemical/structure/'.$arg_refs->{fromFormat}."/file";
my $browser = LWP::UserAgent->new;
my $simple_url = URI->new( $cactus_service );
$simple_url->query_form(
'format' => $arg_refs->{toFormat}
);
my $cactus_content = $browser->get($simple_url);
#my $to_format= $xml->XMLin($cactus_content->content);
my $results = $cactus_content->content;
chomp($results);
return $results;
}
sub _smilesToInchi {
my ($self, $arg_refs) = @_;
my $spider_smiles_service = 'http://www.chemspider.com/InChI.asmx/SMILESToInChI';
my $browser = LWP::UserAgent->new;
my $xml = new XML::Simple;
my $simple_url = URI->new( $spider_smiles_service );
$simple_url->query_form(
'smiles' => $arg_refs->{smiles}
);
my $spider_simple_content = $browser->get($simple_url);
my $to_format= $xml->XMLin($spider_simple_content->content);
return $to_format->{content};
}
sub _inchiToOther{
my ($self, $arg_refs) = @_;
my $token = 'f0cc0b75-342a-4e72-853a-9784c821d552';
my $spider_inchi_to_key_service = 'http://www.chemspider.com/InChI.asmx/' . $arg_refs->{operation};
my $browser = LWP::UserAgent->new;
my $xml = new XML::Simple;
#Get thumbnail image of chemical word
my $simple_url = URI->new( $spider_inchi_to_key_service );
$simple_url->query_form(
'inchi' => $arg_refs->{inchi},
);
my $spider_simple_content = $browser->get($simple_url);
my $inchi_key = $xml->XMLin($spider_simple_content->content);
return $inchi_key->{content};
}
#_smileToMol2: Converts a smile string to a Mol2 file using Ballon
sub _smileToMol2 {
my ($self, $argref) = @_;
my $smile = $argref->{smile};
$smile =~s/\t//g;
chomp($smile);
$smile = "\"$smile\"";
my $mmff_file = $argref->{staticPATH} . 'jmolFile/MMFF94.mff';
my $out_file = $argref->{staticPATH} . 'jmolFile/'.$argref->{filename};
#my $cmd = "balloon --nconfs 1 --noGA $out_file";
local $SIG{'CHLD'}='IGNORE';
my $cmd = $argref->{staticPATH} . "jmolFile/balloon -f $mmff_file --nconfs 1 --noGA $smile $out_file";
my $shit = system($cmd);
return;
}
#hg_word_identifier: Using google translate application to translate the definition
sub hg_word_identifier : Local{
my ( $self, $c ) = @_;
my $word = $c->req->param('term');
my $callback = $c->req->param('whgCallbackFunction');
my $category_id = $c->session->{category_id};
if(exists $c->session->{category_id}){$category_id = $c->session->{category_id};}else{ $category_id = $c->req->param('category');}
#get category_word_id
my $sql = "SELECT category_word_id FROM hg_words, hg_category_words WHERE hg_category_words.word_id=hg_words.word_id AND ";
$sql .= "hg_category_words.category_id = '$category_id' AND hg_words.word='$word'";
my($category_word_id) = SQLExec( $sql, '@' );
warn $sql;
#get word_identifier
#my $sql = "SELECT identifier_id FROM hg_word_identifiers WHERE category_word_id ='$arg_ref->{category_word_id}'";
$sql = "SELECT hg_word_identifiers.word_identifier_id, hg_word_identifiers.identifier, hg_word_type_identifiers.word_type_identifier_id ";
$sql .= "FROM hg_word_identifiers, hg_word_type_identifiers WHERE category_word_id = '$category_word_id' ";
$sql .= "AND hg_word_identifiers.word_type_identifier_id = hg_word_type_identifiers.word_type_identifier_id";
my($word_identifier_id, $identifier,$word_type_identifier_id) = SQLExec( $sql, '@' );
warn $sql;
if(!$word_type_identifier_id){$word_type_identifier_id = 0;}
if($callback){
my $json = JSON::XS->new();
my $jsonStructure->{word_identifier_type} = $word_type_identifier_id;
my $json_cb = $json->encode({'json_data'=>[$jsonStructure]});
$c->res->header('Content-Type', 'text/javascript');
#my $whg_cb = 'function whgCallbackFunction(){var word_identifier_type='.$word_type_identifier_id.';alert("SHIT");}';
my $whg_cb = $callback.'(('.$json_cb.'))';
$c->response->body($whg_cb);
}
else{
$c->stash->{'json_data'} = {word_identifier_type => [$word_type_identifier_id]};
$c->detach($c->view('JSON'));
}
}
sub export_javascript {
my ($rootURL, $category) = @_;
my $javascript = <<EOF;
Ext.onReady(function() {
var category = $category;
function check_term_identifier(target){
var conn = new Ext.data.Connection();
var identifier = Ext.data.Record.create([
{ name: 'word_identifier_type', type: 'int' }
]);
var Store = new Ext.data.JsonStore({
proxy: new Ext.data.ScriptTagProxy({
url : '$rootURL/hg/hg_word_identifier',
callbackParam : 'whgCallbackFunction',
callbackPrefix : 'WHG',
scriptIdPrefix : 'whgScript'
}),
baseParams: {"term": target.innerHTML, "category": category},
root: 'json_data',
fields: identifier
});
var word_identifier_type;
Store.load( {
callback: function(){
Store.each(function(record){
identifier_type = record.data['word_identifier_type'];
hg_window_display(target,identifier_type);
});
}
});
/*Store.on('load',function(){
alert("YEAH BOY!!");
identifier_type = Store.getAt(0);
alert(identifier_type);
hg_window_display(target,identifier_type);
});*/
/*
conn.request({
url: '$rootURL/hg/hg_word_identifier?term='+target.innerHTML+'&category='+category
,method: 'POST'
,params: {"term": target.innerHTML, "category": category}
,success: function(response,options) {
var data = Ext.decode(response.responseText);
identifier_type = data.json_data.word_identifier_type;
hg_window_display(target,identifier_type);
}
,failure: function(f,a) {
Ext.Msg.alert('Status', 'No response from server');
}
,listeners: {
'requestcomplete':{
fn: function(conn,res,opt){
alert('DONESKI!!!!');
},
scope: this
}
}
});
*/
Ext.Ajax.on("requestcmplete", function(conn,response,options){alert("DONE!!");});
// return identifier_type;
}
Ext.select('.hg3').highlight("0000ff", { attr: 'color', duration: 5});
Ext.QuickTips.init()
Ext.select('body').on('click', function(e, t) {
var t = Ext.get(t);
if(t.hasClass('hg3')){
var target = e.getTarget();
identifier_type_id = check_term_identifier(target);
}
});//eo on('click'
}); // eo function onReady
function queryChemSpider(smiles) {
var searchURL = '$rootURL/hg/jChemPaintToChemSpider';
var spiderSearchPanel = new Ext.ux.ManagedIFrame.Panel({
autoLoad:{
url : searchURL
,params : {smiles :smiles}}
,title : 'SMILE String Search'
,defaults : {border:false, activeTab:0}
,hideMode : 'nosize'
,constrain : true
,closable : true
});
tabP.add(spiderSearchPanel);
}
function hg_window_display(target,identifier_type){
var category_id = $category;
var movieURL = '$rootURL/hg/chemEdMovie?term='+target.innerHTML;
var chemspiderURL = '$rootURL/hg/chemSpider?term='+target.innerHTML;
var jchemURL = '$rootURL/hg/jchempaint?term='+target.innerHTML+'&category_id='+category_id;
var jmolURL = '$rootURL/hg/jmol?term='+target.innerHTML;
var defURL = '$rootURL/hg/defTran?term='+target.innerHTML;
var defpanel = ({
defaultSrc : defURL
,title : 'Definition'
,xtype : 'iframepanel'
,layout : 'fit'
});
var spiderpanel = new Ext.ux.ManagedIFrame.Panel({
defaultSrc : chemspiderURL
,title : 'ChemSpider Results'
,defaults : {border:false, activeTab:0}
,hideMode : 'nosize'
,constrain : true
});
var moviepanel = new Ext.ux.ManagedIFrame.Panel({
defaultSrc : movieURL
,title : 'ChemEd DL Video'
,defaults : {border:false, activeTab:0}
,hideMode : 'nosize'
,constrain : true
});
var jmolpanel = new Ext.ux.ManagedIFrame.Panel({
defaultSrc : jmolURL
,title : '3D Structure Model'
,defaults : {border:false, activeTab:0}
,hideMode : 'nosize'
,constrain : true
});
var jchempaintpanel = new Ext.ux.ManagedIFrame.Panel({
defaultSrc : jchemURL
,title : '2D Structure Model'
,defaults : {border:false, activeTab:0}
,hideMode : 'nosize'
,constrain : true
});
var tab_items = new Array();
tab_items[0] = defpanel;
if(identifier_type == 1){
tab_items[1] = spiderpanel;
tab_items[2] = jmolpanel;
tab_items[3] = jchempaintpanel;
}
tabP = new Ext.TabPanel({
title : 'HyperGlossary'
,enableTabScroll : true
,activeTab : 0
,items : tab_items
});
win = new Ext.Window({
title : 'Information Overlay For: '+target.innerHTML,
layout : 'fit',
constrain : true,
width : 600,
height : 500,
closable : true,
border : true,
items : [tabP]
});
win.show(this);
}
EOF
return $javascript;
}
1;
| DeepLit/WHG | lib/HyperGlossary/Controller/Hg.pm | Perl | apache-2.0 | 40,317 |
#!/opt/local/bin/perl -T
#############################################
# -=[ Virtual Patching Converter Script ]=- #
# Converts OWASP ZAP XML Output #
# https://code.google.com/p/zaproxy/ #
# #
# zap2modsec.pl #
# Version: 1.0 #
# #
# Copyright 2011 #
# Trustwave's SpiderLabs Research Team #
# www.trustwave.com #
# #
# Based On Code Originally Created by: #
# The Denim Group #
# www.denimgroup.com #
#############################################
use XML::Smart;
use Switch;
use Data::Types qw(:all);
use Data::Validate::URI qw(is_uri);
use Getopt::Std;
use Acme::Comment type=>'C++', one_line=>1; #Block commenting, can be removed later
#############
# Variables #
#############
# [Configuration Vars]
my %param;
getopt("f",\%param);
$filename = $param{f};
my $all_vulnerabilities_filename = "$filename";
unless ($filename) {
print "Flag:\n\n\t -f:\t path to ZAP xml report file\nUsage:\n\n\t./zap2modsec.pl -f ./zap_report.xml\n\n";
exit;
}
my $modsec_rules_file = "./modsecurity_crs_48_virtual_patches.conf";
# [End Config Vars]
my $VULN_CLASS_XSS = "Cross Site Scripting";
my $VULN_CLASS_SQLI = "SQL Injection";
my $VULN_CLASS_SQLI_FINGERPRINT = "SQL Injection Fingerprinting";
my $VULN_CLASS_LFI = "Path Traversal";
my $VULN_CLASS_RFI = "Remote File Inclusion";
my $VULN_CLASS_HTTPRS = "HTTP Response Splitting";
# Only the vulnerabilities in this array will have
# rules generated for them.
my @supported_vulns = ($VULN_CLASS_XSS, $VULN_CLASS_SQLI, $VULN_CLASS_SQLI_FINGERPRINT, $VULN_CLASS_LFI, $VULN_CLASS_RFI, $VULN_CLASS_HTTPRS);
my $num_rules_generated=0;
my $num_not_supported=0;
my $num_bad_urls=0;
my $wait_for_keypress=1;
my $request_failed=0;
my $all_vulns_xml;
my @type;
my @id;
my $vuln_count;
my $num_attacks_flag=0;
my $num_attacks_noflag=0;
# End Vars ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#############
# Main #
#############
# Clean up env so perl doesn't complain
# when trying to run the restart snort
# script.
delete @ENV{qw(IFS CDPATH ENV BASH_ENV PATH)};
$all_vulns_xml = XML::Smart->new($all_vulnerabilities_filename);
@type = $all_vulns_xml->{OWASPZAPReport}{site}{alerts}{alertitem}('[@]','alert');
@url = $all_vulns_xml->{OWASPZAPReport}{site}{alerts}{alertitem}('[@]','uri');
@param = $all_vulns_xml->{OWASPZAPReport}{site}{alerts}{alertitem}('[@]','param');
open(my $MODSEC_RULES, '>' , $modsec_rules_file) || die "Unable to open modsecurity rules file $modsec_rules_file";
$MODSEC_RULES->autoflush(1);
$vuln_count = 0;
foreach my $current_type (@type){
print "==================================================================================================\n";
print "Vulnerability[$vuln_count] - Type: $current_type\n";
if(exists {map { $_ => 1 } @supported_vulns}->{$current_type}){
parseData(to_string($current_type));
}else {
print "Vulnerability Type: $type is not supported in this version.\n";
$num_not_supported++;
}
$vuln_count++;
}
close($MODSEC_RULES);
print "==================================================================================================\n";
print "\n\n************ END OF SCRIPT RESULTS *****************\n";
print "Number of Vulnerabilities Processed: $vuln_count\n";
print "Number of ModSecurity rules generated: $num_rules_generated\n";
print "Number of Unsupported vulns skipped: $num_not_supported\n";
print "Number of bad URLs (rules not gen): $num_bad_urls\n";
print "****************************************************\n\n";
print "----------------------------------------------------\n";
print "To activate the virtual patching file ($modsec_rules_file),\n";
print "copy it into the CRS \"base_rules\" directory and then create\n";
print "a symlink to it in the \"activated_rules\" directory.\n";
print "-----------------------------------------------------\n\n";
###############
# Subroutines #
###############
sub parseData
{
my($vuln_str) = @_;
my $vuln_detail_filename;
my $current_vuln_xml;
my $current_vuln_url;
my $current_vuln_param;
my $current_uricontent;
my @current_params;
my $id = $vuln_count;
print "Found a $vuln_str vulnerability.\n";
$current_vuln_xml = XML::Smart->new($all_vulnerabilities_filename);
$current_vuln_url = $url[$vuln_count];
print URL_LIST "$current_vuln_url\n";
# Validate url (need separate sub?)
print "Validating URL: $current_vuln_url\n";
if(is_uri(to_string($current_vuln_url))){
print "URL is well-formed\n";
print "Continuing Rule Generation\n";
} else {
print "URL is NOT well-formed. Breaking Out of Rule Generation\n";
$num_bad_urls++;
# Waits for keypress in test mode so you can
# see why the URL failed validation.
if($test_mode){
wait_for_keypress();
}
return;
}
$current_uricontent = get_uricontent($current_vuln_url);
# Only need param if XSS attack,SQLINJ,XPATH
# and maybe for HTTPRS, DT.
# NOT for PRL and DI
if(($vuln_str ne $VULN_CLASS_PRL) && ($vuln_str ne $VULN_CLASS_DI)){
@current_params = $param[$vuln_count];
}
if(($vuln_str ne $VULN_CLASS_PRL) && ($vuln_str ne $VULN_CLASS_DI)){
print "Current vulnerable Param(s): @current_params\n";
}
generate_patch($vuln_str,$current_uricontent,@current_params);
}
sub generate_patch
{
my($type,$uricontent,@params,$current_vuln_xml) = @_;
my $rule = "";
$id = "1".$vuln_count;
switch($type)
{
case ($VULN_CLASS_XSS)
{
if($uricontent ne "" && @params){
foreach(@params){
if($_ ne ""){
# Check to see if each vulnerable parameter is valid
# then generate a rule using both uricontent and the
# parameter
$rule = "SecRule REQUEST_FILENAME \"$uricontent\" \"chain,phase:2,t:none,block,msg:'Virtual Patch for $type',id:'$id',tag:'WEB_ATTACK/XSS',tag:'WASCTC/WASC-8',tag:'WASCTC/WASC-22',tag:'OWASP_TOP_10/A2',tag:'OWASP_AppSensor/IE1',tag:'PCI/6.5.1',logdata:'%{MATCHED_VAR_NAME}',severity:'2'\"\n\tSecRule \&TX:\'\/XSS.*ARGS:$_\/\' \"\@gt 0\" \"setvar:tx.xss_score=+%{tx.critical_anomaly_score},setvar:tx.anomaly_score=+%{tx.critical_anomaly_score}\"";
print $MODSEC_RULES "#\n# OWASP ZAP Virtual Patch Details:\n# ID: $id\n# Type: $type\n# Vulnerable URL: $uricontent\n# Vulnerable Parameter: $_\n#\n".$rule."\n\n";
print "$VULN_CLASS_XSS (uricontent and param) rule successfully generated and saved in $modsec_rules_file.\n";
$num_rules_generated++;
}
}
}
}
case ($VULN_CLASS_SQLI)
{
if($uricontent ne "" && @params){
foreach(@params){
if($_ ne ""){
$rule = "SecRule REQUEST_FILENAME \"$uricontent\" \"chain,phase:2,t:none,block,msg:'Virtual Patch for $type',id:'$id',tag:'WEB_ATTACK/SQL_INJECTION',tag:'WASCTC/WASC-19',tag:'OWASP_TOP_10/A1',tag:'OWASP_AppSensor/CIE1',tag:'PCI/6.5.2',logdata:'%{MATCHED_VAR_NAME}',severity:'2'\"\n\tSecRule \&TX:\'\/SQL_INJECTION.*ARGS:$_\/\' \"\@gt 0\" \"setvar:tx.sql_injection_score=+%{tx.critical_anomaly_score},setvar:tx.anomaly_score=+%{tx.critical_anomaly_score}\"";
print $MODSEC_RULES "#\n# OWASP ZAP Virtual Patch Details:\n# ID: $id\n# Type: $type\n# Vulnerable URL: $uricontent\n# Vulnerable Parameter: $_\n#\n".$rule."\n\n";
print "$VULN_CLASS_SQLI (uricontent and param) rule successfully generated and saved in $modsec_rules_file.\n";
$num_rules_generated++;
}
}
}
}
case ($VULN_CLASS_BLIND_SQLI)
{
if($uricontent ne "" && @params){
foreach(@params){
if($_ ne ""){
$rule = "SecRule REQUEST_FILENAME \"$uricontent\" \"chain,phase:2,t:none,block,msg:'Virtual Patch for $type',id:'$id',tag:'WEB_ATTACK/SQL_INJECTION',tag:'WASCTC/WASC-19',tag:'OWASP_TOP_10/A1',tag:'OWASP_AppSensor/CIE1',tag:'PCI/6.5.2',logdata:'%{MATCHED_VAR_NAME}',severity:'2'\"\n\tSecRule \&TX:\'\/SQL_INJECTION.*ARGS:$_\/\' \"\@gt 0\" \"setvar:tx.sql_injection_score=+%{tx.critical_anomaly_score},setvar:tx.anomaly_score=+%{tx.critical_anomaly_score}\"";
print $MODSEC_RULES "#\n# OWASP ZAP Virtual Patch Details:\n# ID: $id\n# Type: $type\n# Vulnerable URL: $uricontent\n# Vulnerable Parameter: $_\n#\n".$rule."\n\n";
print "$VULN_CLASS_SQLI (uricontent and param) rule successfully generated and saved in $modsec_rules_file.\n";
$num_rules_generated++;
}
}
}
}
case ($VULN_CLASS_LFI)
{
if($uricontent ne "" && @params){
foreach(@params){
if($_ ne ""){
$rule = "SecRule REQUEST_FILENAME \"$uricontent\" \"chain,phase:2,t:none,block,msg:'Virtual Patch for $type',id:'$id',tag:'WEB_ATTACK/LFI',tag:'WASCTC/WASC-33',logdata:'%{MATCHED_VAR_NAME}',severity:'2'\"\n\tSecRule \&TX:\'\/LFI.*ARGS:$_\/\' \"\@gt 0\" \"setvar:tx.anomaly_score=+%{tx.critical_anomaly_score}\"";
print $MODSEC_RULES "#\n# OWASP ZAP Virtual Patch Details:\n# ID: $id\n# Type: $type\n# Vulnerable URL: $uricontent\n# Vulnerable Parameter: $_\n#\n".$rule."\n\n";
print "$VULN_CLASS_LFI (uricontent and param) rule successfully generated and saved in $modsec_rules_file.\n";
$num_rules_generated++;
}
}
}
}
case ($VULN_CLASS_RFI)
{
if($uricontent ne "" && @params){
foreach(@params){
if($_ ne ""){
$rule = "SecRule REQUEST_FILENAME \"$uricontent\" \"chain,phase:2,t:none,block,msg:'Virtual Patch for $type',id:'$id',tag:'WEB_ATTACK/RFI',tag:'WASCTC/WASC-05',logdata:'%{MATCHED_VAR_NAME}',severity:'2'\"\n\tSecRule \&TX:\'\/RFI.*ARGS:$_\/\' \"\@gt 0\" \"setvar:tx.anomaly_score=+%{tx.critical_anomaly_score}\"";
print $MODSEC_RULES "#\n# OWASP ZAP Virtual Patch Details:\n# ID: $id\n# Type: $type\n# Vulnerable URL: $uricontent\n# Vulnerable Parameter: $_\n#\n".$rule."\n\n";
print "$VULN_CLASS_LFI (uricontent and param) rule successfully generated and saved in $modsec_rules_file.\n";
$num_rules_generated++;
}
}
}
}
case ($VULN_CLASS_HTTPRS)
{
if($uricontent ne "" && @params){
foreach(@params){
if($_ ne ""){
$rule = "SecRule REQUEST_FILENAME \"$uricontent\" \"chain,phase:2,t:none,block,msg:'Virtual Patch for $type',id:'$id',tag:'WEB_ATTACK/RESPONSE_SPLITTING',tag:'WASCTC/WASC-25',logdata:'%{MATCHED_VAR_NAME}',severity:'2'\"\n\tSecRule \&TX:\'\/RESPONSE_SPLITTING.*ARGS:$_\/\' \"\@gt 0\" \"setvar:tx.anomaly_score=+%{tx.critical_anomaly_score}\"";
print $MODSEC_RULES "#\n# OWASP ZAP Virtual Patch Details:\n# ID: $id\n# Type: $type\n# Vulnerable URL: $uricontent\n# Vulnerable Parameter: $_\n#\n".$rule."\n\n";
print "$VULN_CLASS_RFI (uricontent and param) rule successfully generated and saved in $modsec_rules_file.\n";
$num_rules_generated++;
}
}
}
}
}
}
sub get_uricontent
{
my($url) = @_;
my $regex = "http:\/\/+[a-zA-Z0-9.:-]*\/";
# First, trim the first part out of the URL:
# http://.../
$url =~ /$regex/;
substr($url,index($url,$&),length($&)) = "";
# If the URL contains a php or cgi query with
# one or more params and values, trim those out.
# Trim from the question mark to the end.
if($url =~ /\?/){
substr($url,index($url,"?")) = "";
}
return $url;
}
| SpiderLabs/owasp-modsecurity-crs | util/virtual-patching/zap2modsec.pl | Perl | apache-2.0 | 12,538 |
=head1 LICENSE
Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
Copyright [2016-2019] EMBL-European Bioinformatics Institute
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=cut
package XrefMapper::LoadMapper;
use strict;
use vars '@ISA';
@ISA = qw{ XrefMapper::BasicMapper };
use warnings;
use XrefMapper::BasicMapper;
use Cwd;
use DBI;
use File::Basename;
use IPC::Open3;
sub update_core {
}
1;
| muffato/ensembl | misc-scripts/xref_mapping/XrefMapper/LoadMapper.pm | Perl | apache-2.0 | 936 |
#
# Copyright 2021 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package apps::vmware::wsman::mode::hardware;
use base qw(centreon::plugins::templates::hardware);
use strict;
use warnings;
use apps::vmware::wsman::mode::components::resources qw($mapping_HealthState $mapping_OperationalStatus);
sub set_system {
my ($self, %options) = @_;
$self->{regexp_threshold_numeric_check_section_option} = '^(cim_numericsensor)$';
$self->{cb_hook1} = 'get_type';
$self->{thresholds} = {
default => [
['Unknown', 'OK'],
['OK', 'OK'],
['Degraded', 'WARNING'],
['Minor failure', 'WARNING'],
['Major failure', 'CRITICAL'],
['Critical failure', 'CRITICAL'],
['Non-recoverable error', 'CRITICAL'],
['Other', 'UNKNOWN'],
['Stressed', 'WARNING'],
['Predictive Failure', 'WARNING'],
['Error', 'CRITICAL'],
['Starting', 'OK'],
['Stopping', 'WARNING'],
['In Service', 'OK'],
['No Contact', 'CRITICAL'],
['Lost Communication', 'CRITICAL'],
['Aborted', 'CRITICAL'],
['Dormant', 'OK'],
['Supporting Entity in Error', 'CRITICAL'],
['Completed', 'OK'],
['Power Mode', 'OK'],
['Relocating', 'WARNING'],
],
};
$self->{components_path} = 'apps::vmware::wsman::mode::components';
$self->{components_module} = ['omc_discretesensor', 'omc_fan', 'omc_psu', 'vmware_storageextent', 'vmware_controller',
'vmware_storagevolume', 'vmware_battery', 'vmware_sassataport', 'cim_card',
'cim_computersystem', 'cim_numericsensor', 'cim_memory', 'cim_processor', 'cim_recordlog'];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
});
return $self;
}
sub get_type {
my ($self, %options) = @_;
my $result = $options{wsman}->request(uri => 'http://schema.omc-project.org/wbem/wscim/1/cim-schema/2/OMC_SMASHFirmwareIdentity', dont_quit => 1);
$result = pop(@$result) if (defined($result));
$self->{manufacturer} = 'unknown';
if (defined($result->{Manufacturer}) && $result->{Manufacturer} ne '') {
$self->{manufacturer} = $result->{Manufacturer};
}
$result = $options{wsman}->request(uri => 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_Chassis');
$result = pop(@$result);
my $model = defined($result->{Model}) && $result->{Model} ne '' ? $result->{Model} : 'unknown';
$self->{output}->output_add(long_msg => sprintf("Manufacturer : %s, Model : %s", $self->{manufacturer}, $model));
$self->{wsman} = $options{wsman};
}
sub get_status {
my ($self, %options) = @_;
my $status;
if ($self->{manufacturer} =~ /HP/i) {
$status = $mapping_HealthState->{$options{entry}->{HealthState}} if (defined($options{entry}->{HealthState}) &&
defined($mapping_HealthState->{$options{entry}->{HealthState}}));
} else {
$status = $mapping_OperationalStatus->{$options{entry}->{OperationalStatus}} if (defined($options{entry}->{OperationalStatus}) &&
defined($mapping_OperationalStatus->{$options{entry}->{OperationalStatus}}));
}
return $status;
}
1;
__END__
=head1 MODE
Check ESXi Hardware.
Example: centreon_plugins.pl --plugin=apps::vmware::wsman::plugin --mode=hardware --hostname='XXX.XXX.XXX.XXX'
--wsman-username='XXXX' --wsman-password='XXXX' --wsman-scheme=https --wsman-port=443 --verbose
=over 8
=item B<--component>
Which component to check (Default: '.*').
Can be: 'omc_discretesensor', 'omc_fan', 'omc_psu', 'vmware_storageextent', 'vmware_controller',
'vmware_storagevolume', 'vmware_battery', 'vmware_sassataport', 'cim_card',
'cim_computersystem', 'cim_numericsensor', 'cim_memory', 'cim_processor', 'cim_recordlog'.
=item B<--filter>
Exclude some parts (comma seperated list) (Example: --filter=cim_card --filter=cim_recordlog)
Can also exclude specific instance: --filter='omc_psu,Power Supply 1'
=item B<--no-component>
Return an error if no compenents are checked.
If total (with skipped) is 0. (Default: 'critical' returns).
=item B<--threshold-overload>
Set to overload default threshold values (syntax: section,[instance,]status,regexp)
It used before default thresholds (order stays).
Example: --threshold-overload='cim_card,CRITICAL,^(?!(OK)$)'
=item B<--warning>
Set warning threshold for temperatures (syntax: type,instance,threshold)
Example: --warning='cim_numericsensor,.*,30'
=item B<--critical>
Set critical threshold for temperatures (syntax: type,instance,threshold)
Example: --critical='cim_numericsensor,.*,40'
=back
=cut
| Tpo76/centreon-plugins | apps/vmware/wsman/mode/hardware.pm | Perl | apache-2.0 | 5,642 |
=head1 LICENSE
# Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
# Copyright [2016-2018] EMBL-European Bioinformatics Institute
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
=head1 CONTACT
Please email comments or questions to the public Ensembl
developers list at <http://lists.ensembl.org/mailman/listinfo/dev>.
Questions may also be sent to the Ensembl help desk at
<http://www.ensembl.org/Help/Contact>.
=cut
=head1 NAME
Bio::EnsEMBL::Analysis::RunnableDB::HaplotypeProjection -
=head1 SYNOPSIS
my $obj = Bio::EnsEMBL::Analysis::RunnableDB::HaplotypeProjection->new(
-db => $db,
-input_id => $id,
);
$obj->fetch_input
$obj->run
my @newfeatures = $obj->output;
=head1 DESCRIPTION
This method is used to get project the genes annotated in the reference chromosome into the Haplotype regions.
=head1 METHODS
=head1 APPENDIX
The rest of the documentation details each of the object methods.
Internal methods are usually preceded with a _
=cut
# Let the code begin...
package Bio::EnsEMBL::Analysis::RunnableDB::HaplotypeProjection;
use warnings ;
use vars qw(@ISA);
use strict;
# Object preamble
use Bio::EnsEMBL::Analysis::RunnableDB;
use Bio::EnsEMBL::Analysis::Runnable::HaplotypeProjection;
use Bio::EnsEMBL::Analysis::RunnableDB::BaseGeneBuild;
use Bio::EnsEMBL::Utils::Exception qw(throw warning);
#use Bio::EnsEMBL::Analysis::Config::HaplotypeProjection qw (
# );
@ISA = qw(Bio::EnsEMBL::Analysis::RunnableDB::BaseGeneBuild);
############################################################
=head2 new
Usage : $self->new(-DBOBJ => $db,
-INPUT_ID => $id,
-SEQFETCHER => $sf,
-ANALYSIS => $analysis,
);
Function: creates a Bio::EnsEMBL::Analysis::RunnableDB::HaplotypeProjection object
Returns : A Bio::EnsEMBL::Analysis::RunnableDB::HaplotypeProjection object
Args : -dbobj: A Bio::EnsEMBL::DBSQL::DBAdaptor (required),
-input_id: Hap_pair input id (required),
-seqfetcher: A Sequence Fetcher Object,
-analysis: A Bio::EnsEMBL::Analysis (optional)
-extend: determines the extension of the virtual contig
note: not implemented yet!
-golden_path: determines the name of the golden path to use
=cut
sub new {
my ($class,@args) = @_;
my $self = $class->SUPER::new(@args);
return $self;
}
############################################################
sub input_id {
my ($self,$arg) = @_;
if (defined($arg)) {
$self->{_input_id} = $arg;
}
return $self->{_input_id};
}
############################################################
=head2 write_output
Title : write_output
Usage : $self->write_output
Function: Writes output data to db
Returns : array of exons (with start and end)
Args : none
=cut
sub write_output {
my($self,@genes) = @_;
my $db = $self->get_dbadaptor("REFERENCE_DB") ;
# sort out analysis
my $analysis = $self->analysis;
unless ($analysis){
$self->throw("an analysis logic name must be defined in the command line");
}
my $gene_adaptor = $db->get_GeneAdaptor;
@genes = $self->output;
foreach my $gene (@genes) {
$gene->biotype($gene->biotype."_proj");
my $before = scalar(@{$gene->get_all_Transcripts});
unless (scalar(@{$gene->get_all_Transcripts})){
warning("GENE DOES NOT HAVE TRANSCRIPTS:\n");
next;
}
my %trans_types;
$gene->analysis($analysis);
$gene->{'stable_id'} = undef;
# poke the caches
my %s_pfhash;
foreach my $tran (@{$gene->get_all_Transcripts}) {
$tran->biotype($tran->biotype."_proj");
$tran->{'stable_id'} = undef;
my @tsf = @{$tran->get_all_supporting_features};
my @exons= @{$tran->get_all_Exons};
my $tln = $tran->translation;
if ($tln){
$tln->{'stable_id'} = undef;
}
foreach my $exon (@exons) {
if ($tran->seq_region_name ne $exon->seq_region_name){
print "EXON WAS NOT TRANSFORMED BEFORE STORAGE\n";
}else{
print "TRANSFORMED transcript: ",$tran->seq_region_name , " exon: ", $exon->seq_region_name,"\n";
}
$exon->{'stable_id'} = undef;
my @esf = @{$exon->get_all_supporting_features};
}
}
# store
# eval {
if ($before > scalar(@{$gene->get_all_Transcripts})){
print "MISSING TRANSCRIPTS IN WRITTING\n";
}
$gene_adaptor->store($gene);
#print STDERR "wrote gene " . $gene->dbID . " to database ".$gene->adaptor->db->dbname."\n";
# };
# if( $@ ) {
# warning("UNABLE TO WRITE GENE:\n$@");
# }
}
my $genebuilders = $self->get_genebuilders;
foreach my $target (keys %{ $genebuilders } ) {
foreach my $query (keys %{$genebuilders->{$target}}){
$genebuilders->{$target}->{$query}->clean_tables;
$genebuilders->{$target}->{$query}->merge_genes;
}
}
return 1;
}
############################################################
=head2 fetch_input
Function: It fetches the slice or contig according to the input_id,
and it defines the database where the
previous annotations are stored and create a Bio::EnsEMBL::Pipeline::GeneBuilder
object for that genomic, input_id and db
Returns : nothing
Args : none
=cut
sub fetch_input {
my( $self) = @_;
$self->throw("No input id") unless defined($self->input_id);
my $discarded_db = $self->get_dbadaptor("DISCARDED_DB");
print "DISCARDED GENE DB: ", $discarded_db->dbname,"\n";
# database where the genebuild produced genes are.
# the final projection will be stored here
my $out_db = $self->get_dbadaptor("HAP_PROJECTION_DB");
print "OUTPUT DB : ", $out_db->dbname,"\n";
# database where the temporary projections will be stored
my $hap_proj_db = $self->get_dbadaptor("REFERENCE_DB");
print "HAP_PROJECTION DB : ", $hap_proj_db->dbname,"\n";
print $self->input_id,"\n";
my @input_id = split(/:/,$self->input_id);
my $hap_slice = $hap_proj_db->get_SliceAdaptor->fetch_by_region($input_id[0],$input_id[2],$input_id[3],$input_id[4],1,$input_id[2]);
my $slice = $hap_proj_db->get_SliceAdaptor->fetch_by_region($input_id[5],$input_id[7],$input_id[8],$input_id[9],1,$input_id[6]);
#$self->fetch_sequence();
print "HAP_slice: ",$hap_slice,"\n";
print "REF_slice: ",$slice,"\n";
$self->query($hap_slice);
$self->target($slice);
print "QUERY: ",$self->query->seq_region_name,"\n";
print "TARGET: ",$self->target->seq_region_name,"\n";
my $genebuilder = new Bio::EnsEMBL::Analysis::Runnable::HaplotypeProjection
(
'-hap_slice' => $self->query,
'-slice' => $self->target,
'-input_id' => $self->input_id,
);
$genebuilder->discarded_db($discarded_db);
$genebuilder->ensembl_db($hap_proj_db);
$genebuilder->output_db($out_db);
# store the object and the piece of genomic where it will run
$self->addgenebuilder($genebuilder,$self->target,$self->query);
}
############################################################
sub addgenebuilder {
my ($self,$arg,$target,$query) = @_;
if (defined($arg) && defined($target) && defined($query)) {
$self->{_genebuilder}{$target->id}{$query->id} = $arg;
}
else {
$self->throw("Wrong number of inputs [$arg,$target,$query]\n");
}
}
############################################################
sub get_genebuilders {
my ($self) = @_;
return $self->{_genebuilder};
}
############################################################
sub run {
my ($self) = @_;
my @genes;
# get a hash, with keys = contig/slice and value = genebuilder object
my $genebuilders = $self->get_genebuilders;
foreach my $target (keys %{ $genebuilders } ) {
foreach my $query (keys %{$genebuilders->{$target}}){
#@projected_genes = $genebuilders->{$target}->{$query}->project_genes;
@genes = $genebuilders->{$target}->{$query}->project_genes;
# $genebuilders->{$target}->{$query}->merge_genes;
# @genes = $genebuilders->{$target}->{$query}->final_genes;
}
}
$self->output( @genes );
}
############################################################
# override the evil RunnableDB output method:
sub output{
my ($self, @genes ) = @_;
unless ( $self->{_output} ){
$self->{_output} = [];
}
if (@genes){
push( @{$self->{_output}}, @genes );
}
return @{$self->{_output}};
}
############################################################
sub target {
my ($self,$slice) = @_;
if (defined($slice)) {
$self->{_target} = $slice;
}
return $self->{_target};
}
1;
| kiwiroy/ensembl-analysis | modules/Bio/EnsEMBL/Analysis/RunnableDB/HaplotypeProjection.pm | Perl | apache-2.0 | 9,772 |
use 5.008001;
use strict;
use warnings;
package Dist::Zilla::Plugin::Meta::Contributors;
# ABSTRACT: Generate an x_contributors section in distribution metadata
our $VERSION = '0.001'; # VERSION
use Moose;
has contributor => (
is => 'ro',
isa => 'ArrayRef[Str]',
default => sub { [] },
);
sub mvp_multivalue_args { qw/contributor/ }
sub metadata {
my $self = shift;
if ( @{$self->contributor} ) {
return { x_contributors => $self->contributor };
}
else {
return {}
}
}
with 'Dist::Zilla::Role::MetaProvider';
__PACKAGE__->meta->make_immutable;
1;
# vim: ts=4 sts=4 sw=4 et:
__END__
=pod
=head1 NAME
Dist::Zilla::Plugin::Meta::Contributors - Generate an x_contributors section in distribution metadata
=head1 VERSION
version 0.001
=head1 SYNOPSIS
[Meta::Contributors]
contributor = Wile E Coyote <coyote@example.com>
contributor = Road Runner <fast@example.com>
=head1 DESCRIPTION
This module adds author names and email addresses to an C<x_contributors> section
of distribution metadata.
=for Pod::Coverage mvp_multivalue_args metadata
=head1 SEE ALSO
=over 4
=item *
L<Dist::Zilla::Plugin::ContributorsFromGit> -- automatic generation from git commit history
=back
=for :stopwords cpan testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan
=head1 SUPPORT
=head2 Bugs / Feature Requests
Please report any bugs or feature requests through the issue tracker
at L<https://github.com/dagolden/dist-zilla-plugin-meta-contributors/issues>.
You will be notified automatically of any progress on your issue.
=head2 Source Code
This is open source software. The code repository is available for
public review and contribution under the terms of the license.
L<https://github.com/dagolden/dist-zilla-plugin-meta-contributors>
git clone git://github.com/dagolden/dist-zilla-plugin-meta-contributors.git
=head1 AUTHOR
David Golden <dagolden@cpan.org>
=head1 COPYRIGHT AND LICENSE
This software is Copyright (c) 2013 by David Golden.
This is free software, licensed under:
The Apache License, Version 2.0, January 2004
=cut
| gitpan/Dist-Zilla-Plugin-Meta-Contributors | lib/Dist/Zilla/Plugin/Meta/Contributors.pm | Perl | apache-2.0 | 2,172 |
#!/usr/bin/perl
use warnings;
use strict;
use Data::Dumper;
my $debug = 1;
use constant {
INCREMENTAL => 0,
COMPLETE => 1,
};
my $src_dataset = $ARGV[0];
my $dst_dataset = $ARGV[1];
my $prefix = $ARGV[2] || '';
$prefix .= "-" if ($prefix);
unless ($src_dataset && $dst_dataset) {
print STDERR "Usage: $0 <src zfs> <dest zfs> [optional snapshot prefix]\n";
exit 1;
}
if ($src_dataset eq $dst_dataset) {
print STDERR "Src dataset and dest dataset cannot have the same name\n";
}
#
# Match pairs of snapshots
#
my $snaps = {};
while (my $line = <STDIN>) {
if ($line =~ m/^$src_dataset(\/+.*)?([@#])($prefix[0-9]{14})/) {
my $dataset = $1 || '';
print STDERR "src: $dataset $3\n" if $debug;
$snaps->{$dataset}->{$3}->{'src'} = ($2 eq '@' ? 'snapshot' : 'bookmark');
}
if ($line =~ m/^$dst_dataset(\/+.*)?@($prefix[0-9]{14})/) {
my $dataset = $1 || '';
print STDERR "dst: $dataset $2\n" if $debug;
$snaps->{$dataset}->{$2}->{'dst'} = 1;
}
}
print STDERR "SNAPSHOTS\n" if $debug;
print STDERR Dumper($snaps) if $debug;
#
# Find the latest snap that is on both
#
my $candidate_snaps = {};
foreach my $dataset (sort keys %$snaps) {
foreach my $snap (sort keys %{$snaps->{$dataset}}) {
$candidate_snaps->{$snap} = INCREMENTAL;
}
}
print STDERR "CANDIDATE SNAPS #1\n" if $debug;
print STDERR Dumper($candidate_snaps) if $debug;
my @deletion_list;
foreach my $dataset (sort keys %$snaps) {
foreach my $snap (sort keys %{$snaps->{$dataset}}) {
if (exists $candidate_snaps->{$snap}) {
print STDERR "Verifying $snap\n" if $debug;
if ($snaps->{$dataset}->{$snap}->{'src'} && $snaps->{$dataset}->{$snap}->{'dst'}) {
print STDERR "snapshot $snap is present on both source and destination datasets $dataset\n" if $debug;
} elsif (exists $snaps->{$dataset}->{$snap}->{'dst'}) {
print STDERR "$snap is not present on destination dataset $dataset, extended check to see if there are ANY snaps on src dataset\n" if $debug;
#
# If we have a candidate snapshot on the destination but there are no snapshots at all on the source that candidate snapshot is OK
#
foreach my $asnap (sort keys %{$snaps->{$dataset}}) {
if (exists $snaps->{$dataset}->{$asnap}->{'src'}) {
print STDERR "source dataset $dataset has snapshot $asnap, discounting snapshot $snap\n" if $debug;
delete $candidate_snaps->{$snap};
last;
}
}
print STDERR "snapshot $snap still acceptable; no snaps on src\n" if exists $candidate_snaps->{$snap} and $debug;
$candidate_snaps->{$snap} = COMPLETE;
} else {
print STDERR "$snap is not present on destination of $dataset, discounting\n" if $debug;
delete $candidate_snaps->{$snap};
}
}
if ($snaps->{$dataset}->{$snap}->{'src'}) {
push @deletion_list, "$src_dataset$dataset\@$snap" if $snaps->{$dataset}->{$snap}->{'src'} eq "snapshot";
push @deletion_list, "$src_dataset$dataset\#$snap" if $snaps->{$dataset}->{$snap}->{'src'} eq "bookmark";
}
}
}
print STDERR "CANDIDATE SNAPS #2\n" if $debug;
print STDERR Dumper($candidate_snaps) if $debug;
my @candidate_list = sort keys %$candidate_snaps;
my $start_snap = pop @candidate_list;
print STDERR "Found starting snapshot $start_snap\n" if $start_snap && $debug;
#
# Create a snapshot name
#
my ( $sec, $min, $hour, $day, $month, $year, $wday, $yday, $isdst ) = localtime(time());
my $now = sprintf("%04d%02d%02d%02d%02d%02d",1900+$year,1+$month,$day,$hour,$min,$sec);
my $end_snap = $src_dataset.'@'.$prefix.$now;
print "zfs snapshot -r $end_snap\n";
if (0) {
my $end_bookmark = $end_snap;
$end_bookmark =~ s/\@/#/;
foreach my $dataset (keys %$snaps) {
print "zfs bookmark ".$src_dataset.$dataset.'@'.$prefix.$now." ".$src_dataset.$dataset.'#'.$prefix.$now."\n";
}
print "zfs destroy $end_snap\n";
$end_snap = $end_bookmark;
}
#
# -q quiet
# -v verbosity zero
# -s blocksize
# -m total buffer size
#
print STDERR Dumper($snaps);
print "zfs send -R ".(defined $start_snap && $candidate_snaps->{$start_snap} == INCREMENTAL ? "-i $src_dataset". ( $snaps->{''}->{$start_snap}->{'src'} eq 'bookmark' ? '#' : '@' ) ."$start_snap" : "")." $end_snap\n";
foreach my $snap (@deletion_list) {
print "zfs destroy $snap\n";
}
| andrewbasterfield/zfs-incremental-backup | zfs-incremental.pl | Perl | apache-2.0 | 4,360 |
#------------------------------------------------------------------------------
# File: MOI.pm
#
# Description: Read MOI meta information
#
# Revisions: 2014/12/15 - P. Harvey Created
#
# References: 1) https://en.wikipedia.org/wiki/MOI_(file_format)
#------------------------------------------------------------------------------
package Image::ExifTool::MOI;
use strict;
use vars qw($VERSION);
use Image::ExifTool qw(:DataAccess :Utils);
$VERSION = '1.02';
# MOI tags (ref 1)
%Image::ExifTool::MOI::Main = (
GROUPS => { 2 => 'Video' },
PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
NOTES => q{
MOI files store information about associated MOD or TOD files, and are
written by some JVC, Canon and Panasonic camcorders.
},
0x00 => { Name => 'MOIVersion', Format => 'string[2]' },
# 0x02 => { Name => 'MOIFileSize', Format => 'int32u' },
0x06 => {
Name => 'DateTimeOriginal',
Description => 'Date/Time Original',
Format => 'undef[8]',
Groups => { 2 => 'Time' },
ValueConv => sub {
my $val = shift;
return undef unless length($val) >= 8;
my @v = unpack('nCCCCn', $val);
$v[5] /= 1000;
return sprintf('%.4d:%.2d:%.2d %.2d:%.2d:%06.3f', @v);
},
PrintConv => '$self->ConvertDateTime($val)',
},
0x0e => {
Name => 'Duration',
Format => 'int32u',
ValueConv => '$val / 1000',
PrintConv => 'ConvertDuration($val)',
},
0x80 => {
Name => 'AspectRatio',
Format => 'int8u',
PrintConv => q{
my $lo = ($val & 0x0f);
my $hi = ($val >> 4);
my $aspect;
if ($lo < 2) {
$aspect = '4:3';
} elsif ($lo == 4 or $lo == 5) {
$aspect = '16:9';
} else {
$aspect = 'Unknown';
}
if ($hi == 4) {
$aspect .= ' NTSC';
} elsif ($hi == 5) {
$aspect .= ' PAL';
}
return $aspect;
},
},
0x84 => {
Name => 'AudioCodec',
Format => 'int16u',
Groups => { 2 => 'Audio' },
PrintHex => 1,
PrintConv => {
0x00c1 => 'AC3',
0x4001 => 'MPEG',
},
},
0x86 => {
Name => 'AudioBitrate',
Format => 'int8u',
Groups => { 2 => 'Audio' },
ValueConv => '$val * 16000 + 48000',
PrintConv => 'ConvertBitrate($val)',
},
0xda => {
Name => 'VideoBitrate',
Format => 'int16u',
PrintHex => 1,
ValueConv => {
0x5896 => '8500000',
0x813d => '5500000',
},
PrintConv => 'ConvertBitrate($val)',
},
);
#------------------------------------------------------------------------------
# Validate and extract metadata from MOI file
# Inputs: 0) ExifTool ref, 1) dirInfo ref
# Returns: 1 on success, 0 if this wasn't a valid MOI file
sub ProcessMOI($$)
{
my ($et, $dirInfo) = @_;
my $raf = $$dirInfo{RAF};
my $buff;
# read enough to allow skipping over run-in if it exists
$raf->Read($buff, 256) == 256 and $buff =~ /^V6/ or return 0;
if (defined $$et{VALUE}{FileSize}) {
my $size = unpack('x2N', $buff);
$size == $$et{VALUE}{FileSize} or return 0;
}
$et->SetFileType();
SetByteOrder('MM');
my $tagTablePtr = GetTagTable('Image::ExifTool::MOI::Main');
return $et->ProcessBinaryData({ DataPt => \$buff }, $tagTablePtr);
}
1; # end
__END__
=head1 NAME
Image::ExifTool::MOI - Read MOI meta information
=head1 SYNOPSIS
This module is used by Image::ExifTool
=head1 DESCRIPTION
This module contains definitions required by Image::ExifTool to read meta
information from MOI files.
=head1 AUTHOR
Copyright 2003-2019, Phil Harvey (phil at owl.phy.queensu.ca)
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
=head1 REFERENCES
=over 4
=item L<https://en.wikipedia.org/wiki/MOI_(file_format)>
=back
=head1 SEE ALSO
L<Image::ExifTool::TagNames/MOI Tags>,
L<Image::ExifTool(3pm)|Image::ExifTool>
=cut
| philmoz/Focus-Points | focuspoints.lrdevplugin/bin/exiftool/lib/Image/ExifTool/MOI.pm | Perl | apache-2.0 | 4,242 |
% generate problem of size 1500
reachable(X,Y) :- edge(X,Y).
reachable(X,Y) :- edge(X,Z), reachable(Z,Y).
edge(0, 1).
edge(1, 2).
edge(2, 3).
edge(3, 4).
edge(4, 5).
edge(5, 6).
edge(6, 7).
edge(7, 8).
edge(8, 9).
edge(9, 10).
edge(10, 11).
edge(11, 12).
edge(12, 13).
edge(13, 14).
edge(14, 15).
edge(15, 16).
edge(16, 17).
edge(17, 18).
edge(18, 19).
edge(19, 20).
edge(20, 21).
edge(21, 22).
edge(22, 23).
edge(23, 24).
edge(24, 25).
edge(25, 26).
edge(26, 27).
edge(27, 28).
edge(28, 29).
edge(29, 30).
edge(30, 31).
edge(31, 32).
edge(32, 33).
edge(33, 34).
edge(34, 35).
edge(35, 36).
edge(36, 37).
edge(37, 38).
edge(38, 39).
edge(39, 40).
edge(40, 41).
edge(41, 42).
edge(42, 43).
edge(43, 44).
edge(44, 45).
edge(45, 46).
edge(46, 47).
edge(47, 48).
edge(48, 49).
edge(49, 50).
edge(50, 51).
edge(51, 52).
edge(52, 53).
edge(53, 54).
edge(54, 55).
edge(55, 56).
edge(56, 57).
edge(57, 58).
edge(58, 59).
edge(59, 60).
edge(60, 61).
edge(61, 62).
edge(62, 63).
edge(63, 64).
edge(64, 65).
edge(65, 66).
edge(66, 67).
edge(67, 68).
edge(68, 69).
edge(69, 70).
edge(70, 71).
edge(71, 72).
edge(72, 73).
edge(73, 74).
edge(74, 75).
edge(75, 76).
edge(76, 77).
edge(77, 78).
edge(78, 79).
edge(79, 80).
edge(80, 81).
edge(81, 82).
edge(82, 83).
edge(83, 84).
edge(84, 85).
edge(85, 86).
edge(86, 87).
edge(87, 88).
edge(88, 89).
edge(89, 90).
edge(90, 91).
edge(91, 92).
edge(92, 93).
edge(93, 94).
edge(94, 95).
edge(95, 96).
edge(96, 97).
edge(97, 98).
edge(98, 99).
edge(99, 100).
edge(100, 101).
edge(101, 102).
edge(102, 103).
edge(103, 104).
edge(104, 105).
edge(105, 106).
edge(106, 107).
edge(107, 108).
edge(108, 109).
edge(109, 110).
edge(110, 111).
edge(111, 112).
edge(112, 113).
edge(113, 114).
edge(114, 115).
edge(115, 116).
edge(116, 117).
edge(117, 118).
edge(118, 119).
edge(119, 120).
edge(120, 121).
edge(121, 122).
edge(122, 123).
edge(123, 124).
edge(124, 125).
edge(125, 126).
edge(126, 127).
edge(127, 128).
edge(128, 129).
edge(129, 130).
edge(130, 131).
edge(131, 132).
edge(132, 133).
edge(133, 134).
edge(134, 135).
edge(135, 136).
edge(136, 137).
edge(137, 138).
edge(138, 139).
edge(139, 140).
edge(140, 141).
edge(141, 142).
edge(142, 143).
edge(143, 144).
edge(144, 145).
edge(145, 146).
edge(146, 147).
edge(147, 148).
edge(148, 149).
edge(149, 150).
edge(150, 151).
edge(151, 152).
edge(152, 153).
edge(153, 154).
edge(154, 155).
edge(155, 156).
edge(156, 157).
edge(157, 158).
edge(158, 159).
edge(159, 160).
edge(160, 161).
edge(161, 162).
edge(162, 163).
edge(163, 164).
edge(164, 165).
edge(165, 166).
edge(166, 167).
edge(167, 168).
edge(168, 169).
edge(169, 170).
edge(170, 171).
edge(171, 172).
edge(172, 173).
edge(173, 174).
edge(174, 175).
edge(175, 176).
edge(176, 177).
edge(177, 178).
edge(178, 179).
edge(179, 180).
edge(180, 181).
edge(181, 182).
edge(182, 183).
edge(183, 184).
edge(184, 185).
edge(185, 186).
edge(186, 187).
edge(187, 188).
edge(188, 189).
edge(189, 190).
edge(190, 191).
edge(191, 192).
edge(192, 193).
edge(193, 194).
edge(194, 195).
edge(195, 196).
edge(196, 197).
edge(197, 198).
edge(198, 199).
edge(199, 200).
edge(200, 201).
edge(201, 202).
edge(202, 203).
edge(203, 204).
edge(204, 205).
edge(205, 206).
edge(206, 207).
edge(207, 208).
edge(208, 209).
edge(209, 210).
edge(210, 211).
edge(211, 212).
edge(212, 213).
edge(213, 214).
edge(214, 215).
edge(215, 216).
edge(216, 217).
edge(217, 218).
edge(218, 219).
edge(219, 220).
edge(220, 221).
edge(221, 222).
edge(222, 223).
edge(223, 224).
edge(224, 225).
edge(225, 226).
edge(226, 227).
edge(227, 228).
edge(228, 229).
edge(229, 230).
edge(230, 231).
edge(231, 232).
edge(232, 233).
edge(233, 234).
edge(234, 235).
edge(235, 236).
edge(236, 237).
edge(237, 238).
edge(238, 239).
edge(239, 240).
edge(240, 241).
edge(241, 242).
edge(242, 243).
edge(243, 244).
edge(244, 245).
edge(245, 246).
edge(246, 247).
edge(247, 248).
edge(248, 249).
edge(249, 250).
edge(250, 251).
edge(251, 252).
edge(252, 253).
edge(253, 254).
edge(254, 255).
edge(255, 256).
edge(256, 257).
edge(257, 258).
edge(258, 259).
edge(259, 260).
edge(260, 261).
edge(261, 262).
edge(262, 263).
edge(263, 264).
edge(264, 265).
edge(265, 266).
edge(266, 267).
edge(267, 268).
edge(268, 269).
edge(269, 270).
edge(270, 271).
edge(271, 272).
edge(272, 273).
edge(273, 274).
edge(274, 275).
edge(275, 276).
edge(276, 277).
edge(277, 278).
edge(278, 279).
edge(279, 280).
edge(280, 281).
edge(281, 282).
edge(282, 283).
edge(283, 284).
edge(284, 285).
edge(285, 286).
edge(286, 287).
edge(287, 288).
edge(288, 289).
edge(289, 290).
edge(290, 291).
edge(291, 292).
edge(292, 293).
edge(293, 294).
edge(294, 295).
edge(295, 296).
edge(296, 297).
edge(297, 298).
edge(298, 299).
edge(299, 300).
edge(300, 301).
edge(301, 302).
edge(302, 303).
edge(303, 304).
edge(304, 305).
edge(305, 306).
edge(306, 307).
edge(307, 308).
edge(308, 309).
edge(309, 310).
edge(310, 311).
edge(311, 312).
edge(312, 313).
edge(313, 314).
edge(314, 315).
edge(315, 316).
edge(316, 317).
edge(317, 318).
edge(318, 319).
edge(319, 320).
edge(320, 321).
edge(321, 322).
edge(322, 323).
edge(323, 324).
edge(324, 325).
edge(325, 326).
edge(326, 327).
edge(327, 328).
edge(328, 329).
edge(329, 330).
edge(330, 331).
edge(331, 332).
edge(332, 333).
edge(333, 334).
edge(334, 335).
edge(335, 336).
edge(336, 337).
edge(337, 338).
edge(338, 339).
edge(339, 340).
edge(340, 341).
edge(341, 342).
edge(342, 343).
edge(343, 344).
edge(344, 345).
edge(345, 346).
edge(346, 347).
edge(347, 348).
edge(348, 349).
edge(349, 350).
edge(350, 351).
edge(351, 352).
edge(352, 353).
edge(353, 354).
edge(354, 355).
edge(355, 356).
edge(356, 357).
edge(357, 358).
edge(358, 359).
edge(359, 360).
edge(360, 361).
edge(361, 362).
edge(362, 363).
edge(363, 364).
edge(364, 365).
edge(365, 366).
edge(366, 367).
edge(367, 368).
edge(368, 369).
edge(369, 370).
edge(370, 371).
edge(371, 372).
edge(372, 373).
edge(373, 374).
edge(374, 375).
edge(375, 376).
edge(376, 377).
edge(377, 378).
edge(378, 379).
edge(379, 380).
edge(380, 381).
edge(381, 382).
edge(382, 383).
edge(383, 384).
edge(384, 385).
edge(385, 386).
edge(386, 387).
edge(387, 388).
edge(388, 389).
edge(389, 390).
edge(390, 391).
edge(391, 392).
edge(392, 393).
edge(393, 394).
edge(394, 395).
edge(395, 396).
edge(396, 397).
edge(397, 398).
edge(398, 399).
edge(399, 400).
edge(400, 401).
edge(401, 402).
edge(402, 403).
edge(403, 404).
edge(404, 405).
edge(405, 406).
edge(406, 407).
edge(407, 408).
edge(408, 409).
edge(409, 410).
edge(410, 411).
edge(411, 412).
edge(412, 413).
edge(413, 414).
edge(414, 415).
edge(415, 416).
edge(416, 417).
edge(417, 418).
edge(418, 419).
edge(419, 420).
edge(420, 421).
edge(421, 422).
edge(422, 423).
edge(423, 424).
edge(424, 425).
edge(425, 426).
edge(426, 427).
edge(427, 428).
edge(428, 429).
edge(429, 430).
edge(430, 431).
edge(431, 432).
edge(432, 433).
edge(433, 434).
edge(434, 435).
edge(435, 436).
edge(436, 437).
edge(437, 438).
edge(438, 439).
edge(439, 440).
edge(440, 441).
edge(441, 442).
edge(442, 443).
edge(443, 444).
edge(444, 445).
edge(445, 446).
edge(446, 447).
edge(447, 448).
edge(448, 449).
edge(449, 450).
edge(450, 451).
edge(451, 452).
edge(452, 453).
edge(453, 454).
edge(454, 455).
edge(455, 456).
edge(456, 457).
edge(457, 458).
edge(458, 459).
edge(459, 460).
edge(460, 461).
edge(461, 462).
edge(462, 463).
edge(463, 464).
edge(464, 465).
edge(465, 466).
edge(466, 467).
edge(467, 468).
edge(468, 469).
edge(469, 470).
edge(470, 471).
edge(471, 472).
edge(472, 473).
edge(473, 474).
edge(474, 475).
edge(475, 476).
edge(476, 477).
edge(477, 478).
edge(478, 479).
edge(479, 480).
edge(480, 481).
edge(481, 482).
edge(482, 483).
edge(483, 484).
edge(484, 485).
edge(485, 486).
edge(486, 487).
edge(487, 488).
edge(488, 489).
edge(489, 490).
edge(490, 491).
edge(491, 492).
edge(492, 493).
edge(493, 494).
edge(494, 495).
edge(495, 496).
edge(496, 497).
edge(497, 498).
edge(498, 499).
edge(499, 500).
edge(500, 501).
edge(501, 502).
edge(502, 503).
edge(503, 504).
edge(504, 505).
edge(505, 506).
edge(506, 507).
edge(507, 508).
edge(508, 509).
edge(509, 510).
edge(510, 511).
edge(511, 512).
edge(512, 513).
edge(513, 514).
edge(514, 515).
edge(515, 516).
edge(516, 517).
edge(517, 518).
edge(518, 519).
edge(519, 520).
edge(520, 521).
edge(521, 522).
edge(522, 523).
edge(523, 524).
edge(524, 525).
edge(525, 526).
edge(526, 527).
edge(527, 528).
edge(528, 529).
edge(529, 530).
edge(530, 531).
edge(531, 532).
edge(532, 533).
edge(533, 534).
edge(534, 535).
edge(535, 536).
edge(536, 537).
edge(537, 538).
edge(538, 539).
edge(539, 540).
edge(540, 541).
edge(541, 542).
edge(542, 543).
edge(543, 544).
edge(544, 545).
edge(545, 546).
edge(546, 547).
edge(547, 548).
edge(548, 549).
edge(549, 550).
edge(550, 551).
edge(551, 552).
edge(552, 553).
edge(553, 554).
edge(554, 555).
edge(555, 556).
edge(556, 557).
edge(557, 558).
edge(558, 559).
edge(559, 560).
edge(560, 561).
edge(561, 562).
edge(562, 563).
edge(563, 564).
edge(564, 565).
edge(565, 566).
edge(566, 567).
edge(567, 568).
edge(568, 569).
edge(569, 570).
edge(570, 571).
edge(571, 572).
edge(572, 573).
edge(573, 574).
edge(574, 575).
edge(575, 576).
edge(576, 577).
edge(577, 578).
edge(578, 579).
edge(579, 580).
edge(580, 581).
edge(581, 582).
edge(582, 583).
edge(583, 584).
edge(584, 585).
edge(585, 586).
edge(586, 587).
edge(587, 588).
edge(588, 589).
edge(589, 590).
edge(590, 591).
edge(591, 592).
edge(592, 593).
edge(593, 594).
edge(594, 595).
edge(595, 596).
edge(596, 597).
edge(597, 598).
edge(598, 599).
edge(599, 600).
edge(600, 601).
edge(601, 602).
edge(602, 603).
edge(603, 604).
edge(604, 605).
edge(605, 606).
edge(606, 607).
edge(607, 608).
edge(608, 609).
edge(609, 610).
edge(610, 611).
edge(611, 612).
edge(612, 613).
edge(613, 614).
edge(614, 615).
edge(615, 616).
edge(616, 617).
edge(617, 618).
edge(618, 619).
edge(619, 620).
edge(620, 621).
edge(621, 622).
edge(622, 623).
edge(623, 624).
edge(624, 625).
edge(625, 626).
edge(626, 627).
edge(627, 628).
edge(628, 629).
edge(629, 630).
edge(630, 631).
edge(631, 632).
edge(632, 633).
edge(633, 634).
edge(634, 635).
edge(635, 636).
edge(636, 637).
edge(637, 638).
edge(638, 639).
edge(639, 640).
edge(640, 641).
edge(641, 642).
edge(642, 643).
edge(643, 644).
edge(644, 645).
edge(645, 646).
edge(646, 647).
edge(647, 648).
edge(648, 649).
edge(649, 650).
edge(650, 651).
edge(651, 652).
edge(652, 653).
edge(653, 654).
edge(654, 655).
edge(655, 656).
edge(656, 657).
edge(657, 658).
edge(658, 659).
edge(659, 660).
edge(660, 661).
edge(661, 662).
edge(662, 663).
edge(663, 664).
edge(664, 665).
edge(665, 666).
edge(666, 667).
edge(667, 668).
edge(668, 669).
edge(669, 670).
edge(670, 671).
edge(671, 672).
edge(672, 673).
edge(673, 674).
edge(674, 675).
edge(675, 676).
edge(676, 677).
edge(677, 678).
edge(678, 679).
edge(679, 680).
edge(680, 681).
edge(681, 682).
edge(682, 683).
edge(683, 684).
edge(684, 685).
edge(685, 686).
edge(686, 687).
edge(687, 688).
edge(688, 689).
edge(689, 690).
edge(690, 691).
edge(691, 692).
edge(692, 693).
edge(693, 694).
edge(694, 695).
edge(695, 696).
edge(696, 697).
edge(697, 698).
edge(698, 699).
edge(699, 700).
edge(700, 701).
edge(701, 702).
edge(702, 703).
edge(703, 704).
edge(704, 705).
edge(705, 706).
edge(706, 707).
edge(707, 708).
edge(708, 709).
edge(709, 710).
edge(710, 711).
edge(711, 712).
edge(712, 713).
edge(713, 714).
edge(714, 715).
edge(715, 716).
edge(716, 717).
edge(717, 718).
edge(718, 719).
edge(719, 720).
edge(720, 721).
edge(721, 722).
edge(722, 723).
edge(723, 724).
edge(724, 725).
edge(725, 726).
edge(726, 727).
edge(727, 728).
edge(728, 729).
edge(729, 730).
edge(730, 731).
edge(731, 732).
edge(732, 733).
edge(733, 734).
edge(734, 735).
edge(735, 736).
edge(736, 737).
edge(737, 738).
edge(738, 739).
edge(739, 740).
edge(740, 741).
edge(741, 742).
edge(742, 743).
edge(743, 744).
edge(744, 745).
edge(745, 746).
edge(746, 747).
edge(747, 748).
edge(748, 749).
edge(749, 750).
edge(750, 751).
edge(751, 752).
edge(752, 753).
edge(753, 754).
edge(754, 755).
edge(755, 756).
edge(756, 757).
edge(757, 758).
edge(758, 759).
edge(759, 760).
edge(760, 761).
edge(761, 762).
edge(762, 763).
edge(763, 764).
edge(764, 765).
edge(765, 766).
edge(766, 767).
edge(767, 768).
edge(768, 769).
edge(769, 770).
edge(770, 771).
edge(771, 772).
edge(772, 773).
edge(773, 774).
edge(774, 775).
edge(775, 776).
edge(776, 777).
edge(777, 778).
edge(778, 779).
edge(779, 780).
edge(780, 781).
edge(781, 782).
edge(782, 783).
edge(783, 784).
edge(784, 785).
edge(785, 786).
edge(786, 787).
edge(787, 788).
edge(788, 789).
edge(789, 790).
edge(790, 791).
edge(791, 792).
edge(792, 793).
edge(793, 794).
edge(794, 795).
edge(795, 796).
edge(796, 797).
edge(797, 798).
edge(798, 799).
edge(799, 800).
edge(800, 801).
edge(801, 802).
edge(802, 803).
edge(803, 804).
edge(804, 805).
edge(805, 806).
edge(806, 807).
edge(807, 808).
edge(808, 809).
edge(809, 810).
edge(810, 811).
edge(811, 812).
edge(812, 813).
edge(813, 814).
edge(814, 815).
edge(815, 816).
edge(816, 817).
edge(817, 818).
edge(818, 819).
edge(819, 820).
edge(820, 821).
edge(821, 822).
edge(822, 823).
edge(823, 824).
edge(824, 825).
edge(825, 826).
edge(826, 827).
edge(827, 828).
edge(828, 829).
edge(829, 830).
edge(830, 831).
edge(831, 832).
edge(832, 833).
edge(833, 834).
edge(834, 835).
edge(835, 836).
edge(836, 837).
edge(837, 838).
edge(838, 839).
edge(839, 840).
edge(840, 841).
edge(841, 842).
edge(842, 843).
edge(843, 844).
edge(844, 845).
edge(845, 846).
edge(846, 847).
edge(847, 848).
edge(848, 849).
edge(849, 850).
edge(850, 851).
edge(851, 852).
edge(852, 853).
edge(853, 854).
edge(854, 855).
edge(855, 856).
edge(856, 857).
edge(857, 858).
edge(858, 859).
edge(859, 860).
edge(860, 861).
edge(861, 862).
edge(862, 863).
edge(863, 864).
edge(864, 865).
edge(865, 866).
edge(866, 867).
edge(867, 868).
edge(868, 869).
edge(869, 870).
edge(870, 871).
edge(871, 872).
edge(872, 873).
edge(873, 874).
edge(874, 875).
edge(875, 876).
edge(876, 877).
edge(877, 878).
edge(878, 879).
edge(879, 880).
edge(880, 881).
edge(881, 882).
edge(882, 883).
edge(883, 884).
edge(884, 885).
edge(885, 886).
edge(886, 887).
edge(887, 888).
edge(888, 889).
edge(889, 890).
edge(890, 891).
edge(891, 892).
edge(892, 893).
edge(893, 894).
edge(894, 895).
edge(895, 896).
edge(896, 897).
edge(897, 898).
edge(898, 899).
edge(899, 900).
edge(900, 901).
edge(901, 902).
edge(902, 903).
edge(903, 904).
edge(904, 905).
edge(905, 906).
edge(906, 907).
edge(907, 908).
edge(908, 909).
edge(909, 910).
edge(910, 911).
edge(911, 912).
edge(912, 913).
edge(913, 914).
edge(914, 915).
edge(915, 916).
edge(916, 917).
edge(917, 918).
edge(918, 919).
edge(919, 920).
edge(920, 921).
edge(921, 922).
edge(922, 923).
edge(923, 924).
edge(924, 925).
edge(925, 926).
edge(926, 927).
edge(927, 928).
edge(928, 929).
edge(929, 930).
edge(930, 931).
edge(931, 932).
edge(932, 933).
edge(933, 934).
edge(934, 935).
edge(935, 936).
edge(936, 937).
edge(937, 938).
edge(938, 939).
edge(939, 940).
edge(940, 941).
edge(941, 942).
edge(942, 943).
edge(943, 944).
edge(944, 945).
edge(945, 946).
edge(946, 947).
edge(947, 948).
edge(948, 949).
edge(949, 950).
edge(950, 951).
edge(951, 952).
edge(952, 953).
edge(953, 954).
edge(954, 955).
edge(955, 956).
edge(956, 957).
edge(957, 958).
edge(958, 959).
edge(959, 960).
edge(960, 961).
edge(961, 962).
edge(962, 963).
edge(963, 964).
edge(964, 965).
edge(965, 966).
edge(966, 967).
edge(967, 968).
edge(968, 969).
edge(969, 970).
edge(970, 971).
edge(971, 972).
edge(972, 973).
edge(973, 974).
edge(974, 975).
edge(975, 976).
edge(976, 977).
edge(977, 978).
edge(978, 979).
edge(979, 980).
edge(980, 981).
edge(981, 982).
edge(982, 983).
edge(983, 984).
edge(984, 985).
edge(985, 986).
edge(986, 987).
edge(987, 988).
edge(988, 989).
edge(989, 990).
edge(990, 991).
edge(991, 992).
edge(992, 993).
edge(993, 994).
edge(994, 995).
edge(995, 996).
edge(996, 997).
edge(997, 998).
edge(998, 999).
edge(999, 1000).
edge(1000, 1001).
edge(1001, 1002).
edge(1002, 1003).
edge(1003, 1004).
edge(1004, 1005).
edge(1005, 1006).
edge(1006, 1007).
edge(1007, 1008).
edge(1008, 1009).
edge(1009, 1010).
edge(1010, 1011).
edge(1011, 1012).
edge(1012, 1013).
edge(1013, 1014).
edge(1014, 1015).
edge(1015, 1016).
edge(1016, 1017).
edge(1017, 1018).
edge(1018, 1019).
edge(1019, 1020).
edge(1020, 1021).
edge(1021, 1022).
edge(1022, 1023).
edge(1023, 1024).
edge(1024, 1025).
edge(1025, 1026).
edge(1026, 1027).
edge(1027, 1028).
edge(1028, 1029).
edge(1029, 1030).
edge(1030, 1031).
edge(1031, 1032).
edge(1032, 1033).
edge(1033, 1034).
edge(1034, 1035).
edge(1035, 1036).
edge(1036, 1037).
edge(1037, 1038).
edge(1038, 1039).
edge(1039, 1040).
edge(1040, 1041).
edge(1041, 1042).
edge(1042, 1043).
edge(1043, 1044).
edge(1044, 1045).
edge(1045, 1046).
edge(1046, 1047).
edge(1047, 1048).
edge(1048, 1049).
edge(1049, 1050).
edge(1050, 1051).
edge(1051, 1052).
edge(1052, 1053).
edge(1053, 1054).
edge(1054, 1055).
edge(1055, 1056).
edge(1056, 1057).
edge(1057, 1058).
edge(1058, 1059).
edge(1059, 1060).
edge(1060, 1061).
edge(1061, 1062).
edge(1062, 1063).
edge(1063, 1064).
edge(1064, 1065).
edge(1065, 1066).
edge(1066, 1067).
edge(1067, 1068).
edge(1068, 1069).
edge(1069, 1070).
edge(1070, 1071).
edge(1071, 1072).
edge(1072, 1073).
edge(1073, 1074).
edge(1074, 1075).
edge(1075, 1076).
edge(1076, 1077).
edge(1077, 1078).
edge(1078, 1079).
edge(1079, 1080).
edge(1080, 1081).
edge(1081, 1082).
edge(1082, 1083).
edge(1083, 1084).
edge(1084, 1085).
edge(1085, 1086).
edge(1086, 1087).
edge(1087, 1088).
edge(1088, 1089).
edge(1089, 1090).
edge(1090, 1091).
edge(1091, 1092).
edge(1092, 1093).
edge(1093, 1094).
edge(1094, 1095).
edge(1095, 1096).
edge(1096, 1097).
edge(1097, 1098).
edge(1098, 1099).
edge(1099, 1100).
edge(1100, 1101).
edge(1101, 1102).
edge(1102, 1103).
edge(1103, 1104).
edge(1104, 1105).
edge(1105, 1106).
edge(1106, 1107).
edge(1107, 1108).
edge(1108, 1109).
edge(1109, 1110).
edge(1110, 1111).
edge(1111, 1112).
edge(1112, 1113).
edge(1113, 1114).
edge(1114, 1115).
edge(1115, 1116).
edge(1116, 1117).
edge(1117, 1118).
edge(1118, 1119).
edge(1119, 1120).
edge(1120, 1121).
edge(1121, 1122).
edge(1122, 1123).
edge(1123, 1124).
edge(1124, 1125).
edge(1125, 1126).
edge(1126, 1127).
edge(1127, 1128).
edge(1128, 1129).
edge(1129, 1130).
edge(1130, 1131).
edge(1131, 1132).
edge(1132, 1133).
edge(1133, 1134).
edge(1134, 1135).
edge(1135, 1136).
edge(1136, 1137).
edge(1137, 1138).
edge(1138, 1139).
edge(1139, 1140).
edge(1140, 1141).
edge(1141, 1142).
edge(1142, 1143).
edge(1143, 1144).
edge(1144, 1145).
edge(1145, 1146).
edge(1146, 1147).
edge(1147, 1148).
edge(1148, 1149).
edge(1149, 1150).
edge(1150, 1151).
edge(1151, 1152).
edge(1152, 1153).
edge(1153, 1154).
edge(1154, 1155).
edge(1155, 1156).
edge(1156, 1157).
edge(1157, 1158).
edge(1158, 1159).
edge(1159, 1160).
edge(1160, 1161).
edge(1161, 1162).
edge(1162, 1163).
edge(1163, 1164).
edge(1164, 1165).
edge(1165, 1166).
edge(1166, 1167).
edge(1167, 1168).
edge(1168, 1169).
edge(1169, 1170).
edge(1170, 1171).
edge(1171, 1172).
edge(1172, 1173).
edge(1173, 1174).
edge(1174, 1175).
edge(1175, 1176).
edge(1176, 1177).
edge(1177, 1178).
edge(1178, 1179).
edge(1179, 1180).
edge(1180, 1181).
edge(1181, 1182).
edge(1182, 1183).
edge(1183, 1184).
edge(1184, 1185).
edge(1185, 1186).
edge(1186, 1187).
edge(1187, 1188).
edge(1188, 1189).
edge(1189, 1190).
edge(1190, 1191).
edge(1191, 1192).
edge(1192, 1193).
edge(1193, 1194).
edge(1194, 1195).
edge(1195, 1196).
edge(1196, 1197).
edge(1197, 1198).
edge(1198, 1199).
edge(1199, 1200).
edge(1200, 1201).
edge(1201, 1202).
edge(1202, 1203).
edge(1203, 1204).
edge(1204, 1205).
edge(1205, 1206).
edge(1206, 1207).
edge(1207, 1208).
edge(1208, 1209).
edge(1209, 1210).
edge(1210, 1211).
edge(1211, 1212).
edge(1212, 1213).
edge(1213, 1214).
edge(1214, 1215).
edge(1215, 1216).
edge(1216, 1217).
edge(1217, 1218).
edge(1218, 1219).
edge(1219, 1220).
edge(1220, 1221).
edge(1221, 1222).
edge(1222, 1223).
edge(1223, 1224).
edge(1224, 1225).
edge(1225, 1226).
edge(1226, 1227).
edge(1227, 1228).
edge(1228, 1229).
edge(1229, 1230).
edge(1230, 1231).
edge(1231, 1232).
edge(1232, 1233).
edge(1233, 1234).
edge(1234, 1235).
edge(1235, 1236).
edge(1236, 1237).
edge(1237, 1238).
edge(1238, 1239).
edge(1239, 1240).
edge(1240, 1241).
edge(1241, 1242).
edge(1242, 1243).
edge(1243, 1244).
edge(1244, 1245).
edge(1245, 1246).
edge(1246, 1247).
edge(1247, 1248).
edge(1248, 1249).
edge(1249, 1250).
edge(1250, 1251).
edge(1251, 1252).
edge(1252, 1253).
edge(1253, 1254).
edge(1254, 1255).
edge(1255, 1256).
edge(1256, 1257).
edge(1257, 1258).
edge(1258, 1259).
edge(1259, 1260).
edge(1260, 1261).
edge(1261, 1262).
edge(1262, 1263).
edge(1263, 1264).
edge(1264, 1265).
edge(1265, 1266).
edge(1266, 1267).
edge(1267, 1268).
edge(1268, 1269).
edge(1269, 1270).
edge(1270, 1271).
edge(1271, 1272).
edge(1272, 1273).
edge(1273, 1274).
edge(1274, 1275).
edge(1275, 1276).
edge(1276, 1277).
edge(1277, 1278).
edge(1278, 1279).
edge(1279, 1280).
edge(1280, 1281).
edge(1281, 1282).
edge(1282, 1283).
edge(1283, 1284).
edge(1284, 1285).
edge(1285, 1286).
edge(1286, 1287).
edge(1287, 1288).
edge(1288, 1289).
edge(1289, 1290).
edge(1290, 1291).
edge(1291, 1292).
edge(1292, 1293).
edge(1293, 1294).
edge(1294, 1295).
edge(1295, 1296).
edge(1296, 1297).
edge(1297, 1298).
edge(1298, 1299).
edge(1299, 1300).
edge(1300, 1301).
edge(1301, 1302).
edge(1302, 1303).
edge(1303, 1304).
edge(1304, 1305).
edge(1305, 1306).
edge(1306, 1307).
edge(1307, 1308).
edge(1308, 1309).
edge(1309, 1310).
edge(1310, 1311).
edge(1311, 1312).
edge(1312, 1313).
edge(1313, 1314).
edge(1314, 1315).
edge(1315, 1316).
edge(1316, 1317).
edge(1317, 1318).
edge(1318, 1319).
edge(1319, 1320).
edge(1320, 1321).
edge(1321, 1322).
edge(1322, 1323).
edge(1323, 1324).
edge(1324, 1325).
edge(1325, 1326).
edge(1326, 1327).
edge(1327, 1328).
edge(1328, 1329).
edge(1329, 1330).
edge(1330, 1331).
edge(1331, 1332).
edge(1332, 1333).
edge(1333, 1334).
edge(1334, 1335).
edge(1335, 1336).
edge(1336, 1337).
edge(1337, 1338).
edge(1338, 1339).
edge(1339, 1340).
edge(1340, 1341).
edge(1341, 1342).
edge(1342, 1343).
edge(1343, 1344).
edge(1344, 1345).
edge(1345, 1346).
edge(1346, 1347).
edge(1347, 1348).
edge(1348, 1349).
edge(1349, 1350).
edge(1350, 1351).
edge(1351, 1352).
edge(1352, 1353).
edge(1353, 1354).
edge(1354, 1355).
edge(1355, 1356).
edge(1356, 1357).
edge(1357, 1358).
edge(1358, 1359).
edge(1359, 1360).
edge(1360, 1361).
edge(1361, 1362).
edge(1362, 1363).
edge(1363, 1364).
edge(1364, 1365).
edge(1365, 1366).
edge(1366, 1367).
edge(1367, 1368).
edge(1368, 1369).
edge(1369, 1370).
edge(1370, 1371).
edge(1371, 1372).
edge(1372, 1373).
edge(1373, 1374).
edge(1374, 1375).
edge(1375, 1376).
edge(1376, 1377).
edge(1377, 1378).
edge(1378, 1379).
edge(1379, 1380).
edge(1380, 1381).
edge(1381, 1382).
edge(1382, 1383).
edge(1383, 1384).
edge(1384, 1385).
edge(1385, 1386).
edge(1386, 1387).
edge(1387, 1388).
edge(1388, 1389).
edge(1389, 1390).
edge(1390, 1391).
edge(1391, 1392).
edge(1392, 1393).
edge(1393, 1394).
edge(1394, 1395).
edge(1395, 1396).
edge(1396, 1397).
edge(1397, 1398).
edge(1398, 1399).
edge(1399, 1400).
edge(1400, 1401).
edge(1401, 1402).
edge(1402, 1403).
edge(1403, 1404).
edge(1404, 1405).
edge(1405, 1406).
edge(1406, 1407).
edge(1407, 1408).
edge(1408, 1409).
edge(1409, 1410).
edge(1410, 1411).
edge(1411, 1412).
edge(1412, 1413).
edge(1413, 1414).
edge(1414, 1415).
edge(1415, 1416).
edge(1416, 1417).
edge(1417, 1418).
edge(1418, 1419).
edge(1419, 1420).
edge(1420, 1421).
edge(1421, 1422).
edge(1422, 1423).
edge(1423, 1424).
edge(1424, 1425).
edge(1425, 1426).
edge(1426, 1427).
edge(1427, 1428).
edge(1428, 1429).
edge(1429, 1430).
edge(1430, 1431).
edge(1431, 1432).
edge(1432, 1433).
edge(1433, 1434).
edge(1434, 1435).
edge(1435, 1436).
edge(1436, 1437).
edge(1437, 1438).
edge(1438, 1439).
edge(1439, 1440).
edge(1440, 1441).
edge(1441, 1442).
edge(1442, 1443).
edge(1443, 1444).
edge(1444, 1445).
edge(1445, 1446).
edge(1446, 1447).
edge(1447, 1448).
edge(1448, 1449).
edge(1449, 1450).
edge(1450, 1451).
edge(1451, 1452).
edge(1452, 1453).
edge(1453, 1454).
edge(1454, 1455).
edge(1455, 1456).
edge(1456, 1457).
edge(1457, 1458).
edge(1458, 1459).
edge(1459, 1460).
edge(1460, 1461).
edge(1461, 1462).
edge(1462, 1463).
edge(1463, 1464).
edge(1464, 1465).
edge(1465, 1466).
edge(1466, 1467).
edge(1467, 1468).
edge(1468, 1469).
edge(1469, 1470).
edge(1470, 1471).
edge(1471, 1472).
edge(1472, 1473).
edge(1473, 1474).
edge(1474, 1475).
edge(1475, 1476).
edge(1476, 1477).
edge(1477, 1478).
edge(1478, 1479).
edge(1479, 1480).
edge(1480, 1481).
edge(1481, 1482).
edge(1482, 1483).
edge(1483, 1484).
edge(1484, 1485).
edge(1485, 1486).
edge(1486, 1487).
edge(1487, 1488).
edge(1488, 1489).
edge(1489, 1490).
edge(1490, 1491).
edge(1491, 1492).
edge(1492, 1493).
edge(1493, 1494).
edge(1494, 1495).
edge(1495, 1496).
edge(1496, 1497).
edge(1497, 1498).
edge(1498, 1499).
edge(1499, 1500).
edge(1500, 0).
| c-cube/datalog | tests/graph1500.pl | Perl | bsd-2-clause | 24,904 |
package WebService::MorphIO;
# Pragmas.
use strict;
use warnings;
# Modules.
use Class::Utils qw(set_params);
use Encode qw(encode_utf8);
use Error::Pure qw(err);
use IO::Barf qw(barf);
use LWP::Simple qw(get);
use URI;
use URI::Escape qw(uri_escape);
# Version.
our $VERSION = 0.02;
# Constructor.
sub new {
my ($class, @params) = @_;
# Create object.
my $self = bless {}, $class;
# Morph.io API key.
$self->{'api_key'} = undef;
# Project.
$self->{'project'} = undef;
# Select.
$self->{'select'} = 'SELECT * FROM data';
# Web URI of service.
$self->{'web_uri'} = 'https://morph.io/';
# Process params.
set_params($self, @params);
# Check API key.
if (! defined $self->{'api_key'}) {
err "Parameter 'api_key' is required.";
}
# Check project.
if (! defined $self->{'project'}) {
err "Parameter 'project' is required.";
}
if ($self->{'project'} !~ m/\/$/ms) {
$self->{'project'} .= '/';
}
# Web URI.
if ($self->{'web_uri'} !~ m/\/$/ms) {
$self->{'web_uri'} .= '/';
}
# Object.
return $self;
}
# Get CSV file.
sub csv {
my ($self, $output_file) = @_;
my $uri = URI->new($self->{'web_uri'}.$self->{'project'}.
'data.csv?key='.$self->{'api_key'}.'&query='.
uri_escape($self->{'select'}));
return $self->_save($uri, $output_file);
}
# Get sqlite file.
sub sqlite {
my ($self, $output_file) = @_;
my $uri = URI->new($self->{'web_uri'}.$self->{'project'}.
'data.sqlite?key='.$self->{'api_key'});
return $self->_save($uri, $output_file);
}
# Save file.
sub _save {
my ($self, $uri, $output_file) = @_;
my $content = get($uri->as_string);
if (! $content) {
err "Cannot get '".$uri->as_string."'.";
}
barf($output_file, encode_utf8($content));
return;
}
1;
__END__
=pod
=encoding utf8
=head1 NAME
WebService::MorphIO - Perl class to communication with morph.io.
=head1 SYNOPSIS
use WebService::MorphIO;
my $obj = WebService::MorphIO->new(%parameters);
$obj->csv('output.csv');
$obj->sqlite('output.sqlite');
=head1 METHODS
=over 8
=item C<new(%parameters)>
Constructor.
=over 8
=item * C<api_key>
Morph.io API key.
It is required.
Default value is undef.
=item * C<project>
Project.
It is required.
Default value is undef.
=item * C<select>
Select.
It is usable for csv() method.
Default value is 'SELECT * FROM data'.
=item * C<web_uri>
Web URI of service.
Default value is 'https://morph.io/'.
=back
=item C<csv($output_file)>
Get CSV file and save to output file.
It is affected by 'select' parameter.
Returns undef.
=item C<sqlite($output_file)>
Get sqlite file and save to output file.
Returns undef.
=back
=head1 ERRORS
new():
Parameter 'api_key' is required.
Parameter 'project' is required.
From Class::Utils::set_params():
Unknown parameter '%s'.
csv():
Cannot get '%s'.
sqlite():
Cannot get '%s'.
=head1 EXAMPLE
# Pragmas.
use strict;
use warnings;
# Modules.
use File::Temp qw(tempfile);
use Perl6::Slurp qw(slurp);
use WebService::MorphIO;
# Arguments.
if (@ARGV < 2) {
print STDERR "Usage: $0 api_key project\n";
exit 1;
}
my $api_key = $ARGV[0];
my $project = $ARGV[1];
# Temp file.
my (undef, $temp_file) = tempfile();
# Object.
my $obj = WebService::MorphIO->new(
'api_key' => $api_key,
'project' => $project,
);
# Save CSV file.
$obj->csv($temp_file);
# Print to output.
print slurp($temp_file);
# Clean.
unlink $temp_file;
# Output:
# Usage: ./examples/ex1.pl api_key project
=head1 DEPENDENCIES
L<Class::Utils>,
L<Encode>,
L<Error::Pure>,
L<IO::Barf>,
L<LWP::Simple>,
L<URI>,
L<URI::Escape>.
=head1 REPOSITORY
L<https://github.com/tupinek/WebService-MorphIO>
=head1 AUTHOR
Michal Špaček L<mailto:skim@cpan.org>
L<http://skim.cz>
=head1 LICENSE AND COPYRIGHT
BSD license.
=head1 VERSION
0.02
=cut
| gitpan/WebService-MorphIO | MorphIO.pm | Perl | bsd-2-clause | 3,877 |
#!/usr/bin/perl -s
#########################################################################
#
# TTYtter v2.0 (c)2007-2012 cameron kaiser (and contributors).
# all rights reserved.
# http://www.floodgap.com/software/ttytter/
#
# distributed under the floodgap free software license
# http://www.floodgap.com/software/ffsl/
#
# After all, we're flesh and blood. -- Oingo Boingo
# If someone writes an app and no one uses it, does his code run? -- me
#
#########################################################################
use FindBin '$Bin';
chdir $Bin or die "Couldn't chdir($Bin): $!";
require 5.005;
BEGIN {
# ONLY STUFF THAT MUST RUN BEFORE INITIALIZATION GOES HERE!
# THIS FUNCTION HAS GOTTEN TOO DAMN CLUTTERED!
# @INC = (); # wreck intentionally for testing
# dynamically changing PERL_SIGNALS doesn't work in Perl 5.14+ (bug
# 92246). we deal with this by forcing -signals_use_posix if the
# environment variable wasn't already set.
if ($] >= 5.014000 && $ENV{'PERL_SIGNALS'} ne 'unsafe') {
$signals_use_posix = 1;
} else {
$ENV{'PERL_SIGNALS'} = 'unsafe';
}
$command_line = $0; $0 = "TTYtter";
$TTYtter_VERSION = "2.0";
$TTYtter_PATCH_VERSION = 3;
$TTYtter_RC_NUMBER = 0; # non-zero for release candidate
# this is kludgy, yes.
$LANG = $ENV{'LANG'} || $ENV{'GDM_LANG'} || $ENV{'LC_CTYPE'} ||
$ENV{'ALL'};
$my_version_string = "${TTYtter_VERSION}.${TTYtter_PATCH_VERSION}";
(warn ("$my_version_string\n"), exit) if ($version);
$space_pad = " " x 1024;
$background_is_ready = 0;
# for multi-module extension handling
$multi_module_mode = 0;
$multi_module_context = 0;
$muffle_server_messages = 0;
undef $master_store;
undef %push_stack;
$padded_patch_version = substr($TTYtter_PATCH_VERSION . " ", 0, 2);
%opts_boolean = map { $_ => 1 } qw(
ansi noansi verbose superverbose ttytteristas noprompt
seven silent hold daemon script anonymous readline ssl
newline vcheck verify noratelimit notrack nonewrts notimeline
synch exception_is_maskable mentions simplestart octwercs
location readlinerepaint nocounter notifyquiet
signals_use_posix dostream nostreamreplies streamallreplies
); %opts_sync = map { $_ => 1 } qw(
ansi pause dmpause ttytteristas verbose superverbose
url rlurl dmurl newline wrap notimeline lists dmidurl
queryurl trendurl track colourprompt colourme notrack
colourdm colourreply colourwarn coloursearch colourlist idurl
notifies filter colourdefault backload searchhits dmsenturl
nostreamreplies mentions wtrendurl atrendurl
); %opts_urls = map {$_ => 1} qw(
url dmurl uurl rurl wurl frurl rlurl update shorturl
apibase queryurl trendurl idurl delurl dmdelurl favsurl
myfavsurl favurl favdelurl rtsofmeurl followurl leaveurl
dmupdate credurl blockurl blockdelurl friendsurl
modifyliurl adduliurl delliurl getliurl getlisurl getfliurl
creliurl delliurl deluliurl crefliurl delfliurl
getuliurl getufliurl dmsenturl rturl rtsbyurl dmidurl
statusliurl followliurl leaveliurl followersurl
oauthurl oauthauthurl oauthaccurl oauthbase wtrendurl
atrendurl frupdurl
); %opts_secret = map { $_ => 1} qw(
superverbose ttytteristas octwercs
); %opts_comma_delimit = map { $_ => 1 } qw(
lists notifytype notifies
); %opts_space_delimit = map { $_ => 1 } qw(
track
);
%opts_can_set = map { $_ => 1 } qw(
url pause dmurl dmpause superverbose ansi verbose
update uurl rurl wurl avatar ttytteristas frurl track
rlurl noprompt shorturl newline wrap verify autosplit
notimeline queryurl octwercs trendurl colourprompt colourme
colourdm colourreply colourwarn coloursearch colourlist idurl
urlopen delurl notrack dmdelurl favsurl myfavsurl
favurl favdelurl slowpost notifies filter colourdefault
rtsofmeurl followurl leaveurl dmupdate mentions backload
lat long location searchhits blockurl blockdelurl woeid
nocounter linelength friendsurl followersurl lists
modifyliurl adduliurl delliurl getliurl getlisurl getfliurl
creliurl delliurl deluliurl crefliurl delfliurl atrendurl
getuliurl getufliurl dmsenturl rturl rtsbyurl wtrendurl
statusliurl followliurl leaveliurl dmidurl nostreamreplies
frupdurl
); %opts_others = map { $_ => 1 } qw(
lynx curl seven silent maxhist noansi hold status
daemon timestamp twarg user anonymous script readline
leader ssl rc norc vcheck apibase notifytype exts
nonewrts synch runcommand authtype oauthkey oauthsecret
tokenkey tokensecret credurl keyf readlinerepaint
simplestart exception_is_maskable oldperl
notify_tool_path oauthurl oauthauthurl oauthaccurl oauthbase
signals_use_posix dostream eventbuf streamallreplies
); %valid = (%opts_can_set, %opts_others);
$rc = (defined($rc) && length($rc)) ? $rc : "";
unless ($norc) {
my $rcf =
($rc =~ m#^/#) ? $rc : "$ENV{'HOME'}/.ttytterrc${rc}";
if (open(W, $rcf)) {
# 5.14 sets this lazily, so this gives us a way out
eval 'binmode(W, ":utf8")' unless ($seven);
while(<W>) {
chomp;
next if (/^\s*$/ || /^#/);
s/^-//;
($key, $value) = split(/\=/, $_, 2);
if ($key eq 'rc') {
warn "** that's stupid, setting rc in an rc file\n";
} elsif ($key eq 'norc') {
warn "** that's dumb, using norc in an rc file\n";
} elsif (length $$key) {
; # carry on
} elsif ($valid{$key} && !length($$key)) {
$$key = $value;
} elsif ($key =~ /^extpref_/) {
$$key = $value;
} elsif (!$valid{$key}) {
warn "** setting $key not supported in this version\n";
}
}
close(W);
} elsif (length($rc)) {
die("couldn't access rc file $rcf: $!\n".
"to use defaults, use -norc or don't specify the -rc option.\n\n");
}
}
$seven ||= 0;
$oldperl ||= 0;
$parent = $$;
$script = 1 if (length($runcommand));
$supreturnto = $verbose + 0;
$postbreak_time = 0;
$postbreak_count = 0;
# our minimum official support is now 5.8.6.
if ($] < 5.008006 && !$oldperl) {
die(<<"EOF");
*** you are using a version of Perl in "extended" support: $] ***
the minimum tested version of Perl now required by TTYtter is 5.8.6.
Perl 5.005 thru 5.8.5 probably can still run TTYtter, but they are not
tested with it. if you want to suppress this warning, specify -oldperl on
the command line, or put oldperl=1 in your .ttytterrc. bug patches will
still be accepted for older Perls; see the TTYtter home page for info.
for Perl 5.005, remember to also specify -seven.
EOF
}
# defaults that our extensions can override
$last_id = 0;
$last_dm = 0;
# a correct fix for -daemon would make this unlimited, but this
# is good enough for now.
$print_max ||= ($daemon) ? 999999 : 250; # shiver
$suspend_output = -1;
# try to find an OAuth keyfile if we haven't specified key+secret
# no worries if this fails; we could be Basic Auth, after all
$whine = (length($keyf)) ? 1 : 0;
$keyf ||= "$ENV{'HOME'}/.ttytterkey";
$keyf = "$ENV{'HOME'}/.ttytterkey${keyf}" if ($keyf !~ m#/#);
$attempted_keyf = $keyf;
if (!length($oauthkey) && !length($oauthsecret) # set later
&& !length($tokenkey)
&& !length($tokensecret) && !$oauthwizard) {
my $keybuf = '';
if(open(W, $keyf)) {
while(<W>) {
chomp;
s/\s+//g;
$keybuf .= $_;
}
close(W);
my (@pairs) = split(/\&/, $keybuf);
foreach(@pairs) {
my (@pair) = split(/\=/, $_, 2);
$oauthkey = $pair[1]
if ($pair[0] eq 'ck');
$oauthsecret = $pair[1]
if ($pair[0] eq 'cs');
$tokenkey = $pair[1]
if ($pair[0] eq 'at');
$tokensecret = $pair[1]
if ($pair[0] eq 'ats');
}
die("** tried to load OAuth tokens from $keyf\n".
" but it seems corrupt or incomplete. please see the documentation,\n".
" or delete the file so that we can try making your keyfile again.\n")
if ((!length($oauthkey) ||
!length($oauthsecret) ||
!length($tokenkey) ||
!length($tokensecret)));
} else {
die("** couldn't open keyfile $keyf: $!\n".
"if you want to run the OAuth wizard to create this file, add ".
"-oauthwizard\n")
if ($whine);
$keyf = ''; # i.e., we loaded nothing from a key file
}
}
# try to init Term::ReadLine if it was requested
# (shakes fist at @br3nda, it's all her fault)
%readline_completion = ();
if ($readline && !$silent && !$script) {
$ENV{"PERL_RL"} = "TTYtter" if (!length($ENV{'PERL_RL'}));
eval
'use Term::ReadLine; $termrl = new Term::ReadLine ("TTYtter", \*STDIN, \*STDOUT)'
|| die(
"$@\nthis perl doesn't have ReadLine. don't use -readline.\n");
$stdout = $termrl->OUT || \*STDOUT;
$stdin = $termrl->IN || \*STDIN;
$readline = '' if ($readline eq '1');
$readline =~ s/^"//; # for optimizer
$readline =~ s/"$//;
#$termrl->Attribs()->{'autohistory'} = undef; # not yet
(%readline_completion) = map {$_ => 1} split(/\s+/, $readline);
%original_readline = %readline_completion;
# readline repaint can't be tested here. we cache our
# result later.
} else {
$stdout = \*STDOUT;
$stdin = \*STDIN;
}
$wrapseq = 0;
$lastlinelength = -1;
print $stdout "$leader\n" if (length($leader));
# state information
$lasttwit = '';
$lastpostid = 0;
# stub namespace for multimodules and (eventually) state saving
undef %store;
$store = \%store;
$pack_magic = ($] < 5.006) ? '' : "U0";
$utf8_encode = sub { ; };
$utf8_decode = sub { ; };
unless ($seven) {
eval
'use utf8;binmode($stdin,":utf8");binmode($stdout,":utf8");return 1' ||
die("$@\nthis perl doesn't fully support UTF-8. use -seven.\n");
# this is for the prinput utf8 validator.
# adapted from http://mail.nl.linux.org/linux-utf8/2003-03/msg00087.html
# eventually this will be removed when 5.6.x support is removed,
# and Perl will do the UTF-8 validation for us.
$badutf8='[\x00-\x7f][\x80-\xbf]+|^[\x80-\xbf]+|'.
'[\xc0-\xdf][\x00-\x7f\xc0-\xff]|'.
'[\xc0-\xdf][\x80-\xbf]{2}|'.
'[\xe0-\xef][\x80-\xbf]{0,1}[\x00-\x7f\xc0-\xff]|'.
'[\xe0-\xef][\x80-\xbf]{3}|'.
'[\xf0-\xf7][\x80-\xbf]{0,2}[\x00-\x7f\xc0-\xff]|'.
'[\xf0-\xf7][\x80-\xbf]{4}|'.
'[\xf8-\xfb][\x80-\xbf]{0,3}[\x00-\x7f\xc0-\xff]|'.
'[\xf8-\xfb][\x80-\xbf]{5}|'.
'[\xfc-\xfd][\x80-\xbf]{0,4}[\x00-\x7f\xc0-\xff]|'.
'\xed[\xa0-\xbf][\x80-\xbf]|'.
'\xef\xbf[\xbe-\xbf]|'.
'[\xf0-\xf7][\x8f,\x9f,\xaf,\xbf]\xbf[\xbe-\xbf]|'.
'\xfe|\xff|'.
'[\xc0-\xc1][\x80-\xbf]|'.
'\xe0[\x80-\x9f][\x80-\xbf]|'.
'\xf0[\x80-\x8f][\x80-\xbf]{2}|'.
'\xf8[\x80-\x87][\x80-\xbf]{3}|'.
'\xfc[\x80-\x83][\x80-\xbf]{4}'; # gah!
eval <<'EOF';
$utf8_encode = sub { utf8::encode(shift); };
$utf8_decode = sub { utf8::decode(shift); };
EOF
}
$wraptime = sub { my $x = shift; return ($x, $x); };
if ($timestamp) {
my $fail = "-- can't use custom timestamps.\nspecify -timestamp by itself to use Twitter's without module.\n";
if (length($timestamp) > 1) { # pattern specified
eval 'use Date::Parse;return 1' ||
die("$@\nno Date::Parse $fail");
eval 'use Date::Format;return 1' ||
die("$@\nno Date::Format $fail");
$timestamp = "%Y-%m-%d %k:%M:%S"
if ($timestamp eq "default" ||
$timestamp eq "def");
$wraptime = sub {
my $time = str2time(shift);
my $stime = time2str($timestamp, $time);
return ($time, $stime);
};
}
}
}
END {
&killkid unless ($in_backticks || $in_buffer); # this is disgusting
}
#### COMMON STARTUP ####
# if we requested POSIX signals, or we NEED posix signals (5.14+), we
# must check if we have POSIX signals actually
if ($signals_use_posix) {
eval 'use POSIX';
# God help the system that doesn't have SIGTERM
$j = eval 'return POSIX::SIGTERM' ;
die(<<"EOF") if (!(0+$j));
*** death permeates me ***
your configuration requires using POSIX signalling (either Perl 5.14+ or
you specifically asked with -signals_use_posix). however, either you don't
have POSIX.pm, or it doesn't work.
TTYtter requires 'unsafe' Perl signals (which are of course for its
purposes perfectly safe). unfortunately, due to Perl bug 92246 5.14+ must
use POSIX.pm, or have the switch set before starting TTYtter. run one of
export PERL_SIGNALS=unsafe # sh, bash, ksh, etc.
setenv PERL_SIGNALS unsafe # csh, tcsh, etc.
and restart TTYtter, or use Perl 5.12 or earlier (without specifying
-signals_use_posix).
EOF
}
# do we have POSIX::Termios? (usually we do)
eval 'use POSIX; $termios = new POSIX::Termios;';
print $stdout "-- termios test: $termios\n" if ($verbose);
# check the TRLT version. versions < 1.3 won't work with 2.0.
if ($termrl && $termrl->ReadLine eq 'Term::ReadLine::TTYtter') {
eval '$trlv = $termrl->Version;';
die (<<"EOF") if (length($trlv) && 0+$trlv < 1.3);
*** death permeates me ***
you need to upgrade your Term::ReadLine::TTYtter to at least version 1.3
to use TTYtter 2.x, or bad things will happen such as signal mismatches,
unexpected quits, and dogs and cats living peacefully in the same house.
EOF
}
# try to get signal numbers for SIG* from POSIX. use internals if failed.
eval 'use POSIX; $SIGUSR1 = POSIX::SIGUSR1; $SIGUSR2 = POSIX::SIGUSR2; $SIGHUP = POSIX::SIGHUP; $SIGTERM = POSIX::SIGTERM';
# from <sys/signal.h>
$SIGHUP ||= 1;
$SIGTERM ||= 15;
$SIGUSR1 ||= 30;
$SIGUSR2 ||= 31;
# wrap warning
die(
"** dude, what the hell kind of terminal can't handle a 5 character line?\n")
if ($wrap > 1 && $wrap < 5);
print $stdout "** warning: prompts not wrapped for wrap < 70\n"
if ($wrap > 1 && $wrap < 70);
# reject stupid combinations
die("you can't use automatic ratelimits with -noratelimit.\nuse -pause=#sec\n")
if ($noratelimit && $pause eq 'auto');
die("you can't use -synch with -script or -daemon.\n")
if ($synch && ($script || $daemon));
die("-script and -daemon cannot be used together.\n")
if ($script && $daemon);
# set up menu codes and caches
$is_background = 0;
$alphabet = "abcdefghijkLmnopqrstuvwxyz";
%store_hash = ();
$mini_split = 250; # i.e., 10 tweets for the mini-menu (/th)
# leaving 50 tweets for the foreground temporary menus
$tweet_counter = 0;
%dm_store_hash = ();
$dm_counter = 0;
%id_cache = ();
%filter_next = ();
# set up threading management
$in_reply_to = 0;
$expected_tweet_ref = undef;
# interpret -script at this level
if ($script) {
$noansi = $noprompt = 1;
$silent = ($verbose) ? 0 : 1;
$pause = $vcheck = $slowpost = $verify = 0;
}
### now instantiate the TTYtter dynamic API ###
### based off the defaults later in script. ####
# first we need to load any extensions specified by -exts.
if (length($exts) && $exts ne '0') {
$multi_module_mode = -1; # mark as loader stage
print "** attempting to load extensions\n" unless ($silent);
# unescape \,
$j=0; $xstring = "ESCAPED_STRING";
while($exts =~ /$xstring$j/) { $j++; }
$xstring .= $j;
$exts =~ s/\\,/$xstring/g;
foreach $file (split(/,/, $exts)) {
#TODO
# wildcards?
$file =~ s/$xstring/,/g;
print "** loading $file\n" unless ($silent);
die("** sorry, you cannot load the same extension twice.\n")
if ($master_store->{$file}->{'loaded'});
# prepare its working space in $store and load the module
$master_store->{$file} = { 'loaded' => 1 };
$store = \%{ $master_store->{$file} };
$EM_DONT_CARE = 0;
$EM_SCRIPT_ON = 1;
$EM_SCRIPT_OFF = -1;
$extension_mode = $EM_DONT_CARE;
die("** $file not found: $!\n") if (! -r "$file");
require $file; # and die if bad
die("** $file failed to load: $@\n") if ($@);
die("** consistency failure: reference failure on $file\n")
if (!$store->{'loaded'});
# check type of extension (interactive or non-interactive). if
# we are in the wrong mode, bail out.
if ($extension_mode) {
die(
"** this extension requires -script. this may conflict with other extensions\n".
" you are loading, which may have their own requirements.\n")
if ($extension_mode == $EM_SCRIPT_ON && !$script);
die(
"** this extension cannot work with -script. this may conflict with other\n".
" extensions you are loading, which may have their own requirements.\n")
if ($extension_mode == $EM_SCRIPT_OFF && $script);
}
# pick off all the subroutine references it makes for storage
# in an array to iterate and chain over later.
# these methods are multi-module safe
foreach $arry (qw(
handle exception tweettype conclude dmhandle dmconclude
heartbeat precommand prepost postpost addaction
eventhandle listhandle userhandle shutdown)) {
if (defined($$arry)) {
$aarry = "m_$arry";
push(@$aarry, [ $file, $$arry ]);
undef $$arry;
}
}
# these methods are NOT multi-module safe
# if a extension already hooked one of
# these and another extension tries to hook it, fatal error.
foreach $arry (qw(
getpassword prompt main autocompletion)) {
if (defined($$arry)) {
$sarry = "l_$arry";
if (defined($$sarry)) {
die(
"** double hook of unsafe method \"$arry\" -- you cannot use this extension\n".
" with the other extensions you are loading. see the documentation.\n");
}
$$sarry = $$arry;
undef $$arry;
}
}
}
# success! enable multi-module support in the TTYtter API and then
# dispatch calls through the multi-module system instead.
$multi_module_mode = 1; # mark as completed loader
$handle = \&multihandle;
$exception = \&multiexception;
$tweettype = \&multitweettype;
$conclude = \&multiconclude;
$dmhandle = \&multidmhandle;
$dmconclude = \&multidmconclude;
$heartbeat = \&multiheartbeat;
$precommand = \&multiprecommand;
$prepost = \&multiprepost;
$postpost = \&multipostpost;
$addaction = \&multiaddaction;
$shutdown = \&multishutdown;
$userhandle = \&multiuserhandle;
$listhandle = \&multilisthandle;
$eventhandle = \&multieventhandle;
} else {
# the old API single-end-point system
$multi_module_mode = 0; # not executing multi module endpoints
$handle = \&defaulthandle;
$exception = \&defaultexception;
$tweettype = \&defaulttweettype;
$conclude = \&defaultconclude;
$dmhandle = \&defaultdmhandle;
$dmconclude = \&defaultdmconclude;
$heartbeat = \&defaultheartbeat;
$precommand = \&defaultprecommand;
$prepost = \&defaultprepost;
$postpost = \&defaultpostpost;
$addaction = \&defaultaddaction;
$shutdown = \&defaultshutdown;
$userhandle = \&defaultuserhandle;
$listhandle = \&defaultlisthandle;
$eventhandle = \&defaulteventhandle;
}
# unsafe methods use the single-end-point
$prompt = $l_prompt || \&defaultprompt;
$main = $l_main || \&defaultmain;
$getpassword = $l_getpassword || \&defaultgetpassword;
# $autocompletion is special:
if ($termrl) {
$termrl->Attribs()->{'completion_function'} =
$l_autocompletion || \&defaultautocompletion;
}
# fetch_id is based off last_id, if an extension set it
$fetch_id = $last_id || 0;
# validate the notify method the user chose, if any.
# we can't do this in BEGIN, because it may not be instantiated yet,
# and we have to do it after loading modules because it might be in one.
@notifytypes = ();
if (length($notifytype) && $notifytype ne '0' &&
$notifytype ne '1' && !$status) {
# NOT $script! scripts have a use case for notifiers!
%dupenet = ();
foreach $nt (split(/\s*,\s*/, $notifytype)) {
$fnt="notifier_${nt}";
(warn("** duplicate notification $nt was ignored\n"), next)
if ($dupenet{$fnt});
eval 'return &$fnt(undef)' ||
die("** invalid notification framework $nt: $@\n");
$dupenet{$fnt}=1;
}
@notifytypes = keys %dupenet;
$notifytype = join(',', @notifytypes);
# warning if someone didn't tell us what notifies they wanted.
warn "-- warning: you specified -notifytype, but no -notifies\n"
if (!$silent && !length($notifies));
}
# set up track tags
if (length($tquery) && $tquery ne '0') {
my $xtquery = &tracktags_tqueryurlify($tquery);
die("** custom tquery is over 140 length: $xtquery\n")
if (length($xtquery) > 139);
@trackstrings = ($xtquery);
} else {
&tracktags_makearray;
}
# compile filter
exit(1) if (!&filter_compile);
# compile lists
exit(1) if (!&list_compile);
# finally, compile notifies. we do this regardless of notifytype, so that
# an extension can look at it if it wants to.
¬ify_compile;
# check that we are using a sensible authtype, based on our guessed user agent
$authtype ||= "oauth";
die("** supported authtypes are basic or oauth only.\n")
if ($authtype ne 'basic' && $authtype ne 'oauth');
if ($termrl) {
$streamout = $stdout; # this is just simpler instead of dupping
warn(<<"EOF") if ($] < 5.006);
***********************************************************
** -readline may not function correctly on Perls < 5.6.0 **
***********************************************************
EOF
print $stdout "-- readline using ".$termrl->ReadLine."\n";
} else {
# dup $stdout for benefit of various other scripts
open(DUPSTDOUT, ">&STDOUT") ||
warn("** warning: could not dup $stdout: $!\n");
binmode(DUPSTDOUT, ":utf8") unless ($seven);
$streamout = \*DUPSTDOUT;
}
if ($silent) {
close($stdout);
open($stdout, ">>/dev/null"); # KLUUUUUUUDGE
}
# after this point, die() may cause problems
# initialize our route back out so background can talk to foreground
pipe(W, P) || die("pipe() error [or your Perl doesn't support it]: $!\n");
select(P); $|++;
binmode(P, ":utf8") unless ($seven);
binmode(W, ":utf8") unless ($seven);
# default command line options
$anonymous ||= 0;
undef $user if ($anonymous);
print $stdout "-- using SSL for default URLs.\n" if ($ssl);
$http_proto = ($ssl) ? 'https' : 'http';
$lat ||= undef;
$long ||= undef;
$location ||= 0;
$linelength ||= 140;
$oauthbase ||= $apibase || "${http_proto}://api.twitter.com";
# this needs to be AFTER oauthbase so that apibase can set oauthbase.
$apibase ||= "${http_proto}://api.twitter.com/1";
$nonewrts ||= 0;
# special case: if we explicitly refuse backload, don't load initially.
$backload = 30 if (!defined($backload)); # zero is valid!
$dont_refresh_first_time = 1 if (!$backload);
$searchhits ||= 20;
$url ||= "${apibase}/statuses/home_timeline.json";
$oauthurl ||= "${oauthbase}/oauth/request_token";
$oauthauthurl ||= "${oauthbase}/oauth/authorize";
$oauthaccurl ||= "${oauthbase}/oauth/access_token";
$credurl ||= "${apibase}/account/verify_credentials.json";
$update ||= "${apibase}/statuses/update.json";
$rurl ||= "${apibase}/statuses/mentions.json";
$uurl ||= "${apibase}/statuses/user_timeline.json";
$idurl ||= "${apibase}/statuses/show";
$delurl ||= "${apibase}/statuses/destroy";
$rturl ||= "${apibase}/statuses/retweet";
$rtsbyurl ||= "${apibase}/statuses/%I/retweeted_by.json";
$rtsofmeurl ||= "${apibase}/statuses/retweets_of_me.json";
$wurl ||= "${apibase}/users/show.json";
$frurl ||= "${apibase}/friendships/exists.json";
$followurl ||= "${apibase}/friendships/create";
$leaveurl ||= "${apibase}/friendships/destroy";
$blockurl ||= "${apibase}/blocks/create.json";
$blockdelurl ||= "${apibase}/blocks/destroy.json";
$friendsurl ||= "${apibase}/statuses/friends.json";
$followersurl ||= "${apibase}/statuses/followers.json";
$frupdurl ||= "${apibase}/friendships/update.json";
$rlurl ||= "${apibase}/account/rate_limit_status.json";
$dmurl ||= "${apibase}/direct_messages.json";
$dmsenturl ||= "${apibase}/direct_messages/sent.json";
$dmupdate ||= "${apibase}/direct_messages/new.json";
$dmdelurl ||= "${apibase}/direct_messages/destroy";
$dmidurl ||= "${apibase}/direct_messages/show";
$favsurl ||= "${apibase}/favorites";
$myfavsurl ||= "${apibase}/favorites.json";
$favurl ||= "${apibase}/favorites/create";
$favdelurl ||= "${apibase}/favorites/destroy";
$getlisurl ||= "${apibase}/lists.json";
$creliurl ||= "${apibase}/lists/create.json";
$delliurl ||= "${apibase}/lists/destroy.json";
$modifyliurl ||= "${apibase}/lists/update.json";
$deluliurl ||= "${apibase}/lists/members/destroy_all.json";
$adduliurl ||= "${apibase}/lists/members/create_all.json";
$getuliurl ||= "${apibase}/lists/memberships.json";
$getufliurl ||= "${apibase}/lists/subscriptions.json";
$delfliurl ||= "${apibase}/lists/subscribers/destroy.json";
$crefliurl ||= "${apibase}/lists/subscribers/create.json";
$getfliurl ||= "${apibase}/lists/subscribers.json";
$getliurl ||= "${apibase}/lists/members.json";
$statusliurl ||= "${apibase}/lists/statuses.json";
$streamurl ||= ($anonymous)
# this doesn't actually work yet.
? "https://stream.twitter.com/1/statuses/sample.json"
: "https://userstream.twitter.com/2/user.json";
$dostream ||= 0;
$eventbuf ||= 0;
$queryurl ||= "http://search.twitter.com/search.json";
#TODO
# this isn't actually used anymore.
$trendurl ||= "${apibase}/trends/daily.json";
$wtrendurl ||= "${apibase}/trends/";
$atrendurl ||= "${apibase}/trends/available.json";
# pick ONE!
#$shorturl ||= "http://api.tr.im/v1/trim_simple?url=";
$shorturl ||= "http://is.gd/api.php?longurl=";
# figure out the domain to stop shortener loops
&generate_shortdomain;
$pause = (($anonymous) ? 120 : "auto") if (!defined $pause);
# NOT ||= ... zero is a VALID value!
$superverbose ||= 0;
$avatar ||= "";
$urlopen ||= 'echo %U';
$hold ||= 0;
$daemon ||= 0;
$maxhist ||= 19;
undef $shadow_history;
$timestamp ||= 0;
$noprompt ||= 0;
$slowpost ||= 0;
$twarg ||= undef;
$verbose ||= $superverbose;
$dmpause = 4 if (!defined $dmpause); # NOT ||= ... zero is a VALID value!
$dmpause = 0 if ($anonymous);
$dmpause = 0 if ($pause eq '0');
$ansi = ($noansi) ? 0 :
(($ansi || $ENV{'TERM'} eq 'ansi' || $ENV{'TERM'} eq 'xterm-color')
? 1 : 0);
# synch overrides these options.
if ($synch) {
$pause = 0;
$dmpause = ($dmpause) ? 1 : 0;
}
$dmcount = $dmpause;
$lastshort = undef;
# ANSI sequences
$colourprompt ||= "CYAN";
$colourme ||= "YELLOW";
$colourdm ||= "GREEN";
$colourreply ||= "RED";
$colourwarn ||= "MAGENTA";
$coloursearch ||= "CYAN";
$colourlist ||= "OFF";
$colourdefault ||= "OFF";
$ESC = pack("C", 27);
$BEL = pack("C", 7);
&generate_ansi;
# to force unambiguous bareword interpretation
$true = 'true';
sub true { return 'true'; }
$false = 'false';
sub false { return 'false'; }
$null = undef;
sub null { return undef; }
select($stdout); $|++;
# figure out what our user agent should be
if ($lynx) {
if (length($lynx) > 1 && -x "/$lynx") {
$wend = $lynx;
print $stdout "Lynx forced to $wend\n";
} else {
$wend = &wherecheck("trying to find Lynx", "lynx",
"specify -curl to use curl instead, or just let TTYtter autodetect stuff.\n");
}
} else {
if (length($curl) > 1 && -x "/$curl") {
$wend = $curl;
print $stdout "cURL forced to $wend\n";
} else {
$wend = (($curl) ? &wherecheck("trying to find cURL", "curl",
"specify -lynx to use Lynx instead, or just let TTYtter autodetect stuff.\n")
: &wherecheck("trying to find cURL", "curl"));
if (!$curl && !length($wend)) {
$wend = &wherecheck("failed. trying to find Lynx",
"lynx",
"you must have either Lynx or cURL installed to use TTYtter.\n")
if (!length($wend));
$lynx = 1;
} else {
$curl = 1;
}
}
}
$baseagent = $wend;
# whoops, no Lynx here if we are not using Basic Auth
die(
"sorry, OAuth is not currently supported with Lynx.\n".
"you must use SSL cURL, or specify -authtype=basic.\n")
if ($lynx && $authtype ne 'basic' && !$anonymous);
# streaming API has multiple prereqs. not fatal; we just fall back on the
# REST API if not there.
unless($status) {
if (!$dostream || $authtype eq 'basic' || !$ssl || $script || $anonymous || $synch) {
$reason = (!$dostream) ? "(no -dostream)"
: ($script) ? "(-script)"
: (!$ssl) ? "(no SSL)"
: ($anonymous) ? "(-anonymous)"
: ($synch) ? "(-synch)"
: ($authtype eq 'basic') ? "(no OAuth)"
: "(it's funkatron's fault)";
print $stdout
"-- Streaming API disabled $reason (TTYtter will use REST API only)\n";
$dostream = 0;
} else {
print $stdout "-- Streaming API enabled\n";
# streams change mentions behaviour; we get them automatically.
# warn the user if the current settings are suboptimal.
if ($mentions) {
if ($nostreamreplies) {
print $stdout
"** warning: -mentions and -nostreamreplies are very inefficient together\n";
} else {
print $stdout
"** warning: -mentions not generally needed in Streaming mode\n";
}
}
}
} else { $dostream = 0; } # -status suppresses streaming
if (!$dostream && $streamallreplies) {
print $stdout
"** warning: -streamallreplies only works in Streaming mode\n";
}
# create and cache the logic for our selected user agent
if ($lynx) {
$simple_agent = "$baseagent -nostatus -source";
@wend = ('-nostatus');
@wind = (@wend, '-source'); # GET agent
@wend = (@wend, '-post_data'); # POST agent
# we don't need to have the request signed by Lynx right now;
# it doesn't know how to pass custom headers. so this is simpler.
$stringify_args = sub {
my $basecom = shift;
my $resource = shift;
my $data = shift;
my $dont_do_auth = shift;
my $k = join("\n", @_);
# if resource is an arrayref, then it's a GET with URL
# and args (mostly generated by &grabjson)
$resource = join('?', @{ $resource })
if (ref($resource) eq 'ARRAY');
die("wow, we have a bug: Lynx only works with Basic Auth\n")
if ($authtype ne 'basic' && !$dont_do_auth);
$k = "-auth=".$mytoken.':'.$mytokensecret."\n".$k
unless ($dont_do_auth);
$k .= "\n";
$basecom = "$basecom \"$resource\" -";
return ($basecom, $k, $data);
};
} else {
$simple_agent = "$baseagent -s -m 20";
@wend = ('-s', '-m', '20', '-A', "TTYtter/$TTYtter_VERSION",
'-H', 'Expect:');
@wind = @wend;
$stringify_args = sub {
my $basecom = shift;
my $resource = shift;
my $data = shift;
my $dont_do_auth = shift;
my $p;
my $l = '';
foreach $p (@_) {
if ($p =~ /^-/) {
$l .= "\n" if (length($l));
$l .= "$p ";
next;
}
$l .= $p;
}
$l .= "\n";
# sign our request (Basic Auth or oAuth)
unless ($dont_do_auth) {
if ($authtype eq 'basic') {
$l .= "-u ".$mytoken.":".$mytokensecret."\n";
} else {
my $nonce;
my $timestamp;
my $sig;
my $verifier = '';
my $header;
my $ttoken = (length($mytoken) ?
(' oauth_token=\\"'.$mytoken.'\\",') :
'');
($timestamp, $nonce, $sig, $verifier) =
&signrequest($resource, $data);
$header = <<"EOF";
-H "Authorization: OAuth oauth_nonce=\\"$nonce\\", oauth_signature_method=\\"HMAC-SHA1\\", oauth_timestamp=\\"$timestamp\\", oauth_consumer_key=\\"$oauthkey\\", oauth_signature=\\"$sig\\",${ttoken}${verifier} oauth_version=\\"1.0\\""
EOF
print $stdout $header if ($superverbose);
$l .= $header;
}
}
# if resource is an arrayref, then it's a GET with URL
# and args (mostly generated by &grabjson)
$resource = join('?', @{ $resource })
if (ref($resource) eq 'ARRAY');
$l .= "url = \"$resource\"\n";
$l .= "data = \"$data\"\n" if length($data);
return ("$basecom -K -", $l, undef);
};
}
# update check
if ($vcheck && !length($status)) {
$vs = &updatecheck(0);
} else {
$vs =
"-- no version check performed (use /vcheck, or -vcheck to check on startup)\n"
unless ($script || $status);
}
print $stdout $vs; # and then again when client starts up
## make sure we have all the authentication pieces we need for the
## chosen method (authtoken handles this for Basic Auth;
## this is where we validate OAuth)
# if we use OAuth, then don't use any Basic Auth credentials we gave
# unless we specifically say -authtype=basic
if ($authtype eq 'oauth' && length($user)) {
print "** warning: -user is ignored when -authtype=oauth (default)\n";
$user = undef;
}
$whoami = (split(/\:/, $user, 2))[0] unless ($anonymous || !length($user));
# yes, this is plaintext. obfuscation would be ludicrously easy to crack,
# and there is no way to hide them effectively or fully in a Perl script.
# so be a good neighbour and leave this the fark alone, okay? stealing
# credentials is mean and inconvenient to users. this is blessed by
# arrangement with Twitter. don't be a d*ck. thanks for your cooperation.
$oauthkey = (!length($oauthkey) || $oauthkey eq 'X') ?
"XtbRXaQpPdfssFwdUmeYw" : $oauthkey;
$oauthsecret = (!length($oauthsecret) || $oauthsecret eq 'X') ?
"csmjfTQPE8ZZ5wWuzgPJPOBR9dyvOBEtHT5cJeVVmAA" : $oauthsecret;
unless ($anonymous) {
# if we are using Basic Auth, ignore any user token we may have in
# our keyfile
if ($authtype eq 'basic') {
$tokenkey = undef;
$tokensecret = undef;
}
# but if we are using OAuth, we can request one, unless we are in script
elsif ($authtype eq 'oauth' && (!length($keyf) || $oauthwizard)) {
if (length($oauthkey) && length($oauthsecret) &&
!length($tokenkey) && !length($tokensecret)) {
# we have a key, we don't have the user token
# but we can't get that with -script
if ($script) {
print $streamout <<"EOF";
AUTHENTICATION FAILURE
YOU NEED TO GET AN OAuth KEY, or use -authtype=basic
(run TTYtter without -script or -runcommand for help)
EOF
exit;
}
# run the wizard, which writes a keyfile for us
$keyf ||= $attempted_keyf;
print $stdout <<"EOF";
+----------------------------------------------------------------------------+
|| WELCOME TO TTYtter: Authorize TTYtter by signing into Twitter with OAuth ||
+----------------------------------------------------------------------------+
Looks like you're starting TTYtter for the first time, and/or creating a
keyfile. Welcome to the most user-hostile, highly obfuscated, spaghetti code
infested and obscenely obscure Twitter client that's out there. You'll love it.
TTYtter generates a keyfile that contains credentials for you, including your
access tokens. This needs to be done JUST ONCE. You can take this keyfile with
you to other systems. If you revoke TTYtter's access, you must remove the
keyfile and start again with a new token. You need to do this once per account
you use with TTYtter; only one account token can be stored per keyfile. If you
have multiple accounts, use -keyf=... to specify different keyfiles. KEEP THESE
FILES SECRET.
** This wizard will overwrite $keyf
Press RETURN/ENTER to continue or CTRL-C NOW! to abort.
EOF
$j = <STDIN>;
print $stdout "\nRequest from $oauthurl ...";
($tokenkey, $tokensecret) = &tryhardfortoken($oauthurl,
"oauth_callback=oob");
$mytoken = $tokenkey;
$mytokensecret = $tokensecret; # needs to be in both places
# kludge in case user does not specify SSL and this is
# Twitter: we know Twitter supports SSL
($oauthauthurl =~ /twitter/) &&
($oauthauthurl =~ s/^http:/https:/);
print $stdout <<"EOF";
1. Visit, in your browser, ALL ON ONE LINE,
${oauthauthurl}?oauth_token=$mytoken
2. If you are not already signed in, fill in your username and password.
3. Verify that TTYtter is the requesting application, and that its permissions
are as you expect (read your timeline, see who you follow and follow new
people, update your profile, post tweets on your behalf and access your
direct messages). IF THIS IS NOT CORRECT, PRESS CTRL-C NOW!
4. Click Authorize app.
5. A PIN will appear. Enter it below.
EOF
$j = '';
while(!(0+$j)) {
print $stdout "Enter PIN> ";
chomp($j = <STDIN>);
}
print $stdout "\nRequest from $oauthaccurl ...";
($tokenkey, $tokensecret) = &tryhardfortoken($oauthaccurl,
"oauth_verifier=$j");
$oauthkey = "X";
$oauthsecret = "X";
open(W, ">$keyf") ||
die("Failed to write keyfile $keyf: $!\n");
print W <<"EOF";
ck=${oauthkey}&cs=${oauthsecret}&at=${tokenkey}&ats=${tokensecret}
EOF
close(W);
chmod(0600, $keyf) || print $stdout
"Warning: could not change permissions on $keyf : $!\n";
print $stdout <<"EOF";
Written keyfile $keyf
Now, restart TTYtter to use this keyfile.
(To choose between multiple keyfiles other than the default .ttytterkey,
tell TTYtter where the key is using -keyf=... .)
EOF
exit;
}
# if we get three of the four, this must have been command line
if (length($oauthkey) && length($oauthsecret) &&
(!length($tokenkey) || !length($tokensecret))) {
my $error = undef;
my $k;
foreach $k (qw(oauthkey oauthsecret tokenkey tokensecret)) {
$error .= "** you need to specify -$k\n"
if (!length($$k));
}
if (length($error)) {
print $streamout <<"EOF";
you are missing portions of the OAuth sequence. either create a keyfile
and point to it with -keyf=... or add these missing pieces:
$error
then restart TTYtter, or use -authtype=basic.
EOF
exit;
}
}
} elsif ($retoke && length($keyf)) {
# start the "re-toke" wizard to convert DM-less cloned app keys.
# dup STDIN for systems that can only "close" it once
open(STDIN2, "<&STDIN") || die("couldn't dup STDIN: $!\n");
print $stdout <<"EOF";
+-------------------------------------------------------------------------+
|| The Re-Toke Wizard: Generate a new TTYtter keyfile for your app/token ||
+-------------------------------------------------------------------------+
Twitter is requiring tokens to now have specific permissions to READ
direct messages. This will be enforced by 1 July 2011. If you find you are
unable to READ direct messages, you will need this wizard. DO NOT use this
wizard if you are NOT using a cloned app key (1.2 and on) -- use -oauthwizard.
This wizard will create a new keyfile for you from your app/user keys/tokens.
You do NOT need this wizard if you are using TTYtter for a purpose that does
not require direct message access. For example, if TTYtter is acting as
your command line posting agent, or you are only using it to read your
timeline, you do NOT need a new token. You also do not need a new token to
SEND a direct message, only to READ ones this account has received.
You SHOULD NOT need this wizard if your app key was cloned after 1 June 2011.
However, you can still use it if you experience this specific issue with DMs,
or need to rebuild your keyfile for any other reason.
** This wizard will overwrite the key at $keyf
** To change this, restart TTYtter with -retoke -keyf=/path/to/keyfile
Press RETURN/ENTER to continue, or CTRL-C NOW! to abort.
EOF
$j = <STDIN>;
print $stdout <<"EOF";
First: let's get your API key, consumer key and consumer secret.
Start your browser.
1. Log into https://twitter.com/ with your desired account.
2. Go to this URL. You must be logged into Twitter FIRST!
https://dev.twitter.com/apps
3. Click the TTYtter cloned app key you need to regenerate or upgrade.
4. Click Edit Application Settings.
5. Make sure Read, Write & Private Message is selected, and click the
"Save application" button.
6. Select All (CTRL/Command-A) on the next screen, copy (CTRL/Command-C) it,
and paste (CTRL/Command-V) it into this window. (You can also cut and
paste a smaller section if I can't understand your browser's layout.)
7. Press ENTER/RETURN and CTRL-D when you have pasted the window contents.
EOF
$q = $/;
PASTE1LOOP: for(;;) {
print $stdout <<"EOF";
-- Press ENTER and CTRL-D AFTER you have pasted the window contents! ---------
Go ahead:
EOF
undef $/;
$j = <STDIN2>;
print $stdout <<"EOF";
-- EOF -----------------------------------------------------------------------
Processing ...
EOF
$j =~ s/[\r\n]/ /sg;
# process this. as a checksum, API key should == consumer key.
$ck = '';
$cs = '';
($j =~ /Consumer key\s+([-a-zA-Z0-9_]{10,})\s+/) && ($ck = $1);
($j =~ /Consumer secret\s+([-a-zA-Z0-9_]{10,})\s+/) &&
($cs = $1);
if (!length($ck) || !length($cs)) {
# escape hatch
print $stdout <<"EOF";
Something's wrong: I could not find your consumer key or consumer
secret in that text. If this was a misfired paste, please restart the wizard.
Otherwise, bug me at \@ttytter or ckaiser\@floodgap.com. Please don't send
keys or secrets to either address.
EOF
exit;
}
last PASTE1LOOP;
}
# this part is similar to the retoke.
$oauthkey = $ck;
$oauthsecret = $cs;
print $stdout "\nI'm testing this key to see if it works.\n";
print $stdout "Request from $oauthurl ...";
($tokenkey, $tokensecret) = &tryhardfortoken($oauthurl,
"oauth_callback=oob");
$mytoken = $tokenkey;
$mytokensecret = $tokensecret;
# kludge in case user does not specify SSL and this is
# Twitter: we know Twitter supports SSL
($oauthauthurl =~ /twitter/) && ($oauthauthurl =~ s/^http:/https:/);
$/ = $q;
print $stdout <<"EOF";
Okay, your consumer key is ==> $ck
and your consumer secret ==> $cs
IF THIS IS WRONG, PRESS CTRL-C NOW AND RESTART THE WIZARD!
Now we will verify your Imperial battle station is fully operational by
signing in with OAuth.
1. Visit, in your browser, ALL ON ONE LINE (you should still be logged in),
${oauthauthurl}?oauth_token=$mytoken
2. Verify that your app is the requesting application, and that its permissions
are as you expect (read your timeline, see who you follow and follow new
people, update your profile, post tweets on your behalf and access your
direct messages). IF THIS IS NOT CORRECT, PRESS CTRL-C NOW!
3. Click Authorize app.
4. A PIN will appear. Enter it below.
EOF
print $stdout "Enter PIN> ";
chomp($j = <STDIN>);
print $stdout "\nRequest from $oauthaccurl ...";
($at, $ats) = &tryhardfortoken($oauthaccurl, "oauth_verifier=$j");
print $stdout <<"EOF";
Consumer key =========> $ck
Consumer secret ======> $cs
Access token =========> $at
Access token secret ==> $ats
EOF
open(W, ">$keyf") || (print $stdout ("Unable to write to $keyf: $!\n"),
exit);
print W "ck=$ck&cs=$cs&at=$at&ats=$ats\n";
close(W);
chmod(0600, $keyf) || print $stdout
"Warning: could not change permissions on $keyf : $!\n";
print $stdout "Keys written to regenerated keyfile $keyf\n";
print $stdout "Now restart TTYtter.\n";
exit;
}
# now, get a token (either from Basic Auth, the keyfile or OAuth)
($mytoken, $mytokensecret) = &authtoken;
} # unless anonymous
# if we are testing the stream, this is where we split
if ($streamtest) {
print $stdout ">>> STREAMING CONNECT TEST <<< (kill process to end)\n";
&start_streaming; } # this never returns in this mode
# initial login tests and command line controls
if ($statusurl) {
$shorstatusturl = &urlshorten($statusurl);
$status = ((length($status)) ? "$status " : "") . $shorstatusturl;
}
$phase = 0;
$didhold = $hold;
$hold = -1 if ($hold == 1 && !$script);
$credentials = '';
$status = pack("U0C*", unpack("C*", $status))
unless ($seven || !length($status) || $LANG =~ /8859/); # kludgy also
if ($status eq '-') {
chomp(@status = <STDIN>);
$status = join("\n", @status);
}
for(;;) {
$rv = 0;
die(
"sorry, you can't tweet anonymously. use an authenticated username.\n")
if ($anonymous && length($status));
die(
"sorry, status too long: reduce by @{[ length($status)-$linelength ]} chars, ".
"or use -autosplit={word,char,cut}.\n")
if (length($status) > $linelength && !$autosplit);
($status, $next) = &csplit($status, ($autosplit eq 'char' ||
$autosplit eq 'cut') ? 1 : 0)
if (!length($next));
if ($autosplit eq 'cut' && length($next)) {
print "-- warning: input autotrimmed to $linelength bytes\n";
$next = "";
}
if (!$anonymous && !length($whoami) && !length($status)) {
# we must be using OAuth tokens. we'll need
# to get our screen name from Twitter. we DON'T need this
# if we're just posting with -status.
print "(checking credentials) "; $data =
$credentials = &backticks($baseagent, '/dev/null', undef,
$credurl, undef, $anonymous, @wind);
$rv = $? || &is_fail_whale($data) || &is_json_error($data);
}
if (!$rv && length($status) && $phase) {
print "post attempt "; $rv = &updatest($status, 0);
} else {
# no longer a way to test anonymous logins
unless ($rv || $anonymous) {
print "test-login ";
$data = &backticks($baseagent, '/dev/null', undef,
$url, undef, $anonymous, @wind);
$rv = $?;
}
}
if ($rv || &is_fail_whale($data) || &is_json_error($data)) {
if (&is_fail_whale($data)) {
print "FAILED -- Fail Whale detected\n";
} elsif ($x = &is_json_error($data)) {
print "FAILED!\n*** server reports: \"$x\"\n";
print "check your password or configuration.\n";
} else {
$x = $rv >> 8;
print
"FAILED. ($x) bad password, login or URL? server down?\n";
}
print "access failure on: ";
print (($phase) ? $update : $url);
print "\n";
print
"--- data received ($hold) ---\n$data\n--- data received ($hold) ---\n"
if ($superverbose);
if ($hold && --$hold) {
print
"trying again in 1 minute, or kill process now.\n\n";
sleep 60;
next;
}
if ($didhold) {
print "giving up after $didhold tries.\n";
} else {
print
"to automatically wait for a connect, use -hold.\n";
}
exit(1);
}
if ($status && !$phase) {
print "SUCCEEDED!\n";
$phase++;
next;
}
if (length($next)) {
print "SUCCEEDED!\n(autosplit) ";
$status = $next;
$next = "";
next;
}
last;
}
print "SUCCEEDED!\n";
exit(0) if (length($status));
&sigify(sub { ; }, qw(USR1 PWR XCPU));
&sigify(sub { $background_is_ready++ }, qw(USR2 SYS UNUSED XFSZ));
if (length($credentials)) {
print "-- processing credentials: ";
$my_json_ref = &parsejson($credentials);
$whoami = $my_json_ref->{'screen_name'};
if (!length($whoami)) {
print "FAILED!\nis your account suspended, or wrong token?\n";
exit;
}
print "logged in as $whoami\n";
$credlog = "-- you are logged in as $whoami\n";
}
#### BOT/DAEMON MODE STARTUP ####
$last_rate_limit = undef;
$rate_limit_left = undef;
$rate_limit_rate = undef;
$rate_limit_next = 0;
$effpause = 0; # for both daemon and background
if ($daemon) {
if (!$pause) {
print $stdout "*** kind of stupid to run daemon with pause=0\n";
exit 1;
}
if ($child = fork()) {
print $stdout "*** detached daemon released. pid = $child\n";
kill 15, $$;
exit 0;
} elsif (!defined($child)) {
print $stdout "*** fork() failed: $!\n";
exit 1;
} else {
$bufferpid = 0;
if ($dostream) {
&sigify(sub {
kill $SIGHUP, $nursepid if ($nursepid);
kill $SIGHUP, $bufferpid if ($bufferpid);
kill 9, $curlpid if ($curlpid);
sleep 1;
# send myself a shutdown
kill 9, $$;
}, qw(TERM HUP PIPE));
&sigify("IGNORE", qw(INT));
$bufferpid = &start_streaming;
$rin = '';
vec($rin, fileno(STBUF), 1) = 1;
}
$parent = 0;
$dmcount = 1 if ($dmpause); # force fetch
$is_background = 1;
DAEMONLOOP: for(;;) {
my $snooze;
my $nfound;
my $wake;
&$heartbeat;
&update_effpause;
&refresh(0);
$dont_refresh_first_time = 0;
if ($dmpause) {
if (!--$dmcount) {
&dmrefresh(0);
$dmcount = $dmpause;
}
}
# service events on the streaming socket, if
# we have one.
$snooze = ($effpause || 0+$pause || 60);
$wake = time() + $snooze;
if (!$bufferpid) {
sleep $snooze;
} else {
SLEEP_AGAIN: for(;;) {
$nfound = select($rout = $rin,
undef, undef, $snooze);
if ($nfound) {
my $buf;
my $rbuf;
my $len;
while (length($buf) < 8) {
read(STBUF, $rbuf, 1);
if ($rbuf =~ /[0-9a-fA-F]/) {
$buf .= $rbuf;
} else {
$buf = '';
}
}
$len = hex($buf);
read(STBUF, $buf, $len);
&streamevents(
&parsejson($buf) );
$snooze = $wake - time();
next SLEEP_AGAIN if
($snooze > 0);
}
last SLEEP_AGAIN;
}
}
}
}
die("uncaught fork() exception\n");
}
#### INTERACTIVE MODE and CONSOLE STARTUP ####
unless ($simplestart) {
print <<"EOF";
###################################################### +oo=========oo+
${EM}TTYtter ${TTYtter_VERSION}.${padded_patch_version} (c)2012 cameron kaiser${OFF} @ @
EOF
$e = <<'EOF';
${EM}all rights reserved.${OFF} +oo= =====oo+
${EM}http://www.floodgap.com/software/ttytter/${OFF} ${GREEN}a==:${OFF} ooo
${GREEN}.++o++.${OFF} ${GREEN}..o**O${OFF}
freeware under the floodgap free software license. ${GREEN}+++${OFF} :O${GREEN}:::::${OFF}
http://www.floodgap.com/software/ffsl/ ${GREEN}+**O++${OFF} # ${GREEN}:ooa${OFF}
#+$$AB=.
${EM}tweet me: http://twitter.com/ttytter${OFF} #;;${YELLOW}ooo${OFF};;
${EM}tell me: ckaiser@floodgap.com${OFF} #+a;+++;O
###################################################### ,$B.${RED}*o***${OFF} O$,
# a=o${RED}$*O*O*$${OFF}o=a
# when ready, hit RETURN/ENTER for a prompt. @${RED}$$$$$${OFF}@
# type /help for commands or /quit to quit. @${RED}o${OFF}@o@${RED}o${OFF}@
# starting background monitoring process. @=@ @=@
#
EOF
$e =~ s/\$\{([A-Z]+)\}/${$1}/eg; print $stdout $e;
} else {
print <<"EOF";
TTYtter ${TTYtter_VERSION}.${padded_patch_version} (c)2012 cameron kaiser
all rights reserved. freeware under the floodgap free software license.
http://www.floodgap.com/software/ffsl/
tweet me: http://twitter.com/ttytter * tell me: ckaiser\@floodgap.com
type /help for commands or /quit to quit.
starting background monitoring process.
EOF
}
if ($superverbose) {
print $stdout "-- OMGSUPERVERBOSITYSPAM enabled.\n\n";
} else {
print $stdout "-- verbosity enabled.\n\n" if ($verbose);
}
sleep 3 unless ($silent);
# these three functions are outside of the usual API assertions for clarity.
# they represent the main loop, which by default is the interactive console.
# the main loop can be redefined.
sub defaultprompt {
my $rv = ($noprompt) ? "" : "TTYtter> ";
my $rvl = ($noprompt) ? 0 : 9;
return ($rv, $rvl) if (shift);
$wrapseq = 0;
print $stdout "${CCprompt}$rv${OFF}" unless ($termrl);
}
sub defaultaddaction { return 0; }
sub defaultmain {
if (length($runcommand)) {
&prinput($runcommand);
&sync_n_quit;
}
@history = ();
print C "rsga---------------\n";
$dont_use_counter = $nocounter;
eval '$termrl->hook_no_counter';
if ($termrl) {
while(defined ($_ = $termrl->readline((&$prompt(1))[0]))) {
kill $SIGUSR1, $child; # suppress output
$rv = &prinput($_);
kill $SIGUSR2, $child; # resume output
last if ($rv < 0);
&sync_console unless (!$rv || !$synch);
if ($dont_use_counter ne $nocounter) {
# only if we have to -- this is expensive
$dont_use_counter = $nocounter;
eval '$termrl->hook_no_counter'
}
}
} else {
&$prompt;
while(<>) { #not stdin so we can read from script files
kill $SIGUSR1, $child; # suppress output
$rv = &prinput(&uforcemulti($_));
kill $SIGUSR2, $child; # resume output
last if ($rv < 0);
&sync_console unless (!$rv || !$synch);
&$prompt;
}
&sync_n_quit if ($script);
}
}
# SIGPIPE in particular must be trapped in case someone kills the background
# or, in streaming mode, buffer processes. we can't recover from that.
# the streamer MUST have been initialized before we start these signal
# handlers, or the streamer will try to run them too. eeek!
#
# DO NOT trap SIGCHLD: we generate child processes that die normally.
&sigify(\&end_me, qw(PIPE INT));
&sigify(\&repaint, qw(USR1 PWR XCPU));
sub sigify {
# this routine abstracts setting signals to a subroutine reference.
# check and see if we have to use POSIX.pm (Perl 5.14+) or we can
# still use $SIG for proper signalling. We prefer the latter, but
# must support the former.
my $subref = shift;
my $k;
if ($signals_use_posix) {
my @w;
my $sigaction = POSIX::SigAction->new($subref);
while ($k = shift) {
my $e = &posix_signal_of($k);
# some signals may not exist on all systems.
next if (!(0+$e));
POSIX::sigaction($e, $sigaction)
|| die("sigaction failure: $! $@\n");
}
} else {
while ($k = shift) { $SIG{$k} = $subref; }
}
}
sub posix_signal_of {
die("never call posix_signal_of if signals_use_posix is false\n")
if (!$signals_use_posix);
# this assumes that POSIX::SIG* returns a scalar int value.
# not all signals exist on all systems. this ensures zeroes are
# returned for locally bogus ones.
return 0+(eval("return POSIX::SIG".shift));
}
sub send_repaint {
unless ($wrapseq){
return;
}
$wrapseq = 0;
return if ($daemon);
if ($child) {
# we are the parent, call our repaint
&repaint;
} else {
# we are not the parent, call the parent to repaint itself
kill $SIGUSR1, $parent; # send SIGUSR1
}
}
sub repaint {
# try to speed this up, since we do it a lot.
$wrapseq = 0;
return &$repaintcache if ($repaintcache) ;
# cache our repaint function (no-op or redisplay)
$repaintcache = sub { ; }; # no-op
return unless ($termrl &&
($termrl->Features()->{'canRepaint'} || $readlinerepaint));
return if ($daemon);
$termrl->redisplay; $repaintcache = sub { $termrl->redisplay; };
}
sub send_removereadline {
# this just stubs into its own removereadline
return &$removereadlinecache if ($removereadlinecache);
$removereadlinecache = sub { ; };
return unless ($termrl && $termrl->Features()->{'canRemoveReadline'});
return if ($daemon);
$termrl->removereadline;
$removereadlinecache = sub { $termrl->removereadline; };
}
# start the background process
# this has to be last or the background process can't see the full API
if ($child = open(C, "|-")) {
close(P);
binmode(C, ":utf8") unless ($seven);
} else {
close(W);
goto MONITOR;
}
eval'$termrl->hook_background_control' if ($termrl);
select(C); $|++; select($stdout);
# handshake for synchronicity mode, if we want it.
if ($synch) {
# we will get two replies for this.
print C "synm---------------\n";
&thump;
# the second will be cleared by the console
}
# wait for background to become ready
sleep 1 while (!$background_is_ready);
# start the
&$main;
# loop until we quit and then we'll
&sync_n_quit if ($script);
# else
exit;
#### command processor ####
sub prinput {
my $i;
local($_) = shift; # bleh
# validate this string if we are in UTF-8 mode
unless ($seven) {
$probe = $_;
&$utf8_encode($probe);
die("utf8 doesn't work right in this perl. run with -seven.\n")
if (&ulength($probe) < length($_));
# should be at least as big
if ($probe =~ /($badutf8)/) {
print $stdout "*** invalid UTF-8: partial delete of a wide character?\n";
print $stdout "*** ignoring this string\n";
return 0;
}
}
$in_reply_to = 0;
chomp;
$_ = &$precommand($_);
s/^\s+//;
s/\s+$//;
my $cfc = 0;
$cfc++ while (s/\033\[[0-9]?[ABCD]// || s/.[\177]// || s/.[\010]//
|| s/[\000-\037\177]//);
if ($cfc) {
$history[0] = $_;
print $stdout "*** filtered control characters; now \"$_\"\n";
print $stdout "*** use %% for truncated version, or append to %%.\n";
return 0;
}
if (/^$/) {
return 1;
}
if (!$slowpost && !$verify && # we assume you know what you're doing!
($_ eq 'h' || $_ eq 'help' || $_ eq 'quit' || $_ eq 'q' ||
/^TTYtter>/ || $_ eq 'ls' || $_ eq '?' ||
m#^help /# || $_ eq 'exit')) {
&add_history($_);
unless ($_ eq 'exit' || /^TTYtter>/ || $_ eq 'ls') {
print $stdout "*** did you mean /$_ ?\n";
print $stdout
"*** to send this as a command, type /%%\n";
} else {
print $stdout
"*** did you really mean to tweet \"$_\"?\n";
}
print $stdout "*** to tweet it anyway, type %%\n";
return 0;
}
if (/^\%(\%|-\d+):p$/) {
my $x = $1;
if ($x eq '%') {
print $stdout "=> \"$history[0]\"\n";
} else {
$x += 0;
if (!$x || $x < -(scalar(@history))) {
print $stdout "*** illegal index\n";
} else {
print $stdout "=> \"$history[-($x + 1)]\"\n";
}
}
return 0;
}
# handle history substitution (including /%%, %%--, %%*, etc.)
$i = 0; # flag
if (/^\%(\%|-\d+)(--|-\d+|\*)?/) {
($i, $proband, $r, $s) = &sub_helper($1, $2, $_);
return 0 if (!$i);
$s = quotemeta($s);
s/^\%${r}${s}/$proband/;
}
if (/[^\\]\%(\%|-\d+)(--|-\d+|\*)?$/) {
($i, $proband, $r, $s) = &sub_helper($1, $2, $_);
return 0 if (!$i);
$s = quotemeta($s);
s/\%${r}${s}$/$proband/;
}
# handle variables second, in case they got in history somehow ...
$i = 1 if (s/^\%URL\%/$urlshort/ || s/\%URL\%$/$urlshort/);
$i = 1 if (s/^\%RT\%/$retweet/ || s/\%RT\%$/$retweet/);
# and escaped history
s/^\\\%/%/;
if ($i) {
print $stdout "(expanded to \"$_\")\n" ;
$in_reply_to = $expected_tweet_ref->{'id_str'} || 0
if (defined $expected_tweet_ref &&
ref($expected_tweet_ref) eq 'HASH');
} else {
$expected_tweet_ref = undef;
}
return 0 unless length; # actually possible to happen
# with control char filters and history.
&add_history($_);
$shadow_history = $_;
# handle history display
if ($_ eq '/history' || $_ eq '/h') {
for ($i = scalar(@history); $i >= 1; $i--) {
print $stdout "\t$i\t$history[($i-1)]\n";
}
return 0;
}
my $slash_first = ($_ =~ m#^/#);
return -1 if ($_ eq '/quit' || $_ eq '/q' || $_ eq '/bye' ||
$_ eq '/exit');
return 0 if (scalar(&$addaction($_)));
# add commands here
if (m#^/du(mp)? ([zZ]?[a-zA-Z][0-9])$#) {
my $code = lc($2);
my $tweet = &get_tweet($code);
my $k;
my $sn;
my $id;
my @superfields = (
[ "user", "screen_name" ], # must always be first
[ "retweeted_status", "id_str" ],
[ "user", "geo_enabled" ],
[ "tag", "type" ],
[ "tag", "payload" ],
);
my $superfield;
if (!defined($tweet)) {
print $stdout "-- no such tweet (yet?): $code\n";
return 0;
}
foreach $superfield (@superfields) {
my $sfn = join('->', @{ $superfield });
my $sfk = "{'" . join("'}->{'", @{ $superfield }) .
"'}";
my $sfv;
eval "\$sfv = &descape(\$tweet->$sfk);";
print $stdout
substr("$sfn ", 0, 25).
" $sfv\n";
$sn = $sfv if (!length($sn) && length($sfv));
}
# geo is special
print $stdout "geo->coordinates (" .
join(', ', @{ $tweet->{'geo'}->{'coordinates'} })
. ")\n";
foreach $k (sort keys %{ $tweet }) {
next if (ref($tweet->{$k}));
print $stdout
substr("$k ", 0, 25) .
" " . &descape($tweet->{$k}) . "\n";
}
# include a URL to the tweet per @augmentedfourth
$urlshort =
"${http_proto}://twitter.com/$sn/statuses/$tweet->{'id_str'}";
print $stdout
"-- %URL% is now $urlshort (/short to shorten)\n";
return 0;
}
# should we go get the DM from the server? maybe in the future.
if (m#^/du(mp)? ([dD][a-zA-Z][0-9])$#) {
my $code = lc($2);
my $dm = &get_dm($code);
my $k;
my $sn;
my $id;
my @superfields = (
[ "sender", "screen_name" ], # must always be first
);
if (!defined($dm)) {
print $stdout "-- no such DM (yet?): $code\n";
return 0;
}
foreach $superfield (@superfields) {
my $sfn = join('->', @{ $superfield });
my $sfk = "{'" . join("'}->{'", @{ $superfield }) .
"'}";
my $sfv;
eval "\$sfv = &descape(\$dm->$sfk);";
print $stdout
substr("$sfn ", 0, 25).
" $sfv\n";
$sn = $sfv if (!length($sn) && length($sfv));
}
foreach $k (sort keys %{ $dm }) {
next if (ref($dm->{$k}));
print $stdout
substr("$k ", 0, 25) .
" " . &descape($dm->{$k}) . "\n";
}
return 0;
}
# evaluator
if (m#^/ev(al)? (.+)$#) {
$k = eval $2;
print $stdout "==> $k $@\n";
return 0;
}
# version check
if (m#^/v(ersion)?check$# || m#^/u(pdate)?check$#) {
print $stdout &updatecheck(1);
return 0;
}
# url shortener routine
if (($_ eq '/sh' || $_ eq '/short') && length($urlshort)) {
$_ = "/short $urlshort";
print $stdout "*** assuming you meant %URL%: $_\n";
# and fall through to ...
}
if (m#^/sh(ort)? (https?|gopher)(://[^ ]+)#) {
my $url = $2 . $3;
my $answer = (&urlshorten($url) || 'FAILED -- %% to retry');
print $stdout "*** shortened to: ";
print $streamout ($answer . "\n");
return 0;
}
# getter for internal value settings
if (/^\/r(ate)?l(imit)?$/) {
$_ = '/print rate_limit_rate';
# and fall through to ...
}
if ($_ eq '/p' || $_ eq '/print') {
foreach $key (sort keys %opts_can_set) {
print $stdout "*** $key => $$key\n"
if (!$opts_secret{$key});
}
return 0;
}
if (/^\/p(rint)?\s+([^ ]+)/) {
my $key = $2;
if ($valid{$key} ||
$key eq 'effpause' ||
$key eq 'rate_limit_rate' ||
$key eq 'rate_limit_left') {
my $value = &getvariable($key);
print $stdout "*** ";
print $stdout "(read-only value) "
if (!$opts_can_set{$key});
print $stdout "$key => $value\n";
# I don't see a need for these in &getvariable, so they are
# not currently supported. whine if you disagree.
} elsif ($key eq 'tabcomp') {
if ($termrl) {
&generate_otabcomp;
} else {
print $stdout "*** readline isn't on\n";
}
} elsif ($key eq 'ntabcomp') { # sigh
if ($termrl) {
print $stdout "*** new TAB-comp entries: ";
$did_print = 0;
foreach(keys %readline_completion) {
next if ($original_readline{$_});
$did_print = 1;
print $stdout "$_ ";
}
print $stdout "(none)" if (!$did_print);
print $stdout "\n";
} else {
print $stdout "*** readline isn't on\n";
}
} else {
print "*** not a valid option or setting: $key\n";
}
return 0;
}
if ($_ eq '/verbose' || $_ eq '/ve') {
$verbose ^= 1;
$_ = "/set verbose $verbose";
print $stdout "-- verbosity.\n" if ($verbose);
# and fall through to set
}
# search api integration (originally based on @kellyterryjones',
# @vielmetti's and @br3nda's patches)
if (/^\/se(arch)?\s+(\+\d+\s+)?(.+)\s*$/) {
my $countmaybe = $2;
my $kw = $3;
$countmaybe =~ s/[^\d]//g if (length($countmaybe));
$countmaybe += 0;
$countmaybe ||= $searchhits;
$kw =~ s/([^ a-z0-9A-Z_])/&uhex($1)/eg;
$kw =~ s/\s+/+/g;
$kw = "q=$kw" if ($kw !~ /^q=/);
$kw .= "&rpp=$countmaybe";
my $r = &grabjson("$queryurl?$kw", 0, 1);
if (defined($r) && ref($r) eq 'ARRAY' && scalar(@{ $r })) {
&dt_tdisplay($r, 'search');
} else {
print $stdout "-- sorry, no results were found.\n";
}
&$conclude;
return 0;
}
if ($_ eq '/notrack') { # special case
print $stdout "*** all tracking keywords cancelled\n";
$track = '';
&setvariable('track', $track, 1);
return 0;
}
if (s/^\/troff\s+// && s/\s*// && length) {
# remove it from array, regenerate $track, call tracktags_makearray
# and then sync
my $k;
my $l = '';
my $q = 0;
my %w;
$_ = lc($_);
my (@ptags) = split(/\s+/, $_);
# filter duplicates and merge quoted strings (again)
# but this time we're building up a hash for fast searches
foreach $k (@ptags) {
if ($q && $k =~ /"$/) { # this has to be first
$l .= " $k";
$q = 0;
} elsif ($k =~ /^"/ || $q) {
$l .= (length($l)) ? " $k" : $k;
$q = 1;
next;
} else {
$l = $k;
}
next if ($w{$l}); # ignore silently here
$w{$l} = 1;
$l = '';
}
print $stdout "-- warning: syntax error, missing quote?\n"
if ($q);
# now filter out of @tracktags
@ptags = ();
foreach $k (@tracktags) {
push (@ptags, $k) unless ($w{$k});
}
unless (scalar(@ptags) < scalar(@tracktags)) {
print $stdout "-- sorry, no track terms matched.\n";
print $stdout (length($track) ?
"-- you are tracking: $track\n" :
"-- (maybe because you're not tracking anything?)\n");
return 0;
}
print $stdout "*** ok, filtered @{[ keys(%w) ]}\n";
$track = join(' ', @ptags);
&setvariable('track', $track, 1);
return 0;
}
if (s#^/tre(nds)?\s*##) {
#TODO
# in 2.1, remove trendurl and make everything based on woeid
my $t;
my $wwoeid = (length) ? $_ : $woeid;
$wwoeid ||= "1";
my $r = ($wwoeid) ?
&grabjson("${wtrendurl}${wwoeid}.json", 0, 0, 0)
: &grabjson("$trendurl", 0, 0, 0); # hack
my $fr = ($wwoeid && $wwoeid ne '1') ?
" FOR WOEID $wwoeid" : ' GLOBALLY';
#{"as_of":1237580149,"trends":{"2009-03-20 20:15:49":[{"query":"#sxsw OR SXSW",
if (defined($r) && ref($r) eq 'HASH') {
$t = $r->{'trends'};
} elsif (defined($r) && ref ($r) eq 'ARRAY') {
$t = $r->[0]->{'trends'};
}
if (defined($t) && (ref($t) eq 'HASH' || ref($t) eq 'ARRAY')) {
my $i;
my $j;
print $stdout "${EM}<<< TRENDING TOPICS${fr} >>>${OFF}\n";
# this is moderate paranoia
if (ref($r) eq 'HASH') {
# this is the old behaviour. it will be removed.
foreach $i (sort { $b cmp $a } keys %{ $t }) {
foreach $j (@{ $t->{$i} }) {
my $k = &descape($j->{'query'});
my $l = ($k =~ /\sOR\s/) ? $k :
($k =~ /^"/) ? $k :
('"' . $k . '"');
print $streamout "/search $l\n";
$k =~ s/\sOR\s/ /g;
$k = '"' . $k . '"' if ($k =~ /\s/
&& $k !~ /^"/);
print $streamout "/tron $k\n";
}
last; # emulate old trends/current behaviour
}
} else {
foreach $j (@{ $t }) {
my $k = &descape($j->{'name'});
my $l = ($k =~ /\sOR\s/) ? $k :
($k =~ /^"/) ? $k :
('"' . $k . '"');
print $streamout "/search $l\n";
$k =~ s/\sOR\s/ /g;
$k = '"' . $k . '"' if ($k =~ /\s/
&& $k !~ /^"/);
print $streamout "/tron $k\n";
}
}
print $stdout "${EM}<<< TRENDING TOPICS >>>${OFF}\n";
} else {
print $stdout
"-- sorry, trends not available for WOEID $wwoeid.\n";
}
return 0;
}
# woeid finder based on lat/long
if ($_ eq '/woeids') {
my $max = 10;
if (!$lat && !$long) {
print $stdout
"-- set your location with lat/long first.\n";
return 0;
}
my $r = &grabjson("$atrendurl?lat=$lat&long=$long", 0, 0, 0);
if (defined($r) && ref($r) eq 'ARRAY') {
my $i;
foreach $i (@{ $r }) {
my $woeid = &descape($i->{'woeid'});
my $nm = &descape($i->{'name'}) . ' (' .
&descape($i->{'countryCode'}) .')';
print $streamout "$nm\n/set woeid $woeid\n";
last unless ($max--);
}
} else {
print $stdout
"-- sorry, couldn't get a supported WOEID for your location.\n";
}
return 0;
}
1 if (s/^\/#([^\s]+)/\/tron #\1/);
# /# command falls through to tron
if (s/^\/tron\s+// && s/\s*$// && length) {
$_ = lc($_);
$track .= " " if (length($track));
$_ = "/set track ${track}$_";
# fall through to set
}
if (/^\/track ([^ ]+)/) {
s#^/#/set #;
# and fall through to set
}
# /listoff
if (s/^\/list?off\s+// && s/\s*$// && length) {
if (/,/ || /\s+/) {
print $stdout "-- one list at a time please\n";
return 0;
}
if (!scalar(@listlist)) {
print $stdout
"-- ok! that was easy! (you don't have any lists in your timeline)\n";
return 0;
}
my $w;
my $newlists = '';
my $didfilter = 0;
foreach $w (@listlist) {
my $x = join('/', @{ $w });
if ($x eq $_ || "$whoami$_" eq $x ||
"$whoami/$_" eq $x) {
print $stdout "*** ok, filtered $x\n";
$didfilter = 1;
} else {
$newlists .= (length($newlists)) ? ",$x"
: $x;
}
}
if ($didfilter) {
&setvariable('lists', $newlists, 1);
} else {
print $stdout "*** hmm, no such list? current value:\n";
print $stdout "*** lists => ",
&getvariable('lists'), "\n";
}
return 0;
}
# /liston
if (s/^\/list?on\s+// && s/\s*$// && length) {
if (/,/ || /\s+/) {
print $stdout "-- one list at a time please\n";
return 0;
}
my $uname;
my $lname;
if (m#/#) {
($uname, $lname) = split(m#/#, $_, 2);
} else {
$lname = $_;
$uname = '';
}
if (!length($uname) && $anonymous) {
print $stdout
"-- you must specify a username for a list when anonymous.\n";
return 0;
}
$uname ||= $whoami;
# check the list validity
my $my_json_ref = &grabjson(
"${statusliurl}?owner_screen_name=${uname}&slug=${lname}",
0, 0, 0);
if (!$my_json_ref || ref($my_json_ref) ne 'ARRAY') {
print $stdout
"*** list $uname/$lname seems bogus; not added\n";
return 0;
}
$_ = "/add lists $uname/$lname";
# fall through to add
}
if (s/^\/a(uto)?lists?\s+// && s/\s*$// && length) {
s/\s+/,/g if (!/,/);
print $stdout
"--- warning: lists aren't checked en masse; make sure they exist\n";
$_ = "/set lists $_";
# and fall through to set
}
# setter for internal value settings
# shortcut for boolean settings
if (/^\/s(et)? ([^ ]+)\s*$/) {
my $key = $2;
$_ = "/set $key 1"
if($opts_boolean{$key} && $opts_can_set{$key});
# fall through to three argument version
}
if (/^\/uns(et)? ([^ ]+)\s*$/) {
my $key = $2;
if ($opts_can_set{$key} && $opts_boolean{$key}) {
&setvariable($key, 0, 1);
return 0;
}
&setvariable($key, undef, 1);
return 0;
}
# stubs out to set variable
if (/^\/s(et)? ([^ ]+) (.+)\s*$/) {
my $key = $2;
my $value = $3;
&setvariable($key, $value, 1);
return 0;
}
# append to a variable (if not boolean)
if (/^\/ad(d)? ([^ ]+) (.+)\s*$/) {
my $key = $2;
my $value = $3;
if ($opts_boolean{$key}) {
print $stdout
"*** why are you appending to a boolean?\n";
return 0;
}
if (length(&getvariable($key))) {
$value = " $value" if ($opts_space_delimit{$key});
$value = ",$value" if ($opts_comma_delimit{$key});
}
&setvariable($key, &getvariable($key).$value, 1);
return 0;
}
# stackable settings
# shortcut for boolean settings (push only -- irrelevant for pad)
if (/^\/pu(sh)? ([^ ]+)\s*$/) {
my $key = $2;
$_ = "/push $key 1"
if($opts_boolean{$key} && $opts_can_set{$key});
# fall through to three argument version
}
# common code for set and append
if (/^\/(pu|push|pad|padd) ([^ ]+) (.+)\s*$/) {
my $comm = $1;
my $key = $2;
my $value = $3;
$comm = ($comm =~ /^pu/) ? "push" : "padd";
if ($opts_boolean{$key} && $comm eq 'padd') {
print $stdout
"*** why are you appending to a boolean?\n";
return 0;
}
my $old = &getvariable($key);
if (!defined($old) || !$opts_can_set{$key}) {
print $stdout
"*** setting is not stackable: $key\n";
return 0;
}
push(@{ $push_stack{$key} }, $old);
print $stdout "--- saved on stack for $key: $old\n";
if ($comm eq 'padd' && length($old)) {
$value = " $value" if ($opts_space_delimit{$key});
$value = ",$value" if ($opts_comma_delimit{$key});
$old .= $value;
} else {
$old = $value;
}
&setvariable($key, $old, 1);
return 0;
}
# we assume that if the setting is in the push stack, it's valid
if (/^\/pop ([^ ]+)\s*$/) {
my $key = $1;
if (!scalar(@{ $push_stack{$key} })) {
print $stdout
"*** setting is not stacked: $key\n";
return 0;
}
&setvariable($key, pop(@{ $push_stack{$key} }), 1);
return 0;
}
# shell escape
if (s/^\/\!// && s/\s*$// && length) {
system("$_");
$x = $? >> 8;
print $stdout "*** exited with $x\n" if ($x);
return 0;
}
if ($_ eq '/help' || $_ eq '/?') {
print <<'EOF';
*** BASIC COMMANDS: :a$AAOOOOOOOOOOOOOOOOOAA$a, ==================
+@A:. .:B@+ ANYTHING WITHOUT
/refresh =@B HELP!!! HELP!!! B@= A LEADING / IS
grabs the newest :a$Ao oA$a, SENT AS A TWEET!
tweets right ;AAA$a; :a$AAAAAAAAAAA; ==================
away (or tells :AOaaao:, .:oA*:. JUST TYPE TO TALK!
you if there .;=$$$OBO***+ .+aaaa$:
is nothing new) :*; :***O@Aaaa*o, ============
by thumping .+++++: o#o REMEMBER!!
the background :OOOOOOA*:::, =@o ,:::::. ============
process. .+++++++++: =@*.....=a$OOOB#; MANY COMMANDS, AND
=@OoO@BAAA#@$o, ALL TWEETS ARE
/again =@o .+aaaaa: --ASYNCHRONOUS--
displays most recent =@Aaaaaaaaaa*o*a;, and might not always
tweets, both old and =@$++=++++++:,;+aA: respond
new. ,+$@*.=O+ ...oO; oAo+. immediately!
,+o$OO=.+aA#####Oa;.*OO$o+.
/dm and /dmagain for DMs. +Ba::;oaa*$Aa=aA$*aa=;::$B:
,===O@BOOOOOOOOO#@$===,
/replies o@BOOOOOOOOO#@+ ==================
shows replies and mentions. o@BOB@B$B@BO#@+ USE + FOR A COUNT:
o@*.a@o a@o.$@+ /re +30 => last 30 replies
/quit resumes your boring life. o@B$B@o a@A$#@+ ==========================
EOF
&linein("PRESS RETURN/ENTER>");
print <<"EOF";
+- MORE COMMANDS -+ -=-=- USER STUFF -=-=-
| | /whois username displays info about username
| See the TTYtter | /again username views their most recent tweets
| home page for | /wagain username combines them all
| complete list | /follow username follow a username
| | /leave username stop following a username
+-----------------+ /dm username message send a username a DM
+--- TWEET AND DM SELECTION -------------------------------------------------+
| all DMs and tweets have menu codes (letters + number, d for DMs). example: |
| a5> <ttytter> Send me Dr Pepper http://www.floodgap.com/TTYtter |
| [DM da0][ttytter/Sun Jan 32 1969] I think you are cute |
| /reply a5 message replies to tweet a5 |
| example: /reply a5 I also like Dr Pepper |
| becomes \@ttytter I also like Dr Pepper (and is threaded) |
| /thread a5 if a5 is part of a thread (the username |
| has a \@) then show all posts up to that |
| /url a5 opens all URLs in tweet a5 |
| Mac OS X users, do first: /set urlopen open %U |
| Dummy terminal users, try /set urlopen lynx -dump %U | more |
| /delete a5 deletes tweet a5, if it's your tweet |
| /rt a5 retweets tweet a5: RT \@tytter: Send me...|
+-- Abbreviations: /re, /th, /url, /del --- menu codes wrap around at end ---+
=====> /reply, /delete and /url work for direct message menu codes too! <=====
EOF
&linein("PRESS RETURN/ENTER>");
print <<"EOF";
Use /set to turn on options or set them at runtime. There is a BIG LIST!
>> EXAMPLE: WANT ANSI? /set ansi 1
or use the -ansi command line option.
WANT TO VERIFY YOUR TWEETS BEFORE POSTING? /set verify 1
or use the -verify command line option.
For more, like readline support, UTF-8, SSL, proxies, etc., see the docs.
** READ THE COMPLETE DOCUMENTATION: http://www.floodgap.com/software/ttytter/
TTYtter $TTYtter_VERSION is (c)2012 cameron kaiser + contributors.
all rights reserved. this software is offered AS IS, with no guarantees. it
is not endorsed by Obvious or the executives and developers of Twitter.
*** subscribe to updates at http://twitter.com/ttytter
or http://twitter.com/floodgap
send your suggestions to me at ckaiser\@floodgap.com
or http://twitter.com/doctorlinguist
EOF
return 0;
}
if ($_ eq '/ruler' || $_ eq '/ru') {
my ($prompt, $prolen) = (&$prompt(1));
$prolen = " " x $prolen;
print $stdout <<"EOF";
${prolen} 1 2 3 4 5 6 7 8 9 0 1 2 3 XX
${prompt}1...5....0....5....0....5....0....5....0....5....0....5....0....5....0....5....0....5....0....5....0....5....0....5....0....5....0....5...XX
EOF
return 0;
}
if ($_ eq '/cls' || $_ eq '/clear') {
if ($ansi) {
print $stdout "${ESC}[H${ESC}[2J\n";
} else {
print $stdout ("\n" x ($ENV{'ROWS'} || 50));
}
return 0;
}
if ($_ eq '/refresh' || $_ eq '/thump' || $_ eq '/r') {
print $stdout "-- /refresh in streaming mode is pretty impatient\n"
if ($dostream);
&thump;
return 0;
}
if (m#^/a(gain)?(\s+\+\d+)?$#) { # the asynchronous form
my $countmaybe = $2;
$countmaybe =~ s/[^\d]//g if (length($countmaybe));
$countmaybe += 0;
if ($countmaybe > 999) {
print $stdout "-- greedy bastard, try +fewer.\n";
return 0;
}
$countmaybe = sprintf("%03i", $countmaybe);
print $stdout "-- background request sent\n" unless ($synch);
print C "reset${countmaybe}-----------\n";
&sync_semaphore;
return 0;
}
# this is for users -- list form is below
if ($_ =~ m#^/(w)?a(gain)?\s+(\+\d+\s+)?([^\s/]+)$#) { #synchronous form
my $mode = $1;
my $uname = lc($4);
my $countmaybe = $3;
$countmaybe =~ s/[^\d]//g if (length($countmaybe));
$countmaybe += 0;
$uname =~ s/^\@//;
$readline_completion{'@'.$uname}++ if ($termrl);
print $stdout
"-- synchronous /again command for $uname ($countmaybe)\n"
if ($verbose);
my $my_json_ref =
&grabjson("${uurl}?screen_name=${uname}&include_rts=true",
0, 0, $countmaybe);
&dt_tdisplay($my_json_ref, 'again');
unless ($mode eq 'w' || $mode eq 'wf') {
return 0;
} # else fallthrough
}
if ($_ =~ m#^/w(hois|a|again)?\s+(\+\d+\s+)?\@?([^\s]+)#) {
my $uname = lc($3);
$uname =~ s/^\@//;
$readline_completion{'@'.$uname}++ if ($termrl);
print $stdout "-- synchronous /whois command for $uname\n"
if ($verbose);
my $my_json_ref =
&grabjson("${wurl}?screen_name=${uname}", 0);
if (defined($my_json_ref) && ref($my_json_ref) eq 'HASH' &&
length($my_json_ref->{'screen_name'})) {
my $sturl = undef;
my $purl =
&descape($my_json_ref->{'profile_image_url'});
if ($avatar && length($purl) && $purl !~
m#^http://[^.]+\.(twimg\.com|twitter\.com).+/images/default_profile_\d+_normal.png#) {
my $exec = $avatar;
my $fext;
($purl =~ /\.([a-z0-9A-Z]+)$/) &&
($fext = $1);
if ($purl !~ /['\\]/) { # careful!
$exec =~ s/\%U/'$purl'/g;
$exec =~ s/\%N/$uname/g;
$exec =~ s/\%E/$fext/g;
print $stdout "\n";
print $stdout "($exec)\n"
if ($verbose);
system($exec);
}
}
print $streamout "\n";
&userline($my_json_ref, $streamout);
print $streamout &wwrap(
"\"@{[ &strim(&descape($my_json_ref->{'description'})) ]}\"\n")
if (length(&strim($my_json_ref->{'description'})));
if (length($my_json_ref->{'url'})) {
$sturl =
$urlshort = &descape($my_json_ref->{'url'});
$urlshort =~ s/^\s+//;
$urlshort =~ s/\s+$//;
print $streamout "${EM}URL:${OFF}\t\t$urlshort\n";
}
print $streamout &wwrap(
"${EM}Location:${OFF}\t@{[ &descape($my_json_ref->{'location'}) ]}\n")
if (length($my_json_ref->{'location'}));
print $streamout <<"EOF";
${EM}Picture:${OFF}\t@{[ &descape($my_json_ref->{'profile_image_url'}) ]}
EOF
unless ($anonymous || $whoami eq $uname) {
my $g =
&grabjson("$frurl?user_a=$whoami&user_b=$uname", 0);
print $streamout &wwrap(
"${EM}Do you follow${OFF} this user? ... ${EM}$g->{'literal'}${OFF}\n")
if (ref($g) eq 'HASH');
my $g =
&grabjson("$frurl?user_a=$uname&user_b=$whoami", 0);
print $streamout &wwrap(
"${EM}Does this user follow${OFF} you? ... ${EM}$g->{'literal'}${OFF}\n")
if (ref($g) eq 'HASH');
print $streamout "\n";
}
print $stdout &wwrap(
"-- %URL% is now $urlshort (/short shortens, /url opens)\n")
if (defined($sturl));
}
return 0;
}
if (m#^/(df|doesfollow)\s+\@?([^\s]+)$#) {
if ($anonymous) {
print $stdout "-- who follows anonymous anyway?\n";
return 0;
}
$_ = "/doesfollow $2 $whoami";
print $stdout "*** assuming you meant: $_\n";
# fall through to ...
}
if (m#^/(df|doesfollow)\s+\@?([^\s]+)\s+\@?([^\s]+)$#) {
my $user_a = $2;
my $user_b = $3;
if ($user_a =~ m#/# || $user_b =~ m#/#) {
print $stdout "--- sorry, this won't work on lists.\n";
return 0;
}
my $g = &grabjson(
"${frurl}?user_a=${user_a}&user_b=${user_b}", 0);
if ($g->{'ok'}) {
print $stdout "--- does $user_a follow ${user_b}? => ";
print $streamout "$g->{'literal'}\n"
}
return 0;
}
# this handles lists too.
if(s#^/(frs|friends|fos|followers)(\s+\+\d+)?\s*##) {
my $countmaybe = $2;
my $mode = $1;
my $arg = lc($_);
my $lname = '';
my $user = '';
my $what = '';
$arg =~ s/^@//;
$who = $arg;
($who, $lname) = split(m#/#, $arg, 2) if (m#/#);
if (length($lname) && !length($user) && $anonymous) {
print $stdout
"-- you must specify a username for a list when anonymous.\n";
return 0;
}
if (!length($lname)) {
$user = "&screen_name=$_" if length;
$what = ($mode eq 'frs' || $mode eq 'friends')
? "friends" : "followers";
$mode = ($mode eq 'frs' || $mode eq 'friends')
? $friendsurl : $followersurl;
$who = "user $who";
} else {
$who ||= $whoami;
$what = ($mode eq 'frs' || $mode eq 'friends')
? "friends/members" : "followers/subscribers";
$mode = ($mode eq 'frs' || $mode eq 'friends')
? $getliurl : $getfliurl;
$user = "&owner_screen_name=${who}&slug=${lname}";
$who = "list $who/$lname";
}
$countmaybe =~ s/[^\d]//g if (length($countmaybe));
$countmaybe += 0;
$countmaybe ||= 20;
# we use the undocumented count= support to, by default,
# reduce the JSON parsing overhead. if we always had to take
# all 100, we really eat it on parsing. the downside is that,
# per @episod, the stuff we get is "less" fresh.
my $countper = ($countmaybe < 100) ? $countmaybe : 100;
# loop through using the cursor until desired number.
my $cursor = -1; # initial value
my $printed = 0;
my $nofetch = 0;
my $json_ref = undef;
my @usarray = undef; shift(@usarray); # force underflow
FABIO: while($countmaybe--) {
if(!scalar(@usarray)) {
last FABIO if ($nofetch);
$json_ref = &grabjson(
"${mode}?count=${countper}&cursor=${cursor}${user}");
@usarray = @{ $json_ref->{'users'} };
last FABIO if (!scalar(@usarray));
$cursor = $json_ref->{'next_cursor_str'} ||
$json_ref->{'next_cursor'} || -1;
$nofetch = ($cursor < 1) ? 1 : 0;
}
&$userhandle(shift(@usarray));
$printed++;
}
print $stdout "-- sorry, no $what found for $who.\n"
if (!$printed);
return 0;
}
# threading
if (m#^/th(read)?\s+(\+\d+\s+)?([zZ]?[a-zA-Z][0-9])$#) {
my $countmaybe = $2;
if (length($countmaybe)) {
print $stdout
"-- /thread does not (yet) support +count\n";
return 0;
}
my $code = lc($3);
my $tweet = &get_tweet($code);
if (!defined($tweet)) {
print $stdout "-- no such tweet (yet?): $code\n";
return 0;
}
my $limit = 9;
my $id = $tweet->{'retweeted_status'}->{'id_str'} ||
$tweet->{'in_reply_to_status_id_str'};
my $thread_ref = [ $tweet ];
while ($id && $limit) {
print $stdout "-- thread: fetching $id\n"
if ($verbose);
my $next = &grabjson("${idurl}/${id}.json", 0);
$id = 0;
$limit--;
if (defined($next) && ref($next) eq 'HASH') {
push(@{ $thread_ref },
&fix_geo_api_data($next));
$id = $next->{'retweeted_status'}->{'id_str'}
|| $next->{'in_reply_to_status_id_str'}
|| 0;
}
}
&tdisplay($thread_ref, 'thread', 0, 1); # use the mini-menu
return 0;
}
# pull out entities. this works for DMs and tweets.
# btw: T.CO IS WACK.
if (m#^/ent?(ities)? ([dDzZ]?[a-zA-Z][0-9])$#) {
my $v;
my $w;
my $thing;
my $genurl;
my $code = lc($2);
my $hash;
if ($code =~ /^d.[0-9]$/) {
$hash = &get_dm($code);
$thing = "DM";
$genurl = $dmidurl;
} else {
$hash = &get_tweet($code);
$thing = "tweet";
$genurl = $idurl;
}
if (!defined($hash)) {
print $stdout "-- no such $thing (yet?): $code\n";
return 0;
}
# we don't ordinarily ask for entities, so now we must.
my $id = $hash->{'id_str'};
$hash = &grabjson("${genurl}/${id}.json?include_entities=1", 0);
if (!defined($hash) || ref($hash) ne 'HASH') {
print $stdout "-- failed to get entities from server, sorry\n";
return 0;
}
my $didprint = 0;
# Twitter puts entities in multiple fields.
foreach $w (qw(media urls)) {
my $p = $hash->{'entities'}->{$w};
next if (!defined($p) || ref($p) ne 'ARRAY');
foreach $v (@{ $p }) {
next if (!defined($v) || ref($v) ne 'HASH');
next if (!length($v->{'url'}) ||
(!length($v->{'expanded_url'}) &&
!length($v->{'media_url'})));
my $u1 = &descape($v->{'url'});
my $u2 = &descape($v->{'expanded_url'});
my $u3 = &descape($v->{'media_url'});
my $u4 = &descape($v->{'media_url_https'});
$u2 = $u4 || $u3 || $u2;
print $stdout "$u1 => $u2\n";
$urlshort = $u4 || $u3 || $u1;
$didprint++;
}
}
if ($didprint) {
print $stdout &wwrap(
"-- %URL% is now $urlshort (/url opens)\n");
} else {
print $stdout "-- no entities or URLs found\n";
}
return 0;
}
if (($_ eq '/url' || $_ eq '/open') && length($urlshort)) {
$_ = "/url $urlshort";
print $stdout "*** assuming you meant %URL%: $_\n";
# and fall through to ...
}
if (m#^/(url|open)\s+(http|gopher|https|ftp)://.+# &&
s#^/(url|open)\s+##) {
&openurl($_);
return 0;
}
if (m#^/(url|open) ([dDzZ]?[a-zA-Z][0-9])$#) {
my $code = lc($2);
my $tweet;
$urlshort = undef;
if ($code =~ /^d/ && length($code) == 3) {
$tweet = &get_dm($code); # USO!
if (!defined($tweet)) {
print $stdout
"-- no such DM (yet?): $code\n";
return 0;
}
} else {
$tweet = &get_tweet($code);
if (!defined($tweet)) {
print $stdout
"-- no such tweet (yet?): $code\n";
return 0;
}
}
my $text = &descape($tweet->{'text'});
# findallurls
while ($text
=~ s#(h?ttp|h?ttps|ftp|gopher)://([a-zA-Z0-9_~/:%\-\+\.\=\&\?\#,]+)##){
# sigh. I HATE YOU TINYARRO.WS
#TODO
# eventually we will have to put a punycode implementation into openurl
# to handle things like Mac OS X's open which don't understand UTF-8 URLs.
# when we do, uncomment this again
# =~ s#(http|https|ftp|gopher)://([^'\\]+?)('|\\|\s|$)##) {
my $url = $1 . "://$2";
$url = "h$url" if ($url =~ /^ttps?:/);
$url =~ s/[\.\?]$//;
&openurl($url);
}
print $stdout "-- sorry, couldn't find any URL.\n"
if (!defined($urlshort));
return 0;
}
if (s/^\/(favourites|favorites|faves|favs|fl)(\s+\+\d+)?\s*//) {
my $my_json_ref;
my $countmaybe = $2;
$countmaybe =~ s/[^\d]//g if (length($countmaybe));
$countmaybe += 0;
if (length) {
$my_json_ref = &grabjson("${favsurl}/${_}.json", 0, 0,
$countmaybe);
} else {
if ($anonymous) {
print $stdout
"-- sorry, you can't haz favourites if you're anonymous.\n";
} else {
print $stdout
"-- synchronous /favourites user command\n"
if ($verbose);
$my_json_ref = &grabjson($myfavsurl, 0, 0,
$countmaybe);
}
}
if (defined($my_json_ref)
&& ref($my_json_ref) eq 'ARRAY') {
if (scalar(@{ $my_json_ref })) {
my $w = "-==- favourites " x 10;
$w = $EM . substr($w, 0, $wrap || 79) . $OFF;
print $stdout "$w\n";
&tdisplay($my_json_ref, "favourites");
print $stdout "$w\n";
} else {
print $stdout
"-- no favourites found, boring impartiality concluded.\n";
}
}
&$conclude;
return 0;
}
if (
m#^/(un)?f(rt|retweet|a|av|ave|avorite|avourite)? ([zZ]?[a-zA-Z][0-9])$#) {
my $mode = $1;
my $secondmode = $2;
my $code = lc($3);
$secondmode = ($secondmode eq 'retweet') ? 'rt' : $secondmode;
my $tweet = &get_tweet($code);
if ($mode eq 'un' && $secondmode eq 'rt') {
print $stdout
"-- hmm. seems contradictory. no dice.\n";
return 0;
}
if (!defined($tweet)) {
print $stdout "-- no such tweet (yet?): $code\n";
return 0;
}
&cordfav($tweet->{'id_str'}, 1,
(($mode eq 'un') ? $favdelurl : $favurl),
&descape($tweet->{'text'}),
(($mode eq 'un') ? 'removed' : 'created'));
if ($secondmode eq 'rt') {
$_ = "/rt $code";
# and fall through
} else {
return 0;
}
}
# Retweet API and manual RTs
if (s#^/([oe]?)r(etweet|t) ([zZ]?[a-zA-Z][0-9])\s*##) {
my $mode = $1;
my $code = lc($3);
my $tweet = &get_tweet($code);
if (!defined($tweet)) {
print $stdout "-- no such tweet (yet?): $code\n";
return 0;
}
# use a native retweet unless we can't (or user used /ort /ert)
unless ($nonewrts || length || length($mode)) {
# we don't always get rs->text, so we simulate it.
my $text = &descape($tweet->{'text'});
$text =~ s/^RT \@[^\s]+:\s+//
if ($tweet->{'retweeted_status'}->{'id_str'});
print $stdout "-- status retweeted\n"
unless(&updatest($text, 1, 0, undef,
$tweet->{'retweeted_status'}->{'id_str'}
|| $tweet->{'id_str'}));
return 0;
}
# we can't or user requested /ert /ort
$retweet = "RT @" .
&descape($tweet->{'user'}->{'screen_name'}) .
": " . &descape($tweet->{'text'});
if ($mode eq 'e') {
&add_history($retweet);
print $stdout &wwrap(
"-- ok, %RT% and %% are now \"$retweet\"\n");
return 0;
}
$_ = (length) ? "$retweet $_" : $retweet;
print $stdout &wwrap("(expanded to \"$_\")");
print $stdout "\n";
goto TWEETPRINT; # fugly! FUGLY!
}
if (m#^/(re)?rts?of?me?(\s+\+\d+)?$# && !$nonewrts) {
#TODO
# when more fields are added, integrate them over the JSON_ref
my $mode = $1;
my $countmaybe = $2;
$countmaybe =~ s/[^\d]//g if (length($countmaybe));
$countmaybe += 0;
my $my_json_ref = &grabjson($rtsofmeurl, 0, 0, $countmaybe);
&dt_tdisplay($my_json_ref, "rtsofme");
if ($mode eq 're') {
$_ = '/re'; # and fall through ...
} else {
return 0;
}
}
if (m#^/rts?of\s+([zZ]?[a-zA-Z][0-9])$# && !$nonewrts) {
my $code = lc($1);
my $tweet = &get_tweet($code);
my $id;
if (!defined($tweet)) {
print $stdout "-- no such tweet (yet?): $code\n";
return 0;
}
$id = $tweet->{'retweeted_status'}->{'id_str'} ||
$tweet->{'id_str'};
if (!$id) {
print $stdout "-- hmmm, that tweet is major bogus.\n";
return 0;
}
my $url = $rtsbyurl;
$url =~ s/%I/$id/;
my $users_ref = &grabjson("$url?count=100");
return if (!defined($users_ref) || ref($users_ref) ne 'ARRAY');
my $k = scalar(@{ $users_ref });
if (!$k) {
print $stdout
"-- no known retweeters, or they're private.\n";
return 0;
}
my $j;
foreach $j (@{ $users_ref }) {
&$userhandle($j);
}
return 0;
}
# enable and disable NewRTs from users
# we allow this even if newRTs are off from -nonewrts
if (s#^/rts(on|off)\s+## && length) {
&rtsonoffuser($_, 1, ($1 eq 'on'));
return 0;
}
if (m#^/del(ete)?\s+([zZ]?[a-zA-Z][0-9])$#) {
my $code = lc($2);
my $tweet = &get_tweet($code);
if (!defined($tweet)) {
print $stdout "-- no such tweet (yet?): $code\n";
return 0;
}
if (lc(&descape($tweet->{'user'}->{'screen_name'}))
ne lc($whoami)) {
print $stdout
"-- not allowed to delete somebody's else's tweets\n";
return 0;
}
print $stdout &wwrap(
"-- verify you want to delete: \"@{[ &descape($tweet->{'text'}) ]}\"");
print $stdout "\n";
$answer = lc(&linein(
"-- sure you want to delete? (only y or Y is affirmative):"));
if ($answer ne 'y') {
print $stdout "-- ok, tweet is NOT deleted.\n";
return 0;
}
$lastpostid = -1 if ($tweet->{'id_str'} == $lastpostid);
&deletest($tweet->{'id_str'}, 1);
return 0;
}
# DM delete version
if (m#^/del(ete)? ([dD][a-zA-Z][0-9])$#) {
my $code = lc($2);
my $dm = &get_dm($code);
if (!defined($dm)) {
print $stdout "-- no such DM (yet?): $code\n";
return 0;
}
print $stdout &wwrap(
"-- verify you want to delete: " .
"(from @{[ &descape($dm->{'sender'}->{'screen_name'}) ]}) ".
"\"@{[ &descape($dm->{'text'}) ]}\"");
print $stdout "\n";
$answer = lc(&linein(
"-- sure you want to delete? (only y or Y is affirmative):"));
if ($answer ne 'y') {
print $stdout "-- ok, DM is NOT deleted.\n";
return 0;
}
&deletedm($dm->{'id_str'}, 1);
return 0;
}
# /deletelast
if (m#^/de?l?e?t?e?last$#) {
if (!$lastpostid) {
print $stdout "-- you haven't posted yet this time!\n";
return 0;
}
if ($lastpostid == -1) {
print $stdout "-- you already deleted it!\n";
return 0;
}
print $stdout &wwrap(
"-- verify you want to delete: \"$lasttwit\"");
print $stdout "\n";
$answer = lc(&linein(
"-- sure you want to delete? (only y or Y is affirmative):"));
if ($answer ne 'y') {
print $stdout "-- ok, tweet is NOT deleted.\n";
return 0;
}
&deletest($lastpostid, 1);
$lastpostid = -1;
return 0;
}
if (s#^/(v)?re(ply)? ([zZ]?[a-zA-Z][0-9]) ## && length) {
my $mode = $1;
my $code = lc($3);
my $tweet = &get_tweet($code);
if (!defined($tweet)) {
print $stdout "-- no such tweet (yet?): $code\n";
return 0;
}
my $target = &descape($tweet->{'user'}->{'screen_name'});
$_ = '@' . $target . " $_";
unless ($mode eq 'v') {
$in_reply_to = $tweet->{'id_str'};
$expected_tweet_ref = $tweet;
} else {
$_ = ".$_";
}
$readline_completion{'@'.lc($target)}++ if ($termrl);
print $stdout &wwrap("(expanded to \"$_\")");
print $stdout "\n";
goto TWEETPRINT; # fugly! FUGLY!
}
# DM reply version
if (s#^/(dm)?re(ply)? ([dD][a-zA-Z][0-9]) ## && length) {
my $code = lc($3);
my $dm = &get_dm($code);
if (!defined($dm)) {
print $stdout "-- no such DM (yet?): $code\n";
return 0;
}
# in the future, add DM in_reply_to here
my $target = &descape($dm->{'sender'}->{'screen_name'});
$readline_completion{'@'.lc($target)}++ if ($termrl);
$_ = "/dm $target $_";
print $stdout &wwrap("(expanded to \"$_\")");
print $stdout "\n";
# and fall through to ...
}
if (m#^/re(plies)?(\s+\+\d+)?$#) {
my $countmaybe = $2;
$countmaybe =~ s/[^\d]//g if (length($countmaybe));
$countmaybe += 0;
if ($anonymous) {
print $stdout
"-- sorry, how can anyone reply to you if you're anonymous?\n";
} else {
# we are intentionally not keeping track of "last_re"
# in this version because it is not automatically
# updated and may not act as we expect.
print $stdout "-- synchronous /replies command\n"
if ($verbose);
my $my_json_ref = &grabjson($rurl, 0, 0, $countmaybe);
&dt_tdisplay($my_json_ref, "replies");
}
return 0;
}
# DMs
if ($_ eq '/dm' || $_ eq '/dmrefresh' || $_ eq '/dmr') {
&dmthump;
return 0;
}
# /dmsent, /dmagain
if (m#^/dm(s|sent|a|again)(\s+\+\d+)?$#) {
my $mode = $1;
my $countmaybe = $2;
$countmaybe =~ s/[^\d]//g if (length($countmaybe));
$countmaybe += 0;
if ($countmaybe > 999) {
print $stdout "-- greedy bastard, try +fewer.\n";
return 0;
}
$countmaybe = sprintf("%03i", $countmaybe);
print $stdout "-- background request sent\n" unless ($synch);
$mode = ($mode =~ /^s/) ? 's' : 'd';
print C "${mode}mreset${countmaybe}---------\n";
&sync_semaphore;
return 0;
}
if (s#^/dm \@?([^\s]+)\s+## && length) {
return &common_split_post($_, undef, $1);
}
# follow and leave users
if (m#^/(follow|leave|unfollow) \@?([^\s/]+)$#) {
my $m = $1;
my $u = lc($2);
&foruuser($u, 1,
(($m eq 'follow') ? $followurl : $leaveurl),
(($m eq 'follow') ? 'started' : 'stopped'));
return 0;
}
# follow and leave lists. this is, frankly, pointless; it does
# nothing other than to mark you. otherwise, /liston and /listoff
# actually add lists to your timeline.
if (m#^/(l?follow|l?leave|l?unfollow) \@?([^\s/]*)/([^\s/]+)$#) {
my $m = $1;
my $uname = lc($2);
my $lname = lc($3);
if (!length($uname) || $uname eq $whoami) {
print $stdout &wwrap(
"** you can't mark/unmark yourself as a follower of your own lists!\n");
print $stdout &wwrap(
"** to add/remove your own lists from your timeline, use /liston /listoff\n");
return 0;
}
if ($m !~ /^l/) {
print $stdout &wwrap(
"-- to mark/unmark you as a follower of a list, use /lfollow /lleave\n");
print $stdout &wwrap(
"-- to add/remove your own lists from your timeline, use /liston /listoff\n");
return 0;
}
my $r = &postjson(
($m ne 'lfollow') ? $delfliurl : $crefliurl,
"owner_screen_name=$uname&slug=$lname");
if ($r) {
my $t = ($m eq 'lfollow') ? "" : "un";
print $stdout &wwrap(
"*** ok, you are now ${t}marked as a follower of $uname/${lname}.\n");
my $c = ($t eq 'un') ? "off" : "on";
$t = ($t eq 'un') ? "remove from" : "add to";
print $stdout &wwrap(
"--- to also $t your timeline, use /list${c}\n");
}
return 0;
}
# block and unblock users
if (m#^/(block|unblock) \@?([^\s/]+)$#) {
my $m = $1;
my $u = lc($2);
if ($m eq 'block') {
$answer = lc(&linein(
"-- sure you want to block $u? (only y or Y is affirmative):"));
if ($answer ne 'y') {
print $stdout "-- ok, $u is NOT blocked.\n";
return 0;
}
}
&boruuser($u, 1,
(($m eq 'block') ? $blockurl : $blockdelurl),
(($m eq 'block') ? 'started' : 'stopped'));
return 0;
}
# list support
# /withlist (/withlis, /with, /wl)
if (s#^/(withlist|withlis|withl|with|wl)\s+([^/\s]+)\s+## &&
($lname=lc($2)) && s/\s*$// && length) {
my $comm = '';
my $args = '';
my $dont_return = 0;
if ($anonymous) {
print $stdout "-- no list love for anonymous\n";
return 0;
}
if (/\s+/) {
($comm, $args) = split(/\s+/, $_, 2);
} else {
$comm = $_;
}
my $return;
# this is a Twitter bug -- it will not give you the
# new slug in the returned hash.
my $state = "modified list $lname (WAIT! then /lists to see new slug)";
if ($comm eq 'create') {
my $desc;
($args, $desc) = split(/\s+/, $args, 2)
if ($args =~ /\s+/);
if ($args ne 'public' && $args ne 'private') {
print $stdout
"-- must specify public or private\n";
return 0;
}
$state = "created new list $lname (mode $args)";
$desc = "description=".&url_oauth_sub($desc)."&"
if (length($desc));
$return = &postjson($creliurl,
"${desc}mode=$args&name=$lname");
} elsif ($comm eq 'private' || $comm eq 'public') {
$return = &postjson($modifyliurl,
"mode=$comm&owner_screen_name=${whoami}&slug=${lname}");
} elsif ($comm eq 'desc' || $comm eq 'description') {
if (!length($args)) {
print $stdout "-- $comm needs an argument\n";
return 0;
}
$return = &postjson($modifyliurl,
"description=".&url_oauth_sub($args).
"&owner_screen_name=${whoami}&slug=${lname}");
} elsif ($comm eq 'name') {
if (!length($args)) {
print $stdout "-- $comm needs an argument\n";
return 0;
}
$return = &postjson($modifyliurl,
"name=".&url_oauth_sub($args).
"&owner_screen_name=${whoami}&slug=${lname}");
$state = "RENAMED list $lname (WAIT! then /lists to see new slug)";
} elsif ($comm eq 'add' || $comm eq 'adduser' ||
($comm eq 'delete' && length($args))) {
my $u = ($comm eq 'delete') ? $deluliurl : $adduliurl;
$state = ($comm eq 'delete')
? "user(s) deleted from list $lname"
: "user(s) added to list $lname";
if ($args !~ /,/ || $args =~ /\s+/) {
1 while ($args =~ s/\s+/,/);
}
if ($args =~ /\s*,\s+/ || $args =~ /\s+,\s*/) {
1 while ($args =~ s/\s+//);
}
if (!length($args)) {
print $stdout "-- illegal/missing argument\n";
return 0;
}
print $stdout "--- warning: user list not checked\n";
$return = &postjson($u,
"owner_screen_name=${whoami}".
"&screen_name=".&url_oauth_sub($args).
"&slug=${lname}");
} elsif ($comm eq 'delete' && !length($args)) {
$state = "deleted list $lname";
print $stdout
"-- verify you want to delete list $lname\n";
my $answer = lc(&linein(
"-- sure you want to delete? (only y or Y is affirmative):"));
if ($answer ne 'y') {
print $stdout "-- ok, list is NOT deleted.\n";
return 0;
}
$return = &postjson($delliurl,
"owner_screen_name=${whoami}&slug=${lname}");
if ($return) {
# check and see if this is in our autolists.
# if it is, delete it there too.
my $value = &getvariable('lists');
&setvariable('lists', $value, 1)
if ($value=~s#(^|,)${whoami}/${lname}($|,)##);
}
} elsif ($comm eq 'list') { # synonym for /list
$_ = "/list /$lname";
$dont_return = 1; # and fall through
} else {
print $stdout "*** illegal list operation $comm\n";
}
if ($return) {
print $stdout "*** ok, $state\n";
}
return 0 unless ($dont_return);
}
# /a to show statuses in a list
if (m#^/a(gain)?\s+(\+\d+\s+)?\@?([^\s/]*)/([^\s/]+)#) {
my $uname = lc($3);
if ($anonymous && !length($uname)) {
print $stdout "-- you must specify a username when anonymous.\n";
return 0;
}
my $lname = lc($4);
my $countmaybe = $2;
$countmaybe =~ s/[^\d]//g if (length($countmaybe));
$countmaybe += 0;
$uname ||= $whoami;
my $my_json_ref = &grabjson(
"${statusliurl}?owner_screen_name=${uname}&slug=${lname}",
0, 0, $countmaybe);
&dt_tdisplay($my_json_ref, "again");
return 0;
}
# /lists command: if @, show their lists. if @?../... show that list.
# trivially duplicates /frs and /fos for lists
# also handles /listfos and /listfrs
if (length($whoami) &&
(m#^/list?s?$# || m#^/list?f[ro](llower|iend)?s$#)) {
$_ .= " $whoami";
}
if (m#^/lis(t|ts|t?fos|tfollowers|t?frs|tfriends)?\s+(\+\d+\s+)?(\@?[^\s]+)$#) {
my $mode = $1;
my $countmaybe = $2;
my $uname = lc($3);
my $lname = '';
$mode = ($mode =~ /^t?fo/) ? 'fo' :
($mode =~ /^t?fr/) ? 'fr' :
'';
$uname =~ s/^\@//;
($uname, $lname) = split(m#/#, $uname, 2) if ($uname =~ m#/#);
if ($anonymous && !length($uname) && length($mode)) {
print $stdout "-- you must specify a username when anonymous.\n";
return 0;
}
$uname ||= $whoami;
if (length($lname) && length($mode)) {
print $stdout "-- specify username only\n";
return 0;
}
$countmaybe =~ s/[^\d]//g if (length($countmaybe));
$countmaybe += 0;
$countmaybe ||= 20;
# this is copied from /friends and /followers (q.v.)
my $countper = ($countmaybe < 100) ? $countmaybe : 100;
my $cursor = -1; # initial value
my $nofetch = 0;
my $printed = 0;
my $json_ref = undef;
my @usarray = undef; shift(@usarray); # force underflow
my $furl = (length($lname)) ? ($getliurl."?owner_")
: ($mode eq '') ? ($getlisurl."?")
: ($mode eq 'fo') ? ($getuliurl."?")
: ($getufliurl."?");
$furl .= "screen_name=${uname}";
$furl .= "&slug=${lname}" if (length($lname));
LABIO: while($countmaybe--) {
if(!scalar(@usarray)) {
last LABIO if ($nofetch);
$json_ref = &grabjson(
"${furl}&count=${countper}&cursor=${cursor}");
@usarray = @{ $json_ref->{
((length($lname)) ? 'users' : 'lists')
} };
last LABIO if (!scalar(@usarray));
$cursor = $json_ref->{'next_cursor_str'} ||
$json_ref->{'next_cursor'} || -1;
$nofetch = ($cursor < 1) ? 1 : 0;
}
my $list_ref = shift(@usarray);
if (length($lname)) {
&$userhandle($list_ref);
} else {
# listhandle?
my $list_name =
"\@$list_ref->{'user'}->{'screen_name'}/@{[ &descape($list_ref->{'slug'}) ]}";
my $list_full_name =
(length($list_ref->{'name'})) ?
&descape($list_ref->{'name'})."${OFF} ($list_name)" : $list_name;
my $list_mode =
(lc(&descape($list_ref->{'mode'})) ne 'public') ?
" ${EM}(@{[ ucfirst(&descape($list_ref->{'mode'})) ]})${OFF}" : "";
print $streamout <<"EOF";
${CCprompt}$list_full_name${OFF} (f:$list_ref->{'member_count'}/$list_ref->{'subscriber_count'})$list_mode
EOF
my $desc = &strim(&descape($list_ref->{'description'}));
my $klen = ($wrap || 79) - 9;
$klen = 10 if ($klen < 0);
$desc = substr($desc, 0, $klen)."..."
if (length($desc) > $klen);
print $streamout (' "' . $desc . '"' . "\n")
if (length($desc));
}
$printed++;
}
if (!$printed) {
print $stdout ((length($lname))
? "-- list $uname/$lname does not follow anyone.\n"
: ($mode eq 'fr')
? "-- user $uname doesn't follow any lists.\n"
: ($mode eq 'fo')
? "-- user $uname isn't followed by any lists.\n"
: "-- no lists found for user $uname.\n");
}
return 0;
}
&sync_n_quit if ($_ eq '/end' || $_ eq '/e');
#####
#
# below this point, we are posting
#
#####
if (m#^/me\s#) {
$slash_first = 0; # kludge!
}
if ($slash_first) {
if (!m#^//#) {
print $stdout "*** invalid command\n";
print $stdout "*** to pass as a tweet, type /%%\n";
return 0;
}
s#^/##; # leave the second slash on
}
TWEETPRINT: # fugly! FUGLY!
return &common_split_post($_, $in_reply_to, undef);
}
# this is the common code used by standard updates and by the /dm command.
sub common_split_post {
my $k = shift;
my $in_reply_to = shift;
my $dm_user = shift;
my $dm_lead = (length($dm_user)) ? "/dm $dm_user " : '';
my $ol = "$dm_lead$k";
my (@tweetstack) = &csplit($k, ($autosplit eq 'char' ||
$autosplit eq 'cut') ? 1 : 0);
my $m = shift(@tweetstack);
if (scalar(@tweetstack)) {
$l = "$dm_lead$m";
$history[0] = $l;
if (!$autosplit) {
print $stdout &wwrap(
"*** sorry, too long to send; ".
"truncated to \"$l\" (@{[ length($m) ]} chars)\n");
print $stdout "*** use %% for truncated version, or append to %%.\n";
return 0;
}
print $stdout &wwrap(
"*** over $linelength; autosplitting to \"$l\"\n");
}
# there was an error; stop autosplit, restore original command
if (&updatest($m, 1, $in_reply_to, $dm_user)) {
$history[0] = $ol;
return 0;
}
if (scalar(@tweetstack)) {
$k = shift(@tweetstack);
$l = "$dm_lead$k";
&add_history($l);
print $stdout &wwrap("*** next part is ready: \"$l\"\n");
print $stdout "*** (this will also be automatically split)\n"
if (length($k) > $linelength);
print $stdout
"*** to send this next portion, use %%.\n";
}
return 1;
}
# helper functions for the command line processor.
sub add_history {
my $h = shift;
@history = (($h, @history)[0..&min(scalar(@history), $maxhist)]);
if ($termrl) {
if ($termrl->Features()->{'canSetTopHistory'}) {
$termrl->settophistory($h);
} else {
$termrl->addhistory($h);
}
}
}
sub sub_helper {
my $r = shift;
my $s = shift;
my $g = shift;
my $x;
my $q = 0;
my $proband;
if ($r eq '%') {
$x = -1;
} else {
$x = $r + 0;
}
if (!$x || $x < -(scalar(@history))) {
print $stdout "*** illegal history index\n";
return (0, $_, undef, undef, undef);
}
$proband = $history[-($x + 1)];
if ($s eq '--') {
$q = 1;
} elsif ($s eq '*') {
if ($x != -1 || !length($shadow_history)) {
print $stdout
"*** can only %%* on most recent command\n";
return (0, $_, undef, undef, undef);
}
# we assume it's at the end; it's only relevant there
$proband = substr($shadow_history, length($g)-(2+length($r)));
} else {
$q = -(0+$s);
}
if ($q) {
my $j;
my $c;
for($j=0; $j<$q; $j++) {
$c++ if ($proband =~ s/\s+[^\s]+$//);
}
if ($j != $c) {
print $stdout "*** illegal word index\n";
return (0, $_, undef, undef, undef);
}
}
return (1, $proband, $r, $s);
}
# this is used for synchronicity mode to make sure we receive the
# GA semaphore from the background before printing another prompt.
sub sync_console {
&thump;
&dmthump unless (!$dmpause);
}
sub sync_semaphore {
if ($synch) {
my $k = '';
while(!length($k)) {
sysread(W, $k, 1);
} # wait for semaphore
}
}
# wrapper function to get a line from the terminal.
sub linein {
my $prompt = shift;
my $return;
return 'y' if ($script);
$prompt .= " ";
if ($termrl) {
$dont_use_counter = 1;
eval '$termrl->hook_no_counter';
$return = $termrl->readline($prompt);
$dont_use_counter = $nocounter;
eval '$termrl->hook_no_counter';
} else {
print $stdout $prompt;
chomp($return = lc(<$stdin>));
}
return $return;
}
#### this is the background part of the process ####
MONITOR:
%store_hash = ();
$is_background = 1;
$first_synch = $synchronous_mode = 0;
$rin = '';
vec($rin,fileno(STDIN),1) = 1;
# paranoia
binmode($stdout, ":crlf") if ($termrl);
unless ($seven) {
binmode(STDIN, ":utf8");
binmode($stdout, ":utf8");
}
# allow foreground process to squelch us
# we have to cover all the various versions of 30/31 signals on various
# systems just in case we are on a system without POSIX.pm. this set should
# cover Linux 2.x/3.x, AIX, Mac OS X, *BSD and Solaris. we have to assert
# these signals before starting streaming, or we may "kill" ourselves by
# accident because it is possible to process a tweet before these are
# operational.
&sigify(sub {
$suspend_output ^= 1 if ($suspend_output != -1);
$we_got_signal = 1;
}, qw(USR1 PWR XCPU));
&sigify( sub {
$suspend_output = -1; $we_got_signal = 1;
}, qw(USR2 SYS UNUSED XFSZ));
&sigify("IGNORE", qw(INT)); # don't let slowpost kill us
# now we can safely initialize streaming
if ($dostream) {
@events = ();
$lasteventtime = time();
&sigify(sub {
print $stdout "-- killing processes $nursepid $bufferpid\n"
if ($verbose);
kill $SIGHUP, $nursepid if ($nursepid);
kill $SIGHUP, $bufferpid if ($bufferpid);
kill 9, $curlpid if ($curlpid);
sleep 1;
# send myself a shutdown
kill 9, $nursepid if ($nursepid);
kill 9, $bufferpid if ($bufferpid);
kill $SIGTERM, $$;
}, qw(HUP)); # use SIGHUP etc. from parent process to signal end
$bufferpid = &start_streaming;
vec($rin, fileno(STBUF), 1) = 1;
} else {
&sigify("IGNORE", qw(HUP)); # we only respond to SIGKILL/SIGTERM
}
$interactive = $previous_last_id = $we_got_signal = 0;
$suspend_output = -1;
$stream_failure = 0;
$dm_first_time = ($dmpause) ? 1 : 0;
# tell the foreground we are ready
kill $SIGUSR2, $parent;
# loop until we are killed or told to stop.
# we receive instructions on stdin, and send data back on our pipe().
for(;;) {
&$heartbeat;
&update_effpause;
$wrapseq = 0; # remember, we don't know when commands are sent.
&refresh($interactive, $previous_last_id) unless
(!$effpause && !$interactive);
$dont_refresh_first_time = 0;
$previous_last_id = $last_id;
if ($dmpause && ($effpause || $synch)) {
if ($dm_first_time) {
&dmrefresh(0);
$dmcount = $dmpause;
} elsif (!$interactive) {
if (!--$dmcount) {
&dmrefresh($interactive); # using dm_first_time
$dmcount = $dmpause;
}
}
}
DONT_REFRESH:
# nrvs is tricky with synchronicity
if (!$synch || ($synch && $synchronous_mode && !$dm_first_time)) {
$k = length($notify_rate) + length($vs) + length($credlog);
if ($k) {
&send_removereadline if ($termrl);
print $stdout $notify_rate;
print $stdout $vs;
print $stdout $credlog;
$wrapseq = 1;
}
$notify_rate = "";
$vs = "";
$credlog = "";
}
print P "0" if ($synchronous_mode && $interactive);
&send_repaint if ($termrl);
# this core loop is tricky. most signals will not restart the call.
# -- respond to alarms if we are ignoring our timeout.
# -- do not respond to bogus packets if a signal handler triggered it.
# -- clear our flag when we detect a signal handler has been called.
# if our master select is interrupted, we must restart with the
# appropriate time taken from effpause. however, most implementations
# don't report timeleft, so we must.
$restarttime = time() + $effpause;
RESTART_SELECT:
&send_repaint if ($termrl);
$interactive = 0;
$we_got_signal = 0; # acknowledge all signals
if ($effpause == undef) { # -script and anonymous have no effpause.
print $stdout "-- select() loops forever\n" if ($verbose);
$nfound = select($rout = $rin, undef, undef, undef);
} else {
$actualtime = $restarttime - time();
print $stdout "-- select pending ($actualtime sec left)\n"
if ($superverbose);
if ($actualtime <= 0) {
$nfound = 0;
} else {
$nfound = select(
$rout = $rin, undef, undef, $actualtime);
}
}
if ($nfound > 0) {
my $len;
# service the streaming socket first, if we have one.
if ($dostream) {
if (vec($rout, fileno(STBUF), 1) == 1) {
my $json_ref;
my $buf = '';
my $rbuf;
my $reads = 0;
print $stdout "-- data on streaming socket\n"
if ($superverbose);
# read until we get eight hex digits. this forces the
# data stream to synchronize.
# first, however, make sure we actually have valid
# data, or we sit here and slow down the user.
sysread(STBUF, $buf, 1);
if (!length($buf)) {
# if we get a "ready" but there's actually
# no data, that means either 1) a signal
# occurred on the buffer, which we need to
# ignore, or 2) something killed the
# buffer, which is unrecoverable. if we keep
# getting repeated ready-no data situations,
# it's probably the latter.
$stream_failure++;
&screech(<<"EOF") if ($stream_failure > 100);
*** fatal error ***
something killed the streaming buffer process. I can't recover from this.
please restart TTYtter.
EOF
goto DONESTREAM;
}
$stream_failure = 0;
if ($buf !~ /^[0-9a-fA-F]+$/) {
print $stdout
"-- warning: bogus character(s) ".unpack("H*", $buf)."\n"
if ($superverbose);
goto DONESTREAM;
}
while (length($buf) < 8) {
# don't read 8 -- read 1. that means we can
# skip trailing garbage without a window.
sysread(STBUF, $rbuf, 1);
$reads++;
if ($rbuf =~ /[0-9a-fA-F]/) {
$buf .= $rbuf;
$reads = 0;
} else {
print $stdout
"-- warning: bogus character(s) ".unpack("H*", $rbuf)."\n"
if ($superverbose);
$buf = ''
if (length($rbuf)); # bogus data
}
print $stdout
"-- master, I am stuck: $reads reads on stream and no valid data\n"
if ($reads > 0 && ($reads % 1000) == 0);
}
print $stdout "-- length packet: $buf\n"
if ($superverbose);
$len = hex($buf);
$buf = '';
while (length($buf) < $len) {
sysread(STBUF, $rbuf, ($len-length($buf)));
$buf .= $rbuf;
}
print $stdout
"-- streaming data ($len) --\n$buf\n-- streaming data --\n\n"
if ($superverbose);
$json_ref = &parsejson($buf);
push(@events, $json_ref);
if (scalar(@events) > $eventbuf || (scalar(@events) &&
(time()-$lasteventtime) > $effpause)){
sleep 5 while ($suspend_output > 0);
&streamevents(@events);
&send_repaint if ($termrl);
@events = ();
$lasteventtime = time();
}
}
DONESTREAM: print $stdout "-- done with streaming events\n"
if ($superverbose);
}
# then, check if there is data on our control socket.
# command packets should always be (initially) 20 characters.
# if we come up short, it's either a bug, signal or timeout.
if ($we_got_signal) {
goto RESTART_SELECT;
}
goto RESTART_SELECT if(vec($rout, fileno(STDIN), 1) != 1);
print $stdout "-- waiting for data ", scalar localtime, "\n"
if ($superverbose);
goto RESTART_SELECT if(sysread(STDIN, $rout, 20) != 20);
# background communications central command code
# we received a command from the console, so let's look at it.
print $stdout "-- command received ", scalar
localtime, " $rout" if ($verbose);
if ($rout =~ /^rsga/) {
$suspend_output = 0; # reset our status
goto RESTART_SELECT;
} elsif ($rout =~ /^pipet (..)/) {
my $key = &get_tweet($1);
my $ms = $key->{'menu_select'} || 'XX';
my $ds = $key->{'created_at'} || 'argh, no created_at';
$ds =~ s/\s/_/g;
my $src = $key->{'source'} || 'unknown';
$src =~ s/\|//g; # shouldn't be any anyway.
$key = substr(( "$ms ".($key->{'id_str'})." ".
($key->{'in_reply_to_status_id_str'})." ".
($key->{'retweeted_status'}->{'id_str'})." ".
($key->{'user'}->{'geo_enabled'} || "false") . " ".
($key->{'geo'}->{'coordinates'}->[0]). " ".
($key->{'geo'}->{'coordinates'}->[1]). " ".
$key->{'tag'}->{'type'}. " ". # NO SPACES!
unpack("${pack_magic}H*", $key->{'tag'}->{'payload'}). " ".
($key->{'retweet_count'} || "0") . " " .
$key->{'user'}->{'screen_name'}." $ds $src|".
unpack("${pack_magic}H*", $key->{'text'}).
$space_pad), 0, 1024);
print P $key;
goto RESTART_SELECT;
} elsif ($rout =~ /^piped (..)/) {
my $key = $dm_store_hash{$1};
my $ms = $key->{'menu_select'} || 'XX';
my $ds = $key->{'created_at'} || 'argh, no created_at';
$ds =~ s/\s/_/g;
$key = substr(( "$ms ".($key->{'id_str'})." ".
$key->{'sender'}->{'screen_name'}." $ds ".
unpack("${pack_magic}H*", $key->{'text'}).
$space_pad), 0, 1024);
print P $key;
goto RESTART_SELECT;
} elsif ($rout =~ /^ki ([^\s]+) /) {
my $key = $1;
my $module;
sysread(STDIN, $module, 1024);
$module =~ s/\s+$//;
$module = pack("H*", $module);
print $stdout "-- fetch for module $module key $key\n"
if ($verbose);
print P substr(unpack("${pack_magic}H*",
$master_store->{$module}->{$key}).$space_pad,
0, 1024);
goto RESTART_SELECT;
} elsif ($rout =~ /^kn ([^\s]+) /) {
my $key = $1;
my $module;
sysread(STDIN, $module, 1024);
$module =~ s/\s+$//;
$module = pack("H*", $module);
print $stdout "-- nulled module $module key $key\n"
if ($verbose);
$master_store->{$module}->{$key} = undef;
goto RESTART_SELECT;
} elsif ($rout =~ /^ko ([^\s]+) /) {
my $key = $1;
my $value;
my $module;
sysread(STDIN, $module, 1024);
$module =~ s/\s+$//;
$module = pack("H*", $module);
sysread(STDIN, $value, 1024);
$value =~ s/\s+$//;
print $stdout
"-- set module $module key $key = $value\n"
if ($verbose);
$master_store->{$module}->{$key} = pack("H*", $value);
goto RESTART_SELECT;
} elsif ($rout =~ /^sync/) {
print $stdout "-- synced; exiting at ",
scalar localtime, "\n"
if ($verbose);
exit $laststatus;
} elsif ($rout =~ /^synm/) {
$first_synch = $synchronous_mode = 1;
print $stdout "-- background is now synchronous\n"
if ($verbose);
} elsif ($rout =~ /([\=\?\+])([^ ]+)/) {
$comm = $1;
$key =$2;
if ($comm eq '?') {
print P substr("${$key}$space_pad", 0, 1024);
} else {
sysread(STDIN, $value, 1024);
$value =~ s/\s+$//;
$interactive = ($comm eq '+') ? 0 : 1;
if ($key eq 'tquery') {
print $stdout
"*** custom query installed\n"
if ($interactive || $verbose);
print $stdout
"$value" if ($verbose);
@trackstrings = ();
# already URL encoded
push(@trackstrings, $value);
} else {
$$key = $value;
print $stdout
"*** changed: $key => $$key\n"
if ($interactive || $verbose);
&generate_ansi if ($key eq 'ansi' ||
$key =~ /^colour/);
$rate_limit_next = 0
if ($key eq 'pause' &&
$value eq 'auto');
&tracktags_makearray
if ($key eq 'track');
&filter_compile
if ($key eq 'filter');
¬ify_compile
if ($key eq 'notifies');
&list_compile
if ($key eq 'lists');
}
}
goto RESTART_SELECT;
} else {
$interactive = 1;
($fetchwanted = 0+$1, $fetch_id = 0, $last_id = 0)
if ($rout =~ /^reset(\d+)/);
($dmfetchwanted = 0+$1, $last_dm = 0)
if ($rout =~ /^dmreset(\d+)/);
if ($rout =~ /^smreset/) { # /dmsent
$dmfetchwanted = 0+$1
if ($rout =~ /(\d+)/);
&dmrefresh(1, 1);
&send_repaint if ($termrl);
# we do not want to force a refresh.
goto DONT_REFRESH;
}
if ($rout =~ /^dm/) {
&dmrefresh($interactive);
&send_repaint if ($termrl);
$dmcount = $dmpause;
goto DONT_REFRESH;
}
}
} else {
if ($we_got_signal || $nfound == -1) {
# we need to restart the call. we might be waiting
# longer, but this is unavoidable.
goto RESTART_SELECT;
}
print $stdout
"-- routine refresh (effpause = $effpause, $dmcount to next dm) ",
scalar localtime, "\n" if ($verbose);
}
}
#### internal implementation functions for the twitter API. DON'T ALTER ####
# manage automatic rate limiting by checking our max.
#TODO
# autoslowdown as we run out of requests, then speed up when hour
# has passed.
sub update_effpause {
return ($effpause = undef) if ($script); # for select()
if ($pause ne 'auto' && $noratelimit) {
$effpause = (0+$pause) || undef;
return;
}
$effpause = (0+$pause) || undef
if ($anonymous || (!$pause && $pause ne 'auto'));
if (!$rate_limit_next && !$anonymous && ($pause > 0 ||
$pause eq 'auto')) {
# {'reset_time_in_seconds':1218948315,'remaining_hits':98,'reset_time':'Sun Aug 17 04:45:15 +0000 2008','hourly_limit':100}
$rate_limit_next = 5;
$rate_limit_ref = &grabjson($rlurl, 0);
if (defined $rate_limit_ref &&
ref($rate_limit_ref) eq 'HASH') {
$rate_limit_left =
$rate_limit_ref->{'remaining_hits'}+0;
$rate_limit_rate =
$rate_limit_ref->{'hourly_limit'}+0;
if ($rate_limit_left < 10 && $rate_limit_rate) {
$estring =
"*** warning: $rate_limit_left API requests remain";
if ($pause eq 'auto') {
$estring .=
"; temporarily halting autofetch";
$effpause = 0;
}
&$exception(5, "$estring\n");
} else {
if ($pause eq 'auto') {
# this is computed to give you approximately 50% over the limit for client
# requests
# first, how many requests do we want to make an hour? $dmpause in a sec
$effpause =
$rate_limit_rate - ($rate_limit_rate * 0.5);
# second, take requests away for $dmpause (e.g., 4:1 means reduce by 25%)
$effpause -=
((1/$dmpause) * $effpause) if ($dmpause);
# third, divide by two (1:1) if replies "mention" streamix is on
$effpause = int($effpause/2)
if ($mentions);
# take 1 request away for each subscription in @listlist (i.e., each one,
# cut effpause in half again). if this gets us below zero, warn here.
if (scalar(@listlist)) {
$effpause = int($effpause/(2**scalar(@listlist)));
if (!$effpause) {
print $stdout "** WARNING: YOU ARE FOLLOWING TOO MANY LISTS SIMULTANEOUSLY!\n";
print $stdout "** automatic rate limit control cannot manage this many lists\n";
print $stdout "** to disable this message, use a fixed number with -pause\n";
print $stdout "** or use /lists or /listoff to reduce the number of lists\n";
# and fall through to the fallback ha ha ha
}
}
# finally determine how many seconds should elapse
print $stdout
"-- effective pause time zero?!, using fallback 180sec\n"
if (!$effpause && $verbose);
$effpause =
($effpause) ? int(3600/$effpause) : 180;
# we don't go under sixty.
$effpause = 60
if ($effpause < 60);
} else {
$effpause = 0+$pause;
}
}
print $stdout
"-- rate limit check: $rate_limit_left/$rate_limit_rate (rate is $effpause sec)\n"
if ($verbose);
$adverb = (!$last_rate_limit) ? ' currently' :
($last_rate_limit < $rate_limit_rate) ? ' INCREASED to':
($last_rate_limit > $rate_limit_rate) ? ' REDUCED to':
'';
$notify_rate =
"-- notification: API rate limit is${adverb} ${rate_limit_rate} req/hr\n"
if ($last_rate_limit != $rate_limit_rate);
$last_rate_limit = $rate_limit_rate;
} else {
$rate_limit_next = 0;
$effpause = ($pause eq 'auto') ? 120 : 0+$pause;
print $stdout
"-- failed to fetch rate limit (rate is $effpause sec)\n"
if ($verbose);
}
} else {
$rate_limit_next-- unless ($anonymous);
}
}
# streaming API support routines
### INITIALIZE STREAMING
### spin off a nurse process to proxy data from curl, and a buffer process
### to protect the background process from signals curl may generate.
sub start_streaming {
$bufferpid = 0;
unless ($streamtest) {
if($bufferpid = open(STBUF, "-|")) {
# streaming processes initialized
return $bufferpid;
}
}
# now within buffer process
# verbosity does not work here, so force both off.
$verbose = 0;
$superverbose = 0;
$0 = "TTYtter (streaming buffer thread)";
$in_buffer = 1;
# set up signal handlers
$streampid = 0;
&sigify(sub {
# in an earlier version we wrote a disconnect packet to the
# pipe in this handler. THIS IS NOT SAFE on certain OS/Perl
# combinations. I moved this down to the HELLOAGAINNURSE loop,
# or otherwise you get random seg faults.
$i = $streampid;
$streampid = 0;
waitpid $i, 0 if ($i);
}, qw(CHLD PIPE));
&sigify(sub {
$i = $streampid;
$streampid = 0; # suppress handler above
kill ($SIGHUP, $i) if ($i);
waitpid $i, 0 if ($i);
kill 9, $curlpid if ($curlpid && !$i);
kill 9, $$;
}, qw(HUP TERM));
&sigify("IGNORE", qw(INT));
$packets_read = 0; # part of exponential backoff
$wait_time = 0;
# open the nurse process
HELLOAGAINNURSE: $w = "{\"packet\" : \"connect\", \"payload\" : {} }";
select(STDOUT); $|++;
printf STDOUT ("%08x%s", length($w), $w);
close(NURSE);
if (!$packets_read) { $wait_time += (($wait_time) ? $wait_time : 1) }
else { $wait_time = 0; }
$packets_read = 0;
$wait_time = ($wait_time > 60) ? 60 : $wait_time;
if ($streampid = open(NURSE, "-|")) {
# within the buffer process
select(NURSE); $|++; select(STDOUT);
my $rin = '';
vec($rin,fileno(NURSE),1) = 1;
my $datasize = 0;
my $buf = '';
my $cuf = '';
my $duf = '';
# read the curlpid from the stream
read(NURSE, $curlpax, 8);
$curlpid = hex($curlpax);
# if we are testing the socket, just emit data.
if ($streamtest) {
my $c;
for(;;) {
sysread(NURSE, $c, 1);
print STDOUT $c;
}
}
HELLONURSE: while(1) {
# restart nurse process if it/curl died
goto HELLOAGAINNURSE if(!$streampid);
# read a line of text (hopefully numbers)
chomp($buf = <NURSE>);
# should be nothing but digits and whitespace.
# if anything else, we're getting garbage, and we
# should reconnect.
if ($buf =~ /[^0-9\r\l\n\s]+/s) {
close(NURSE);
kill 9, $streampid if ($streampid);
# and SIGCHLD will reap
kill 9, $curlpid if ($curlpid);
goto HELLOAGAINNURSE;
}
$datasize = 0+$buf;
next HELLONURSE if (!$datasize);
$datasize--;
read(NURSE, $duf, $datasize);
# don't send broken entries
next HELLONURSE if (length($duf) < $datasize);
# yank out all \r\n
1 while $duf =~ s/[\r\n]//g;
$duf = "{ \"packet\" : \"data\", \"pid\" : \"$streampid\", \"curlpid\" : \"$curlpid\", \"payload\" : $duf }";
printf STDOUT ("%08x%s", length($duf), $duf);
$packets_read++;
}
} else {
# within the nurse process
$0 = "TTYtter (waiting $wait_time sec to connect to stream)";
sleep $wait_time;
$curlpid = 0;
$replarg = ($streamallreplies) ? '&replies=all' : '';
&sigify(sub {
kill 9, $curlpid if ($curlpid);
waitpid $curlpid, 0 unless (!$curlpid);
$curlpid = 0;
kill 9, $$;
}, qw(CHLD PIPE));
&sigify(sub {
kill 9, $curlpid if ($curlpid);
}, qw(INT HUP TERM)); # which will cascade into SIGCHLD
($comm, $args, $data) = &$stringify_args($baseagent,
[ $streamurl, "delimited=length${replarg}" ],
undef, undef,
'-s',
'-A', "TTYtter_Streaming/$TTYtter_VERSION",
'-N',
'-H', 'Expect:');
($curlpid = open(K, "|$comm")) || die("failed curl: $!\n");
printf STDOUT ("%08x", $curlpid);
# "DIE QUICKLY"
$0 = "TTYtter (streaming socket nurse thread to ${curlpid})";
select(K); $|++; select(STDOUT); $|++;
print K "$args\n";
close(K);
waitpid $curlpid, 0;
$curlpid = 0;
kill 9, $$;
}
}
# handle a set of events acquired from the streaming socket.
# ordinarily only the background is calling this.
sub streamevents {
my (@events) = (@_);
my $w;
my @x;
my %k; # need temporary dedupe
foreach $w (@events) {
my $tmp;
# don't send non-data events (yet).
next if ($w->{'packet'} ne 'data');
# try to get PID information if available for faster shutdown
$nnursepid = 0+($w->{'pid'});
if ($nnursepid != $nursepid) {
$nursepid = $nnursepid;
print $stdout
"-- got new pid of streaming nurse socket process: $nursepid\n"
if ($verbose);
}
$ncurlpid = 0+($w->{'curlpid'});
if ($ncurlpid != $curlpid) {
$curlpid = $ncurlpid;
print $stdout
"-- got new pid of streaming curl process: $ncurlpid\n"
if ($verbose);
}
# we don't use this (yet).
next if ($w->{'payload'}->{'friends'});
sleep 5 while ($suspend_output > 0);
# dispatch tweets
if ($w->{'payload'}->{'text'} && !$notimeline) {
# normalize the tweet first.
my $payload = &normalizejson($w->{'payload'});
my $sid = $payload->{'id_str'};
$payload->{'tag'}->{'type'} = 'timeline';
$payload->{'tag'}->{'payload'} = 'stream';
# filter replies from streaming socket if the
# user requested it. use $tweettype to determine
# this so the user can interpose custom logic.
if ($nostreamreplies) {
my $sn = &descape(
$payload->{'user'}->{'screen_name'});
my $text = &descape($payload->{'text'});
next if (&$tweettype($payload, $sn, $text) eq
'reply');
}
# finally, filter everything else and dedupe.
unless (length($id_cache{$sid}) ||
$filter_next{$sid} ||
$k{$sid}) {
&tdisplay([ $payload ]);
$k{$sid}++;
}
# roll *_id so that we don't do unnecessary work
# testing the API. don't roll fetch_id, search uses
# it. don't roll if last_id was zero, because that
# means we are streaming *before* the API backfetch.
$last_id = $sid unless (!$last_id);
}
# dispatch DMs
elsif (($tmp = $w->{'payload'}->{'direct_message'}) &&
$dmpause) {
&dmrefresh(0, 0, [ $tmp ]);
# don't roll last_dm yet.
}
# must be an event. see if standardevent can make sense of it.
elsif (!$notimeline) {
&send_removereadline if ($termrl);
&$eventhandle($w->{'payload'});
$wrapseq = 1;
&send_repaint if ($termrl);
}
}
}
# REST API support
#
# thump for timeline
# THIS MUST ONLY BE RUN BY THE BACKGROUND.
sub refresh {
my $interactive = shift;
my $relative_last_id = shift;
my $k;
my $my_json_ref = undef;
my $i;
my @streams = ();
my $dont_roll_back_too_far = 0;
# this mixes all the tweet streams (timeline, hashtags, replies
# and lists) into a single unified data river.
# backload can be zero, but this will still work since &grabjson
# sees a count of zero as "default."
# first, get my own timeline
# note that anonymous has no timeline (but they can sample the
# stream)
unless ($notimeline || $anonymous) {
# in streaming mode, use $last_id
# in API mode, use $fetch_id
my $base_json_ref = &grabjson($url,
($dostream) ? $last_id : $fetch_id,
0,
(($last_id) ? 250 : $fetchwanted || $backload), {
"type" => "timeline",
"payload" => "api"
});
# if I can't get my own timeline, ABORT! highest priority!
return if (!defined($base_json_ref) ||
ref($base_json_ref) ne 'ARRAY');
# we have to filter against the ID cache right now, because
# we might not have any other streams!
if ($fetch_id && $last_id) {
$my_json_ref = [];
my $l;
my %k; # need temporary dedupe
foreach $l (@{ $base_json_ref }) {
unless (length($id_cache{$l->{'id_str'}}) ||
$filter_next{$l->{'id_str'}} ||
$k{$l->{'id_str'}}) {
push(@{ $my_json_ref }, $l);
$k{$l->{'id_str'}}++;
}
}
} else {
$my_json_ref = $base_json_ref;
}
}
# add stream for replies, if requested
if ($mentions) {
# same thing
my $r = &grabjson($rurl,
($dostream && !$nostreamreplies) ? $last_id : $fetch_id,
0,
(($last_id) ? 250
: $fetchwanted || $backload), {
"type" => "reply",
"payload" => ""
});
push(@streams, $r)
if (defined($r) &&
ref($r) eq 'ARRAY' &&
scalar(@{ $r }));
}
# next handle hashtags and tracktags
# failure here does not abort, because search may be down independently
# of the main timeline.
if (!$notrack && scalar(@trackstrings)) {
my $r;
my $k;
my $l;
if (!$last_id) {
$l = &min($backload, $searchhits);
} else {
$l = (($fetchwanted) ? $fetchwanted :
&max(100, $searchhits));
}
# temporarily squelch server complaints (see below)
$muffle_server_messages = 1 unless ($verbose);
foreach $k (@trackstrings) {
# use fetch_id here in both modes.
$r = &grabjson("$queryurl?${k}&rpp=${l}&result_type=recent",
$fetch_id, 1, 0, {
"type" => "search",
"payload" => $k
});
# depending on the state of the search API, we might be using
# a bogus search ID that is too far back. so if this fails,
# try again with last_id, but not if we're streaming (it
# will always fetch zero).
if (!defined($r) || ref($r) ne 'ARRAY' || !$dostream) {
print $stdout "-- search retry $k attempted with last_id\n"
if ($verbose);
$r = &grabjson("$queryurl?${k}&rpp=${l}&result_type=recent",
$last_id, 1, 0, {
"type" => "search",
"payload" => $k
});
$dont_roll_back_too_far = 1;
}
# or maybe not even then?
if (!defined($r) || ref($r) ne 'ARRAY') {
print $stdout "-- search retry $k attempted with zero!\n"
if ($verbose);
$r = &grabjson("$queryurl?${k}&rpp=${l}&result_type=recent",
0, 1, 0, {
"type" => "search",
"payload" => $k
});
$dont_roll_back_too_far = 1;
}
push(@streams, $r)
if (defined($r) &&
ref($r) eq 'ARRAY' &&
scalar(@{ $r }));
}
$muffle_server_messages = 0;
}
# add stream for lists we have on with /set lists, and tag it with
# the list.
if (scalar(@listlist)) {
foreach $k (@listlist) {
# always use fetch_id
my $r = &grabjson(
"${statusliurl}?owner_screen_name=".$k->[0].'&slug='.$k->[1],
$fetch_id, 0,
(($last_id) ? 250 : $fetchwanted), {
"type" => "list",
"payload" => ($k->[0] ne $whoami) ?
"$k->[0]/$k->[1]" :
"$k->[1]"
});
push(@streams, $r)
if (defined($r) && ref($r) eq 'ARRAY' &&
scalar(@{ $r }));
}
}
$fetchwanted = 0; # done with that.
# now, streamix all the streams into my_json_ref, discarding duplicates
# a simple hash lookup is no good; it has to be iterative. because of
# that, we might as well just splice it in here and save a sort later.
# the streammix logic is unnecessarily complex, probably.
# remember, the most recent tweets are FIRST.
if (scalar(@streams)) {
my $j;
my $k;
my $l = scalar(@{ $my_json_ref });
my $m;
my $n;
foreach $n (@streams) {
SMIX0: foreach $j (@{ $n }) {
my $id = $j->{'id_str'}; # for ease of use
# possible to happen if search tryhard is on
next SMIX0 if ($id < $fetch_id);
# filter this lot against the id cache
# and any tweets we just filtered.
next SMIX0 if (length($id_cache{$id}) &&
$fetch_id);
next SMIX0 if ($filter_next{$id} &&
$fetch_id);
if (!$l) { # degenerate case
push (@{ $my_json_ref }, $j);
$l++;
next SMIX0;
}
# find the same ID, or one just before,
# and splice in
$m = -1;
SMIX1: for($i=0; $i<$l; $i++) {
next SMIX0 # it's a duplicate
if($my_json_ref->[$i]->{'id_str'} == $id);
if($my_json_ref->[$i]->{'id_str'} < $id) {
$m = $i;
last SMIX1; # got it
}
}
if ($m == -1) { # didn't find
push (@{ $my_json_ref }, $j);
} elsif ($m == 0) { # degenerate case
unshift (@{ $my_json_ref }, $j);
} else { # did find, so splice
splice(@{ $my_json_ref }, $m, 0,
$j);
}
$l++;
}
}
}
%filter_next = ();
# fetch_id gyration. initially start with last_id, then roll. we
# want to keep a window, though, so we try to pick a sensible value
# that doesn't fetch too much but includes some overlap. we can't
# do computations on the ID itself, because it's "opaque."
$fetch_id = 0 if ($last_id == 0);
&send_removereadline if ($termrl);
if ($dont_refresh_first_time) {
$last_id = &max($my_json_ref->[0]->{'id_str'}, $last_id);
} else {
($last_id, $crap) =
&tdisplay($my_json_ref, undef, $relative_last_id);
}
my $new_fi = (scalar(@{ $my_json_ref })) ?
$my_json_ref->[(scalar(@{ $my_json_ref })-1)]->{'id_str'} :
'';
# try to widen the window to a "reasonable amount"
$fetch_id = ($fetch_id == 0) ? $last_id :
(length($new_fi) && $new_fi ne $last_id
&& $new_fi > $fetch_id) ? $new_fi :
($relative_last_id > 0 && $relative_last_id ne $last_id &&
$relative_last_id > $fetch_id) ?
$relative_last_id : $fetch_id;
print $stdout
"-- last_id $last_id, fetch_id $fetch_id, rollback $relative_last_id\n".
"-- (@{[ scalar(keys %id_cache) ]} cached)\n"
if ($verbose);
&send_removereadline if ($termrl);
&$conclude;
$wrapseq = 1;
&send_repaint if ($termrl);
}
# handle (i.e., display) an array of tweets in standard format
sub tdisplay { # used by both synchronous /again and asynchronous refreshes
my $my_json_ref = shift;
my $class = shift;
my $relative_last_id = shift;
my $mini_id = shift;
my $printed = 0;
my $disp_max = &min($print_max, scalar(@{ $my_json_ref }));
my $save_counter = -1;
my $i;
my $j;
if ($disp_max) { # null list may be valid if we get code 304
unless ($is_background) { # reset store hash each console
if ($mini_id) {
#TODO
# generalize this at some point instead of hardcoded menu codes
# maybe an ma0-mz9?
$save_counter = $tweet_counter;
$tweet_counter = $mini_split;
for(0..9) {
undef $store_hash{"zz$_"};
}
}# else {
# $tweet_counter = $back_split;
# %store_hash = ();
#}
}
for($i = $disp_max; $i > 0; $i--) {
my $g = ($i-1);
$j = $my_json_ref->[$g];
my $id = $j->{'id_str'};
next if (!length($j->{'user'}->{'screen_name'}));
if ($filter_c && &$filter_c(&descape($j->{'text'}))) {
$filtered++;
$filter_next{$j->{'id_str'}}++
if ($is_background);
next;
}
# assign menu codes and place into caches
$key = (($is_background) ? '' : 'z' ).
substr($alphabet, $tweet_counter/10, 1) .
$tweet_counter % 10;
$tweet_counter =
($tweet_counter == 259) ? $mini_split :
($tweet_counter == ($mini_split - 1))
? 0 : ($tweet_counter+1);
$j->{'menu_select'} = $key;
$key = lc($key);
# recover ID cache memory: find the old ID with this
# menu code and remove it, then add the new one
# except if this is the foreground. we don't use this
# in the foreground.
if ($is_background) {
delete $id_cache{$store_hash{$key}->{'id_str'}};
$id_cache{$id} = $key;
}
# finally store in menu code cache
$store_hash{$key} = $j;
sleep 5 while ($suspend_output > 0);
&send_removereadline if ($termrl);
$wrapseq++;
$printed += scalar(&$handle($j,
($class || (($id <= $relative_last_id) ? 'again' :
undef))));
}
}
$tweet_counter = $save_counter if ($save_counter > -1);
sleep 5 while ($suspend_output > 0);
&$exception(6,"*** warning: more tweets than menu codes; truncated\n")
if (scalar(@{ $my_json_ref }) > $print_max);
if (($interactive || $verbose) && !$printed) {
&send_removereadline if ($termrl);
print $stdout "-- sorry, nothing to display.\n";
$wrapseq = 1;
}
return (&max($my_json_ref->[0]->{'id_str'}, $last_id), $j);
}
sub dt_tdisplay {
my $my_json_ref = shift;
my $class = shift;
if (defined($my_json_ref)
&& ref($my_json_ref) eq 'ARRAY'
&& scalar(@{ $my_json_ref })) {
my ($crap, $art) = &tdisplay($my_json_ref, $class);
unless ($timestamp) {
my ($time, $ts1) = &$wraptime(
$my_json_ref->[(&min($print_max,scalar(@{ $my_json_ref }))-1)]->{'created_at'});
my ($time, $ts2) = &$wraptime($art->{'created_at'});
print $stdout &wwrap(
"-- update covers $ts1 thru $ts2\n");
}
&$conclude;
}
}
# thump for DMs
sub dmrefresh {
my $interactive = shift;
my $sent_dm = shift;
# for streaming API to inject DMs it receives
my $my_json_ref = shift;
if ($anonymous) {
print $stdout
"-- sorry, you can't read DMs if you're anonymous.\n"
if ($interactive);
return;
}
# no point in doing this if we can't even get to our own timeline
# (unless user specifically requested it, or our timeline is off)
return if (!$interactive && !$last_id && !$notimeline); # NOT last_dm
$my_json_ref = &grabjson((($sent_dm) ? $dmsenturl : $dmurl),
(($sent_dm) ? 0 : $last_dm), 0, $dmfetchwanted)
if (!defined($my_json_ref) ||
ref($my_json_ref) ne 'ARRAY');
return if (!defined($my_json_ref)
|| ref($my_json_ref) ne 'ARRAY');
my $orig_last_dm = $last_dm;
$last_dm = 0 if ($sent_dm);
$dmfetchwanted = 0;
my $printed = 0;
my $max = 0;
my $disp_max = &min($print_max, scalar(@{ $my_json_ref }));
my $i;
my $g;
my $key;
if ($disp_max) { # an empty list can be valid
if ($dm_first_time) {
sleep 5 while ($suspend_output > 0);
&send_removereadline if ($termrl);
print $stdout
"-- checking for most recent direct messages:\n";
$disp_max = 2;
$interactive = 1;
}
for($i = $disp_max; $i > 0; $i--) {
$g = ($i-1);
my $j = $my_json_ref->[$g];
next if (!$sent_dm && $j->{'id_str'} <= $last_dm);
next if (!length($j->{'sender'}->{'screen_name'}) ||
!length($j->{'recipient'}->{'screen_name'}));
$key = substr($alphabet, $dm_counter/10, 1) .
$dm_counter % 10;
$dm_counter =
($dm_counter == 259) ? 0 :
($dm_counter+1);
$j->{'menu_select'} = $key;
$dm_store_hash{lc($key)} = $j;
sleep 5 while ($suspend_output > 0);
&send_removereadline if ($termrl);
$wrapseq++;
$printed += scalar(&$dmhandle($j));
}
$max = $my_json_ref->[0]->{'id_str'};
}
sleep 5 while ($suspend_output > 0);
if (($interactive || $verbose) && !$printed && !$dm_first_time) {
&send_removereadline if ($termrl);
print $stdout (($sent_dm)
? "-- you haven't sent anything yet.\n"
: "-- sorry, no new direct messages.\n");
$wrapseq = 1;
}
$last_dm = ($sent_dm) ? $orig_last_dm
: &max($last_dm, $max);
$dm_first_time = 0 if ($last_dm || !scalar(@{ $my_json_ref }));
print $stdout "-- dm bookmark is $last_dm.\n" if ($verbose);
&$dmconclude;
&send_repaint if ($termrl);
}
# post an update
# this is a general API function that handles status updates and sending DMs.
sub updatest {
my $string = shift;
my $interactive = shift;
my $in_reply_to = shift;
my $user_name_dm = shift;
my $rt_id = shift; # even if this is set, string should also be set.
my $urle = '';
my $i;
my $subpid;
my $istring;
my $verb = (length($user_name_dm)) ? "DM $user_name_dm" :
($rt_id) ? 'RE-tweet' :
'tweet';
if ($anonymous) {
print $stdout
"-- sorry, you can't $verb if you're anonymous.\n"
if ($interactive);
return 99;
}
# "the pastebrake"
if (!$slowpost && !$verify && !$script) {
if ((time() - $postbreak_time) < 5) {
$postbreak_count++;
if ($postbreak_count == 3) {
print $stdout
"-- you're posting pretty fast. did you mean to do that?\n".
"-- waiting three seconds before taking the next set of tweets\n".
"-- hit CTRL-C NOW! to kill TTYtter if you accidentally pasted in this window\n";
sleep 3;
$postbreak_count = 0;
}
} else {
$postbreak_count = 0;
}
$postbreak_time = time();
}
my $payload = (length($user_name_dm)) ? 'text' : 'status';
$string = &$prepost($string) unless ($user_name_dm || $rt_id);
# YES, you *can* verify and slowpost. I thought about this and I
# think I want to allow it.
if ($verify && !$status) {
my $answer;
print $stdout
&wwrap("-- verify you want to $verb: \"$string\"\n");
$answer = lc(&linein(
"-- send to server? (only y or Y is affirmative):"));
if ($answer ne 'y') {
print $stdout "-- ok, NOT sent to server.\n";
return 97;
}
}
unless ($rt_id) {
if ($octwercs) {
1 while ($string =~ s#http(s?)://#ttp\1://#);
}
$urle = '';
foreach $i (unpack("${pack_magic}C*", $string)) {
my $k = chr($i);
if ($k =~ /[-._~a-zA-Z0-9]/) {
$urle .= $k;
} else {
$k = sprintf("%02X", $i);
$urle .= "%$k";
}
}
}
$user_name_dm = (length($user_name_dm)) ?
"&user=$user_name_dm" : '';
my $i = '';
$i .= "source=TTYtter&" if ($authtype eq 'basic');
$i .= "in_reply_to_status_id=${in_reply_to}&" if ($in_reply_to > 0);
if (!$rt_id && defined $lat && defined $long && $location) {
print $stdout "-- using lat/long: ($lat, $long)\n";
$i .= "lat=${lat}&long=${long}&";
} elsif ((defined $lat || defined $long) && $location && !$rt_id) {
print $stdout
"-- warning: incomplete location ($lat, $long) ignored\n";
}
$i .= "${payload}=${urle}${user_name_dm}" unless ($rt_id);
$i .= "id=$rt_id" if ($rt_id);
$slowpost += 0; if ($slowpost && !$script && !$status && !$silent) {
if($pid = open(SLOWPOST, '-|')) {
# pause background so that it doesn't kill itself
# when this signal occurs.
kill $SIGUSR1, $child;
print $stdout &wwrap(
"-- waiting $slowpost seconds to $verb, ^C cancels: \"$string\"\n");
close(SLOWPOST); # this should wait for us
if ($? > 256) {
print $stdout
"\n-- not sent, cancelled by user\n";
return 97;
}
print $stdout "-- sending to server\n";
kill $SIGUSR2, $child;
&send_removereadline if ($termrl && $dostream);
} else {
$in_backticks = 1; # defeat END sub
&sigify(sub { exit 254; }, qw(BREAK INT TERM PIPE));
sleep $slowpost;
exit 0;
}
}
my $return = &backticks($baseagent, '/dev/null', undef,
(length($user_name_dm)) ? $dmupdate :
($rt_id) ? "$rturl/${rt_id}.json" :
$update, $i, 0, @wend);
print $stdout "-- return --\n$return\n-- return --\n"
if ($superverbose);
if ($? > 0) {
$x = $? >> 8;
print $stdout <<"EOF" if ($interactive);
${MAGENTA}*** warning: connect timeout or no confirmation received ($x)
*** to attempt a resend, type %%${OFF}
EOF
return $?;
}
my $ec;
if ($ec = &is_json_error($return)) {
print $stdout <<"EOF" if ($interactive);
${MAGENTA}*** warning: server error message received
*** "$ec"${OFF}
EOF
return 98;
}
if ($ec = &is_fail_whale($return) ||
$return =~ /^\[?\]?<!DOCTYPE\s+html/i ||
$return =~ /^(Status:\s*)?50[0-9]\s/ ||
$return =~ /^<html>/i ||
$return =~ /^<\??xml\s+/) {
print $stdout <<"EOF" if ($interactive);
${MAGENTA}*** warning: Twitter Fail Whale${OFF}
EOF
return 98;
}
$lastpostid = &parsejson($return)->{'id_str'};
unless ($user_name_dm || $rt_id) {
$lasttwit = $string;
&$postpost($string);
}
return 0;
}
# this dispatch routine replaces the common logic of deletest, deletedm,
# follow, leave and the favourites system.
# this is a modified, abridged version of &updatest.
sub central_cd_dispatch {
my ($payload, $interactive, $update) = (@_);
my $return = &backticks($baseagent, '/dev/null', undef,
$update, $payload, 0, @wend);
print $stdout "-- return --\n$return\n-- return --\n"
if ($superverbose);
if ($? > 0) {
$x = $? >> 8;
print $stdout <<"EOF" if ($interactive);
${MAGENTA}*** warning: connect timeout or no confirmation received ($x)
*** to attempt again, type %%${OFF}
EOF
return ($?, '');
}
my $ec;
if ($ec = &is_json_error($return)) {
print $stdout <<"EOF" if ($interactive);
${MAGENTA}*** warning: server error message received
*** "$ec"${OFF}
EOF
return (98, $return);
}
return (0, $return);
}
# the following functions may be user-exposed in a future version of
# TTYtter, but are officially still "private interfaces."
# delete a status
sub deletest {
my $id = shift;
my $interactive = shift;
my $update = "${delurl}/${id}.json";
my ($en, $em) = ¢ral_cd_dispatch("id=$id", $interactive, $update);
print $stdout "-- tweet id #${id} has been removed\n"
if ($interactive && !$en);
print $stdout "*** (was the tweet already deleted?)\n"
if ($interactive && $en);
return 0;
}
# delete a DM
sub deletedm {
my $id = shift;
my $interactive = shift;
my $update = "${dmdelurl}/${id}.json";
my ($en, $em) = ¢ral_cd_dispatch("id=$id", $interactive, $update);
print $stdout "-- DM id #${id} has been removed\n"
if ($interactive && !$en);
print $stdout "*** (was the DM already deleted?)\n"
if ($interactive && $en);
return 0;
}
# create or destroy a favourite
sub cordfav {
my $id = shift;
my $interactive = shift;
my $basefav = shift;
my $text = shift;
my $verb = shift;
my $update = "${basefav}/${id}.json";
my ($en, $em) = ¢ral_cd_dispatch("id=$id", $interactive, $update);
print $stdout "-- favourite $verb for tweet id #${id}: \"$text\"\n"
if ($interactive && !$en);
print $stdout "*** (was the favourite already ${verb}?)\n"
if ($interactive && $en);
return 0;
}
# follow or unfollow a user
sub foruuser {
my $uname = shift;
my $interactive = shift;
my $basef = shift;
my $verb = shift;
my $update = "${basef}/${uname}.json";
my ($en, $em) = ¢ral_cd_dispatch("screen_name=$uname",
$interactive, $update);
print $stdout "-- ok, you have $verb following user $uname.\n"
if ($interactive && !$en);
return 0;
}
# block or unblock a user
sub boruuser {
my $uname = shift;
my $interactive = shift;
my $basef = shift;
my $verb = shift;
my ($en, $em) = ¢ral_cd_dispatch("screen_name=$uname",
$interactive, $basef);
print $stdout "-- ok, you have $verb blocking user $uname.\n"
if ($interactive && !$en);
return 0;
}
# enable or disable retweets for a user
sub rtsonoffuser {
my $uname = shift;
my $interactive = shift;
my $selection = shift;
my $verb = ($selection) ? 'enabled' : 'disabled';
my $tval = ($selection) ? 'true' : 'false';
my ($en, $em) = ¢ral_cd_dispatch(
"retweets=${tval}&screen_name=${uname}",
$interactive, $frupdurl);
print $stdout "-- ok, you have ${verb} retweets for user $uname.\n"
if ($interactive && !$en);
return 0;
}
#### TTYtter internal API utility functions ####
# ... which your API *can* call
# gets and returns the contents of a URL (optionally pass a POST body)
sub graburl {
my $resource = shift;
my $data = shift;
return &backticks($baseagent,
'/dev/null', undef, $resource, $data,
1, @wind);
}
# format a tweet based on user options
sub standardtweet {
my $ref = shift;
my $nocolour = shift;
my $sn = &descape($ref->{'user'}->{'screen_name'});
my $tweet = &descape($ref->{'text'});
my $colour;
my $g;
my $h;
# wordwrap really ruins our day here, thanks a lot, @augmentedfourth
# have to insinuate the ansi sequences after the string is wordwrapped
$g = $colour = ${'CC' . scalar(&$tweettype($ref, $sn, $tweet)) }
unless ($nocolour);
$colour = $OFF . $colour
unless ($nocolour);
# prepend screen name "badges"
$sn = "\@$sn" if ($ref->{'in_reply_to_status_id_str'} > 0);
$sn = "+$sn" if ($ref->{'user'}->{'geo_enabled'} eq 'true' &&
$ref->{'geo'}->{'coordinates'}->[0] ne 'undef' &&
length($ref->{'geo'}->{'coordinates'}->[0]) &&
$ref->{'geo'}->{'coordinates'}->[1] ne 'undef' &&
length($ref->{'geo'}->{'coordinates'}->[0]));
$sn = "%$sn" if (length($ref->{'retweeted_status'}->{'id_str'}));
$sn = "*$sn" if ($ref->{'source'} =~ /TTYtter/ && $ttytteristas);
# prepend list information, if this tweet originated from a list
$sn = "($ref->{'tag'}->{'payload'})$sn"
if (length($ref->{'tag'}->{'payload'}) &&
$ref->{'tag'}->{'type'} eq 'list');
$tweet = "<$sn> $tweet";
# twitter doesn't always do this right.
$h = $ref->{'retweet_count'}; $h += 0; #$h = "${h}+" if ($h >= 100);
# twitter doesn't always handle single retweets right. good f'n grief.
$tweet = "(x${h}) $tweet" if ($h > 1 && !$nonewrts);
# br3nda's modified timestamp patch
if ($timestamp) {
my ($time, $ts) = &$wraptime($ref->{'created_at'});
$tweet = "[$ts] $tweet";
}
# pull it all together
$tweet = &wwrap($tweet, ($wrapseq <= 1) ? ((&$prompt(1))[1]) : 0)
if ($wrap); # remember to account for prompt length on #1
$tweet =~ s/^([^<]*)<([^>]+)>/${g}\1<${EM}\2${colour}>/
unless ($nocolour);
$tweet =~ s/\n*$//;
$tweet .= ($nocolour) ? "\n" : "$OFF\n";
# highlight anything that we have in track
if(scalar(@tracktags)) { # I'm paranoid
foreach $h (@tracktags) {
$h =~ s/^"//; $h =~ s/"$//; # just in case
$tweet =~ s/(^|[^a-zA-Z0-9])($h)([^a-zA-Z0-9]|$)/\1${EM}\2${colour}\3/ig
unless ($nocolour);
}
}
# smb's underline/bold patch goes on last (modified for lists)
unless ($nocolour) {
# only do this after the < > portion.
my $k = index($tweet, ">");
my $botsub = substr($tweet, $k);
my $topsub = substr($tweet, 0, $k);
$botsub =~
s/(^|[^a-zA-Z0-9_])\@([a-zA-Z0-9_\/]+)/\1\@${UNDER}\2${colour}/g;
$tweet = $topsub . $botsub;
}
return $tweet;
}
# format a DM based on standard user options
sub standarddm {
my $ref = shift;
my $nocolour = shift;
my ($time, $ts) = &$wraptime($ref->{'created_at'});
my $text = &descape($ref->{'text'});
my $sns = &descape($ref->{'sender'}->{'screen_name'});
if ($sns eq $whoami) {
$sns = "->" . &descape($ref->{'recipient'}->{'screen_name'});
}
my $g = &wwrap("[DM d$ref->{'menu_select'}]".
"[$sns/$ts] $text", ($wrapseq <= 1) ? ((&$prompt(1))[1]) : 0);
$g =~ s/^\[DM ([^\/]+)\//${CCdm}[DM ${EM}\1${OFF}${CCdm}\//
unless ($nocolour);
$g =~ s/\n*$//;
$g .= ($nocolour) ? "\n" : "$OFF\n";
$g =~ s/(^|[^a-zA-Z0-9_])\@(\w+)/\1\@${UNDER}\2${OFF}${CCdm}/g
unless ($nocolour);
return $g;
}
# format an event record based on standard user options (mostly for
# streaming API, perhaps REST API one day)
sub standardevent {
my $ref = shift;
my $nocolour = shift;
my $g = '>>> ';
my $verb = &descape($ref->{'event'});
# @episod has promised me he will document all of the events.
# still waiting ...
if (length($verb)) { # delete is different.
my $tar_sn = '@'.&descape($ref->{'target'}->{'screen_name'});
my $sou_sn = '@'.&descape($ref->{'source'}->{'screen_name'});
if ($verb eq 'favorite' || $verb eq 'unfavorite') {
my $txt = &descape($ref->{'target_object'}->{'text'});
$g .=
"$sou_sn just ${verb}d ${tar_sn}'s tweet: \"$txt\"";
} elsif ($verb eq 'follow') {
$g .= "$sou_sn is now following $tar_sn";
} elsif ($verb eq 'user_update') {
$g .= "$sou_sn updated their profile (/whois $sou_sn to see)";
#TODO
# these need to be fleshed out
} elsif ($verb eq 'list_member_added') {
$g .= "$sou_sn added $tar_sn to a list";
} elsif ($verb eq 'list_member_removed') {
$g .= "$sou_sn removed $tar_sn from a list";
} elsif ($verb eq 'list_user_subscribed') {
$g .= "$sou_sn is now following a list from $tar_sn";
} elsif ($verb eq 'list_user_unsubscribed') {
$g .= "$sou_sn is no longer following a list from $tar_sn";
} elsif ($verb eq 'list_create') {
$g .= "$sou_sn created a new list";
} elsif ($verb eq 'list_destroyed') {
$g .= "$sou_sn destroyed a list";
} elsif ($verb eq 'list_updated') {
$g .= "$sou_sn updated a list";
} else {
# try to handle new types of events we don't
# recognize yet
$verb .= ($verb =~ /e$/) ? 'd' : 'ed';
$g .= "$sou_sn $verb $tar_sn (basic)";
}
} elsif ($ref->{'delete'}) {
# this is the best we can do -- it's already on the screen!
# we don't want to make it easy which tweet it is, since that
# would be embarrassing, so just say a delete occurred.
$g .=
"tweet ID# ".$ref->{'delete'}->{'status'}->{'id_str'}.
" deleted by server";
} else {
# we have no idea what this is. just BS our way out.
$g .= "unknown server event received (non-fatal)";
}
if ($timestamp) {
my ($time, $ts) = &$wraptime($ref->{'created_at'});
$g = "[$ts] $g";
}
$g = &wwrap("$g\n", ($wrapseq <= 1) ? ((&$prompt(1))[1]) : 0);
# highlight screen names
$g =~
s/(^|[^a-zA-Z0-9_])\@([a-zA-Z0-9_\-\/]+)/\1\@${UNDER}\2${OFF}/g
unless ($nocolour);
return $g;
}
# for future expansion: this is the declared API callable method
# for executing a command as if the console had typed it.
sub ucommand {
die("** can't call &ucommand during multi-module loading.\n")
if ($multi_module_mode == -1);
&prinput(@_);
}
# your application can also call &grabjson to get a hashref
# corresponding to parsed JSON from an arbitrary resource.
# see that function later on.
#### DEFAULT TTYtter INTERNAL API METHODS ####
# don't change these here. instead, use -exts=yourlibrary.pl and set there.
# note that these are all anonymous subroutine references.
# anything you don't define is overwritten by the defaults.
# it's better'n'superclasses.
# NOTE: defaultaddaction, defaultmain and defaultprompt
# are all defined in the "console" section above for
# clarity.
# this first set are the multi-module aware ones.
# the standard iterator for multi-module methods
sub multi_module_dispatch {
my $default = shift;
my $dispatch_chain = shift;
my $rv_handler = shift;
my @args = @_;
local $dispatch_ref; # on purpose; get_key/set_key may need it
# $*_call_default is a global
$did_call_default = 0;
$this_call_default = 0;
$multi_module_context = 0;
if ($rv_handler == 0) {
$rv_handler = sub {
return 0;
};
}
# fall through to default if no dispatch chain
if (!scalar(@{ $dispatch_chain })) {
return &$default(@args);
}
foreach $dispatch_ref (@{ $dispatch_chain }) {
# each reference has the code, and the file that specified it.
# set up a multi-module context and run that function. if the
# default ever gets called, we log it to tell the multi-module
# handler to call the default at the end.
my $rv;
my $irv;
my $caller = (caller(1))[3];
$caller =~ s/^main::multi//;
$multi_module_context = 1; # defaults then know to defer
$this_call_default = 0;
$store = $master_store->{ $dispatch_ref->[0] };
print "-- calling \$$caller in $dispatch_ref->[0]\n"
if ($verbose);
my $code_ref = $dispatch_ref->[1];
$rv = &$rv_handler(@irv = &$code_ref(@args));
$multi_module_context = 0;
if ($rv & 4) {
# rv_handler indicating to call default and halt
# if it was called.
return &$default(@args) if ($did_call_default);
}
if ($rv & 2) {
# rv_handler indicating to make new @args from @irv
@args = @irv;
}
if ($rv & 1) {
# rv_handler indicating to halt early. do so.
return (wantarray) ? @irv : $irv[0];
}
}
$multi_module_context = 0;
return &$default(@args) if ($did_call_default);
return (wantarray) ? @irv : $irv[0];
}
# these are the stubs that call the dispatcher.
sub multiaddaction {
&multi_module_dispatch(\&defaultaddaction, \@m_addaction, sub{
# return immediately on the first extension to accept
return (shift>0);
}, @_);
}
sub multiconclude {
&multi_module_dispatch(\&defaultconclude, \@m_conclude, 0, @_);
}
sub multidmconclude {
&multi_module_dispatch(\&defaultdmconclude, \@m_dmconclude, 0, @_);
}
sub multidmhandle {
&multi_module_dispatch(\&defaultdmhandle, \@m_dmhandle, sub {
my $rv = shift;
# skip default calls.
return 0 if ($this_call_default);
# if not a default call, and the DM was refused for
# processing by this extension, then the DM is now
# suppressed. do not call any other extensions after this.
# even if it ends in suppression, we still call the default
# if it was ever called before.
return 5 if ($rv == 0);
# if accepted in any manner, keep calling.
return 0;
}, @_);
}
sub multieventhandle {
&multi_module_dispatch(\&defaulteventhandle, \@m_eventhandle, sub {
my $rv = shift;
# skip default calls.
return 0 if ($this_call_default);
# if not a default call, and the event was refused for
# processing by this extension, then the event is now
# suppressed. do not call any other extensions after this.
# even if it ends in suppression, we still call the default
# if it was ever called before.
return 5 if ($rv == 0);
# if accepted in any manner, keep calling.
return 0;
}, @_);
}
sub multiexception {
# this is a secret option for people who want to suppress errors.
if ($exception_is_maskable) {
&multi_module_dispatch(\&defaultexception, \@m_exception, sub {
my $rv = shift;
# same logic as handle/dmhandle, except return -1-
# to mask from subsequent extensions.
return 0 if ($this_call_default);
return 5 if ($rv);
return 0;
}, @_);
} else {
&multi_module_dispatch(
\&defaultexception, \@m_exception, 0, @_);
}
}
sub multishutdown {
return if ($shutdown_already_called++);
&multi_module_dispatch(\&defaultshutdown, \@m_shutdown, 0, @_);
}
sub multiuserhandle {
&multi_module_dispatch(\&defaultuserhandle, \@m_userhandle, sub{
# skip default calls.
return 0 if ($this_call_default);
# return immediately on the first extension to accept
return (shift>0);
}, @_);
}
sub multilisthandle {
&multi_module_dispatch(\&defaultlisthandle, \@m_listhandle, sub{
# skip default calls.
return 0 if ($this_call_default);
# return immediately on the first extension to accept
return (shift>0);
}, @_);
}
sub multihandle {
&multi_module_dispatch(\&defaulthandle, \@m_handle, sub {
my $rv = shift;
# skip default calls.
return 0 if ($this_call_default);
# if not a default call, and the tweet was refused for
# processing by this extension, then the tweet is now
# suppressed. do not call any other extensions after this.
# even if it ends in suppression, we still call the default
# if it was ever called before.
return 5 if ($rv==0);
# if accepted in any manner, keep calling.
return 0;
}, @_);
}
sub multiheartbeat {
&multi_module_dispatch(\&defaultheartbeat, \@m_heartbeat, 0, @_);
}
sub multiprecommand {
&multi_module_dispatch(\&defaultprecommand, \@m_precommand, sub {
return 2; # feed subsequent chains the result.
}, @_);
}
sub multiprepost {
&multi_module_dispatch(\&defaultprepost, \@m_prepost, sub {
return 2; # feed subsequent chains the result.
}, @_);
}
sub multipostpost {
&multi_module_dispatch(\&defaultpostpost, \@m_postpost, 0, @_);
}
sub multitweettype {
&multi_module_dispatch(\&defaulttweettype, \@m_tweettype, sub {
# if this module DID NOT call default, exit now.
return (!$this_call_default);
}, @_);
}
sub flag_default_call { $this_call_default++; $did_call_default++; }
# now the actual default methods
sub defaultexception {
(&flag_default_call, return) if ($multi_module_context);
my $msg_code = shift;
return if ($msg_code == 2 && $muffle_server_messages);
my $message = "@_";
$message =~ s/\n*$//sg;
if ($timestamp) {
my ($time, $ts) = &$wraptime(scalar(localtime));
$message = "[$ts] $message";
$message =~ s/\n/\n[$ts] /sg;
}
&send_removereadline if ($termrl);
$wrapseq = 1;
print $stdout "${MAGENTA}${message}${OFF}\n";
&send_repaint if ($termrl);
$laststatus = 1;
}
sub defaultshutdown {
(&flag_default_call, return) if ($multi_module_context);
}
sub defaultlisthandle {
(&flag_default_call, return) if ($multi_module_context);
my $list_ref = shift;
print $streamout "*** for future expansion ***\n";
return 1;
}
sub defaulthandle {
(&flag_default_call, return) if ($multi_module_context);
my $tweet_ref = shift;
my $class = shift;
my $dclass = ($verbose) ? "{$class,$tweet_ref->{'id_str'}} " : '';
my $sn = &descape($tweet_ref->{'user'}->{'screen_name'});
my $tweet = &descape($tweet_ref->{'text'});
my $stweet = &standardtweet($tweet_ref);
my $menu_select = $tweet_ref->{'menu_select'};
$menu_select = (length($menu_select) && !$script)
? (($menu_select =~ /^z/) ?
"${EM}${menu_select}>${OFF} " :
"${menu_select}> ")
: '';
print $streamout $menu_select . $dclass . $stweet;
&sendnotifies($tweet_ref, $class);
return 1;
}
sub defaultuserhandle {
(&flag_default_call, return) if ($multi_module_context);
my $user_ref = shift;
&userline($user_ref, $streamout);
my $desc = &strim(&descape($user_ref->{'description'}));
my $klen = ($wrap || 79) - 9;
$klen = 10 if ($klen < 0);
$desc = substr($desc, 0, $klen)."..." if (length($desc) > $klen);
print $streamout (' "' . $desc . '"' . "\n") if (length($desc));
return 1;
}
sub userline { # used by both $userhandle and /whois
my $my_json_ref = shift;
my $fh = shift;
my $verified =
($my_json_ref->{'verified'} eq 'true') ?
"${EM}(Verified)${OFF} " : '';
my $protected =
($my_json_ref->{'protected'} eq 'true') ?
"${EM}(Protected)${OFF} " : '';
print $fh <<"EOF";
${CCprompt}@{[ &descape($my_json_ref->{'name'}) ]}${OFF} (@{[ &descape($my_json_ref->{'screen_name'}) ]}) (f:$my_json_ref->{'friends_count'}/$my_json_ref->{'followers_count'}) (u:$my_json_ref->{'statuses_count'}) ${verified}${protected}
EOF
return;
}
sub sendnotifies { # this is a default subroutine of a sort, right?
my $tweet_ref = shift;
my $class = shift;
my $sn = &descape($tweet_ref->{'user'}->{'screen_name'});
my $tweet = &descape($tweet_ref->{'text'});
# interactive? first time?
unless (length($class) || !$last_id || !length($tweet)) {
$class = scalar(&$tweettype($tweet_ref, $sn, $tweet));
¬ifytype_dispatch($class,
&standardtweet($tweet_ref, 1), $tweet_ref)
if ($notify_list{$class});
}
}
sub defaulttweettype {
(&flag_default_call, return) if ($multi_module_context);
my $ref = shift;
my $sn = shift;
my $tweet = shift;
# br3nda's and smb's modified colour patch
unless ($anonymous) {
if ($sn eq $whoami) {
# if it's me speaking, colour the line yellow
return 'me';
} elsif ($tweet =~ /\@$whoami(\b|$)/i) {
# if I'm in the tweet, colour red
return 'reply';
}
}
if ($ref->{'class'} eq 'search') { # anonymous allows this too
# if this is a search result, colour cyan
return 'search';
}
if ($ref->{'tag'}->{'type'} eq 'list') { # anonymous allows this too
return 'list';
}
return 'default';
}
sub defaultconclude {
(&flag_default_call, return) if ($multi_module_context);
if ($filtered && $filter_attribs{'count'}) {
print $stdout "-- (filtered $filtered tweets)\n";
$filtered = 0;
}
}
sub defaultdmhandle {
(&flag_default_call, return) if ($multi_module_context);
my $dm_ref = shift;
my $sns = &descape($dm_ref->{'sender'}->{'screen_name'});
print $streamout &standarddm($dm_ref);
&senddmnotifies($dm_ref) if ($sns ne $whoami);
return 1;
}
sub senddmnotifies {
my $dm_ref = shift;
¬ifytype_dispatch('DM', &standarddm($dm_ref, 1), $dm_ref)
if ($notify_list{'dm'} && $last_dm);
}
sub defaulteventhandle {
(&flag_default_call, return) if ($multi_module_context);
my $event_ref = shift;
# in this version, we silently filter delete events, but your
# extension would still get them delivered.
return 1 if ($event_ref->{'delete'});
print $streamout &standardevent($event_ref);
return 1;
}
sub defaultdmconclude {
(&flag_default_call, return) if ($multi_module_context);
}
sub defaultheartbeat {
(&flag_default_call, return) if ($multi_module_context);
}
# not much sense to multi-module protect these.
sub defaultprecommand { return ("@_"); }
sub defaultprepost { return ("@_"); }
sub defaultpostpost {
(&flag_default_call, return) if ($multi_module_context);
my $line = shift;
return if (!$termrl);
# populate %readline_completion if readline is on
while($line =~ s/^\@(\w+)\s+//) {
$readline_completion{'@'.lc($1)}++;
}
if ($line =~ /^[dD]\s+(\w+)\s+/) {
$readline_completion{'@'.lc($1)}++;
}
}
sub defaultautocompletion {
my ($text, $line, $start) = (@_);
my $qmtext = quotemeta($text);
my @proband;
my @rlkeys;
# handle / completion
if ($start == 0 && $text =~ m#^/#) {
return sort grep(/^$qmtext/i, '/history',
'/print', '/quit', '/bye', '/again',
'/wagain', '/whois', '/thump', '/dm',
'/refresh', '/dmagain', '/set', '/help',
'/reply', '/url', '/thread', '/retweet',
'/replies', '/ruler', '/exit', '/me', '/vcheck',
'/oretweet', '/eretweet', '/fretweet', '/liston',
'/listoff', '/dmsent', '/rtsof', '/rtsofme',
'/lists', '/withlist', '/add', '/padd', '/push',
'/pop', '/followers', '/friends', '/lfollow',
'/lleave', '/listfollowers', '/listfriends',
'/unset', '/verbose', '/short', '/follow', '/unfollow',
'/doesfollow', '/search', '/tron', '/troff',
'/delete', '/deletelast', '/dump',
'/track', '/trends', '/block', '/unblock',
'/fave', '/faves', '/unfave', '/eval');
}
@rlkeys = keys(%readline_completion);
# handle @ completion. this works slightly weird because
# readline hands us the string WITHOUT the @, so we have to
# test somewhat blindly. this works even if a future readline
# DOES give us the word with @. also handles D, /wa, /wagain,
# /a, /again, etc.
if (($line =~ m#^(D|/wa|/wagain|/a|/again) #i) ||
($start == 1 && substr($line, 0, 1) eq '@') ||
# this code is needed to prevent inline @ from flipping out
($start >= 1 && substr($line, ($start-2), 2) eq ' @')) {
@proband = grep(/^\@$qmtext/i, @rlkeys);
if (scalar(@proband)) {
@proband = map { s/^\@//;$_ } @proband;
return @proband;
}
}
# definites that are left over, including @ if it were included
if(scalar(@proband = grep(/^$qmtext/i, @rlkeys))) {
return @proband;
}
# heuristics
# URL completion (this doesn't always work of course)
if ($text =~ m#https?://#) {
return (&urlshorten($text) || $text);
}
# "I got nothing."
return ();
}
#### built-in notification routines ####
# growl for Mac OS X
sub notifier_growl {
my $class = shift;
my $text = shift;
my $ref = shift; # not used in this version
if (!defined($class) || !length($notify_tool_path)) {
# we are being asked to initialize
$notify_tool_path = &wherecheck("trying to find growlnotify",
"growlnotify",
"growlnotify must be installed to use growl notifications. check your\n" .
"documentation for how to do this.\n")
unless ($notify_tool_path);
if (!defined($class)) {
return 1 if ($script || $notifyquiet);
$class = 'Growl support activated';
$text =
'You can configure notifications for TTYtter in the Growl preference pane.';
}
}
# handle this in the background for faster performance.
# to avoid problems with SIGCHLD, we fork ourselves twice (mmm!),
# leaving an orphan which init should grab (we need SIGCHLD for
# proper backticks, so it can't be IGNOREd).
my $gchild;
if ($gchild = fork()) {
# the parent harvests the child, which will die immediately.
waitpid($gchild, 0);
return 1;
} elsif (!defined ($gchild)) {
print $stdout "warning: failed growl fork: $!\n";
return 1;
}
# this is the child. spawn, then exit and abandon our own child,
# which init will reap. the problem with teen pregnancy is mounting.
$in_backticks = 1;
my $hchild;
if ($hchild = fork()) {
exit;
} elsif (!defined ($hchild)) {
print $stdout "warning: failed growl fork: $!\n";
exit;
}
# this is the subchild, which is abandoned at a fire sta^W^W^Winit.
open(GROWL, "|$notify_tool_path -n 'TTYtter' 'TTYtter: $class'");
binmode(GROWL, ":utf8") unless ($seven);
print GROWL $text;
close(GROWL);
exit;
}
# libnotify for {Linux,whatevs}
# this is EXPERIMENTAL, and requires this patch to notify-send:
# http://www.floodgap.com/software/ttytter/libnotifypatch.txt
# why it has not already been applied is fricking beyond me, it makes
# sense. would YOU want arbitrary characters on the command line
# separated only from overwriting your home directory by a quoting routine?
sub notifier_libnotify {
my $class = shift;
my $text = shift;
my $ref = shift; # not used in this version
if (!defined($class) || !defined($notify_tool_path)) {
# we are being asked to initialize
$notify_tool_path = &wherecheck("trying to find notify-send",
"notify-send",
"notify-send must be installed to use libnotify, and it must be modified\n".
"for standard input. see the documentation for how to do this.\n")
unless ($notify_tool_path);
if (!defined($class)) {
return 1 if ($script || $notifyquiet);
$class = 'libnotify support activated';
$text =
'Congratulations, your notify-send is correctly configured for TTYtter.';
}
}
# figure out the time to display based on length of tweet
my $t = 1000+50*length($text); # about 150-180wpm read speed
open(NOTIFYSEND,
"|$notify_tool_path -t $t -f - 'TTYtter: $class'");
binmode(NOTIFYSEND, ":utf8") unless ($seven);
print NOTIFYSEND $text;
close(NOTIFYSEND);
return 1;
}
#### IPC routines for communicating between the foreground + background ####
# this is the central routine that takes a rolling tweet code, figures
# out where that tweet is, and returns something approximating a tweet
# structure (or the actual tweet structure itself if it can).
sub get_tweet {
my $code = lc(shift);
return undef if ($code !~ /^z?[a-z][0-9]$/);
my $source = ($code =~ /^z/) ? 1 : 0;
my $k = '';
my $l = '';
my $w = {'user' => {}};
if ($is_background) {
if ($source == 1) { # foreground only
return undef;
}
return $store_hash{$code};
}
return $store_hash{$code} if ($source); # foreground c/foreground twt
print $stdout "-- querying background: $code\n" if ($verbose);
kill $SIGUSR2, $child if ($child);
print C "pipet $code ----------\n";
while(length($k) < 1024) {
sysread(W, $l, 1024);
$k .= $l;
}
return undef if ($k !~ /[^\s]/);
$k =~ s/\s+$//; # remove trailing spaces
print $stdout "-- background store fetch: $k\n" if ($verbose);
($w->{'menu_select'}, $w->{'id_str'}, $w->{'in_reply_to_status_id_str'},
$w->{'retweeted_status'}->{'id_str'},
$w->{'user'}->{'geo_enabled'},
$w->{'geo'}->{'coordinates'}->[0],
$w->{'geo'}->{'coordinates'}->[1],
$w->{'tag'}->{'type'},
$w->{'tag'}->{'payload'},
$w->{'retweet_count'},
$w->{'user'}->{'screen_name'}, $w->{'created_at'},
$l) = split(/\s/, $k, 13);
($w->{'source'}, $k) = split(/\|/, $l, 2);
$w->{'text'} = pack("H*", $k);
$w->{'tag'}->{'payload'} = pack("H*", $w->{'tag'}->{'payload'});
return undef if (!length($w->{'text'})); # not possible
$w->{'created_at'} =~ s/_/ /g;
return $w;
}
# this is the analogous function for a rolling DM code. it is somewhat
# simpler as DM codes are always rolling and have no foreground store
# currently, so it always executes a background request.
sub get_dm {
my $code = lc(shift);
my $k = '';
my $l = '';
my $w = {'sender' => {}};
return undef if (length($code) != 3 || $code !~ s/^d// ||
$code !~ /^[a-z][0-9]$/);
kill $SIGUSR2, $child if ($child); # prime pipe
print C "piped $code ----------\n"; # internally two alphanum, recall
while(length($k) < 1024) {
sysread(W, $l, 1024);
$k .= $l;
}
return undef if ($k !~ /[^\s]/);
$k =~ s/\s+$//; # remove trailing spaces
print $stdout "-- background store fetch: $k\n" if ($verbose);
($w->{'menu_select'}, $w->{'id_str'},
$w->{'sender'}->{'screen_name'}, $w->{'created_at'},
$l) = split(/\s/, $k, 5);
$w->{'text'} = pack("H*", $l);
return undef if (!length($w->{'text'})); # not possible
$w->{'created_at'} =~ s/_/ /g;
return $w;
}
# this function requests a $store key from the background. it only works
# if foreground.
sub getbackgroundkey {
if ($is_background) {
print $stdout "*** can't call getbackgroundkey from background\n";
return undef;
}
my $key = shift;
my $l;
my $k;
print C substr("ki $key ---------------------", 0, 19)."\n";
my $ref = (length($dispatch_ref->[0])) ? ($dispatch_ref->[0]) :
"DEFAULT";
print C substr(unpack("${pack_magic}H*", $ref).$space_pad, 0, 1024);
while(length($k) < 1024) {
sysread(W, $l, 1024);
$k .= $l;
}
$k =~ s/[^0-9a-fA-F]//g;
print $stdout "-- background store fetch: $k\n" if ($verbose);
return pack("H*", $k);
}
# this function sends a $store key to the background. it only works if
# foreground.
sub sendbackgroundkey {
if ($is_background) {
print $stdout "*** can't call sendbackgroundkey from background\n";
return;
}
my $key = shift;
my $value = shift;
if (ref($value)) {
print $stdout "*** send_key only supported for scalars\n";
return;
}
if (!length($value)) {
print C substr("kn $key ---------------------", 0, 19)."\n";
} else {
print C substr("ko $key ---------------------", 0, 19)."\n";
}
my $ref = (length($dispatch_ref->[0])) ? ($dispatch_ref->[0]) :
"DEFAULT";
print C substr(unpack("${pack_magic}H*", $ref).$space_pad, 0, 1024);
return if (!length($value));
print C substr(unpack("${pack_magic}H*", $value).$space_pad, 0, 1024);
}
sub thump { print C "update-------------\n"; &sync_semaphore; }
sub dmthump { print C "dmthump------------\n"; &sync_semaphore; }
sub sync_n_quit {
if ($child) {
print $stdout "waiting for child ...\n" unless ($silent);
print C "sync---------------\n";
waitpid $child, 0;
$child = 0;
print $stdout "exiting.\n" unless ($silent);
exit ($? >> 8);
}
exit;
}
# setter for internal variables, with all the needed side effects for those
# variables that are programmed to trigger internal actions when changed.
sub setvariable {
my $key = shift;
my $value = shift;
my $interactive = 0+shift;
$value =~ s/^\s+//;
$value =~ s/\s+$//; # mostly to avoid problems with /(p)add
if ($key eq 'script') { # this can never be changed by this routine
print $stdout "*** script may only be changed on init\n";
return 1;
}
if ($key eq 'tquery' && $value eq '0') { # undo tqueries
$tquery = undef;
$key = 'track';
$value = $track; # falls thru to sync
&tracktags_makearray;
}
if ($opts_can_set{$key} ||
# we CAN set read-only variables during initialization
($multi_module_mode == -1 && $valid{$key})) {
if (length($value) > 1023) {
# can't transmit this in a packet
print $stdout "*** value too long\n";
return 1;
} elsif ($opts_boolean{$key} && $value ne '0' &&
$value ne '1') {
print $stdout "*** 0|1 only (boolean): $key\n";
return 1;
} elsif ($opts_urls{$key} &&
$value !~ m#^(http|https|gopher)://#) {
print $stdout "*** must be valid URL: $key\n";
return 1;
} else {
KEYAGAIN: $$key = $value;
print $stdout "*** changed: $key => $$key\n"
if ($interactive || $verbose);
# handle special values
&generate_ansi if ($key eq 'ansi' ||
$key =~ /^colour/);
&generate_shortdomain if ($key eq 'shorturl');
&tracktags_makearray if ($key eq 'track');
&filter_compile if ($key eq 'filter');
¬ify_compile if ($key eq 'notifies');
&list_compile if ($key eq 'lists');
# transmit to background process sync-ed values
if ($opts_sync{$key}) {
&synckey($key, $value, $interactive);
}
if ($key eq 'superverbose') {
if ($value eq '0') {
$key = 'verbose';
$value = $supreturnto;
goto KEYAGAIN;
}
$supreturnto = $verbose;
}
}
# virtual keys
} elsif ($key eq 'tquery') {
my $ivalue = &tracktags_tqueryurlify($value);
if (length($ivalue) > 139) {
print $stdout
"*** custom query is too long (encoded: $ivalue)\n";
return 1;
} else {
$tquery = $value;
&synckey($key, $ivalue, $interactive);
}
} elsif ($valid{$key}) {
print $stdout
"*** read-only, must change on command line: $key\n";
return 1;
} else {
print $stdout
"*** not a valid option or setting: $key\n";
return 1;
}
return 0;
}
sub synckey {
my $key = shift;
my $value = shift;
my $interactive = 0+shift;
my $commchar = ($interactive) ? '=' : '+';
print $stdout "*** (transmitting to background)\n"
if ($interactive || $verbose);
return if (!$child);
kill $SIGUSR2, $child if ($child);
print C
(substr("${commchar}$key ", 0, 19) . "\n");
print C (substr(($value . $space_pad), 0, 1024));
sleep 1;
}
# getter for internal variables. right now this just returns the variable by
# name and a couple virtuals, but in the future this might be expanded.
sub getvariable {
my $key = shift;
if ($valid{$key}) {
return $$key;
}
if ($key eq 'effpause' ||
$key eq 'rate_limit_rate' ||
$key eq 'rate_limit_left') {
my $value;
kill $SIGUSR2, $child if ($child);
print C (substr("?$key ", 0, 19) . "\n");
sysread(W, $value, 1024);
$value =~ s/\s+$//;
return $value;
}
return undef;
}
# compatibility stub for extensions calling the old wraptime
sub wraptime { return &$wraptime(@_); }
#### url management (/url, /short) ####
sub generate_shortdomain {
my $x;
my $y;
undef $shorturldomain;
($shorturl =~ m#^http://([^/]+)/#) && ($x = $1);
# chop off any leading hostname stuff (like api., etc.)
while(1) {
$y = $x;
$x =~ s/^[^\.]*\.//;
if ($x !~ /\./) { # a cut too far
$shorturldomain = "http://$y/";
last;
}
}
print $stdout "-- warning: couldn't parse shortener service\n"
if (!length($shorturldomain));
}
sub openurl {
my $comm = $urlopen;
my $url = shift;
$url = "http://gopher.floodgap.com/gopher/gw?".&url_oauth_sub($url)
if ($url =~ m#^gopher://# && $comm !~ /^[^\s]*lynx/);
$urlshort = $url;
$comm =~ s/\%U/'$url'/g;
print $stdout "($comm)\n";
system("$comm");
}
sub urlshorten {
my $url = shift;
my $rc;
my $cl;
$url = "http://gopher.floodgap.com/gopher/gw?".&url_oauth_sub($url)
if ($url =~ m#^gopher://#);
return $url if ($url =~ /^$shorturldomain/i); # stop loops
$url = &url_oauth_sub($url);
$cl = "$simple_agent \"${shorturl}$url\"";
print $stdout "$cl\n" if ($superverbose);
chomp($rc = `$cl`);
return ($urlshort = (($rc =~ m#^http://#) ? $rc : undef));
}
##### optimizers -- these compile into an internal format #####
# utility routine for tquery support
sub tracktags_tqueryurlify {
my $value = shift;
$value =~ s/([^ a-z0-9A-Z_])/"%".unpack("H2",$1)/eg;
$value =~ s/\s/+/g;
$value = "q=$value" if ($value !~ /^q=/);
return $value;
}
# tracking subroutines
# run when a string is passed
sub tracktags_makearray {
@tracktags = ();
$track =~ s/^'//; $track =~ s/'$//; $track = lc($track);
if (!length($track)) {
@trackstrings = ();
return;
}
my $k;
my $l = '';
my $q = 0;
my %w;
my (@ptags) = split(/\s+/, $track);
# filter duplicates and merge quoted strings
foreach $k (@ptags) {
if ($q && $k =~ /"$/) { # this has to be first
$l .= " $k";
$q = 0;
} elsif ($k =~ /^"/ || $q) {
$l .= (length($l)) ? " $k" : $k;
$q = 1;
next;
} else {
$l = $k;
}
if ($w{$l}) {
print $stdout
"-- warning: dropping duplicate track term \"$l\"\n";
} elsif (uc($l) eq 'OR' || uc($l) eq 'AND') {
print $stdout
"-- warning: dropping unnecessary logical op \"$l\"\n";
} else {
$w{$l} = 1;
push(@tracktags, $l);
}
$l = '';
}
print $stdout "-- warning: syntax error, missing quote?\n" if ($q);
$track = join(' ', @tracktags);
&tracktags_compile;
}
# run when array is altered (based on @kellyterryjones' code)
sub tracktags_compile {
@trackstrings = ();
return if (!scalar(@tracktags));
my $k;
my $l = '';
my @jtags = map { # don't alter @tracktags, and support UTF-8
$j=$_; $j=~s/([^0-9a-zA-Z_])/&uhex($1)/eg; $j;
} @tracktags;
# need to make 140 character pieces
TAGBAG: foreach $k (@jtags) {
if (length($k) > 130) { # I mean, really
print $stdout
"-- warning: track tag \"$k\" is TOO LONG\n";
next TAGBAG;
}
if (length($l)+length($k) > 130) { # reasonable safety
push(@trackstrings, $l);
$l = '';
}
$l = (length($l)) ? "${l}+OR+${k}" : "q=${k}";
}
push(@trackstrings, $l) if (length($l));
}
# notification multidispatch
sub notifytype_dispatch {
return if (!scalar(@notifytypes));
my $nt; foreach $nt (@notifytypes) { &$nt(@_); }
}
# notifications compiler
sub notify_compile {
if ($notifies) {
my $w;
undef %notify_list;
foreach $w (split(/\s*,\s*/, $notifies)) {
$notify_list{$w} = 1;
}
$notifies = join(',', keys %notify_list);
}
}
# lists compiler
# we don't check the validity of lists here; /liston and /listoff do that.
sub list_compile {
my @oldlistlist = @listlist;
my %already;
undef @listlist;
if ($lists) {
my $w;
my $u;
my $l;
foreach $w (split(/\s*,\s*/, $lists)) {
$w =~ s/^@//;
if ($w =~ m#/#) {
($u, $l) = split(m#\s*/\s*#, $w, 2);
} else {
$l = $w;
}
if (!length($u) && $anonymous) {
print $stdout "*** must use fully specified lists when anonymous\n";
@listlist = @oldlistlist;
return 0;
}
$u ||= $whoami;
if ($l =~ m#/#) {
print $stdout "*** syntax error in list $u/$l\n";
@listlist = @oldlistlist;
return 0;
}
if ($already{"$u/$l"}++) {
print $stdout "*** duplicate list $u/$l ignored\n";
} else {
push(@listlist, [ $u, $l ]);
}
}
$lists = join(',', keys %already);
}
return 1;
}
# filter compiler
sub filter_compile {
undef %filter_attribs;
undef $filter_c;
if ($filter) {
my $tfilter = $filter;
$tfilter =~ s/^['"]//;
$tfilter =~ s/['"]$//;
# note attributes
$filter_attribs{$1}++ while ($tfilter =~ s/^([a-z]+),//);
my $b = <<"EOF";
\$filter_c = sub {
local \$_ = shift;
return ($tfilter);
};
EOF
#print $b;
eval $b;
if (!defined($filter_c)) {
print $stdout ("** syntax error in your filter: $@\n");
return 0;
}
}
return 1;
}
#### common system subroutines follow ####
sub updatecheck {
my $vcheck_url =
"http://www.floodgap.com/software/ttytter/02current.txt";
my $vrlcheck_url =
"http://www.floodgap.com/software/ttytter/01readlin.txt";
my $update_url = shift;
my $vs = '';
my $vvs;
my $tverify;
my $inversion;
my $bversion;
my $rcnum;
my $download;
my $maj;
my $min;
my $s1, $s2, $s3;
my $update_trlt = undef;
if ($termrl && $termrl->ReadLine eq 'Term::ReadLine::TTYtter') {
my $trlv = $termrl->Version;
print $stdout
"-- checking Term::ReadLine::TTYtter version: $vrlcheck_url\n";
$vvs = `$simple_agent $vrlcheck_url`;
print $stdout "-- server response: $vvs\n" if ($verbose);
($vvs, $s1, $s2, $s3) = split(/--__--\n/s, $vvs);
$s1 = undef if ($s1 !~ /^\*/) ;
$s2 = undef if ($s2 !~ /^\*/) ;
$s3 = undef if ($s3 !~ /^\*/) ;
chomp($vvs);
# right now we're only using $inversion (no betas/rcs).
($tverify, $inversion, $bversion, $rcnum, $download,
$bdownload) = split(/;/, $vvs, 6);
if ($tverify ne 'trlt') {
$vs .= "-- warning: unable to verify Term::ReadLine::TTYtter version\n";
} else {
if ($trlv < 0+$inversion) {
$vs .= "** NEW Term::ReadLine::TTYtter VERSION AVAILABLE: $inversion **\n" .
"** GET IT: $download\n";
$update_trlt = $download;
} else {
$vs .= "-- your version of Term::ReadLine::TTYtter is up to date ($inversion)\n";
}
}
}
print $stdout "-- checking TTYtter version: $vcheck_url\n";
$vvs = `$simple_agent $vcheck_url`;
print $stdout "-- server response: $vvs\n" if ($verbose);
($vvs, $s1, $s2, $s3) = split(/--__--\n/s, $vvs);
$s1 = undef if ($s1 !~ /^\*/) ;
$s2 = undef if ($s2 !~ /^\*/) ;
$s3 = undef if ($s3 !~ /^\*/) ;
chomp($vvs);
($tverify, $inversion, $bversion, $rcnum, $download, $bdownload) =
split(/;/, $vvs, 6);
if ($tverify ne 'ttytter') {
$vs .= "-- warning: unable to verify TTYtter version\n";
} else {
if ($my_version_string eq $bversion) {
$vs .=
"** REMINDER: you are using a beta version (${my_version_string}b${TTYtter_RC_NUMBER})\n";
$vs .=
"** NEW TTYtter RELEASE CANDIDATE AVAILABLE: build $rcnum **\n" .
"** get it: $bdownload\n$s2"
if ($TTYtter_RC_NUMBER < $rcnum);
$vs .= "** (this is the most current beta)\n"
if ($TTYtter_RC_NUMBER == $rcnum);
$vs .= "$s1$s3";
if ($TTYtter_RC_NUMBER < $rcnum) {
if ($update_url) {
$vs .=
"-- %URL% is now $bdownload (/short shortens, /url opens)\n";
$urlshort = $bdownload;
}
} elsif (length($update_trlt) && $update_url) {
$urlshort = $update_trlt;
$vs .= "-- %URL% is now $urlshort (/short shortens, /url opens)\n";
}
return $vs;
}
if ($my_version_string eq $inversion && $TTYtter_RC_NUMBER) {
$vs .=
"** FINAL TTYtter RELEASE NOW AVAILABLE for version $inversion **\n" .
"** get it: $download\n$s2$s1";
if ($update_url) {
$vs .=
"-- %URL% is now $bdownload (/short shortens, /url opens)\n";
$urlshort = $bdownload;
}
return $vs;
}
($inversion =~/^(\d+\.\d+)\.(\d+)$/) && ($maj = 0+$1,
$min = 0+$2);
if (0+$TTYtter_VERSION < $maj ||
(0+$TTYtter_VERSION == $maj &&
$TTYtter_PATCH_VERSION < $min)) {
$vs .=
"** NEWER TTYtter VERSION NOW AVAILABLE: $inversion **\n" .
"** get it: $download\n$s2$s1";
if ($update_url) {
$vs .=
"-- %URL% is now $download (/short shortens, /url opens)\n";
$urlshort = $download;
}
return $vs;
} elsif (0+$TTYtter_VERSION > $maj ||
(0+$TTYtter_VERSION == $maj &&
$TTYtter_PATCH_VERSION > $min)) {
$vs .=
"** unable to identify your version of TTYtter\n$s1";
} else {
$vs .=
"-- your version of TTYtter is up to date ($inversion)\n$s1";
}
}
# if we got this far, then there is no TTYtter update, but maybe a
# T:RL:T update, so we offer that as the URL
if (length($update_trlt) && $update_url) {
$urlshort = $update_trlt;
$vs .= "-- %URL% is now $urlshort (/short shortens, /url opens)\n";
}
return $vs;
}
sub generate_otabcomp {
if (scalar(@j = keys(%readline_completion))) {
# print optimized readline. include all that we
# manually specified, plus/including top @s, total 10.
@keys = sort { $readline_completion{$b} <=>
$readline_completion{$a} } @j;
$factor = $readline_completion{$keys[0]};
foreach(keys %original_readline) {
$readline_completion{$_} += $factor;
}
print $stdout "*** optimized readline:\n";
@keys = sort { $readline_completion{$b} <=>
$readline_completion{$a} } keys
%readline_completion;
@keys = @keys[0..14] if (scalar(@keys) > 15);
print $stdout "-readline=\"@keys\"\n";
}
}
sub end_me { exit; } # which falls through to, via END, ...
sub killkid {
# for streaming assistance
if ($child) {
print $stdout "\n\ncleaning up.\n";
kill $SIGHUP, $child; # warn it about shutdown
if (length($track)) {
print $stdout "*** you were tracking:\n";
print $stdout "-track='$track'\n";
}
if (length($filter)) {
print $stdout "*** your current filter expression:\n";
print $stdout "-filter='$filter'\n";
}
&generate_otabcomp;
sleep 2 if ($dostream);
kill 9, $curlpid if ($curlpid);
kill 9, $child;
}
&$shutdown unless (!$shutdown);
}
sub generate_ansi {
my $k;
$BLUE = ($ansi) ? "${ESC}[34;1m" : '';
$RED = ($ansi) ? "${ESC}[31;1m" : '';
$GREEN = ($ansi) ? "${ESC}[32;1m" : '';
$YELLOW = ($ansi) ? "${ESC}[33m" : '';
$MAGENTA = ($ansi) ? "${ESC}[35m" : '';
$CYAN = ($ansi) ? "${ESC}[36m" : '';
$EM = ($ansi) ? "${ESC}[1m" : '';
$UNDER = ($ansi) ? "${ESC}[4m" : '';
$OFF = ($ansi) ? "${ESC}[0m" : '';
foreach $k (qw(prompt me dm reply warn search list default)) {
${"colour$k"} = uc(${"colour$k"});
if (!defined($${"colour$k"})) {
print $stdout
"-- warning: bogus colour '".${"colour$k"}."'\n";
} else {
eval("\$CC$k = \$".${"colour$k"});
}
}
eval '$termrl->hook_use_ansi' if ($termrl);
}
# always POST
sub postjson {
my $url = shift;
my $postdata = shift; # add _method=DELETE for delete
my $data;
# this is copied mostly verbatim from grabjson
chomp($data = &backticks($baseagent, '/dev/null', undef, $url,
$postdata, 0, @wend));
my $k = $? >> 8;
$data =~ s/[\r\l\n\s]*$//s;
$data =~ s/^[\r\l\n\s]*//s;
if (!length($data) || $k == 28 || $k == 7 || $k == 35) {
&$exception(1, "*** warning: timeout or no data\n");
return undef;
}
# old non-JSON based error reporting code still supported
if ($data =~ /^\[?\]?<!DOCTYPE\s+html/i || $data =~ /^(Status:\s*)?50[0-9]\s/ || $data =~ /^<html>/i || $data =~ /^<\??xml\s+/) {
print $stdout $data if ($superverbose);
if (&is_fail_whale($data)) {
&$exception(2, "*** warning: Twitter Fail Whale\n");
} else {
&$exception(2, "*** warning: Twitter error message received\n" .
(($data =~ /<title>Twitter:\s*([^<]+)</) ?
"*** \"$1\"\n" : ''));
}
return undef;
}
if ($data =~ /^rate\s*limit/i) {
print $stdout $data if ($superverbose);
&$exception(3,
"*** warning: exceeded API rate limit for this interval.\n" .
"*** no updates available until interval ends.\n");
return undef;
}
if ($k > 0) {
&$exception(4,
"*** warning: unexpected error code ($k) from user agent\n");
return undef;
}
# handle things like 304, or other things that look like HTTP
# error codes
if ($data =~ m#^HTTP/\d\.\d\s+(\d+)\s+#) {
$code = 0+$1;
print $stdout $data if ($superverbose);
# 304 is actually a cop-out code and is not usually
# returned, so we should consider it a non-fatal error
if ($code == 304 || $code == 200 || $code == 204) {
&$exception(1, "*** warning: timeout or no data\n");
return undef;
}
&$exception(4,
"*** warning: unexpected HTTP return code $code from server\n");
return undef;
}
# test for error/warning conditions with trivial case
if ($data =~ /^\s*\{\s*(['"])(warning|error)\1\s*:\s*\1([^\1]*?)\1/s
|| $data =~ /(['"])(warning|error)\1\s*:\s*\1([^\1]*?)\1\}/s) {
print $stdout $data if ($superverbose);
&$exception(2, "*** warning: server $2 message received\n" .
"*** \"$3\"\n");
return undef;
}
return &parsejson($data);
}
# always GET
sub grabjson {
my $data;
my $url = shift;
my $last_id = shift;
my $is_anon = shift;
my $count = shift;
my $tag = shift;
my $kludge_search_api_adjust = 0;
my $my_json_ref = undef; # durrr hat go on foot
my $i;
my $tdata;
my $seed;
#undef $/; $data = <STDIN>;
# we may need to sort our args for more flexibility here.
my @xargs = (); my $i = index($url, "?");
if ($i > -1) {
# throw an error if "?" is at the end.
push(@xargs, split(/\&/, substr($url, ($i+1))));
$url = substr($url, 0, $i);
}
# count needs to be removed for the default case due to show, etc.
push(@xargs, "count=$count") if ($count);
# timeline control. this speeds up parsing since there's less data.
# can't use skip_user: no SN
push (@xargs, "since_id=${last_id}") if ($last_id);
my $resource = (scalar(@xargs)) ?
[ $url, join('&', sort @xargs) ] : $url;
chomp($data = &backticks($baseagent,
'/dev/null', undef, $resource, undef,
$is_anon + $anonymous, @wind));
my $k = $? >> 8;
$data =~ s/[\r\l\n\s]*$//s;
$data =~ s/^[\r\l\n\s]*//s;
if (!length($data) || $k == 28 || $k == 7 || $k == 35) {
&$exception(1, "*** warning: timeout or no data\n");
return undef;
}
# old non-JSON based error reporting code still supported
if ($data =~ /^\[?\]?<!DOCTYPE\s+html/i || $data =~ /^(Status:\s*)?50[0-9]\s/ || $data =~ /^<html>/i || $data =~ /^<\??xml\s+/) {
print $stdout $data if ($superverbose);
if (&is_fail_whale($data)) {
&$exception(2, "*** warning: Twitter Fail Whale\n");
} else {
&$exception(2, "*** warning: Twitter error message received\n" .
(($data =~ /<title>Twitter:\s*([^<]+)</) ?
"*** \"$1\"\n" : ''));
}
return undef;
}
if ($data =~ /^rate\s*limit/i) {
print $stdout $data if ($superverbose);
&$exception(3,
"*** warning: exceeded API rate limit for this interval.\n" .
"*** no updates available until interval ends.\n");
return undef;
}
if ($k > 0) {
&$exception(4,
"*** warning: unexpected error code ($k) from user agent\n");
return undef;
}
# handle things like 304, or other things that look like HTTP
# error codes
if ($data =~ m#^HTTP/\d\.\d\s+(\d+)\s+#) {
$code = 0+$1;
print $stdout $data if ($superverbose);
# 304 is actually a cop-out code and is not usually
# returned, so we should consider it a non-fatal error
if ($code == 304 || $code == 200 || $code == 204) {
&$exception(1, "*** warning: timeout or no data\n");
return undef;
}
&$exception(4,
"*** warning: unexpected HTTP return code $code from server\n");
return undef;
}
# test for error/warning conditions with trivial case
if ($data =~ /^\s*\{\s*(['"])(warning|error)\1\s*:\s*\1([^\1]*?)\1/s
|| $data =~ /(['"])(warning|error)\1\s*:\s*\1([^\1]*?)\1\}/s) {
print $stdout $data if ($superverbose);
&$exception(2, "*** warning: server $2 message received\n" .
"*** \"$3\"\n");
return undef;
}
# THIS IS A TEMPORARY KLUDGE for API issue #26
# http://code.google.com/p/twitter-api/issues/detail?id=26
if ($data =~ s/Couldn't find Status with ID=[0-9]+,//) {
print $stdout ">>> cfswi sucky kludge tripped <<<\n"
if ($superverbose);
}
# if wrapped in results object, unwrap it (@kellyterryjones)
# (and tag it to do more later)
if ($data =~ s/^(\{.+,|\{)\s*['"]results['"]\s*:\s*(\[.*\]).*$/$2/isg) {
$kludge_search_api_adjust = 1;
}
$my_json_ref = &parsejson($data);
# normalize the data into a standard form.
# single tweets such as from statuses/show aren't arrays, so
# we special-case for them.
if (defined($my_json_ref) && ref($my_json_ref) eq 'HASH' &&
$my_json_ref->{'favorited'} &&
$my_json_ref->{'source'} &&
((0+$my_json_ref->{'id'}) ||
length($my_json_ref->{'id_str'}))) {
$my_json_ref = &normalizejson($my_json_ref);
}
if (defined($my_json_ref) && ref($my_json_ref) eq 'ARRAY') {
foreach $i (@{ $my_json_ref }) {
$i = &normalizejson($i,$kludge_search_api_adjust,$tag);
}
}
$laststatus = 0;
return $my_json_ref;
}
# takes a tweet structure and normalizes it according to settings.
# what this currently does is the following gyrations:
# - if there is no id_str, see if we can convert id into one. if
# there is loss of precision, warn the user. same for
# in_reply_to_status_id_str.
# - if the source of this JSON data source is the Search API, translate
# its fields into the standard API.
# - if the calling function has specified a tag, tag the tweets, since
# we're iterating through them anyway. the tag should be a hashref payload.
# - if the tweet is an newRT, unwrap it so that the full tweet text is
# revealed (unless -nonewrts).
# - if this appears to be a tweet, put in a stub geo hash if one does
# not yet exist.
# - if coordinates are flat string 'null', turn into a real null.
# one day I would like this code to go the hell away.
sub normalizejson {
my $i = shift;
my $kludge_search_api_adjust = shift;
my $tag = shift;
my $rt;
# tag the tweet
$i->{'tag'} = $tag if (defined($tag));
# id -> id_str if needed
if (!length($i->{'id_str'})) {
my $k = "" + (0 + $i->{'id'});
if ($k !~ /[eE][+-]/) {
$i->{'id_str'} = $k;
} else {
# desperately try to convert
$k =~ s/[eE][+-]\d+$//;
$k =~ s/\.//g;
# this is a hack, so we warn.
&$exception(13,
"*** impending doom: ID overflows Perl precision; stubbed to $k\n");
$i->{'id_str'} = $k;
}
}
# irtsid -> irtsid_str (if there is one)
if (!length($i->{'in_reply_to_status_id_str'}) &&
$i->{'in_reply_to_status_id'}) {
my $k = "" + (0+$i->{'in_reply_to_status_id'});
if ($k !~ /[eE][+-]/) {
$i->{'in_reply_to_status_id_str'} = $k;
} else {
# desperately try to convert
$k =~ s/[eE][+-]\d+$//;
$k =~ s/\.//g;
# this is a hack, so we warn.
&$exception(13,
"*** impending doom: IRT-ID overflows Perl precision; stubbed to $k\n");
$i->{'in_reply_to_status_id_str'} = $k;
}
}
# normalize geo. if this has a source and it has a
# favorited, then it is probably a tweet and we will
# add a stub geo hash if one doesn't exist yet.
if ($kludge_search_api_adjust ||
($i->{'favorited'} && $i->{'source'})){
$i = &fix_geo_api_data($i);
}
# normalize Search
if ($kludge_search_api_adjust) {
# hopefully this hack can die with API v2.
$i->{'class'} = "search";
$i->{'user'}->{'screen_name'} =
$i->{'from_user'};
# translate time stamps
# Fri Mar 20 13:18:18 +0000 2009 (twitter) vs
# Fri, 20 Mar 2009 16:35:56 +0000 (search)
$i->{'created_at'} =~
s/(...), (..) (...) (....) (..:..:..) (.....)/\1 \3 \2 \5 \6 \4/;
}
# normalize newRTs
# if we get newRTs with -nonewrts, oh well
if (!$nonewrts && ($rt = $i->{'retweeted_status'})) {
# reconstruct the RT in a "canonical" format
# without truncation
$i->{'text'} =
"RT \@$rt->{'user'}->{'screen_name'}" . ': ' . $rt->{'text'};
}
return $i;
}
# process the JSON data ... simplemindedly, because I just write utter crap,
# am not a professional programmer, and don't give a flying fig whether
# kludges suck or no. this used to be part of grabjson, but I split it out.
sub parsejson {
my $data = shift;
my $my_json_ref = undef; # durrr hat go on foot
my $i;
my $tdata;
my $seed;
my $bbqqmask;
my $ddqqmask;
my $ssqqmask;
# test for single logicals
return {
'ok' => 1,
'result' => (($1 eq 'true') ? 1 : 0),
'literal' => $1,
} if ($data =~ /^['"]?(true|false)['"]?$/);
# first isolate escaped backslashes with a unique sequence.
$bbqqmask = "BBQQ";
$seed = 0;
$seed++ while ($data =~ /$bbqqmask$seed/);
$bbqqmask .= $seed;
$data =~ s/\\\\/$bbqqmask/g;
# next isolate escaped quotes with another unique sequence.
$ddqqmask = "DDQQ";
$seed = 0;
$seed++ while ($data =~ /$ddqqmask$seed/);
$ddqqmask .= $seed;
$data =~ s/\\\"/$ddqqmask/g;
# then turn literal ' into another unique sequence. you'll see
# why momentarily.
$ssqqmask = "SSQQ";
$seed = 0;
$seed++ while ($data =~ /$ssqqmask$seed/);
$ssqqmask .= $seed;
$data =~ s/\'/$ssqqmask/g;
# here's why: we're going to turn doublequoted strings into single
# quoted strings to avoid nastiness like variable interpolation.
$data =~ s/\"/\'/g;
# and then we're going to turn the inline ones all back except
# ssqq, which we'll do last so that our syntax checker still works.
$data =~ s/$bbqqmask/\\\\/g;
$data =~ s/$ddqqmask/"/g;
print $stdout "$data\n" if ($superverbose);
# trust, but verify. I'm sure twitter wouldn't send us malicious
# or bogus JSON, but one day this might talk to something that would.
# in particular, need to make sure nothing in this will eval badly or
# run arbitrary code. that would really suck!
# first, generate a syntax tree.
$tdata = $data;
1 while $tdata =~ s/'[^']*'//; # empty strings are valid too ...
$tdata =~ s/-?[0-9]+\.?[0-9]*([eE][+-][0-9]+)?//g;
# have to handle floats *and* their exponents
$tdata =~ s/(true|false|null)//g;
$tdata =~ s/\s//g;
print $stdout "$tdata\n" if ($superverbose);
# now verify the syntax tree.
# the remaining stuff should just be enclosed in [ ], and only {}:,
# for example, imagine if a bare semicolon were in this ...
if ($tdata !~ s/^\[// || $tdata !~ s/\]$// || $tdata =~ /[^{}:,]/) {
$tdata =~ s/'[^']*$//; # cut trailing strings
if (($tdata =~ /^\[/ && $tdata !~ /\]$/)
|| ($tdata =~ /^\{/ && $tdata !~ /\}$/)) {
# incomplete transmission
&$exception(10, "*** JSON warning: connection cut\n");
return undef;
}
# it seems that :[], or :[]} should be accepted as valid in the syntax tree
# since identica uses this as possible for null properties
# ,[], shouldn't be, etc.
if ($tdata =~ /(^|[^:])\[\]($|[^},])/) { # oddity
&$exception(11, "*** JSON warning: null list\n");
return undef;
}
# total failure should fail hard, because this indicates an
# absolutely serious error at this stage (all traps failed)
&screech
("$data\n$tdata\nJSON IS UNSAFE TO EXECUTE! BAILING OUT!\n")
if ($tdata =~ /[^\[\]\{\}:,]/);
}
# syntax tree passed, so let's turn it into a Perl reference.
# have to turn colons into ,s or Perl will gripe. but INTELLIGENTLY!
1 while
($data =~ s/([^'])'\s*:\s*(true|false|null|\'|\{|\[|-?[0-9])/\1\',\2/);
# finally, single quotes, just before interpretation.
$data =~ s/$ssqqmask/\\'/g;
# now somewhat validated, so safe (?) to eval() into a Perl struct
eval "\$my_json_ref = $data;";
print $stdout "$data => $my_json_ref $@\n" if ($superverbose);
# do a sanity check
&screech("$data\n$tdata\nJSON could not be parsed: $@\n")
if (!defined($my_json_ref));
return $my_json_ref;
}
sub fix_geo_api_data {
my $ref = shift;
$ref->{'geo'}->{'coordinates'} = undef
if ($ref->{'geo'}->{'coordinates'} eq 'null' ||
$ref->{'geo'}->{'coordinates'}->[0] eq '' ||
$ref->{'geo'}->{'coordinates'}->[1] eq '');
$ref->{'geo'}->{'coordinates'} ||= [ "undef", "undef" ];
return $ref;
}
sub is_fail_whale {
# is this actually the dump from a fail whale?
my $data = shift;
return ($data =~ m#<title>Twitter.+Over.+capacity.*</title>#i ||
$data =~ m#[\r\l\n\s]*DB_DataObject Error: Connect failed#s);
}
sub is_json_error {
# is this actually a JSON error message? if so, extract it
my $data = shift;
if ($data =~ /(['"])(warning|errors?)\1\s*:\s*\1([^\1]*?)\1\}/s) {
my $probe = $3;
if ($data =~ /^\s*\{/s) { # JSON object?
my $dref = &parsejson($data);
return $dref->{'error'} if (length($dref->{'error'}));
return (split(/\\n/, $dref->{'errors'}))[0]
if(length($dref->{'errors'}));
}
return $probe;
}
return undef;
}
sub backticks {
# more efficient/flexible backticks system
my $comm = shift;
my $rerr = shift;
my $rout = shift;
my $resource = shift;
my $data = shift;
my $dont_do_auth = shift;
my $buf = '';
my $undersave = $_;
my $pid;
my $args;
($comm, $args, $data) = &$stringify_args($comm, $resource,
$data, $dont_do_auth, @_);
print $stdout "$comm\n$args\n$data\n" if ($superverbose);
if(open(BACTIX, '-|')) {
while(<BACTIX>) {
$buf .= $_;
} close(BACTIX);
$_ = $undersave;
return $buf; # and $? is still in $?
} else {
$in_backticks = 1;
&sigify(sub {
die(
"** user agent not honouring timeout (caught by sigalarm)\n");
}, qw(ALRM));
alarm 120; # this should be sufficient
if (length($rerr)) {
close(STDERR);
open(STDERR, ">$rerr");
}
if (length($rout)) {
close(STDOUT);
open(STDOUT, ">$rout");
}
if(open(FRONTIX, "|$comm")) {
print FRONTIX "$args\n";
print FRONTIX "$data" if (length($data));
close(FRONTIX);
} else {
die(
"backticks() failure for $comm $rerr $rout @_: $!\n");
}
$rv = $? >> 8;
exit $rv;
}
}
sub wherecheck {
my ($prompt, $filename, $fatal) = (@_);
my (@paths) = split(/\:/, $ENV{'PATH'});
my $setv = '';
push(@paths, '/usr/bin'); # the usual place
@paths = ('') if ($filename =~ m#^/#); # for absolute paths
print $stdout "$prompt ... " unless ($silent);
foreach(@paths) {
if (-r "$_/$filename") {
$setv = "$_/$filename";
1 while $setv =~ s#//#/#;
print $stdout "$setv\n" unless ($silent);
last;
}
}
if (!length($setv)) {
print $stdout "not found.\n";
if ($fatal) {
print $stdout $fatal;
exit(1);
}
}
return $setv;
}
sub screech {
print $stdout "\n\n${BEL}${BEL}@_";
if ($is_background) {
kill 9, $parent;
kill 9, $$;
} elsif ($child) {
kill 9, $child;
kill 9, $$;
}
die("death not achieved conventionally");
}
sub descape {
my $x = shift;
my $mode = shift;
$x =~ s#\\/#/#g;
# try to do something sensible with unicode
if ($mode) { # this probably needs to be revised
$x =~ s/\\u([0-9a-fA-F]{4})/"&#" . hex($1) . ";"/eg;
} else {
# intermediate form if HTML entities get in
$x =~ s/\&\#([0-9]+);/'\u' . sprintf("%04x", $1)/eg;
$x =~ s/\\u202[89]/\\n/g;
# canonicalize Unicode whitespace
1 while ($x =~ s/\\u(00[aA]0)/ /g);
1 while ($x =~ s/\\u(200[0-9aA])/ /g);
1 while ($x =~ s/\\u(20[25][fF])/ /g);
if ($seven) {
# known UTF-8 entities (char for char only)
$x =~ s/\\u201[89]/\'/g;
$x =~ s/\\u201[cCdD]/\"/g;
# 7-bit entities (32-126) also ok
$x =~ s/\\u00([2-7][0-9a-fA-F])/chr(((hex($1)==127)?46:hex($1)))/eg;
# dot out the rest
$x =~ s/\\u([0-9a-fA-F]{4})/./g;
$x =~ s/[\x80-\xff]/./g;
} else {
# try to promote to UTF-8
&$utf8_decode($x);
# Twitter uses UTF-16 for high code points, which
# Perl's UTF-8 support does not like as surrogates.
# try to decode these here; they are always back-to-
# back surrogates of the form \uDxxx\uDxxx
$x =~
s/\\u([dD][890abAB][0-9a-fA-F]{2})\\u([dD][cdefCDEF][0-9a-fA-F]{2})/&deutf16($1,$2)/eg;
# decode the rest
$x =~ s/\\u([0-9a-fA-F]{4})/chr(hex($1))/eg;
$x = &uforcemulti($x);
}
$x =~ s/\"/"/g;
$x =~ s/\'/'/g;
$x =~ s/\</\</g;
$x =~ s/\>/\>/g;
$x =~ s/\&/\&/g;
}
if ($newline) {
$x =~ s/\\n/\n/sg;
$x =~ s/\\r//sg;
}
return $x;
}
# used by descape: turn UTF-16 surrogates into a Unicode character
sub deutf16 {
my $one = hex(shift);
my $two = hex(shift);
# subtract 55296 from $one to yield top ten bits
$one -= 55296; # $d800
# subtract 56320 from $two to yield bottom ten bits
$two -= 56320; # $dc00
# experimentally, Twitter uses this endianness below (we have no BOM)
# see RFC 2781 4.3
return chr(($one << 10) + $two + 65536);
}
sub max { return ($_[0] > $_[1]) ? $_[0] : $_[1]; }
sub min { return ($_[0] < $_[1]) ? $_[0] : $_[1]; }
sub prolog { my $k = shift;
return "" if (!scalar(@_));
my $l = shift; return (&$k($l) . &$k(@_)); }
# this is mostly a utility function for /eval. it is a recursive descent
# pretty printer.
sub a {
my $w;
my $x;
return '' if(scalar(@_) < 1);
if(scalar(@_) > 1) { $x = "(";
foreach $w (@_) {
$x .= &a($w);
}
return $x."), ";
}
$w = shift;
if(ref($w) eq 'SCALAR') { return "\\\"". $$w . "\", "; }
if(ref($w) eq 'HASH') { my %m = %{ $w };
return "\n\t{".&prolog(\&a, %m)."}, "; }
if(ref($w) eq 'ARRAY') { return "\n\t[".&prolog(\&a, @{ $w })."], "; }
return "\"$w\", ";
}
sub ssa { return (scalar(@_) ? ("('" . join("', '", @_) . "')") : "NULL"); }
sub strim { my $x=shift; $x=~ s/^\s+//; $x=~ s/\s+$//; return $x; }
sub wwrap {
return shift if (!$wrap);
my $k;
my $klop = ($wrap > 1) ? $wrap : ($ENV{'COLUMNS'} || 79);
$klop--; # don't ask me why
my $lop;
my $buf = '';
my $string = shift;
my $indent = shift; # for very first time with the prompt
my $needspad = 0;
my $stringpad = " " x 3;
$indent += 4; # for the menu select string
$lop = $klop - $indent;
$lop -= $indent;
W: while($k = length($string)) {
$lop += $indent if ($lop < $klop);
($buf .= $string, last W) if ($k <= $lop && $string !~ /\n/);
($string =~ s/^\s*\n//) && ($buf .= "\n",
$needspad = 1,
next W);
if ($needspad) {
$string = " $string";
$needspad = 0;
}
# I don't know if people will want this, so it's commented out.
#($string =~ s#^(http://[^\s]+)# #) && ($buf .= "$1\n",
# next W);
($string =~ s/^(.{4,$lop})\s/ /) && ($buf .= "$1\n",
next W); # i.e., at least one char, plus 3 space indent
($string =~ s/^(.{$lop})/ /) && ($buf .= "$1\n",
next W);
warn
"-- pathologic string somehow failed wordwrap! \"$string\"\n";
return $buf;
}
1 while ($buf =~ s/\n\n\n/\n\n/s); # mostly paranoia
$buf =~ s/[ \t]+$//;
return $buf;
}
# these subs look weird, but they're encoding-independent and run anywhere
sub uforcemulti { # forces multi-byte interpretation by abusing Perl
my $x = shift;
return $x if ($seven);
$x = "\x{263A}".$x;
return pack("${pack_magic}H*", substr(unpack("${pack_magic}H*",$x),6));
}
sub ulength { my @k; return (scalar(@k = unpack("${pack_magic}C*", shift))); }
sub uhex {
# URL-encode an arbitrary string, even UTF-8
# more versatile than the miniature one in &updatest
my $k = '';
my $s = shift;
&$utf8_encode($s);
foreach(split(//, $s)) {
my $j = unpack("H256", $_);
while(length($j)) {
$k .= '%' . substr($j, 0, 2);
$j = substr($j, 2);
}
}
return $k;
}
# take a string and return up to $linelength CHARS plus the rest.
sub csplit { return &cosplit(@_, sub { return length(shift); }); }
# take a string and return up to $linelength BYTES plus the rest.
sub usplit { return &cosplit(@_, sub { return &ulength(shift); }); }
sub cosplit {
# this is the common code for &csplit and &usplit.
# this is tricky because we don't want to split up UTF-8 sequences, so
# we let Perl do the work since it internally knows where they end.
my $orig_k = shift;
my $mode = shift;
my $lengthsub = shift;
my $z;
my @m;
my $q;
my $r;
$mode += 0;
$k = $orig_k;
# optimize whitespace
$k =~ s/^\s+//;
$k =~ s/\s+$//;
$k =~ s/\s+/ /g;
$z = &$lengthsub($k);
return ($k) if ($z <= $linelength); # also handles the trivial case
# this needs to be reply-aware, so we put @'s at the beginning of
# the second half too (and also Ds for DMs)
$r .= $1 if ($k =~ s/^(\@[^\s]+\s)\s*// ||
$k =~ s/^(D\s+[^\s]+\s)\s*//); # not while -- just one
$k = "$r$k";
my $i = $linelength;
$i-- while(($z = &$lengthsub($q = substr($k, 0, $i))) > $linelength);
$m = substr($k, $i);
# if we just wanted split-on-byte, return now (mode = 1)
if ($mode) {
# optimize again in case we split on whitespace
$q =~ s/\s+$//;
$m =~ s/^\s+//;
return ($q, "$r$m");
}
# else try to do word boundary and cut even more
if (!$autosplit) { # use old mechanism first: drop trailing non-alfanum
($q =~ s/([^a-zA-Z0-9]+)$//) && ($m = "$1$m");
# optimize again in case we split on whitespace
$q =~ s/\s+$//;
return (&cosplit($orig_k, 1, $lengthsub))
if (!length($q) && !$mode);
# it totally failed. fall back on charsplit.
if (&$lengthsub($q) < $linelength) {
$m =~ s/^\s+//;
return($q, "$r$m")
}
}
($q =~ s/\s+([^\s]+)$//) && ($m = "$1$m");
return (&cosplit($orig_k, 1, $lengthsub)) if (!length($q) && !$mode);
# it totally failed. fall back on charsplit.
return ($q, "$r$m");
}
### OAuth methods, including our own homegrown SHA-1 and HMAC ###
### no Digest:* required! ###
### these routines are not byte-safe and need a use bytes; before you call ###
# this is a modified, deciphered and deobfuscated version of the famous Perl
# one-liner SHA-1 written by John Allen. hope he doesn't mind.
sub sha1 {
my $string = shift;
print $stdout "string length: @{[ length($string) ]}\n"
if ($showwork);
my $constant = "D9T4C`>_-JXF8NMS^\$#)4=L/2X?!:\@GF9;MGKH8\\;O-S*8L'6";
my @A = unpack('N*', unpack('u', $constant));
my @K = splice(@A, 5, 4);
my $M = sub { # 64-bit warning
my $x;
my $m;
($x = pop @_) - ($m=4294967296) * int($x / $m);
};
my $L = sub { # 64-bit warning
my $n = pop @_;
my $x;
((($x = pop @_) << $n) | ((2 ** $n - 1) & ($x >> 32 - $n))) &
4294967295;
};
my $l = '';
my $r;
my $a;
my $b;
my $c;
my $d;
my $e;
my $us;
my @nuA;
my $p = 0;
$string = unpack("H*", $string);
do {
my $i;
$us = substr($string, 0, 128);
$string = substr($string, 128);
$l += $r = (length($us) / 2);
print $stdout "pad length: $r\n" if ($showwork);
($r++, $us .= "80") if ($r < 64 && !$p++);
my @W = unpack('N16', pack("H*", $us) . "\000" x 7);
$W[15] = $l * 8 if ($r < 57);
foreach $i (16 .. 79) {
push(@W,
&$L($W[$i - 3] ^ $W[$i - 8] ^ $W[$i - 14] ^ $W[$i - 16], 1));
}
($a, $b, $c, $d, $e) = @A;
foreach $i (0 .. 79) {
my $qq = ($i < 20) ? ($b & ($c ^ $d) ^ $d) :
($i < 40) ? ($b ^ $c ^ $d) :
($i < 60) ? (($b | $c) & $d | $b & $c) :
($b ^ $c ^ $d);
$t = &$M($qq + $e + $W[$i] + $K[$i / 20] + &$L($a, 5));
$e = $d;
$d = $c;
$c = &$L($b, 30);
$b = $a;
$a = $t;
}
@nuA = ($a, $b, $c, $d, $e);
print $stdout "$a $b $c $d $e\n" if ($showwork);
$i = 0;
@A = map({ &$M($_ + $nuA[$i++]); } @A);
} while ($r > 56);
my $x = sprintf('%.8x' x 5, @A);
@A = unpack("C*", pack("H*", $x));
return($x, @A);
}
# heavily modified from MIME::Base64
sub simple_encode_base64 {
my $result = '';
my $input = shift;
pos($input) = 0;
while($input =~ /(.{1,45})/gs) {
$result .= substr(pack("u", $1), 1);
chop($result);
}
$result =~ tr|` -_|AA-Za-z0-9+/|;
my $padding = (3 - length($input) % 3) % 3;
$result =~ s/.{$padding}$/("=" x $padding)/e if ($padding);
return $result;
}
# from RFC 2104/RFC 2202
sub hmac_sha1 {
my $message = shift;
my @key = (@_);
my $opad;
my $ipad;
my $i;
my @j;
# sha1 blocksize is 512, so key should be 64 bytes
print $stdout " KEY HASH \n" if ($showwork);
($i, @key) = &sha1(pack("C*", @key)) while (scalar(@key) > 64);
push(@key, 0) while(scalar(@key) < 64);
$opad = pack("C*", map { ($_ ^ 92) } @key);
$ipad = pack("C*", map { ($_ ^ 54) } @key);
print $stdout " MESSAGE HASH \n" if ($showwork);
($i, @j) = &sha1($ipad . $message);
print $stdout " FINAL HASH \n" if ($showwork);
$i = pack("C*", @j); # output hash is 160 bits
($i, @j) = &sha1($opad . $i);
$i = &simple_encode_base64(pack("C20", @j));
return $i;
}
# simple encoder for OAuth modified URL encoding (used for lots of things,
# actually)
# this is NOT UTF-8 safe
sub url_oauth_sub {
my $x = shift;
$x =~ s/([^-0-9a-zA-Z._~])/"%".uc(unpack("H2",$1))/eg; return $x;
}
# default method of getting password: ask for it. only relevant for Basic Auth,
# which is no longer the default.
sub defaultgetpassword {
# original idea by @jcscoobyrs, heavily modified
my $k;
my $l;
my $pass;
$l = "no termios; password WILL";
if ($termios) {
$termios->getattr(fileno($stdin));
$k = $termios->getlflag;
$termios->setlflag($k ^ &POSIX::ECHO);
$termios->setattr(fileno($stdin));
$l = "password WILL NOT";
}
print $stdout "enter password for $whoami ($l be echoed): ";
chomp($pass = <$stdin>);
if ($termios) {
print $stdout "\n";
$termios->setlflag($k);
$termios->setattr(fileno($stdin));
}
return $pass;
}
# this returns an immutable token corresponding to the current authenticated
# session. in the case of Basic Auth, it is simply the user:password pair.
# it does not handle OAuth -- that is run by a separate wizard.
# the function then returns (token,secret) which for Basic Auth is token,undef.
# most of the time we will be using tokens in a keyfile, however, so this
# function runs in that case as a stub.
sub authtoken {
my @foo;
my $pass;
my $sig;
my $return;
my $tries = ($hold > 3) ? $hold : 3;
# give up on token if we don't get one
return (undef,undef) if ($anonymous);
return ($tokenkey,$tokensecret)
if (length($tokenkey) && length($tokensecret));
@foo = split(/:/, $user, 2);
$whoami = $foo[0];
die("choose -user=username[:password], or -anonymous.\n")
if (!length($whoami) || $whoami eq '1');
$pass = length($foo[1]) ? $foo[1] : &$getpassword;
die("a password must be specified.\n") if (!length($pass));
return ($whoami, $pass);
}
# this is a sucky nonce generator. I was looking for an awesome nonce
# generator, and then I realized it would only be used once, so who cares?
# *rimshot*
sub generate_nonce { unpack("H9000", pack("u", rand($$).$$.time())); }
# this signs a request with the token and token secret. the result is undef if
# Basic Auth. payload should already be URL encoded and *sorted*.
# this is typically called by stringify_args to get authentication information.
sub signrequest {
# this horrible kludge is needed to account for both 5.005, or for
# 5.6+ installs with no stdlibs and just a bare Perl, both of which
# we support. I hope Larry Wall will forgive me for messing with
# compiler internals next time I see him at church.
BEGIN { $^H |= 0x00000008 unless ($] < 5.006); }
my $resource = shift;
my $payload = shift;
# when we sign the initial request for an token, we obviously
# don't have one yet, so mytoken/mytokensecret can be null.
my $nonce = &generate_nonce;
my @keybytes;
my $sig_base;
my $timestamp = time();
return undef if ($authtype eq 'basic');
# stub for oAuth 2.0
return undef if (!length($oauthkey) || !length($oauthsecret));
(@keybytes) = map { ord($_) }
split(//, $oauthsecret.'&'.$mytokensecret);
if (ref($resource) eq 'ARRAY' || length($payload)) {
# split into _a and _b payloads lexically
my $payload_a = '';
my $payload_b = '';
my $payload_c = ''; # this is for a special case
my $w;
my $aorb = 0;
my $verifier = '';
my $method = "GET";
my $url;
if (length($payload)) {
$method = "POST";
# this is a bit problematic since it won't be
# sorted. we'll deal with this as we need to.
if (ref($resource) eq 'ARRAY') {
$url = &url_oauth_sub($resource->[0]);
$payload .= "&" . $resource->[1];
} else {
$url = &url_oauth_sub($resource);
}
} elsif (ref($resource) eq 'ARRAY') {
$url = &url_oauth_sub($resource->[0]);
$payload = $resource->[1];
} else {
$url = &url_oauth_sub($resource);
}
# this is pretty simplistic but it's really all we need.
# the exception is oauth_verifier: that has to be wormed
# into the middle, and we assume it's just that.
if ($payload !~ /^oauth_verifier/) {
foreach $w (split(/\&/, $payload)) {
$aorb = 1 if
($w =~ /^[p-z]/ || $w =~ /^o[b-z]/);
$w = &url_oauth_sub("${w}&");
if ($aorb) {
$payload_b .= $w;
} else {
$payload_a .= $w;
}
}
} else {
$payload_c = &url_oauth_sub($payload) . "%26";
$payload_a = $payload_b = '';
$payload =~ s/^oauth_verifier=//;
$verifier = ' oauth_verifier=\\"' . $payload . '\\",';
}
$payload_b =~ s/%26$//;
$sig_base = $method . "&" .
$url . "&" .
(length($payload_a) ? $payload_a : '').
"oauth_consumer_key%3D" . $oauthkey . "%26" .
"oauth_nonce%3D" . $nonce . "%26" .
"oauth_signature_method%3DHMAC-SHA1%26" .
"oauth_timestamp%3D" . $timestamp . "%26" .
(length($mytoken) ?
("oauth_token%3D" . $mytoken . "%26") : '') .
$payload_c .
"oauth_version%3D1.0" .
(length($payload_b) ? ("%26" . $payload_b) : '');
} else {
$sig_base = "GET&" .
&url_oauth_sub($resource) . "&" .
"oauth_consumer_key%3D" . $oauthkey . "%26" .
"oauth_nonce%3D" . $nonce . "%26" .
"oauth_signature_method%3DHMAC-SHA1%26" .
"oauth_timestamp%3D" . $timestamp . "%26" .
(length($mytoken) ?
("oauth_token%3D" . $mytoken . "%26") : '') .
$payload_c . # could be part of it
"oauth_version%3D1.0" ;
}
print $stdout
"token-secret: $mytokensecret\nconsumer-secret: $oauthsecret\nsig-base: $sig_base\n"
if ($superverbose);
return ($timestamp, $nonce,
&url_oauth_sub(&hmac_sha1($sig_base, @keybytes)),
$verifier);
}
# this takes a token request and "tries hard" to get it.
sub tryhardfortoken {
my $url = shift;
my $body = shift;
my $tries = shift;
my $rawtoken;
$tries ||= 3;
while($tries) {
my $i;
$rawtoken = &backticks($baseagent, '/dev/null', undef,
$url, $body, 0, @wend);
print $stdout ("token = $rawtoken\n")
if ($superverbose);
my (@keyarr) = split(/\&/, $rawtoken);
my $got_token = '';
my $got_secret = '';
foreach $i (@keyarr) {
my $key;
my $value;
($key, $value) = split(/\=/, $i);
$got_token = $value if ($key eq 'oauth_token');
$got_secret = $value if ($key eq 'oauth_token_secret');
}
if (length($got_token) && length($got_secret)) {
print $stdout " SUCCEEDED!\n";
return ($got_token, $got_secret);
}
print $stdout ".";
$tries--;
}
print $stdout " FAILED!: \"$rawtoken\"\n";
die("unable to fetch token. here are some possible reasons:\n".
" - root certificates are not updated (see documentation)\n".
" - you entered your authentication information wrong\n".
" - your computer's clock is not set correctly\n" .
" - Twitter farted\n" .
"fix these possible problems, or try again later.\n");
exit;
}
| nestukh/dotfiles | bin/ttytter-2.0.03.pl | Perl | mit | 220,158 |
#/usr/bin/perl -w
use utf8;
binmode STDIN, ':utf8';
binmode STDOUT, ':utf8';
while (<>)
{
chomp;
@words = split(/([\s+|,|\.|:|;|\-|\[|\]|\(|\)|\?|\"|\¡|\–|\¿|\!|\/|%|…|“|”|«|»])/);
foreach (@words)
{
if (m/^\s*$/)
{ next;}
if( \$_ == \$words[-1] && $_ !~ /,|\.|:|;|\-|\[|\]|\(|\)|\?|\"|\¡|\–|\¿|\!|\/|%|…|“|”|«|»/ )
{print $_."\n#EOS\n";}
else
{print $_."\n";}
}
} | ariosquoia/squoia | treebanks/quz/scripts/tokenize_withsentPerLine.pl | Perl | apache-2.0 | 441 |
package Paws::DAX::UntagResourceResponse;
use Moose;
has Tags => (is => 'ro', isa => 'ArrayRef[Paws::DAX::Tag]');
has _request_id => (is => 'ro', isa => 'Str');
### main pod documentation begin ###
=head1 NAME
Paws::DAX::UntagResourceResponse
=head1 ATTRIBUTES
=head2 Tags => ArrayRef[L<Paws::DAX::Tag>]
The tag keys that have been removed from the cluster.
=head2 _request_id => Str
=cut
1; | ioanrogers/aws-sdk-perl | auto-lib/Paws/DAX/UntagResourceResponse.pm | Perl | apache-2.0 | 411 |
#!/usr/bin/env perl
# Pragmas.
use strict;
use warnings;
# Modules.
use Encode qw(encode_utf8);
use Mock::Person::SK::ROM qw(name);
# Error.
print encode_utf8(name())."\n";
# Output like:
# Kevin Mižigar | gitpan/Mock-Person-SK-ROM | examples/ex1.pl | Perl | bsd-2-clause | 208 |
package AsposeWordsCloud::Object::ProtectionDataResponse;
require 5.6.0;
use strict;
use warnings;
use utf8;
use JSON qw(decode_json);
use Data::Dumper;
use Module::Runtime qw(use_module);
use Log::Any qw($log);
use Date::Parse;
use DateTime;
use base "AsposeWordsCloud::Object::BaseObject";
#
#
#
#NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
#
my $swagger_types = {
'ProtectionData' => 'ProtectionData',
'DocumentLink' => 'Link',
'Code' => 'string',
'Status' => 'string'
};
my $attribute_map = {
'ProtectionData' => 'ProtectionData',
'DocumentLink' => 'DocumentLink',
'Code' => 'Code',
'Status' => 'Status'
};
# new object
sub new {
my ($class, %args) = @_;
my $self = {
#
'ProtectionData' => $args{'ProtectionData'},
#
'DocumentLink' => $args{'DocumentLink'},
#
'Code' => $args{'Code'},
#
'Status' => $args{'Status'}
};
return bless $self, $class;
}
# get swagger type of the attribute
sub get_swagger_types {
return $swagger_types;
}
# get attribute mappping
sub get_attribute_map {
return $attribute_map;
}
1;
| asposewords/Aspose_Words_Cloud | SDKs/Aspose.Words-Cloud-SDK-for-Perl/lib/AsposeWordsCloud/Object/ProtectionDataResponse.pm | Perl | mit | 1,216 |
#
# Copyright 2017 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package cloud::nutanix::snmp::mode::storagepoolusage;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use centreon::plugins::misc;
my $instance_mode;
sub custom_usage_perfdata {
my ($self, %options) = @_;
my $label = 'used';
my $value_perf = $self->{result_values}->{used};
if (defined($instance_mode->{option_results}->{free})) {
$label = 'free';
$value_perf = $self->{result_values}->{free};
}
my $extra_label = '';
$extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
my %total_options = ();
if ($instance_mode->{option_results}->{units} eq '%') {
$total_options{total} = $self->{result_values}->{total};
$total_options{cast_int} = 1;
}
$self->{output}->perfdata_add(label => $label . $extra_label, unit => 'B',
value => $value_perf,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options),
min => 0, max => $self->{result_values}->{total});
}
sub custom_usage_threshold {
my ($self, %options) = @_;
my ($exit, $threshold_value);
$threshold_value = $self->{result_values}->{used};
$threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free}));
if ($instance_mode->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_used};
$threshold_value = $self->{result_values}->{prct_free} if (defined($instance_mode->{option_results}->{free}));
}
$exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]);
return $exit;
}
sub custom_usage_output {
my ($self, %options) = @_;
my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total});
my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used});
my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free});
my $msg = sprintf("Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)",
$total_size_value . " " . $total_size_unit,
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used},
$total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free});
return $msg;
}
sub custom_usage_calc {
my ($self, %options) = @_;
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
$self->{result_values}->{total} = $options{new_datas}->{$self->{instance} . '_spitTotalCapacity'};
$self->{result_values}->{used} = $options{new_datas}->{$self->{instance} . '_spitUsedCapacity'};
$self->{result_values}->{free} = $self->{result_values}->{total} - $self->{result_values}->{used};
$self->{result_values}->{prct_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total};
$self->{result_values}->{prct_free} = 100 - $self->{result_values}->{prct_used};
return 0;
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'sp', type => 1, cb_prefix_output => 'prefix_sp_output', message_multiple => 'All storage pools are ok', skipped_code => { -10 => 1 } },
];
$self->{maps_counters}->{sp} = [
{ label => 'usage', set => {
key_values => [ { name => 'display' }, { name => 'spitUsedCapacity' }, { name => 'spitTotalCapacity' } ],
closure_custom_calc => $self->can('custom_usage_calc'),
closure_custom_output => $self->can('custom_usage_output'),
closure_custom_perfdata => $self->can('custom_usage_perfdata'),
closure_custom_threshold_check => $self->can('custom_usage_threshold'),
}
},
{ label => 'avg-latency', set => {
key_values => [ { name => 'spitAvgLatencyUsecs' }, { name => 'display' } ],
output_template => 'Average Latency : %s µs',
perfdatas => [
{ label => 'avg_latency', value => 'spitAvgLatencyUsecs_absolute', template => '%s', unit => 'µs',
min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
],
}
},
{ label => 'iops', set => {
key_values => [ { name => 'spitIOPerSecond' }, { name => 'display' } ],
output_template => 'IOPs : %s',
perfdatas => [
{ label => 'iops', value => 'spitIOPerSecond_absolute', template => '%s', unit => 'iops',
min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
],
}
},
];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"filter-name:s" => { name => 'filter_name' },
"units:s" => { name => 'units', default => '%' },
"free" => { name => 'free' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
}
sub prefix_sp_output {
my ($self, %options) = @_;
return "Storage Pool '" . $options{instance_value}->{display} . "' ";
}
my $mapping = {
spitStoragePoolName => { oid => '.1.3.6.1.4.1.41263.7.1.3' },
spitTotalCapacity => { oid => '.1.3.6.1.4.1.41263.7.1.4' },
spitUsedCapacity => { oid => '.1.3.6.1.4.1.41263.7.1.5' },
spitIOPerSecond => { oid => '.1.3.6.1.4.1.41263.7.1.6' },
spitAvgLatencyUsecs => { oid => '.1.3.6.1.4.1.41263.7.1.7' },
};
my $oid_spitEntry = '.1.3.6.1.4.1.41263.7.1';
sub manage_selection {
my ($self, %options) = @_;
if ($options{snmp}->is_snmpv1()) {
$self->{output}->add_option_msg(short_msg => "Need to use SNMP v2c or v3.");
$self->{output}->option_exit();
}
$self->{sp} = {};
my $snmp_result = $options{snmp}->get_table(oid => $oid_spitEntry,
nothing_quit => 1);
foreach my $oid (keys %{$snmp_result}) {
next if ($oid !~ /^$mapping->{spitStoragePoolName}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
$result->{spitStoragePoolName} = centreon::plugins::misc::trim($result->{spitStoragePoolName});
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
$result->{spitStoragePoolName} !~ /$self->{option_results}->{filter_name}/) {
$self->{output}->output_add(long_msg => "skipping '" . $result->{spitStoragePoolName} . "': no matching filter.", debug => 1);
next;
}
$self->{sp}->{$instance} = { display => $result->{spitStoragePoolName},
%$result,
};
}
if (scalar(keys %{$self->{sp}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No storage pool found.");
$self->{output}->option_exit();
}
}
1;
__END__
=head1 MODE
Check storage pool usage.
=over 8
=item B<--filter-counters>
Only display some counters (regexp can be used).
Example: --filter-counters='^usage$'
=item B<--filter-name>
Filter storage pool name (can be a regexp).
=item B<--warning-*>
Threshold warning.
Can be: 'usage', 'avg-latency', 'iops'.
=item B<--critical-*>
Threshold critical.
Can be: 'usage', 'avg-latency', 'iops'.
=item B<--units>
Units of thresholds (Default: '%') ('%', 'B').
=item B<--free>
Thresholds are on free space left.
=back
=cut
| Shini31/centreon-plugins | cloud/nutanix/snmp/mode/storagepoolusage.pm | Perl | apache-2.0 | 9,304 |
#!/bin/perl
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Compare PerfSuite lines in one file against those in another...
$argOne = shift( @ARGV );
$argTwo = shift( @ARGV );
$argOne =~ s/\\/\//g;
$argTwo =~ s/\\/\//g;
# Read baseline
if ( ! -f "$argOne" ) {
print "Error: No baseline file to for host, checkin appropriate testPutGetPerf.out as file $argOne\n";
exit( 1 );
}
open( FILONE, "grep PerfSuite $argOne|" ) || die( "Error: No baseline file to for host, checkin appropriate testPutGetPerf.out as file $argOne" );
while( $line = <FILONE> ) {
$line =~ m/PerfSuite\] (\w+) -- (\d+) ops/;
$key = $1;
$value = $2;
$dataone{"${key}"} = $value;
}
close( FILONE );
@tmp = keys( %dataone );
if ( $#tmp == -1 ) {
print "Error: No data found in $argOne\n";
exit( 1 );
}
# Read new results
if ( ! -f "$argTwo" ) {
print "Error: No result file from test to compare, expected $argTwo\n";
exit( 1 );
}
open( FILTWO, "grep PerfSuite $argTwo|" ) || die( "No file $argTwo" );
while( $line = <FILTWO> ) {
$line =~ m/PerfSuite\] (\w+) -- (\d+) ops/;
$key = $1;
$value = $2;
$datatwo{"${key}"} = $value;
}
close( FILTWO );
$code = 0;
@tmp = keys( %datatwo );
if ( $#tmp == -1 ) {
print "Error: No data found in $argTwo\n";
exit( 1 );
}
# display comparisons
format top =
%CHANGE TESTCASE BASELINE CURRENT
======== ============================ ======== ================
.
format STDOUT =
( @##% ) @<<<<<<<<<<<<<<<<<<<<<<<<<<< @####### @####### ops/sec
$percent, $item, $baseValue, $newValue
.
foreach $item (sort( keys( %dataone ) )) {
$change = $datatwo{"${item}"} - $dataone{"${item}"};
$percent = int( 100 * ( $change / $dataone{"${item}"} ));
$baseValue = $dataone{"${item}"};
$newValue = $datatwo{"${item}"};
write;
if ( $percent < ( -5 ) ) {
$code++;
}
}
if ( $code > 0 ) {
print "Error: $code performance cases failed by more than 5%\n";
}
exit( $code );
| PivotalSarge/geode-native | src/cppcache/integration-test/comparePerf.pl | Perl | apache-2.0 | 2,704 |
package NiHTest;
use strict;
use warnings;
use Cwd;
use File::Copy;
use File::Path qw(mkpath remove_tree);
use Getopt::Long qw(:config posix_default bundling no_ignore_case);
use IPC::Open3;
#use IPC::Cmd qw(run);
use Storable qw(dclone);
use Symbol 'gensym';
use UNIVERSAL;
#use Data::Dumper qw(Dumper);
# NiHTest -- package to run regression tests
# Copyright (C) 2002-2016 Dieter Baron and Thomas Klausner
#
# This file is part of ckmame, a program to check rom sets for MAME.
# The authors can be contacted at <ckmame@nih.at>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. The names of the authors may not be used to endorse or promote
# products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# runtest TESTNAME
#
# files:
# TESTNAME.test: test scenario
#
# test scenario:
# Lines beginning with # are comments.
#
# The following commands are recognized; return and args must
# appear exactly once, the others are optional.
#
# args ARGS
# run program with command line arguments ARGS
#
# description TEXT
# description of what test is for
#
# features FEATURE ...
# only run test if all FEATUREs are present, otherwise skip it.
#
# file TEST IN OUT
# copy file IN as TEST, compare against OUT after program run.
#
# file-del TEST IN
# copy file IN as TEST, check that it is removed by program.
#
# file-new TEST OUT
# check that file TEST is created by program and compare
# against OUT.
#
# mkdir MODE NAME
# create directory NAME with permissions MODE.
#
# precheck COMMAND ARGS ...
# if COMMAND exits with non-zero status, skip test.
#
# preload LIBRARY
# pre-load LIBRARY before running program.
#
# program PRG
# run PRG instead of ckmame.
#
# return RET
# RET is the expected exit code
#
# setenv VAR VALUE
# set environment variable VAR to VALUE.
#
# stderr TEXT
# program is expected to produce the error message TEXT. If
# multiple stderr commands are used, the messages are
# expected in the order given.
#
# stderr-replace REGEX REPLACEMENT
# run regex replacement over expected and got stderr output.
#
# stdin TEST
# Provide TEXT to program's stdin.
#
# stdin-file FILE
# pipe FILE to program's stdin.
#
# stdout TEXT
# program is expected to print TEXT to stdout. If multiple
# stdout commands are used, the messages are expected in
# the order given.
#
# touch MTIME FILE
# set last modified timestamp of FILE to MTIME (seconds since epoch).
# If FILE doesn't exist, an empty file is created.
#
# ulimit C VALUE
# set ulimit -C to VALUE while running the program.
#
# exit status
# runtest uses the following exit codes:
# 0: test passed
# 1: test failed
# 2: other error
# 77: test was skipped
#
# environment variables:
# RUN_GDB: if set, run gdb on program in test environment
# KEEP_BROKEN: if set, don't delete test environment if test failed
# NO_CLEANUP: if set, don't delete test environment
# SETUP_ONLY: if set, exit after creating test environment
# VERBOSE: if set, be more verbose (e. g., output diffs)
my %EXIT_CODES = (
PASS => 0,
FAIL => 1,
SKIP => 77,
ERROR => 99
);
# MARK: - Public API
sub new {
my $class = UNIVERSAL::isa ($_[0], __PACKAGE__) ? shift : __PACKAGE__;
my $self = bless {}, $class;
my ($opts) = @_;
$self->{default_program} = $opts->{default_program};
$self->{zipcmp} = $opts->{zipcmp} // 'zipcmp';
$self->{zipcmp_flags} = $opts->{zipcmp_flags} // '-p';
$self->{directives} = {
args => { type => 'string...', once => 1, required => 1 },
description => { type => 'string', once => 1 },
features => { type => 'string...', once => 1 },
file => { type => 'string string string' },
'file-del' => { type => 'string string' },
'file-new' => { type => 'string string' },
mkdir => { type => 'string string' },
precheck => { type => 'string...' },
preload => { type => 'string', once => 1 },
program => { type => 'string', once => 1 },
'return' => { type => 'int', once => 1, required => 1 },
setenv => { type => 'string string' },
stderr => { type => 'string' },
'stderr-replace' => { type => 'string string' },
stdin => { type => 'string' },
'stdin-file' => { type => 'string', once => 1 },
stdout => { type => 'string' },
touch => { type => 'int string' },
ulimit => { type => 'char string' }
};
$self->{compare_by_type} = {};
$self->{copy_by_type} = {};
$self->{hooks} = {};
$self->get_variable('srcdir', $opts);
$self->get_variable('top_builddir', $opts);
$self->{in_sandbox} = 0;
$self->{verbose} = $ENV{VERBOSE};
$self->{keep_broken} = $ENV{KEEP_BROKEN};
$self->{no_cleanup} = $ENV{NO_CLEANUP};
$self->{setup_only} = $ENV{SETUP_ONLY};
return $self;
}
sub add_comparator {
my ($self, $ext, $sub) = @_;
return $self->add_file_proc('compare_by_type', $ext, $sub);
}
sub add_copier {
my ($self, $ext, $sub) = @_;
return $self->add_file_proc('copy_by_type', $ext, $sub);
}
sub add_directive {
my ($self, $name, $def) = @_;
if (exists($self->{directives}->{$name})) {
$self->die("directive $name already defined");
}
# TODO: validate $def
$self->{directives}->{$name} = $def;
return 1;
}
sub add_file_proc {
my ($self, $proc, $ext, $sub) = @_;
$self->{$proc}->{$ext} = [] unless (defined($self->{$proc}->{$ext}));
unshift @{$self->{$proc}->{$ext}}, $sub;
return 1;
}
sub add_hook {
my ($self, $hook, $sub) = @_;
$self->{hooks}->{$hook} = [] unless (defined($self->{hooks}->{$hook}));
push @{$self->{hooks}->{$hook}}, $sub;
return 1;
}
sub add_variant {
my ($self, $name, $hooks) = @_;
if (!defined($self->{variants})) {
$self->{variants} = [];
$self->add_directive('variants' => { type => 'string...', once => 1 });
}
for my $variant (@{$self->{variants}}) {
if ($variant->{name} eq $name) {
$self->die("variant $name already defined");
}
}
push @{$self->{variants}}, { name => $name, hooks => $hooks };
return 1;
}
sub end {
my ($self, @results) = @_;
my $result = 'PASS';
for my $r (@results) {
if ($r eq 'ERROR' || ($r eq 'FAIL' && $result ne 'ERROR')) {
$result = $r;
}
}
$self->end_test($result);
}
sub run {
my ($self, @argv) = @_;
$self->setup(@argv);
$self->end($self->runtest());
}
sub runtest {
my ($self) = @_;
if (defined($self->{variants})) {
my @results = ();
$self->{original_test} = $self->{test};
my %variants;
if (defined($self->{test}->{variants})) {
%variants = map { $_ => 1; } @{$self->{test}->{variants}};
}
for my $variant (@{$self->{variants}}) {
next if (defined($self->{test}->{variants}) && !exists($variants{$variant->{name}}));
$self->{variant_hooks} = $variant->{hooks};
$self->{test} = dclone($self->{original_test});
$self->{variant} = $variant->{name};
$self->mangle_test_for_variant();
push @results, $self->runtest_one($variant->{name});
}
return @results;
}
else {
return $self->runtest_one();
}
}
sub runtest_one {
my ($self, $tag) = @_;
$ENV{TZ} = "UTC";
$ENV{LC_CTYPE} = "C";
$ENV{POSIXLY_CORRECT} = 1;
$self->sandbox_create($tag);
$self->sandbox_enter();
my $ok = 1;
$ok &= $self->copy_files();
$ok &= $self->run_hook('post_copy_files');
$ok &= $self->touch_files();
$ok &= $self->run_hook('prepare_sandbox');
return 'ERROR' unless ($ok);
if ($self->{setup_only}) {
$self->sandbox_leave();
return 'SKIP';
}
for my $env (@{$self->{test}->{'setenv'}}) {
$ENV{$env->[0]} = $env->[1];
}
my $preload_env_var = 'LD_PRELOAD';
if ($^O eq 'darwin') {
$preload_env_var = 'DYLD_INSERT_LIBRARIES';
}
if (defined($self->{test}->{'preload'})) {
if (-f cwd() . "/../.libs/$self->{test}->{'preload'}") {
$ENV{$preload_env_var} = cwd() . "/../.libs/$self->{test}->{'preload'}";
} else {
$ENV{$preload_env_var} = cwd() . "/../lib$self->{test}->{'preload'}";
}
}
$self->run_program();
for my $env (@{$self->{test}->{'setenv'}}) {
delete ${ENV{$env->[0]}};
}
if (defined($self->{test}->{'preload'})) {
delete ${ENV{$preload_env_var}};
}
if ($self->{test}->{stdin}) {
$self->{stdin} = [ @{$self->{test}->{stdin}} ];
}
if ($self->{test}->{stdout}) {
$self->{expected_stdout} = [ @{$self->{test}->{stdout}} ];
}
else {
$self->{expected_stdout} = [];
}
if ($self->{test}->{stderr}) {
$self->{expected_stderr} = [ @{$self->{test}->{stderr}} ];
}
else {
$self->{expected_stderr} = [];
}
$self->run_hook('post_run_program');
my @failed = ();
if ($self->{exit_status} != ($self->{test}->{return} // 0)) {
push @failed, 'exit status';
if ($self->{verbose}) {
print "Unexpected exit status:\n";
print "-" . ($self->{test}->{return} // 0) . "\n+$self->{exit_status}\n";
}
}
if (!$self->compare_arrays($self->{expected_stdout}, $self->{stdout}, 'output')) {
push @failed, 'output';
}
if (!$self->compare_arrays($self->{expected_stderr}, $self->{stderr}, 'error output')) {
push @failed, 'error output';
}
if (!$self->compare_files()) {
push @failed, 'files';
}
$self->{failed} = \@failed;
$self->run_hook('checks');
my $result = scalar(@{$self->{failed}}) == 0 ? 'PASS' : 'FAIL';
$self->sandbox_leave();
if (!($self->{no_cleanup} || ($self->{keep_broken} && $result eq 'FAIL'))) {
$self->sandbox_remove();
}
$self->print_test_result($tag, $result, join ', ', @{$self->{failed}});
return $result;
}
sub setup {
my ($self, @argv) = @_;
my @save_argv = @ARGV;
@ARGV = @argv;
my $ok = GetOptions(
'help|h' => \my $help,
'bin-sub-directory=s' => \$self->{bin_sub_directory},
'keep-broken|k' => \$self->{keep_broken},
'no-cleanup' => \$self->{no_cleanup},
# 'run-gdb' => \$self->{run_gdb},
'setup-only' => \$self->{setup_only},
'verbose|v' => \$self->{verbose}
);
@argv = @ARGV;
@ARGV = @save_argv;
if (!$ok || scalar(@argv) != 1 || $help) {
print STDERR "Usage: $0 [-hv] [--bin-sub-directory DIR] [--keep-broken] [--no-cleanup] [--setup-only] testcase\n";
exit(1);
}
my $testcase = shift @argv;
$testcase .= '.test' unless ($testcase =~ m/\.test$/);
my $testcase_file = $self->find_file($testcase);
$self->die("cannot find test case $testcase") unless ($testcase_file);
$testcase =~ s,^(?:.*/)?([^/]*)\.test$,$1,;
$self->{testname} = $testcase;
$self->die("error in test case definition") unless $self->parse_case($testcase_file);
$self->check_features_requirement() if ($self->{test}->{features});
$self->run_precheck() if ($self->{test}->{precheck});
$self->end_test('SKIP') if ($self->{test}->{preload} && ($^O eq 'darwin' || $^O eq 'MSWin32'));
$self->end_test('SKIP') if (($self->{test}->{stdin} || $self->{test}->{'stdin-file'}) && $^O eq 'MSWin32');
}
# MARK: - Internal Methods
sub add_file {
my ($self, $file) = @_;
if (defined($self->{files}->{$file->{destination}})) {
$self->warn("duplicate specification for input file $file->{destination}");
return undef;
}
$self->{files}->{$file->{destination}} = $file;
return 1;
}
sub check_features_requirement() {
my ($self) = @_;
my %features;
my $fh;
unless (open($fh, '<', "$self->{top_builddir}/config.h")) {
$self->die("cannot open config.h in top builddir $self->{top_builddir}");
}
while (my $line = <$fh>) {
if ($line =~ m/^#define HAVE_([A-Z0-9_a-z]*)/) {
$features{$1} = 1;
}
}
close($fh);
my @missing = ();
for my $feature (@{$self->{test}->{features}}) {
if (!$features{$feature}) {
push @missing, $feature;
}
}
if (scalar @missing > 0) {
my $reason = "missing features";
if (scalar(@missing) == 1) {
$reason = "missing feature";
}
$self->print_test_result('SKIP', "$reason: " . (join ' ', @missing));
$self->end_test('SKIP');
}
return 1;
}
sub comparator_zip {
my ($self, $got, $expected) = @_;
my $zipcmp = (-f $self->{zipcmp}) ? $self->{zipcmp} : $self->find_program('zipcmp');
my @args = ($zipcmp, $self->{verbose} ? '-v' : '-q');
push @args, $self->{zipcmp_flags} if ($self->{zipcmp_flags});
push @args, ($expected, $got);
my $ret = system(@args);
return $ret == 0;
}
sub compare_arrays() {
my ($self, $a, $b, $tag) = @_;
my $ok = 1;
if (scalar(@$a) != scalar(@$b)) {
$ok = 0;
}
else {
for (my $i = 0; $i < scalar(@$a); $i++) {
if ($a->[$i] ne $b->[$i]) {
$ok = 0;
last;
}
}
}
if (!$ok && $self->{verbose}) {
print "Unexpected $tag:\n";
print "--- expected\n+++ got\n";
diff_arrays($a, $b);
}
return $ok;
}
sub file_cmp($$) {
my ($a, $b) = @_;
my $result = 0;
open my $fha, "< $a";
open my $fhb, "< $b";
binmode $fha;
binmode $fhb;
BYTE: while (!eof $fha && !eof $fhb) {
if (getc $fha ne getc $fhb) {
$result = 1;
last BYTE;
}
}
$result = 1 if eof $fha != eof $fhb;
close $fha;
close $fhb;
return $result;
}
sub compare_file($$$) {
my ($self, $got, $expected) = @_;
my $real_expected = $self->find_file($expected);
unless ($real_expected) {
$self->warn("cannot find expected result file $expected");
return 0;
}
my $ok = $self->run_comparator($got, $real_expected);
if (!defined($ok)) {
my $ret;
if ($self->{verbose}) {
$ret = system('diff', '-u', $real_expected, $got);
}
else {
$ret = file_cmp($real_expected, $got);
}
$ok = ($ret == 0);
}
return $ok;
}
sub list_files {
my ($root) = @_;
my $ls;
my @files = ();
my @dirs = ($root);
while (scalar(@dirs) > 0) {
my $dir = shift @dirs;
opendir($ls, $dir);
unless ($ls) {
# TODO: handle error
}
while (my $entry = readdir($ls)) {
my $file = "$dir/$entry";
if ($dir eq '.') {
$file = $entry;
}
if (-f $file) {
push @files, "$file";
}
if (-d $file && $entry ne '.' && $entry ne '..') {
push @dirs, "$file";
}
}
closedir($ls);
}
return @files;
}
sub compare_files() {
my ($self) = @_;
my $ok = 1;
my @files_got = sort(list_files("."));
my @files_should = ();
for my $file (sort keys %{$self->{files}}) {
push @files_should, $file if ($self->{files}->{$file}->{result} || $self->{files}->{$file}->{ignore});
}
$self->{files_got} = \@files_got;
$self->{files_should} = \@files_should;
unless ($self->run_hook('post_list_files')) {
return 0;
}
$ok = $self->compare_arrays($self->{files_should}, $self->{files_got}, 'files');
for my $file (@{$self->{files_got}}) {
my $file_def = $self->{files}->{$file};
next unless ($file_def && $file_def->{result});
$ok &= $self->compare_file($file, $file_def->{result});
}
return $ok;
}
sub copy_files {
my ($self) = @_;
my $ok = 1;
for my $filename (sort keys %{$self->{files}}) {
my $file = $self->{files}->{$filename};
next unless ($file->{source});
my $src = $self->find_file($file->{source});
unless ($src) {
$self->warn("cannot find input file $file->{source}");
$ok = 0;
next;
}
if ($file->{destination} =~ m,/,) {
my $dir = $file->{destination};
$dir =~ s,/[^/]*$,,;
if (! -d $dir) {
mkpath($dir);
}
}
my $this_ok = $self->run_copier($src, $file->{destination});
if (defined($this_ok)) {
$ok &= $this_ok;
}
else {
unless (copy($src, $file->{destination})) {
$self->warn("cannot copy $src to $file->{destination}: $!");
$ok = 0;
}
}
}
if (defined($self->{test}->{mkdir})) {
for my $dir_spec (@{$self->{test}->{mkdir}}) {
my ($mode, $dir) = @$dir_spec;
if (! -d $dir) {
unless (mkdir($dir, oct($mode))) {
$self->warn("cannot create directory $dir: $!");
$ok = 0;
}
}
}
}
$self->die("failed to copy input files") unless ($ok);
}
sub die() {
my ($self, $msg) = @_;
print STDERR "$0: $msg\n" if ($msg);
$self->end_test('ERROR');
}
sub end_test {
my ($self, $status) = @_;
my $exit_code = $EXIT_CODES{$status} // $EXIT_CODES{ERROR};
$self->exit($exit_code);
}
sub exit() {
my ($self, $status) = @_;
### TODO: cleanup
exit($status);
}
sub find_file() {
my ($self, $fname) = @_;
for my $dir (('', "$self->{srcdir}/")) {
my $f = "$dir$fname";
$f = "../$f" if ($self->{in_sandbox} && $dir !~ m,^(\w:)?/,);
return $f if (-f $f);
}
return undef;
}
sub get_extension {
my ($self, $fname) = @_;
my $ext = $fname;
if ($ext =~ m/\./) {
$ext =~ s/.*\.//;
}
else {
$ext = '';
}
return $ext;
}
sub get_variable {
my ($self, $name, $opts) = @_;
$self->{$name} = $opts->{$name} // $ENV{$name};
if (!defined($self->{$name}) || $self->{$name} eq '') {
my $fh;
unless (open($fh, '<', 'Makefile')) {
$self->die("cannot open Makefile: $!");
}
while (my $line = <$fh>) {
chomp $line;
if ($line =~ m/^$name = (.*)/) {
$self->{$name} = $1;
last;
}
}
close ($fh);
}
if (!defined($self->{$name}) || $self->{$name} eq '') {
$self->die("cannot get variable $name");
}
}
sub mangle_test_for_variant {
my ($self) = @_;
$self->{test}->{stdout} = $self->strip_tags($self->{variant}, $self->{test}->{stdout});
$self->{test}->{stderr} = $self->strip_tags($self->{variant}, $self->{test}->{stderr});
$self->run_hook('mangle_test');
return 1;
}
sub parse_args {
my ($self, $type, $str) = @_;
if ($type eq 'string...') {
my $args = [];
while ($str ne '') {
if ($str =~ m/^\"/) {
unless ($str =~ m/^\"([^\"]*)\"\s*(.*)/) {
$self->warn_file_line("unclosed quote in [$str]");
return undef;
}
push @$args, $1;
$str = $2;
}
else {
$str =~ m/^(\S+)\s*(.*)/;
push @$args, $1;
$str = $2;
}
}
return $args;
}
elsif ($type =~ m/(\s|\.\.\.$)/) {
my $ellipsis = 0;
if ($type =~ m/(.*)\.\.\.$/) {
$ellipsis = 1;
$type = $1;
}
my @types = split /\s+/, $type;
my @strs = split /\s+/, $str;
my $optional = 0;
for (my $i = scalar(@types) - 1; $i >= 0; $i--) {
last unless ($types[$i] =~ m/(.*)\?$/);
$types[$i] = $1;
$optional++;
}
if ($ellipsis && $optional > 0) {
# TODO: check this when registering a directive
$self->warn_file_line("can't use ellipsis together with optional arguments");
return undef;
}
if (!$ellipsis && (scalar(@strs) < scalar(@types) - $optional || scalar(@strs) > scalar(@types))) {
my $expected = scalar(@types);
if ($optional > 0) {
$expected = ($expected - $optional) . "-$expected";
}
$self->warn_file_line("expected $expected arguments, got " . (scalar(@strs)));
return undef;
}
my $args = [];
my $n = scalar(@types);
for (my $i=0; $i<scalar(@strs); $i++) {
my $val = $self->parse_args(($i >= $n ? $types[$n-1] : $types[$i]), $strs[$i]);
return undef unless (defined($val));
push @$args, $val;
}
return $args;
}
else {
if ($type eq 'string') {
return $str;
}
elsif ($type eq 'int') {
if ($str !~ m/^\d+$/) {
$self->warn_file_line("illegal int [$str]");
return undef;
}
return $str+0;
}
elsif ($type eq 'char') {
if ($str !~ m/^.$/) {
$self->warn_file_line("illegal char [$str]");
return undef;
}
return $str;
}
else {
$self->warn_file_line("unknown type $type");
return undef;
}
}
}
sub parse_case() {
my ($self, $fname) = @_;
my $ok = 1;
open TST, "< $fname" or $self->die("cannot open test case $fname: $!");
$self->{testcase_fname} = $fname;
my %test = ();
while (my $line = <TST>) {
$line =~ s/(\n|\r)//g;
next if ($line =~ m/^\#/);
unless ($line =~ m/(\S*)(?:\s(.*))?/) {
$self->warn_file_line("cannot parse line $line");
$ok = 0;
next;
}
my ($cmd, $argstring) = ($1, $2//"");
my $def = $self->{directives}->{$cmd};
unless ($def) {
$self->warn_file_line("unknown directive $cmd in test file");
$ok = 0;
next;
}
my $args = $self->parse_args($def->{type}, $argstring);
unless (defined($args)) {
$ok = 0;
next;
}
if ($def->{once}) {
if (defined($test{$cmd})) {
$self->warn_file_line("directive $cmd appeared twice in test file");
}
$test{$cmd} = $args;
}
else {
$test{$cmd} = [] unless (defined($test{$cmd}));
push @{$test{$cmd}}, $args;
}
}
close TST;
return undef unless ($ok);
for my $cmd (sort keys %test) {
if ($self->{directives}->{$cmd}->{required} && !defined($test{$cmd})) {
$self->warn_file("required directive $cmd missing in test file");
$ok = 0;
}
}
if ($test{'stdin-file'} && $test{stdin}) {
$self->warn_file("both stdin-file and stdin provided, choose one");
$ok = 0;
}
if (defined($self->{variants})) {
if (defined($test{variants})) {
for my $name (@{$test{variants}}) {
my $found = 0;
for my $variant (@{$self->{variants}}) {
if ($name eq $variant->{name}) {
$found = 1;
last;
}
}
if ($found == 0) {
$self->warn_file("unknown variant $name");
$ok = 0;
}
}
}
}
return undef unless ($ok);
if (defined($test{'stderr-replace'}) && defined($test{stderr})) {
$test{stderr} = [ map { $self->stderr_rewrite($test{'stderr-replace'}, $_); } @{$test{stderr}} ];
}
if (!defined($test{program})) {
$test{program} = $self->{default_program};
}
$self->{test} = \%test;
$self->run_hook('mangle_program');
if (!$self->parse_postprocess_files()) {
return 0;
}
return $self->run_hook('post_parse');
}
sub parse_postprocess_files {
my ($self) = @_;
$self->{files} = {};
my $ok = 1;
for my $file (@{$self->{test}->{file}}) {
$ok = 0 unless ($self->add_file({ source => $file->[1], destination => $file->[0], result => $file->[2] }));
}
for my $file (@{$self->{test}->{'file-del'}}) {
$ok = 0 unless ($self->add_file({ source => $file->[1], destination => $file->[0], result => undef }));
}
for my $file (@{$self->{test}->{'file-new'}}) {
$ok = 0 unless ($self->add_file({ source => undef, destination => $file->[0], result => $file->[1] }));
}
return $ok;
}
sub print_test_result {
my ($self, $tag, $result, $reason) = @_;
if ($self->{verbose}) {
print "$self->{testname}";
print " ($tag)" if ($tag);
print " -- $result";
print ": $reason" if ($reason);
print "\n";
}
}
sub run_comparator {
my ($self, $got, $expected) = @_;
return $self->run_file_proc('compare_by_type', $got, $expected);
}
sub run_copier {
my ($self, $src, $dest) = @_;
return $self->run_file_proc('copy_by_type', $src, $dest);
}
sub run_file_proc {
my ($self, $proc, $got, $expected) = @_;
my $ext = ($self->get_extension($got)) . '/' . ($self->get_extension($expected));
if ($self->{variant}) {
if (defined($self->{$proc}->{"$self->{variant}/$ext"})) {
for my $sub (@{$self->{$proc}->{"$self->{variant}/$ext"}}) {
my $ret = $sub->($self, $got, $expected);
return $ret if (defined($ret));
}
}
}
if (defined($self->{$proc}->{$ext})) {
for my $sub (@{$self->{$proc}->{$ext}}) {
my $ret = $sub->($self, $got, $expected);
return $ret if (defined($ret));
}
}
return undef;
}
sub run_hook {
my ($self, $hook) = @_;
my $ok = 1;
my @hooks = ();
if (defined($self->{variant_hooks}) && defined($self->{variant_hooks}->{$hook})) {
push @hooks, $self->{variant_hooks}->{$hook};
}
if (defined($self->{hooks}->{$hook})) {
push @hooks, @{$self->{hooks}->{$hook}};
}
for my $sub (@hooks) {
unless ($sub->($self, $hook, $self->{variant})) {
$self->warn("hook $hook failed");
$ok = 0;
}
}
return $ok;
}
sub args_decode {
my ($str, $srcdir) = @_;
if ($str =~ m/\\/) {
$str =~ s/\\a/\a/gi;
$str =~ s/\\b/\b/gi;
$str =~ s/\\f/\f/gi;
$str =~ s/\\n/\n/gi;
$str =~ s/\\r/\r/gi;
$str =~ s/\\t/\t/gi;
$str =~ s/\\v/\cK/gi;
$str =~ s/\\s/ /gi;
# TODO: \xhh, \ooo
$str =~ s/\\(.)/$1/g;
}
if ($srcdir !~ m,^/,) {
$srcdir = "../$srcdir";
}
if ($str =~ m/^\$srcdir(.*)/) {
$str = "$srcdir$1";
}
return $str;
}
sub run_precheck {
my ($self) = @_;
for my $precheck (@{$self->{test}->{precheck}}) {
unless (system(@{$precheck}) == 0) {
$self->print_test_result('SKIP', "precheck failed");
$self->end_test('SKIP');
}
}
return 1;
}
sub find_program() {
my ($self, $pname) = @_;
my @directories = (".");
if ($self->{bin_sub_directory}) {
push @directories, $self->{bin_sub_directory};
}
for my $up (('.', '..', '../..', '../../..')) {
for my $sub (('.', 'src')) {
for my $dir (@directories) {
for my $ext (('', '.exe')) {
my $f = "$up/$sub/$dir/$pname$ext";
return $f if (-f $f);
}
}
}
}
return undef;
}
sub run_program {
my ($self) = @_;
my ($stdin, $stdout, $stderr);
$stderr = gensym;
my @cmd = ($self->find_program($self->{test}->{program}), map ({ args_decode($_, $self->{srcdir}); } @{$self->{test}->{args}}));
### TODO: catch errors?
my $pid;
if ($self->{test}->{'stdin-file'}) {
open(SPLAT, '<', $self->{test}->{'stdin-file'});
my $is_marked = eof SPLAT; # mark used
$pid = open3("<&SPLAT", $stdout, $stderr, @cmd);
}
else {
$pid = open3($stdin, $stdout, $stderr, @cmd);
}
$self->{stdout} = [];
$self->{stderr} = [];
if ($self->{test}->{stdin}) {
foreach my $line (@{$self->{test}->{stdin}}) {
print $stdin $line . "\n";
}
close($stdin);
}
while (my $line = <$stdout>) {
$line =~ s/(\n|\r)//g;
push @{$self->{stdout}}, $line;
}
my $prg = $self->{test}->{program};
$prg =~ s,.*/,,;
while (my $line = <$stderr>) {
$line =~ s/(\n|\r)//g;
$line =~ s/^[^: ]*$prg(\.exe)?: //;
if (defined($self->{test}->{'stderr-replace'})) {
$line = $self->stderr_rewrite($self->{test}->{'stderr-replace'}, $line);
}
push @{$self->{stderr}}, $line;
}
waitpid($pid, 0);
$self->{exit_status} = $? >> 8;
}
sub sandbox_create {
my ($self, $tag) = @_;
$tag = ($tag ? "-$tag" : "");
$self->{sandbox_dir} = "sandbox-$self->{testname}$tag.d$$";
$self->die("sandbox $self->{sandbox_dir} already exists") if (-e $self->{sandbox_dir});
mkdir($self->{sandbox_dir}) or $self->die("cannot create sandbox $self->{sandbox_dir}: $!");
return 1;
}
sub sandbox_enter {
my ($self) = @_;
$self->die("internal error: cannot enter sandbox before creating it") unless (defined($self->{sandbox_dir}));
return if ($self->{in_sandbox});
chdir($self->{sandbox_dir}) or $self->die("cannot cd into sandbox $self->{sandbox_dir}: $!");
$self->{in_sandbox} = 1;
}
sub sandbox_leave {
my ($self) = @_;
return if (!$self->{in_sandbox});
chdir('..') or $self->die("cannot leave sandbox: $!");
$self->{in_sandbox} = 0;
}
sub sandbox_remove {
my ($self) = @_;
remove_tree($self->{sandbox_dir});
return 1;
}
sub strip_tags {
my ($self, $tag, $lines) = @_;
my @stripped = ();
for my $line (@$lines) {
if ($line =~ m/^<([a-zA-Z0-9_]*)> (.*)/) {
if ($1 eq $tag) {
push @stripped, $2;
}
}
else {
push @stripped, $line;
}
}
return \@stripped;
}
sub touch_files {
my ($self) = @_;
my $ok = 1;
if (defined($self->{test}->{touch})) {
for my $args (@{$self->{test}->{touch}}) {
my ($mtime, $fname) = @$args;
if (!-f $fname) {
my $fh;
unless (open($fh, "> $fname") and close($fh)) {
# TODO: error message
$ok = 0;
next;
}
}
unless (utime($mtime, $mtime, $fname) == 1) {
# TODO: error message
$ok = 0;
}
}
}
return $ok;
}
sub warn {
my ($self, $msg) = @_;
print STDERR "$0: $msg\n";
}
sub warn_file {
my ($self, $msg) = @_;
$self->warn("$self->{testcase_fname}: $msg");
}
sub warn_file_line {
my ($self, $msg) = @_;
$self->warn("$self->{testcase_fname}:$.: $msg");
}
sub stderr_rewrite {
my ($self, $pattern, $line) = @_;
for my $repl (@{$pattern}) {
$line =~ s/$repl->[0]/$repl->[1]/;
}
return $line;
}
# MARK: array diff
sub diff_arrays {
my ($a, $b) = @_;
my ($i, $j);
for ($i = $j = 0; $i < scalar(@$a) || $j < scalar(@$b);) {
if ($i >= scalar(@$a)) {
print "+$b->[$j]\n";
$j++;
}
elsif ($j >= scalar(@$b)) {
print "-$a->[$i]\n";
$i++;
}
elsif ($a->[$i] eq $b->[$j]) {
print " $a->[$i]\n";
$i++;
$j++;
}
else {
my ($off_a, $off_b) = find_best_offsets($a, $i, $b, $j);
my ($off_b_2, $off_a_2) = find_best_offsets($b, $j, $a, $i);
if ($off_a + $off_b > $off_a_2 + $off_b_2) {
$off_a = $off_a_2;
$off_b = $off_b_2;
}
for (my $off = 0; $off < $off_a; $off++) {
print "-$a->[$i]\n";
$i++;
}
for (my $off = 0; $off < $off_b; $off++) {
print "+$b->[$j]\n";
$j++;
}
}
}
}
sub find_best_offsets {
my ($a, $i, $b, $j) = @_;
my ($best_a, $best_b);
for (my $off_a = 0; $off_a < (defined($best_a) ? $best_a + $best_b : scalar(@$a) - $i); $off_a++) {
my $off_b = find_entry($a->[$i+$off_a], $b, $j, defined($best_a) ? $best_a + $best_b - $off_a : scalar(@$b) - $j);
next unless (defined($off_b));
if (!defined($best_a) || $best_a + $best_b > $off_a + $off_b) {
$best_a = $off_a;
$best_b = $off_b;
}
}
if (!defined($best_a)) {
return (scalar(@$a) - $i, scalar(@$b) - $j);
}
return ($best_a, $best_b);
}
sub find_entry {
my ($entry, $array, $start, $max_offset) = @_;
for (my $offset = 0; $offset < $max_offset; $offset++) {
return $offset if ($array->[$start + $offset] eq $entry);
}
return undef;
}
1;
| chromium/chromium | third_party/libzip/src/regress/NiHTest.pm | Perl | bsd-3-clause | 30,292 |
#!/usr/local/bin/perl
use strict;
use diagnostics;
# Convert a decimal to a binary
sub dec2bin {
my $str = unpack("B32", pack("N", shift));
}
# Convert a binary number to a decimal number
sub bin2dec {
unpack("N", pack("B32", substr("0" x 32 . shift, -32)));
}
# XOR Function
sub myxor {
return 0 if ($_[0]==$_[1]);
return 1 if ($_[0]!=$_[1]);
}
# Binary to Gray-Code Converter
sub bin2gray {
my @bin=split(//,$_[0]);
my @gray;
$gray[0]=$bin[0];
for(my $i=1; $i<=$#bin ; $i++){
$gray[$i]=myxor($bin[$i],$bin[$i-1]);
}
my $graystr=join('',@gray);
}
# Decimal to Gray-Code Converter
sub dec2gray {
bin2gray(dec2bin($_[0]));
}
my $bini;
my $n;
$n = (32 - $ARGV[1]) if defined $ARGV[1];
for (my $i=0;$i<=$ARGV[0];$i++){
$bini=dec2bin($i);
$bini =~ s/^0{$n}//; # To remove leading zeros
printf("%6d -> %s\n",$i,$bini);
}
| kshenoy/dotfiles | scripts/dec2bin.pl | Perl | mit | 846 |
#!/usr/bin/env perl6
use v6;
use v6.c;
use lib 'ext/File__Find/lib/';
use lib 'ext/Shell__Command/lib/';
use Shell::Command;
sub MAIN(Str :$prefix is copy) {
say '==> Bootstrapping Panda';
# prevent a lot of expensive dynamic lookups
my $CWD := $*CWD;
my $DISTRO := $*DISTRO;
my %ENV := %*ENV;
%ENV<PANDA_SUBMIT_TESTREPORTS>:delete;
my $is_win = $DISTRO.is-win;
my $panda-base;
my $repo;
$prefix = "$CWD/$prefix" if defined($prefix) && $is_win && $prefix !~~ /^ '/' /;
my @repos = $*REPO.repo-chain.grep(CompUnit::Repository::Installable).grep(*.can-install);
my @custom-lib = <site home>.map({CompUnit::RepositoryRegistry.repository-for-name($_)});
for grep(*.defined, flat $prefix, @custom-lib, @repos) -> $target {
if $target ~~ CompUnit::Repository {
$prefix = $target.path-spec;
$repo = $prefix;
$panda-base = "{$target.prefix}/panda";
try mkdir $panda-base unless $panda-base.IO.d;
}
else {
$prefix = $target;
$repo = "$target/lib";
$panda-base = "$target/panda";
try mkdir $prefix;
try mkpath $panda-base unless $panda-base.IO ~~ :d;
}
last if $panda-base.IO.w
}
unless $panda-base.IO.w {
warn "panda-base: { $panda-base.perl }";
die "Found no writable directory into which panda could be installed";
}
my $projects = slurp 'projects.json.bootstrap';
$projects ~~ s:g/_BASEDIR_/$*CWD\/ext/;
$projects .= subst('\\', '/', :g) if $is_win;
given open "$panda-base/projects.json", :w {
.say: $projects;
.close;
}
my $env_sep = $DISTRO.?cur-sep // $DISTRO.path-sep;
%ENV<PERL6LIB> = join( $env_sep,
"file#$CWD/ext/File__Find/lib",
"file#$CWD/ext/Shell__Command/lib",
"file#$CWD/ext/JSON__Fast/lib",
"file#$CWD/lib",
$repo,
);
my $prefix_str = $prefix ?? "--prefix=$prefix" !! '';
shell "$*EXECUTABLE --ll-exception bin/panda --force $prefix_str install $*CWD";
$prefix = $prefix.substr(5) if $prefix.starts-with("inst#");
say "==> Please make sure that $prefix/bin is in your PATH";
unlink "$panda-base/projects.json";
}
# vim: ft=perl6
| timo/panda | bootstrap.pl | Perl | mit | 2,295 |
# !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
# This file is machine-generated by lib/unicore/mktables from the Unicode
# database, Version 12.1.0. Any changes made here will be lost!
# !!!!!!! INTERNAL PERL USE ONLY !!!!!!!
# This file is for internal use by core Perl only. The format and even the
# name or existence of this file are subject to change without notice. Don't
# use it directly. Use Unicode::UCD to access the Unicode character data
# base.
return <<'END';
V10
113664
113771
113776
113789
113792
113801
113808
113818
113820
113828
END
| operepo/ope | client_tools/svc/rc/usr/share/perl5/core_perl/unicore/lib/Scx/Dupl.pl | Perl | mit | 561 |
#Copyright (C)2001-2010 Altera Corporation
#Any megafunction design, and related net list (encrypted or decrypted),
#support information, device programming or simulation file, and any other
#associated documentation or information provided by Altera or a partner
#under Altera's Megafunction Partnership Program may be used only to
#program PLD devices (but not masked PLD devices) from Altera. Any other
#use of such megafunction design, net list, support information, device
#programming or simulation file, or any other related documentation or
#information is prohibited for any other purpose, including, but not
#limited to modification, reverse engineering, de-compiling, or use with
#any other silicon devices, unless such use is explicitly licensed under
#a separate agreement with Altera or a megafunction partner. Title to
#the intellectual property, including patents, copyrights, trademarks,
#trade secrets, or maskworks, embodied in any such megafunction design,
#net list, support information, device programming or simulation file, or
#any other related documentation or information provided by Altera or a
#megafunction partner, remains with Altera, the megafunction partner, or
#their respective licensors. No other licenses, including any licenses
#needed under any third party's intellectual property, are provided herein.
#Copying or modifying any file, or portion thereof, to which this notice
#is attached violates this copyright.
use europa_all;
use strict;
my $Address_Width = 9; # 2KBytes = 11 bits, 32 bits --> -2.
my $Data_Width = 32;
my $file_location;
sub make_epcs
{
my $Address_Width = 9;
my $Data_Width = 32;
my ($project, $Options, $module) = (@_);
my $slave_name = &get_slave_name();
my $register_offset = $project->{register_offset};
my $use_asmi_atom = $project->{use_asmi_atom};
my $SBI = $slave_name;
$file_location= $Options->{project_info}{system_directory} ;
my $top_level_module_name = $module->name();
$module->update();
my @inner_ports = $module->get_object_names("e_port");
my $new_name = $top_level_module_name . "_sub";
my $inner_mod = $project->module_hash()->{$top_level_module_name};
$inner_mod->name($new_name);
$project->module_hash()->{$new_name} = $inner_mod;
delete $project->module_hash()->{$top_level_module_name};
my $module = e_module->new({
name => $top_level_module_name,
project => $project,
});
$module->add_contents(
e_instance->new({
module => $new_name,
}),
);
my @port_list = ();
my %spi_port_names_by_type;
foreach my $port_name (@inner_ports)
{
my $port = $inner_mod->get_object_by_name($port_name);
ribbit() if not $port;
ribbit() if not ref($port) eq "e_port";
$spi_port_names_by_type{$port->type()} = $port_name;
next if ($port->type() eq '' ) ||
($port->type() eq 'address' ) ||
($port->type() eq 'chipselect') ||
($port->type() eq 'writedata' ) ||
($port->type() eq 'readdata' ) ;
push @port_list, e_port->new({
name => $port->name(),
width => $port->width(),
direction => $port->direction(),
type => $port->type(),
});
}
push (@port_list, e_port->news(
{name => "address",
type => "address",
width => $Address_Width,
direction => "input",
},
{name => "writedata",
type => "writedata",
width => 32,
direction => "input",
},
{name => "readdata",
type => "readdata",
width => 32,
direction => "output",
},
));
$module->add_contents(@port_list);
my %type_map = ();
map {$type_map{$_->name()} = $_->type()} @port_list;
$module->add_contents(
e_avalon_slave->new({
name => 'epcs_control_port',
type_map => \%type_map,
})
);
if ($project->{use_asmi_atom} eq "0") {
$module->add_contents(
e_port->new(["dclk", 1, "output"]),
e_port->new(["sce", 1, "output"]),
e_port->new(["sdo", 1, "output"]),
e_port->new(["data0", 1, "input"]),
e_assign->new(["dclk", "SCLK"]),
e_assign->new(["sce", "SS_n"]),
e_assign->new(["sdo", "MOSI"]),
e_assign->new(["MISO", "data0"])
);
}
else {
my $tspi_name = 'tornado_' . $top_level_module_name . '_atom';
my $tspi_module = e_module->new({
name => $tspi_name,
project => $project,
});
$tspi_module->do_black_box(1);
my $device_family = uc($project->{device_family});
if( ($device_family eq "STRATIXV") ) {
$tspi_module->add_contents(
e_port->new(['dclkin', 1, 'input',]),
e_port->new(['scein', 1, 'input',]),
e_port->new(['sdoin', 1, 'input',]),
e_port->new(['oe', 1, 'input',]),
e_port->new(['data0out', 1, 'output',]),
e_blind_instance->new({
tag => 'synthesis',
name => 'the_stratixv_asmiblock',
module => 'stratixv_asmiblock',
in_port_map => {
dclk => 'dclkin',
sce => 'scein',
data0out => 'sdoin', # MOSI
data1out => 0,
data2out => 0,
data3out => 0,
data0oe => '~oe',
data1oe => 0,
data2oe => 0,
data3oe => 0,
oe => 'oe',
},
out_port_map => {
data1in => 'data0out', # MISO
},
}),
e_assign->new({
tag => 'simulation',
lhs => 'data0out',
rhs => 'sdoin | scein | dclkin | oe',
}),
);
}
elsif( ($device_family eq "ARRIAV") ) {
$tspi_module->add_contents(
e_port->new(['dclkin', 1, 'input',]),
e_port->new(['scein', 1, 'input',]),
e_port->new(['sdoin', 1, 'input',]),
e_port->new(['oe', 1, 'input',]),
e_port->new(['data0out', 1, 'output',]),
e_blind_instance->new({
tag => 'synthesis',
name => 'the_arriav_asmiblock',
module => 'arriav_asmiblock',
in_port_map => {
dclk => 'dclkin',
sce => 'scein',
data0out => 'sdoin', # MOSI
data1out => 0,
data2out => 0,
data3out => 0,
data0oe => '~oe',
data1oe => 0,
data2oe => 0,
data3oe => 0,
oe => 'oe',
},
out_port_map => {
data1in => 'data0out', # MISO
},
}),
e_assign->new({
tag => 'simulation',
lhs => 'data0out',
rhs => 'sdoin | scein | dclkin | oe',
}),
);
}
elsif( ($device_family eq "ARRIAVGZ") ) {
$tspi_module->add_contents(
e_port->new(['dclkin', 1, 'input',]),
e_port->new(['scein', 1, 'input',]),
e_port->new(['sdoin', 1, 'input',]),
e_port->new(['oe', 1, 'input',]),
e_port->new(['data0out', 1, 'output',]),
e_blind_instance->new({
tag => 'synthesis',
name => 'the_arriavgz_asmiblock',
module => 'arriavgz_asmiblock',
in_port_map => {
dclk => 'dclkin',
sce => 'scein',
data0out => 'sdoin', # MOSI
data1out => 0,
data2out => 0,
data3out => 0,
data0oe => '~oe',
data1oe => 0,
data2oe => 0,
data3oe => 0,
oe => 'oe',
},
out_port_map => {
data1in => 'data0out', # MISO
},
}),
e_assign->new({
tag => 'simulation',
lhs => 'data0out',
rhs => 'sdoin | scein | dclkin | oe',
}),
);
}
elsif( ($device_family eq "CYCLONEV") ) {
$tspi_module->add_contents(
e_port->new(['dclkin', 1, 'input',]),
e_port->new(['scein', 1, 'input',]),
e_port->new(['sdoin', 1, 'input',]),
e_port->new(['oe', 1, 'input',]),
e_port->new(['data0out', 1, 'output',]),
e_blind_instance->new({
tag => 'synthesis',
name => 'the_cyclonev_asmiblock',
module => 'cyclonev_asmiblock',
in_port_map => {
dclk => 'dclkin',
sce => 'scein',
data0out => 'sdoin', # MOSI
data1out => 0,
data2out => 0,
data3out => 0,
data0oe => '~oe',
data1oe => 0,
data2oe => 0,
data3oe => 0,
oe => 'oe',
},
out_port_map => {
data1in => 'data0out', # MISO
},
}),
e_assign->new({
tag => 'simulation',
lhs => 'data0out',
rhs => 'sdoin | scein | dclkin | oe',
}),
);
}
else {
$tspi_module->add_contents(
e_port->new(['dclkin', 1, 'input',]),
e_port->new(['scein', 1, 'input',]),
e_port->new(['sdoin', 1, 'input',]),
e_port->new(['oe', 1, 'input',]),
e_port->new(['data0out', 1, 'output',]),
e_blind_instance->new({
tag => 'synthesis',
name => 'the_tornado_spiblock',
module => 'tornado_spiblock',
in_port_map => {
dclkin => 'dclkin',
scein => 'scein',
sdoin => 'sdoin',
oe => 'oe',
},
out_port_map => {
data0out => 'data0out',
},
}),
e_assign->new({
tag => 'simulation',
lhs => 'data0out',
rhs => 'sdoin | scein | dclkin | oe',
}),
);
}
$module->add_contents(
e_instance->new({
module => $tspi_name,
port_map => {
dclkin => 'SCLK',
scein => 'SS_n',
sdoin => 'MOSI',
oe => "1'b0",
data0out => 'MISO',
},
}),
);
}
if ((&Bits_To_Encode(get_code_size($project) - 1) - 2) > ($Address_Width - 1))
{
my $addr_bits = $SBI->{Address_Width};
ribbit ("EPCS Boot copier program (@{[get_code_size($project)]}) too big for address-range (($addr_bits)");
}
my $rom_data_width = $Data_Width;
my $bytes_per_word = $rom_data_width / 8;
my $rom_address_width = &Bits_To_Encode(get_code_size($project) / $bytes_per_word - 1);
my $rom_parameter_map = {
init_file => qq("@{[get_contents_file_name($project, 'hex')]}"),
operation_mode => qq("ROM"),
width_a => $Data_Width,
widthad_a => $rom_address_width,
numwords_a => get_code_size($project) / $bytes_per_word,
lpm_type => qq("altsyncram"),
byte_size => 8,
outdata_reg_a => qq("UNREGISTERED"),
read_during_write_mode_mixed_ports => qq("DONT_CARE"),
};
my $rom_in_port_map = { address_a => sprintf("address[%d : 0]", $rom_address_width - 1),
clock0 => 'clk',
clocken0 => 'clocken' };
my $rom_out_port_map = { q_a => 'rom_readdata' };
$module->add_contents(
e_blind_instance->new({
tag => 'synthesis',
name => 'the_boot_copier_rom',
module => 'altsyncram',
in_port_map => $rom_in_port_map,
out_port_map => $rom_out_port_map,
parameter_map => $rom_parameter_map,
})
);
$module->add_contents(
e_parameter->adds({
name => "INIT_FILE",
default => get_contents_file_name($project, 'hex'),
vhdl_type => "STRING",
})
);
$rom_parameter_map->{init_file} = 'INIT_FILE';
$module->add_contents(
e_blind_instance->new({
tag => 'simulation',
name => 'the_boot_copier_rom',
module => 'altsyncram',
in_port_map => $rom_in_port_map,
out_port_map => $rom_out_port_map,
parameter_map => $rom_parameter_map,
use_sim_models => 1,
})
);
©_and_convert_contents_file($project);
$module->add_contents (
e_assign->new ({
lhs => "clocken",
rhs => "~reset_req",
}),
);
my $address_msb = (&Bits_To_Encode(get_code_size($project) - 1) - 1) + 1;
$address_msb -= 2; # Word address --> byte address
$module->add_contents (
e_assign->new ({
lhs => $spi_port_names_by_type {"chipselect"},
rhs => "chipselect && (address \[ $address_msb \] )",
}),
e_assign->new ({
lhs => $spi_port_names_by_type {"address"},
rhs => "address",
}),
e_assign->new ({
lhs => $spi_port_names_by_type {"writedata"},
rhs => "writedata",
}),
);
my $spi_chipselect = $spi_port_names_by_type {"chipselect"};
my $spi_readdata = $spi_port_names_by_type {"readdata" };
$module->add_contents (
e_signal->new({name => 'rom_readdata', width => $rom_data_width,}),
e_assign->new ({
lhs => "readdata",
rhs => "$spi_chipselect ? $spi_readdata : rom_readdata",
})
);
$project->add_module($module);
$project->top($module);
$project->{"MODULE $top_level_module_name"}->{register_offset} = sprintf("0x%X", get_code_size($project));
}
my $g_slave_name = 'epcs_control_port';
sub get_slave_name
{
return $g_slave_name;
}
sub get_contents_file_name
{
my $project = shift;
my $extension = shift;
my $suffix = shift;
my $module = $project->top();
my $top_level_module_name = $module->name();
if ($extension && $extension !~ /^\./)
{
$extension = '.' . $extension;
}
if ($suffix)
{
$extension = "$suffix" . $extension;
}
return "$top_level_module_name\_boot_rom$extension";
}
sub copy_and_convert_contents_file
{
my ($project, $Options, $module) = (@_);
my $device_family = shift;
my $top_level_module_name = $module;
my $slave_name = &get_slave_name();
my $SBI = $slave_name;
require "format_conversion_utils.pm";
my $args =
{
comments => "0",
width => "32",
address_low => 0,
address_high => get_code_size($project) - 1,
};
my $boot_copier_srec;
my $device_family = uc($project->{device_family});
if( ($device_family eq "CYCLONE") ||
($device_family eq "CYCLONEII"))
{
$boot_copier_srec = "$ENV{QUARTUS_ROOTDIR}/../ip/altera/nios2_ip/altera_nios2/boot_loader_epcs.srec";
}
elsif( ($device_family eq "STRATIXII") ||
($device_family eq "STRATIXIIGX") ||
($device_family eq "STRATIXIIGXLITE") ||
($device_family eq "STRATIXIII") ||
($device_family eq "STRATIXIV") ||
($device_family eq "ARRIAII") ||
($device_family eq "ARRIAIIGZ") ||
($device_family eq "ARRIAIIGX") ||
($device_family eq "CYCLONEIII") ||
($device_family eq "TARPON") ||
($device_family eq "STINGRAY") ||
($device_family eq "CYCLONEIVE") ||
($device_family eq "CYCLONEIVGX"))
{
$boot_copier_srec = "$ENV{QUARTUS_ROOTDIR}/../ip/altera/nios2_ip/altera_nios2/boot_loader_epcs_sii_siii_ciii.srec";
}
else
{
$boot_copier_srec = "$ENV{QUARTUS_ROOTDIR}/../ip/altera/nios2_ip/altera_nios2/boot_loader_universal.srec";
}
if (-e $boot_copier_srec) {
$$args{infile} = $boot_copier_srec;
} else {
print STDERR ("Warning: $boot_copier_srec not found.\n");
}
my @contents_file_spec = (
{
oformat => 'hex',
outfile => "$file_location",
},
);
map {
$_->{outfile} .= get_contents_file_name($project, $_->{oformat})
} @contents_file_spec;
for my $file_spec (@contents_file_spec)
{
my %specific_args = %$args;
for (keys %$file_spec)
{
$specific_args{$_} = $file_spec->{$_};
}
format_conversion_utils::fcu_convert(\%specific_args);
}
}
sub get_code_size
{
my $project = shift;
my $device_family = uc($project->{device_family});
if( ($device_family eq "CYCLONE") ||
($device_family eq "CYCLONEII"))
{
return 0x200;
}
else
{
return 0x400;
}
}
return 1;
| UdayanSinha/Code_Blocks | Nios-2/Nios/practica4/ip/bemicro_max10_serial_flash_controller/em_epcs_qsys.pm | Perl | mit | 16,322 |
/Users/cabouffard-laptop/Music/Exteel.mp3
/Users/cabouffard-laptop/Music/Raptor.mp3
/Users/cabouffard-laptop/music/6Hour-Eve.mp3
/Users/cabouffard-laptop/Music/Atlantica.mp3
| cabouffard/dotfiles | .cmus/playlist.pl | Perl | mit | 174 |
#!/usr/bin/env perl
package CountReads;
__PACKAGE__->run() unless caller();
use strict;
use warnings;
use List::MoreUtils qw(pairwise);
use IO::File;
sub run() {
my $class = shift;
my $ifh = shift;
unless($ifh) {
print STDERR $ARGV[0], "\n";
if ($ARGV[0]) {
$ifh = IO::File->new($ARGV[0], "r")
or die "Unable to open $ARGV[0]\n";
}
else {
$ifh = IO::File->new_from_fd(fileno(STDIN), "r")
or die "Unable to open filehandle to STDIN\n";
}
}
my $ofh = shift;
unless($ofh) {
$ofh = IO::File->new_from_fd(fileno(STDOUT), "w")
or die "Unable to open filehandle to STDOUT\n";
}
my $variants;
my %variant_counts;
my %file_handles;
my $discarded = 0;
my $spanning_counts = 0;
my @position_counts;
while(<$ifh>) {
$_ =~ s/\R$//g;
unless($variants) {
$variants = $class->parse_header($_);
next;
}
my ($ref_name, $read_name, @bases) = split ",", $_, -1;
if($class->valid(@bases)) {
my @variant_in_read = $class->variants_in_read($variants, @bases);
if(@variant_in_read) {
my $name = join(",", map {$_->{id}} @variant_in_read);
$variant_counts{$name} += 1;
$class->print_readname(\%file_handles, $name, $class->correct_readname($read_name));
}
$spanning_counts += 1;
}
else {
$discarded += 1;
}
for my $index (0..$#bases) {
$position_counts[$index]->{$bases[$index]} += 1;
}
}
for(my $index = 0; $index < @$variants; ++$index) {
print STDERR $variants->[$index]->{id}, ":\n";
for my $base (keys %{$position_counts[$index]}) {
print STDERR "\t$base\t$position_counts[$index]->{$base}\n";
}
}
print STDERR "Discarded $discarded non-spanning reads\n";
print STDERR "Evaluated $spanning_counts spanning reads\n";
print $ofh "Variant(s)\tVariant Supporting Reads\tTotal Spanning Reads\tVAF\n";
for my $variant (sort keys %variant_counts) {
printf $ofh "%s\t%d\t%d\t%f%%\n", $variant, $variant_counts{$variant}, $spanning_counts, $variant_counts{$variant} / $spanning_counts * 100;
}
}
sub correct_readname {
my ($class, $name) = @_;
$name =~ s/\/ccs$//g;
return $name;
}
sub parse_header {
my ($class, $header_line) = @_;
chomp $header_line;
my @parsed_variants;
my ($ref_name, $read_name_header, @variants) = split ",", $header_line;
for my $variant (@variants) {
my ($ref, $pos, $var) = $variant =~ /(\D+)(\d+)(\D+)/;
unless(defined $ref and defined $var) {
die "Error parsing variant $variant from header\n";
}
push @parsed_variants, {id => $variant, variant => $var};
}
return \@parsed_variants;
}
sub valid {
my ($class, @bases) = @_;
for my $base (@bases) {
if( !defined $base
|| $base eq ''
#|| $base eq 'N'
) {
return 0;
}
}
return 1;
}
sub variant_for_base {
my ($class, $position_info, $base) = @_;
if($position_info->{variant} eq $base) {
return $position_info;
}
return;
}
sub variants_in_read {
my ($class, $variant_array, @bases) = @_;
my @variant_vector = grep { $_ } pairwise { $class->variant_for_base($a, $b) } @$variant_array, @bases;
return @variant_vector;
}
sub create_readname_filename {
my ($class, $variant_name) = @_;
my $filename = $variant_name;
$filename =~ s/,/_/g;
$filename .= "_readnames.txt";
return $filename;
}
sub print_readname {
my ($class, $filehandles_hashref, $variant_name, $readname) = @_;
my $fh;
unless(exists $filehandles_hashref->{$variant_name}) {
my $filename = $class->create_readname_filename($variant_name);
$fh = IO::File->new($filename,"w")
or die "Unable to open $filename to output readnames supporting $variant_name\n";
$filehandles_hashref->{$variant_name} = $fh;
}
else {
$fh = $filehandles_hashref->{$variant_name};
}
print $fh "$readname\n";
}
| ernfrid/count_read_variants | CountReads.pm | Perl | mit | 4,267 |
package Spreadsheet::XLSXSpokes;
use Exporter;
use Carp;
use Archive::Zip qw/:ERROR_CODES/;
use Data::Dumper;
use XML::Bare qw/xval forcearray/;
use Time::JulianDay;
@ISA = qw(Exporter);
@EXPORT_OK = qw();
use strict;
use warnings;
$Spreadsheet::XLSXSpokes::VERSION = '0.01';
sub new { my $pkg = shift; return bless { @_ }, $pkg; }
sub read {
my $self = shift;
my %args = ( @_ );
my ( $zip, $files ) = $self->read_zip( $args{'file'} );
# Ensure that all the basic files we need exist in the XLSX file
my @ensure = qw|xl/worksheets/sheet1.xml xl/workbook.xml xl/sharedStrings.xml xl/styles.xml|;
for my $file ( @ensure ) {
if( !$files->{ $file } ) {
die "$file is missing";
}
}
my $data = $self->load_xml_files( $zip, $files );
my $sheets = $self->{'sheets'} = $self->parse_data( $data );
#print Dumper( $sheets );
}
sub write_xml {
my $self = shift;
my %args = ( @_ );
open( my $file, ">".$args{'file'} );
my $xml = $self->convert_sheets_to_xml( $self->{'sheets'} );
print Dumper( $xml );
print $file XML::Bare::Object::xml( 0, $xml );
close( $file );
}
sub convert_sheets_to_xml {
my ( $self, $sheets ) = @_;
my $xml = {};
for my $sheet ( @$sheets ) {
my $name = $sheet->{'name'};
$xml->{ $name } = { row => $self->convert_sheet_to_xml( $sheet ) };
}
return $xml;
}
sub convert_sheet_to_xml {
my ( $self, $sheet ) = @_;
my $rows = $sheet->{'rows'};
my $titles = shift @$rows;
$titles = $titles->{'cells'};
my @xrows;
for my $rawrow ( @$rows ) {
my $cells = $rawrow->{'cells'};
my $i = 0;
my $xrow = {};
for my $cell ( @$cells ) {
my $cellname = $titles->[ $i ];
$xrow->{ $cellname } = { value => $cell };
$i++;
}
push( @xrows, $xrow );
}
return \@xrows;
}
sub read_zip {
my ( $self, $file ) = @_;
my $zip = Archive::Zip->new();
if( $zip->read( $file ) != AZ_OK ) { die 'read error'; }
my @files = $zip->memberNames();
my %hash = map { $_ => 1 } @files;
return ( $zip, \%hash );
}
sub load_xml_files {
my ( $self, $zip, $files ) = @_;
my $workbook = $zip->contents( { memberOrZipName => "xl/workbook.xml" } );
my $strings = $zip->contents( { memberOrZipName => "xl/sharedStrings.xml" } );
my $styles = $zip->contents( { memberOrZipName => "xl/styles.xml" } );
my @sheetdata;
for( my $i=0;$i<20;$i++ ) {
my $internal = "xl/worksheets/sheet$i.xml";
if( $files->{ $internal } ) {
my $data = $zip->contents( { memberOrZipName => $internal } );
push( @sheetdata, $data );
}
}
return $self->{'data'} = {
workbook => $workbook,
strings => $strings,
sheetdata => \@sheetdata,
styles => $styles
};
}
sub parse_data {
my ( $self, $data ) = @_;
my ( $ob, $workbook ) = XML::Bare->new( text => $data->{'workbook'} );
my $sheets = forcearray( $workbook->{'workbook'}{'sheets'}{'sheet'} );
my ( $ob1, $strings ) = XML::Bare->new( text => $data->{'strings'} );
my $string_data = forcearray( $strings->{'sst'}{'si'} );
my ( $ob3, $styles ) = XML::Bare->new( text => $data->{'styles'} );
my $cell_styles = forcearray( $styles->{'styleSheet'}{'cellXfs'}{'xf'} );
# Parse the sheet data and store it in @sheetdata
my $sheetdata_raw = $data->{'sheetdata'};
my @sheetdata;
for my $raw ( @$sheetdata_raw ) {
my ( $ob2, $data_xml ) = XML::Bare->new( text => $raw );
push( @sheetdata, $data_xml );
}
my $parsed = $self->parse_sheets( \@sheetdata, $sheets, $string_data, $cell_styles );
return $parsed;
}
sub parse_sheets {
my ( $self, $sheet_datasets, $rawsheets, $string_data, $cell_styles ) = @_;
my @sheets;
my $sheeti = 0;
for my $rawsheet ( @$rawsheets ) {
my %sheet = (
name => xval( $rawsheet->{'name'} )
);
my $sheet_data = $sheet_datasets->[ $sheeti ];
my $raw_rows = forcearray( $sheet_data->{'worksheet'}{'sheetData'}{'row'} );
$sheet{'numrows'} = scalar @$raw_rows;
my @rows;
for my $raw_row ( @$raw_rows ) {
my $raw_cells = forcearray( $raw_row->{'c'} );
my @cells;
my $empty = 1;
for my $cell ( @$raw_cells ) {
my $val = xval $cell->{'v'};
if( $cell->{'t'} ) {
my $t = xval $cell->{'t'};
if( $t eq 's' ) {
$val = xval $string_data->[ $val ]{'t'};
$val =~ s/^\s+|\s+$//g;
}
}
if( $cell->{'s'} ) {
my $s = xval $cell->{'s'};
my $style = $cell_styles->[ $s ];
my $format_id = xval $style->{'numFmtId'};
# Consider using CPAN Spreadsheet::ParseExcel::Utility
if( $format_id >= 14 && $format_id <= 17 ) {
$val = decode_date( $val );
}
}
$empty = 0 if( $val ne '' );
push( @cells, $val );
}
push( @rows, { cells => \@cells } ) if( !$empty );
}
$sheet{'rows'} = \@rows;
push( @sheets, \%sheet );
$sheeti++;
}
return \@sheets;
}
sub decode_date {
my $jd = shift + julian_day(1900, 1, 0) - 1;
my ($year, $month, $day) = inverse_julian_day($jd);
return "$month-$day-$year";
}
1; | nanoscopic/perl-Spreadsheet-XLSXSpokes | lib/Spreadsheet/XLSXSpokes.pm | Perl | mit | 5,150 |
package Paws::Organizations::ListPoliciesForTargetResponse;
use Moose;
has NextToken => (is => 'ro', isa => 'Str');
has Policies => (is => 'ro', isa => 'ArrayRef[Paws::Organizations::PolicySummary]');
has _request_id => (is => 'ro', isa => 'Str');
### main pod documentation begin ###
=head1 NAME
Paws::Organizations::ListPoliciesForTargetResponse
=head1 ATTRIBUTES
=head2 NextToken => Str
If present, this value indicates that there is more output available
than is included in the current response. Use this value in the
C<NextToken> request parameter in a subsequent call to the operation to
get the next part of the output. You should repeat this until the
C<NextToken> response element comes back as C<null>.
=head2 Policies => ArrayRef[L<Paws::Organizations::PolicySummary>]
The list of policies that match the criteria in the request.
=head2 _request_id => Str
=cut
1; | ioanrogers/aws-sdk-perl | auto-lib/Paws/Organizations/ListPoliciesForTargetResponse.pm | Perl | apache-2.0 | 900 |
=head1 LICENSE
Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
Copyright [2016-2017] EMBL-European Bioinformatics Institute
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=cut
=head1 CONTACT
Please email comments or questions to the public Ensembl
developers list at <http://lists.ensembl.org/mailman/listinfo/dev>.
Questions may also be sent to the Ensembl help desk at
<http://www.ensembl.org/Help/Contact>.
=cut
# Ensembl module for Bio::EnsEMBL::Variation::VariationFeature
#
#
=head1 NAME
Bio::EnsEMBL::Variation::BaseVariationFeature - Abstract base class for variation features
=head1 SYNOPSIS
None
=head1 DESCRIPTION
Abstract base class representing variation features. Should not be instantiated
directly.
=head1 METHODS
=cut
use strict;
use warnings;
package Bio::EnsEMBL::Variation::BaseVariationFeature;
use Bio::EnsEMBL::Feature;
our @ISA = ('Bio::EnsEMBL::Feature');
=head2 consequence_type
Arg [1] : (optional) String $term_type
Description: Get a list of all the unique consequence terms of this
VariationFeature. By default returns Ensembl display terms
(e.g. 'NON_SYNONYMOUS_CODING'). $term_type can also be 'label'
(e.g. 'Non-synonymous coding'), 'SO' (Sequence Ontology, e.g.
'non_synonymous_codon') or 'NCBI' (e.g. 'missense')
Returntype : listref of strings
Exceptions : none
Status : Stable
=cut
sub consequence_type {
my $self = shift;
my $term_type = shift;
my $method_name;
# delete cached term
if(defined($term_type)) {
delete $self->{consequence_types};
$method_name = $term_type.($term_type eq 'label' ? '' : '_term');
$method_name = 'SO_term' unless @{$self->get_all_OverlapConsequences} && $self->get_all_OverlapConsequences->[0]->can($method_name);
}
$method_name ||= 'SO_term';
if (exists($self->{current_consequence_method}) && $self->{current_consequence_method} ne $method_name) {
delete $self->{consequence_type};
}
unless ($self->{consequence_types}) {
# work out the terms from the OverlapConsequence objects
$self->{consequence_types} =
[ map { $_->$method_name } @{ $self->get_all_OverlapConsequences } ];
}
$self->{current_consequence_method} = $method_name;
return $self->{consequence_types};
}
=head2 display_consequence
Arg [1] : (optional) String $term_type
Description: Get the term for the most severe consequence of this
VariationFeature. By default returns the Sequence Ontology term
(e.g. 'missense_variant'). $term_type can also be 'label'
(e.g. 'Missense variant'), 'Ensembl' ((e.g. 'NON_SYNONYMOUS_CODING')
or 'NCBI' (e.g. 'missense')
Returntype : string
Exceptions : none
Status : Stable
=cut
sub display_consequence {
my $self = shift;
my $term_type = shift;
my $method_name;
# delete cached term
if(defined($term_type)) {
$method_name = $term_type.($term_type eq 'label' ? '' : '_term');
$method_name = 'SO_term' unless @{$self->get_all_OverlapConsequences} && $self->get_all_OverlapConsequences->[0]->can($method_name);
}
$method_name ||= 'SO_term';
return $self->most_severe_OverlapConsequence->$method_name;
}
=head2 most_severe_OverlapConsequence
Description: Get the OverlapConsequence considered (by Ensembl) to be the most severe
consequence of all the alleles of this VariationFeature
Returntype : Bio::EnsEMBL::Variation::OverlapConsequence
Exceptions : none
Status : At Risk
=cut
sub most_severe_OverlapConsequence {
my $self = shift;
unless ($self->{_most_severe_consequence}) {
my $highest;
for my $cons (@{ $self->get_all_OverlapConsequences }) {
$highest ||= $cons;
if ($cons->rank < $highest->rank) {
$highest = $cons;
}
}
$self->{_most_severe_consequence} = $highest;
}
return $self->{_most_severe_consequence};
}
=head2 transfer
Arg [1] : Bio::EnsEMBL::Slice $slice
The slice to transfer this feature to
Example : $vf = $vf->transfer($slice);
next if(!defined($feature));
Description: Returns a copy of this VariationFeature shifted onto
another slice.
If the new slice is in a different coordinate system the
feature is transformed first and then placed on the slice.
If the feature would be split across a coordinate system
boundary or mapped to a gap undef is returned instead.
If the feature cannot be placed on the provided slice because
it maps to an entirely different location, undef is returned
instead.
Returntype : Bio::EnsEMBL::BaseVariationFeature (or undef)
Exceptions : throw on incorrect argument
throw if feature does not have attached slice
Caller : general, transform()
Status : Stable
=cut
sub transfer {
my $self = shift;
# differ only from parent class's implementation in that
# cached values for seq_region_start, seq_region_end must be removed
delete $self->{$_} for qw(seq_region_start seq_region_end);
return $self->SUPER::transfer(@_);
}
=head2 transform
Arg [1] : string $coord_system
The coord system to transform this feature to.
Arg [2] : string $version (optional)
The version of the coord system to transform this feature to.
Arg [3] : Bio::EnsEMBL::Slice (optional)
Specified when a projection may land on many overlapping slices
and disambiguation is required.
Example : $vf = $vf->transform('contig');
next if(!defined($vf));
Description: Returns a copy of this feature, but converted to a different
coordinate system. The converted feature will be placed on a
slice which spans an entire sequence region of the new
coordinate system. If the requested coordinate system is the
same coordinate system it is simply placed on a slice which
spans the entire seq_region (as opposed to the original slice
which may have only partially covered the seq_region).
If a feature spans a boundary in the new coordinate system,
undef is returned instead.
For example, transforming an exon in contig coordinates to one
in chromosomal coodinates will place the exon on a slice of an
entire chromosome.
Returntype : Bio::EnsEMBL::BaseVariationFeature (or undef)
Exceptions : thrown if an invalid coordinate system is provided
warning if Feature is not attached to a slice
Caller : general, transfer()
Status : Stable
=cut
sub transform {
my $self = shift;
# differ only from parent class's implementation in that
# cached values for seq_region_start, seq_region_end must be removed
delete $self->{$_} for qw(seq_region_start seq_region_end);
return $self->SUPER::transform(@_);
}
=head2 seq_region_start
Arg [1] : none
Example : print $vf->seq_region_start();
Description: Convenience method which returns the absolute start of this
feature on the seq_region, as opposed to the relative (slice)
position.
Returns undef if this feature is not on a slice or slice is
circular and cannot determine the position of the feature from
the db.
Returntype : int or undef
Exceptions : none
Caller : general
Status : Stable
=cut
sub seq_region_start {
my ($self, $new_seq_region_start) = @_;
return $self->{seq_region_start} = $new_seq_region_start if $new_seq_region_start;
return $self->{seq_region_start} ||= $self->SUPER::seq_region_start;
}
=head2 seq_region_end
Arg [1] : none
Example : print $vf->seq_region_end();
Description: Convenience method which returns the absolute end of this
feature on the seq_region, as opposed to the relative (slice)
position.
Returns undef if this feature is not on a slice or slice is
circular and cannot determine the position of the feature from
the db.
Returntype : int or undef
Exceptions : none
Caller : general
Status : Stable
=cut
sub seq_region_end {
my ($self, $new_seq_region_end) = @_;
return $self->{seq_region_end} = $new_seq_region_end if $new_seq_region_end;
return $self->{seq_region_end} ||= $self->SUPER::seq_region_end;
}
sub _get_transcript_key {
my $self = shift;
my $tr = shift;
my $key = $tr->stable_id;
if(my $dbID = $tr->dbID) {
$key .= '_'.$dbID;
}
return $key;
}
=head2 _get_prev_base
Arg 1 : (optional) int $strand
Example : $base = $bvf->get_prev_base();
Description: Get the base preceding the given variant's position. Will
use FASTA or database; returns "N" if sequence retrieval fails.
Defaults to retrieving sequence for the slice's strand;
strand may be specified with the first argument
Returntype : string
Exceptions : none
Caller : to_VCF_record(),
Status : Stable
=cut
sub _get_prev_base {
my $self = shift;
my $strand = shift;
# we need the ref base before the variation
# default to N in case we cant get it
my $prev_base = 'N';
if(my $slice = $self->{slice}) {
my $sub_slice = $slice->sub_Slice($self->start - 1, $self->start - 1, $strand);
$prev_base = $sub_slice->seq if defined($sub_slice);
}
return $prev_base;
}
1;
| willmclaren/ensembl-variation | modules/Bio/EnsEMBL/Variation/BaseVariationFeature.pm | Perl | apache-2.0 | 10,385 |
#
# Copyright 2019 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package apps::hyperv::2012::local::mode::scvmmintegrationservice;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use centreon::plugins::misc;
use centreon::common::powershell::hyperv::2012::scvmmintegrationservice;
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
sub custom_status_output {
my ($self, %options) = @_;
my $msg = 'VMAddition : ' . $self->{result_values}->{vmaddition};
return $msg;
}
sub custom_status_calc {
my ($self, %options) = @_;
$self->{result_values}->{vm} = $options{new_datas}->{$self->{instance} . '_vm'};
$self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'};
$self->{result_values}->{vmaddition} = $options{new_datas}->{$self->{instance} . '_vmaddition'};
$self->{result_values}->{operatingsystemshutdownenabled} = $options{new_datas}->{$self->{instance} . '_operatingsystemshutdownenabled'};
$self->{result_values}->{timesynchronizationenabled} = $options{new_datas}->{$self->{instance} . '_timesynchronizationenabled'};
$self->{result_values}->{dataexchangeenabled} = $options{new_datas}->{$self->{instance} . '_dataexchangeenabled'};
$self->{result_values}->{heartbeatenabled} = $options{new_datas}->{$self->{instance} . '_heartbeatenabled'};
$self->{result_values}->{backupenabled} = $options{new_datas}->{$self->{instance} . '_backupenabled'};
return 0;
}
sub custom_integrationservice_output {
my ($self, %options) = @_;
my $msg = $self->{result_values}->{output_label} . ' : ' . $self->{result_values}->{service_status};
return $msg;
}
sub custom_integrationservice_calc {
my ($self, %options) = @_;
$self->{result_values}->{output_label} = $options{extra_options}->{output_label};
$self->{result_values}->{service_status} = $options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{name_status}};
$self->{result_values}->{vm} = $options{new_datas}->{$self->{instance} . '_vm'};
$self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'};
return 0;
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'vm', type => 1, cb_prefix_output => 'prefix_vm_output', message_multiple => 'All integration services are ok' },
];
$self->{maps_counters}->{vm} = [
{ label => 'status', , threshold => 0, set => {
key_values => [ { name => 'vm' }, { name => 'status' }, { name => 'vmaddition' },
{ name => 'operatingsystemshutdownenabled' }, { name => 'timesynchronizationenabled' },
{ name => 'dataexchangeenabled' }, { name => 'heartbeatenabled' }, { name => 'backupenabled' } ],
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
{ label => 'osshutdown-status', threshold => 0, set => {
key_values => [ { name => 'status' }, { name => 'vm' }, { name => 'operatingsystemshutdownenabled' } ],
closure_custom_calc => $self->can('custom_integrationservice_calc'),
closure_custom_calc_extra_options => { output_label => 'Operating System Shutdown', name_status => 'operatingsystemshutdownenabled' },
closure_custom_output => $self->can('custom_integrationservice_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
{ label => 'timesync-status', threshold => 0, set => {
key_values => [ { name => 'status' }, { name => 'vm' }, { name => 'timesynchronizationenabled' } ],
closure_custom_calc => $self->can('custom_integrationservice_calc'),
closure_custom_calc_extra_options => { output_label => 'Time Synchronization', name_status => 'timesynchronizationenabled' },
closure_custom_output => $self->can('custom_integrationservice_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
{ label => 'dataexchange-status', threshold => 0, set => {
key_values => [ { name => 'status' }, { name => 'vm' }, { name => 'dataexchangeenabled' } ],
closure_custom_calc => $self->can('custom_integrationservice_calc'),
closure_custom_calc_extra_options => { output_label => 'Data Exchange', name_status => 'dataexchangeenabled' },
closure_custom_output => $self->can('custom_integrationservice_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
{ label => 'heartbeat-status', threshold => 0, set => {
key_values => [ { name => 'status' }, { name => 'vm' }, { name => 'heartbeatenabled' } ],
closure_custom_calc => $self->can('custom_integrationservice_calc'),
closure_custom_calc_extra_options => { output_label => 'Heartbeat', name_status => 'heartbeatenabled' },
closure_custom_output => $self->can('custom_integrationservice_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
{ label => 'backup-status', threshold => 0, set => {
key_values => [ { name => 'status' }, { name => 'vm' }, { name => 'backupenabled' } ],
closure_custom_calc => $self->can('custom_integrationservice_calc'),
closure_custom_calc_extra_options => { output_label => 'Backup', name_status => 'backupenabled' },
closure_custom_output => $self->can('custom_integrationservice_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
];
}
sub prefix_vm_output {
my ($self, %options) = @_;
return "VM '" . $options{instance_value}->{vm} . "' ";
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"scvmm-hostname:s" => { name => 'scvmm_hostname' },
"scvmm-username:s" => { name => 'scvmm_username' },
"scvmm-password:s" => { name => 'scvmm_password' },
"scvmm-port:s" => { name => 'scvmm_port', default => 8100 },
"timeout:s" => { name => 'timeout', default => 50 },
"command:s" => { name => 'command', default => 'powershell.exe' },
"command-path:s" => { name => 'command_path' },
"command-options:s" => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
"no-ps" => { name => 'no_ps' },
"ps-exec-only" => { name => 'ps_exec_only' },
"filter-vm:s" => { name => 'filter_vm' },
"filter-description:s" => { name => 'filter_description' },
"filter-hostgroup:s" => { name => 'filter_hostgroup' },
"filter-status:s" => { name => 'filter_status' },
"warning-status:s" => { name => 'warning_status', default => '' },
"critical-status:s" => { name => 'critical_status', default => '%{vmaddition} =~ /not detected/i' },
"warning-osshutdown-status:s" => { name => 'warning_osshutdown_status', default => '' },
"critical-osshutdown-status:s" => { name => 'critical_osshutdown_status', default => '' },
"warning-timesync-status:s" => { name => 'warning_timesync_status', default => '' },
"critical-timesync-status:s" => { name => 'critical_timesync_status', default => '' },
"warning-dataexchange-status:s" => { name => 'warning_dataexchange_status', default => '' },
"critical-dataexchange-status:s" => { name => 'critical_dataexchange_status', default => '' },
"warning-heartbeat-status:s" => { name => 'warning_heartbeat_status', default => '' },
"critical-heartbeat-status:s" => { name => 'critical_heartbeat_status', default => '' },
"warning-backup-status:s" => { name => 'warning_backup_status', default => '' },
"critical-backup-status:s" => { name => 'critical_backup_status', default => '' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
foreach my $label (('scvmm_hostname', 'scvmm_username', 'scvmm_password', 'scvmm_port')) {
if (!defined($self->{option_results}->{$label}) || $self->{option_results}->{$label} eq '') {
my ($label_opt) = $label;
$label_opt =~ tr/_/-/;
$self->{output}->add_option_msg(short_msg => "Need to specify --" . $label_opt . " option.");
$self->{output}->option_exit();
}
}
$self->change_macros(macros => ['warning_status', 'critical_status', 'warning_osshutdown_status', 'critical_osshutdown_status',
'warning_timesync_status', 'critical_timesync_status', 'warning_dataexchange_status', 'critical_dataexchange_status',
'warning_heartbeat_status', 'critical_heartbeat_status', 'warning_backup_status', 'critical_backup_status']);
}
sub manage_selection {
my ($self, %options) = @_;
my $ps = centreon::common::powershell::hyperv::2012::scvmmintegrationservice::get_powershell(
scvmm_hostname => $self->{option_results}->{scvmm_hostname},
scvmm_username => $self->{option_results}->{scvmm_username},
scvmm_password => $self->{option_results}->{scvmm_password},
scvmm_port => $self->{option_results}->{scvmm_port},
no_ps => $self->{option_results}->{no_ps});
$self->{option_results}->{command_options} .= " " . $ps;
my ($stdout) = centreon::plugins::misc::execute(output => $self->{output},
options => $self->{option_results},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
if (defined($self->{option_results}->{ps_exec_only})) {
$self->{output}->output_add(severity => 'OK',
short_msg => $stdout);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
#[VM= test1 ][Description= Test Descr - - pp - - aa ][Status= Running ][Cloud= ][HostGroup= All Hosts\CORP\test1 ][VMAddition= 6.3.9600.16384 ]
#[VM= test2 ][Description= ][Status= HostNotResponding ][Cloud= ][HostGroup= All Hosts\CORP\test2 ][VMAddition= Not Detected ]
#[VM= test3 ][Description= ][Status= HostNotResponding ][Cloud= ][HostGroup= All Hosts\CORP\test3 ][VMAddition= Not Detected ]
#[VM= test4 ][Description= ][Status= HostNotResponding ][Cloud= ][HostGroup= All Hosts\CORP\test4 ][VMAddition= Not Detected ]
$self->{vm} = {};
my $id = 1;
my @lines = split /\n/, $stdout;
foreach my $line (@lines) {
my %values;
while ($line =~ /\[(.*?)=\s*(.*?)\s*\]/g) {
$values{lc($1)} = $2;
}
$values{hostgroup} =~ s/\\/\//g;
my $filtered = 0;
foreach (('vm', 'description', 'status', 'hostgroup')) {
if (defined($self->{option_results}->{'filter_' . $_}) && $self->{option_results}->{'filter_' . $_} ne '' &&
$values{$_} !~ /$self->{option_results}->{'filter_' . $_}/i) {
$self->{output}->output_add(long_msg => "skipping '" . $values{$_} . "': no matching filter.", debug => 1);
$filtered = 1;
last;
}
}
$self->{vm}->{$id} = { %values } if ($filtered == 0);
$id++;
}
}
1;
__END__
=head1 MODE
Check virtual machine integration services on SCVMM.
=over 8
=item B<--scvmm-hostname>
SCVMM hostname (Required).
=item B<--scvmm-username>
SCVMM username (Required).
=item B<--scvmm-password>
SCVMM password (Required).
=item B<--scvmm-port>
SCVMM port (Default: 8100).
=item B<--timeout>
Set timeout time for command execution (Default: 50 sec)
=item B<--no-ps>
Don't encode powershell. To be used with --command and 'type' command.
=item B<--command>
Command to get information (Default: 'powershell.exe').
Can be changed if you have output in a file. To be used with --no-ps option!!!
=item B<--command-path>
Command path (Default: none).
=item B<--command-options>
Command options (Default: '-InputFormat none -NoLogo -EncodedCommand').
=item B<--ps-exec-only>
Print powershell output.
=item B<--filter-status>
Filter virtual machine status (can be a regexp).
=item B<--filter-description>
Filter by description (can be a regexp).
=item B<--filter-vm>
Filter virtual machines (can be a regexp).
=item B<--filter-hostgroup>
Filter hostgroup (can be a regexp).
=item B<--warning-status>
Set warning threshold for status (Default: '').
Can used special variables like: %{vm}, %{vmaddition}, %{status}
=item B<--critical-status>
Set critical threshold for status (Default: '%{vmaddition} =~ /not detected/i').
Can used special variables like: %{vm}, %{vmaddition}, %{status}
=back
=cut
| Sims24/centreon-plugins | apps/hyperv/2012/local/mode/scvmmintegrationservice.pm | Perl | apache-2.0 | 15,489 |
=head1 LICENSE
Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
Copyright [2016-2021] EMBL-European Bioinformatics Institute
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=cut
package EnsEMBL::Draw::GlyphSet::VEPSequence;
## VEP sequence track for contigviewbottom
use strict;
use warnings;
use parent qw(EnsEMBL::Draw::GlyphSet::variation);
sub get_data {
my $self = shift;
my $object = $self->{'config'}->hub->core_object('Tools') or return;
$object = $object->get_sub_object('VEP');
my $job = $object->get_requested_job({'with_all_results' => 1}) or return;
my $slice = $self->{'container'};
my $start = $slice->start;
my $strand = $self->strand;
my @variants = grep $strand eq $_->{'strand'}, @{$object->get_all_variants_in_slice_region($job, $slice)};
my $fnum = scalar @variants;
my $calc_type = $fnum > 200 ? 0 : 1;
# Can we actually draw this many features?
unless ($calc_type) {
$self->errorTrack("Cannot display more than 200 variants");
return [];
}
my $features;
my $colour_lookup = {};
for (@variants) {
my ($vstart, $vend) = $_->{'start'} < $_->{'end'} ? ($_->{'start'}, $_->{'end'}) : ($_->{'end'}, $_->{'start'});
$vend = $vend - $vstart;
$vstart = $vstart - $start + 1;
$vend = $vstart + $vend;
my $snp = {
'start' => $vstart,
'end' => $vend,
'strand' => $_->{'strand'},
'label' => $_->{'variation_name'},
'href' => $self->href($_),
'colour_key' => $_->{'consequence_type'},
};
## Set colour and do legend
my $key = $snp->{'colour_key'};
$colour_lookup->{$key} ||= $self->get_colours($snp);
my $colour = $self->{'legend'}{'variation_legend'}{$key} ||= $colour_lookup->{$key}{'feature'};
$snp->{'colour'} = $colour;
$snp->{'colour_lookup'} = $colour_lookup->{$key};
$self->{'legend'}{'variation_legend'}{$key} ||= $colour;
push @$features, $snp;
}
return [{'features' => $features}];
}
sub href {
my ($self, $f, $tl) = @_;
return $self->_url({
species => $self->species,
type => 'Tools',
action => 'VEP',
v => $f->{'variation_name'},
config => $self->{'config'}{'type'},
track => $self->type,
tl => $f->{'tl'}
});
}
1;
| Ensembl/public-plugins | tools/modules/EnsEMBL/Draw/GlyphSet/VEPSequence.pm | Perl | apache-2.0 | 2,921 |
:- module(graph,[
reorder_edges/5,
compare_vertices/4,
compare_edges/4,
compare_paths/4,
compare_map/5,
reverse_order/4,
compare_compose/5,
compare_path_lengths/3
]).
:- meta_predicate reorder_edges(3,3,?,?,?).
reorder_edges(OrderPred,Rel,P1,Edge,P2) :-
(var(P1) *-> (
aggregate(set(V),E^V1^call(Rel,V,E,V1),Vs),
member(P1,Vs)
) ; true),
findall([E,V],call(Rel,P1,E,V),Unsorted),
predsort(OrderPred,Unsorted,Sorted),
member([Edge,P2],Sorted).
:- meta_predicate compare_vertices(3,-,+,+),
compare_edges(3,-,+,+),
compare_map(2,3,-,+,+),
reverse_order(3,-,+,+).
compare_vertices(OrderPred,Res,[_,V1],[_,V2]) :-
call(OrderPred,Res,V1,V2).
compare_edges(OrderPred,Res,[E1,_],[E2,_]) :-
call(OrderPred,Res,E1,E2).
compare_paths(OrderPred,Res,[_,P1],[_,P2]) :-
call(OrderPred,Res,P1,P2).
compare_map(MapPred,OrderPred,Res,X,Y) :-
call(MapPred,X,X1),
call(MapPred,Y,Y1),
call(OrderPred,Res,X1,Y1).
reverse_order(OrderPred,Res,X,Y) :-
call(OrderPred,Res,Y,X).
compare_compose(OrderPred1,OrderPred2,Res,X,Y) :-
call(OrderPred1,Res1,X,Y),
(Res1 = (=) -> call(OrderPred2,Res,X,Y) ; Res = Res1).
compare_path_lengths(Res,[_,P1],[_,P2]) :-
length(P1,N1),
length(P2,N2),
compare(Res,N1,N2). | joaoraf/searchalgorithms | src/main/prolog/graph.pl | Perl | apache-2.0 | 1,245 |
package Paws::Pinpoint::CampaignState;
use Moose;
has CampaignStatus => (is => 'ro', isa => 'Str');
1;
### main pod documentation begin ###
=head1 NAME
Paws::Pinpoint::CampaignState
=head1 USAGE
This class represents one of two things:
=head3 Arguments in a call to a service
Use the attributes of this class as arguments to methods. You shouldn't make instances of this class.
Each attribute should be used as a named argument in the calls that expect this type of object.
As an example, if Att1 is expected to be a Paws::Pinpoint::CampaignState object:
$service_obj->Method(Att1 => { CampaignStatus => $value, ..., CampaignStatus => $value });
=head3 Results returned from an API call
Use accessors for each attribute. If Att1 is expected to be an Paws::Pinpoint::CampaignState object:
$result = $service_obj->Method(...);
$result->Att1->CampaignStatus
=head1 DESCRIPTION
State of the Campaign
=head1 ATTRIBUTES
=head2 CampaignStatus => Str
The status of the campaign, or the status of a treatment that belongs
to an A/B test campaign. Valid values: SCHEDULED, EXECUTING,
PENDING_NEXT_RUN, COMPLETED, PAUSED
=head1 SEE ALSO
This class forms part of L<Paws>, describing an object used in L<Paws::Pinpoint>
=head1 BUGS and CONTRIBUTIONS
The source code is located here: https://github.com/pplu/aws-sdk-perl
Please report bugs to: https://github.com/pplu/aws-sdk-perl/issues
=cut
| ioanrogers/aws-sdk-perl | auto-lib/Paws/Pinpoint/CampaignState.pm | Perl | apache-2.0 | 1,420 |
#
# Copyright 2021 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package apps::graylog::restapi::mode::query;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0, skipped_code => { -10 => 1 } }
];
$self->{maps_counters}->{global} = [
{ label => 'query-matches', nlabel => 'graylog.query.match.count', set => {
key_values => [ { name => 'query_matches' } ],
output_template => 'current queue messages: %s',
perfdatas => [
{ template => '%d', min => 0 }
]
}
}
];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
bless $self, $class;
$options{options}->add_options(arguments => {
'query:s' => { name => 'query' },
'timeframe:s' => { name => 'timeframe', default => 300 }
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
if (!defined($self->{option_results}->{query}) || $self->{option_results}->{query} eq '') {
$self->{output}->add_option_msg(short_msg => 'Please set --query option.');
$self->{output}->option_exit();
}
if (defined($self->{option_results}->{timeframe}) && $self->{option_results}->{timeframe} eq '') {
$self->{output}->add_option_msg(short_msg => 'Please set --timeframe value.');
$self->{output}->option_exit();
}
}
sub manage_selection {
my ($self, %options) = @_;
my $result = $options{custom}->query_relative(
query => $self->{option_results}->{query},
timeframe => $self->{option_results}->{timeframe}
);
$self->{global} = {
query_matches => $result->{total_results}
};
}
1;
__END__
=head1 MODE
Perform Lucene queries against Graylog API
Example:
perl centreon_plugins.pl --plugin=apps::graylog::restapi::plugin
--mode=query --hostname=10.0.0.1 --api-username='username' --api-password='password' --query='my query'
More information on https://docs.graylog.org/en/<version>/pages/configuration/rest_api.html
=over 8
=item B<--query>
Set a Lucene query.
=item B<--timeframe>
Set timeframe in seconds (E.g '300' to check last 5 minutes).
=item B<--warning-query-matches> B<--critical-query-matches>
Threshold on the number of results.
=back
=cut
| Tpo76/centreon-plugins | apps/graylog/restapi/mode/query.pm | Perl | apache-2.0 | 3,250 |
# Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
# Copyright [2016-2018] EMBL-European Bioinformatics Institute
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
=pod
=head1 NAME
Bio::EnsEMBL::Analysis::RunnableDB::BWA
=head1 SYNOPSIS
my $runnableDB = Bio::EnsEMBL::Analysis::RunnableDB::BWA->new( );
$runnableDB->fetch_input();
$runnableDB->run();
=head1 DESCRIPTION
This module uses BWA to align fastq to a genomic sequence
=head1 CONTACT
Post general queries to B<http://lists.ensembl.org/mailman/listinfo/dev>
=head1 APPENDIX
=cut
package Bio::EnsEMBL::Analysis::RunnableDB::BWA2BAM;
use warnings ;
use strict;
use Bio::EnsEMBL::Utils::Exception qw(throw warning);
use Bio::EnsEMBL::Analysis::Runnable::BWA2BAM;
use Bio::EnsEMBL::Analysis::RunnableDB::BWA;
use vars qw(@ISA);
@ISA = ("Bio::EnsEMBL::Analysis::RunnableDB::BWA");
sub new {
my ( $class, @args ) = @_;
my $self = $class->SUPER::new(@args);
return $self;
}
sub fetch_input {
my ($self) = @_;
my %parameters = %{$self->parameters_hash};
my $program = $self->analysis->program_file;
$self->throw("BWA program not defined in analysis \n")
if not defined $program;
my $filename = $self->INDIR ."/" .$self->input_id;
my $fastqpair;
my $method;
if ( $self->PAIRED ) {
$method = " sampe " . $self->SAMPE_OPTIONS;
# need to seaprate the 2 file names in the input id
my @files = split(/:/,$self->input_id);
$self->throw("Cannot parse 2 file names out of $self->input_id should be separated by :\n")
unless scalar(@files) == 2;
$filename = $self->INDIR ."/" .$files[0];
$fastqpair = $self->INDIR ."/" .$files[1];
} else {
$method = " samse " . $self->SAMSE_OPTIONS;
}
$self->throw("Fastq file $filename not found\n")
unless ( -e $filename );
if ( $self->PAIRED) {
$self->throw("Fastq pair file $fastqpair not found\n")
unless ( -e $fastqpair );
}
my $runnable = Bio::EnsEMBL::Analysis::Runnable::BWA2BAM->new
(
-analysis => $self->analysis,
-program => $program,
-fastq => $filename,
-fastqpair => $fastqpair,
-options => $self->OPTIONS,
-outdir => $self->OUTDIR,
-genome => $self->GENOMEFILE,
-method => $method,
-samtools => $self->SAMTOOLS_PATH,
-header => $self->HEADER,
-min_mapped => $self->MIN_MAPPED,
-min_paired => $self->MIN_PAIRED,
%parameters,
);
$self->runnable($runnable);
}
| kiwiroy/ensembl-analysis | modules/Bio/EnsEMBL/Analysis/RunnableDB/BWA2BAM.pm | Perl | apache-2.0 | 3,022 |
eval(prefix(A,X),[A|T]) :- eval(X,T).
eval(choice(X,_Y),T) :- eval(X,T).
eval(choice(_X,Y),T) :- eval(Y,T).
eval(stop,[]).
eval(par(X,Y),T) :- eval(X,T), eval(Y,T).
eval(agent(X),T) :- agent(X,Def), eval(Def,T).
agent(p, prefix(a,agent(p))).
agent(q, prefix(a, choice(stop, agent(q)))).
agent(r, par(agent(q), agent(q))).
agent(s, prefix(a, choice(prefix(b,stop), agent(s)))).
agent(t, choice(stop,prefix(a, par(agent(t),agent(t))))).
test(T) :- eval(agent(r),T).
test2(T) :- eval(par(agent(q),agent(s)),T).
test3(T) :- eval(agent(t),T).
p([c]).
p([b]).
p([a|X]):- p(X).
p([b|X]) :- p(X).
q([d]).
q([b]).
q([a|X]) :- q(X).
r([a]).
r([a|T]) :- r(T).
r([b|T]) :- r(T).
r([c|T]) :- r(T).
rev([],L,L).
rev([H|T],A,R) :- rev(T,[H|A],R).
t(X,R) :- p(X),q(X),rev(X,[],R),r(R).
t2(X) :- p(X),rev(X,[],X).
trans(prefix(A,X),A,X).
trans(par(X,Y),A,par(X2,Y2)) :- trans(X,A,X2), trans(Y,A,Y2).
trans(interleave(X,Y),A,interleave(X2,Y)) :- trans(X,A,X2).
trans(interleave(X,Y),A,interleave(X,Y2)) :- trans(Y,A,Y2).
trans(choice(X,Y),A,X2) :- trans(X,A,X2).
trans(choice(X,Y),A,Y2) :- trans(Y,A,Y2).
trans(agent(X),A,Y) :- agent_def(X,Def), trans(Def,A,Y).
stop(stop).
stop(par(X,Y)) :- stop(X),stop(Y).
stop(interleave(X,Y)) :- stop(X),stop(Y).
stop(choice(X,_Y)) :- stop(X).
stop(choice(_X,Y)) :- stop(Y).
agent_def(inf_as,choice(prefix(b,stop),prefix(a,agent(inf_as)))).
agent_def(p,choice(prefix(c,stop),prefix(a,par(agent(p),agent(p))))).
agent_def(q,choice(prefix(c,stop),prefix(a,agent(q)))).
agent_def(v,choice(stop,prefix(a,interleave(agent(v),prefix(b,stop))))).
agent_def(w,choice(prefix(b,stop),prefix(a,prefix(b,agent(w))))).
agent_def(v2,prefix(a,interleave(agent(v2),prefix(b,stop)))).
agent_def(w2,choice(prefix(b,stop),prefix(a,prefix(b,agent(w2))))).
agent_def(z2,prefix(a,interleave(agent(z2),agent(z2)))).
trace(X,[]) :- stop(X).
trace(X,[A|T]) :- trans(X,A,Y), trace(Y,T).
/* prefix traces: */
ptrace(X,[]).
ptrace(X,[A|T]) :- trans(X,A,Y), ptrace(Y,T).
test4(T) :- trace(agent(inf_as),T), trace(agent(q),T).
test5(T) :- trace(agent(inf_as),T), trace(agent(p),T).
test6(T) :- trace(agent(v),T), trace(agent(w),T).
test7(T) :- ptrace(agent(v2),T), ptrace(agent(w2),T).
/* check whether exists trace common to both */
| leuschel/ecce | ecce_examples/rultest.process.pl | Perl | apache-2.0 | 2,250 |
package VMOMI::VspanDestPortConflict;
use parent 'VMOMI::DvsFault';
use strict;
use warnings;
our @class_ancestors = (
'DvsFault',
'VimFault',
'MethodFault',
);
our @class_members = (
['vspanSessionKey1', undef, 0, ],
['vspanSessionKey2', undef, 0, ],
['portKey', undef, 0, ],
);
sub get_class_ancestors {
return @class_ancestors;
}
sub get_class_members {
my $class = shift;
my @super_members = $class->SUPER::get_class_members();
return (@super_members, @class_members);
}
1;
| stumpr/p5-vmomi | lib/VMOMI/VspanDestPortConflict.pm | Perl | apache-2.0 | 526 |
package Tapper::Reports::API;
# git description: v4.1.1-1-ga1a0e21
BEGIN {
$Tapper::Reports::API::AUTHORITY = 'cpan:TAPPER';
}
{
$Tapper::Reports::API::VERSION = '4.1.2';
}
# ABSTRACT: Tapper - Remote network API for result evaluation
use 5.010;
use strict;
use warnings;
use parent 'Net::Server::Fork';
use Tapper::Reports::DPath::Mason;
use Tapper::Reports::DPath::TT;
use Tapper::Model 'model';
use Data::Dumper;
sub process_request
{
my ($self) = @_;
my $cmdline = <STDIN>;
my ($cmd, @args) = _split_cmdline( $cmdline );
no strict 'refs'; ## no critic (ProhibitNoStrict)
$cmd //= "TAP";
my $handle = "handle_$cmd";
$self->$handle (@args);
}
sub handle_TAP
{
my ($self, @args) = @_;
#print STDERR "Unrecognized input, interpret as TAP, but: TAP reporting via this API not yet implemented\n";
print STDERR "Unrecognized input.\n";
}
sub handle_download
{
my ($self, $report_id, $filename, $index) = @_;
$index ||= 0;
my $asc_desc = $index < 0 ? '-desc' : '-asc';
$index = abs $index;
my %reportfilter = ();
$reportfilter{report_id} = $report_id if $report_id;
my $reportfile =
model('ReportsDB')
->resultset('ReportFile')
->search ({ %reportfilter,
filename => { like => $filename } },
{ order_by => { $asc_desc => 'id' } })
->slice($index, $index)->first;
print $reportfile->filecontent if $reportfile;
}
sub get_payload
{
my ($self, @args) = @_;
# unite '<<' and EOFMARKER when whitespace separated, in order to fix confusion
$args[-2] .= pop @args if $args[-2] && $args[-2] eq '<<';
my $EOFMARKER;
$EOFMARKER = $1 if $args[-1] =~ /<<(.*)/;
return '' unless $EOFMARKER;
# ----- read template -----
my $line;
my $payload = '';
while ($line = <STDIN>)
{
last if ($line =~ /^$EOFMARKER\s*$/);
$payload .= $line;
}
return $payload;
}
sub handle_tt
{
my ($self, @args) = @_;
do { print "Template Toolkit is not enabled\n"; return } unless Tapper::Config->subconfig->{reports_enable_tt};
my %args = _parse_args(@args[0..$#args-1]);
my $payload = $self->get_payload(@args);
my $tt = Tapper::Reports::DPath::TT->new (
debug => $args{debug} ? 1 : 0,
puresqlabstract => $args{puresqlabstract} ? 1 : 0,
);
my $answer = $tt->render(template => $payload);
print $answer;
}
sub handle_upload
{
my ($self, $report_id, $filename, $contenttype) = @_;
my $payload = '';
$payload .= $_ while <STDIN>;
my $reportfile = model('ReportsDB')->resultset('ReportFile')->new({ report_id => $report_id,
filename => $filename,
filecontent => $payload,
contenttype => $contenttype || 'plain', # 'application/octet-stream',
});
$reportfile->insert;
}
sub _parse_args {
my (@args) = @_;
my %args = ();
foreach (@args) {
my ($k, $v) = split /=/;
$k =~ s/^-+//;
$args{$k} = $v;
}
return %args;
}
sub handle_mason
{
my ($self, @args) = @_;
do { print "Mason is not enabled\n"; return } unless Tapper::Config->subconfig->{reports_enable_mason};
my %args = _parse_args(@args[0..$#args-1]);
my $payload = $self->get_payload(@args);
my $mason = Tapper::Reports::DPath::Mason->new (
debug => $args{debug} ? 1 : 0,
puresqlabstract => $args{puresqlabstract} ? 1 : 0,
);
my $answer = $mason->render(template => $payload);
print $answer;
}
sub _split_cmdline
{
my ($cmdline) = @_;
$cmdline =~ s/^\s+//;
my @list = split (/\s+/, $cmdline);
shift @list; # no shebang
return @list;
}
sub post_process_request_hook
{
my ($self) = @_;
}
1; # End of Tapper::Reports::API
__END__
=pod
=encoding utf-8
=head1 NAME
Tapper::Reports::API - Tapper - Remote network API for result evaluation
=head2 process_request
Initial hook called on incoming data, reads first line and calls
respective handler.
=head2 handle_TAP
Handler for incoming TAP.
=head2 handle_download
Handler for download request.
=head2 get_payload
Get the payload of an API request (the stuff after the first line).
=head2 handle_tt
Handler for TT query API requests.
=head2 handle_upload
Handler for upload requests.
=head2 handle_mason
Handler for TT query API requests.
=head2 post_process_request_hook
Hook called after processing, currrently a no-op.
=head1 AUTHOR
AMD OSRC Tapper Team <tapper@amd64.org>
=head1 COPYRIGHT AND LICENSE
This software is Copyright (c) 2012 by Advanced Micro Devices, Inc..
This is free software, licensed under:
The (two-clause) FreeBSD License
=cut
| gitpan/Tapper-Reports-API | lib/Tapper/Reports/API.pm | Perl | bsd-2-clause | 5,613 |
#!/usr/bin/perl
# Permutations
#
'(C) Copyright 2005-2015 Robert Dowling.';
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
package perm;
# Usage
# $p = new perm;
# @p = $p->init (3);
# do {
# print join(',', @p), "\n";
# @p = $p->next;
# } while (@p);
#
# use List::Util 'shuffle';
require Exporter;
our @ISA = qw(Exporter);
our @EXPORT = qw(fact);
# our @EXPORT = qw(new init state next fact);
# Create a new permutation object for N elements
sub new ()
{
my $self = {};
bless $self;
$self;
}
# Reinitialize to a new size (or the same size if no size passed in)
# Returns the first permutation, the one that goes 0..N-1
sub init ($$)
{
my ($self, $N) = @_;
$self->{N} = $N;
$self->{P} = [0..$N-1];
return $self->state;
}
sub state ()
{
my $self = shift;
return @{$self->{P}};
}
# Returns the next permutation or an empty list when done
sub next ()
{
my $self = shift;
my @P = @{$self->{P}};
# E.W.Dijkstra, A Discipline of Programming, Prentice-Hall, 1976, P 71.
my $i = $#P-1;
$i-- while ($P[$i] > $P[$i+1]);
return () if $i < 0;
my $j = $#P;
$j-- while ($P[$i] > $P[$j]);
# Swap P[i] and P[j]
($P[$i], $P[$j]) = ($P[$j], $P[$i]);
$i++;
$j = $#P;
while ($j > $i)
{
($P[$i], $P[$j]) = ($P[$j], $P[$i]);
$i++;
$j--;
}
$self->{P} = \@P;
@P;
}
##############################################################################
sub fact ($)
{
my $n = shift;
$n > 1 ? $n * fact($n-1) : 1;
}
1;
__END__
=head1 NAME
perm - perl library for simple permutations
=head1 SYNOPSIS
use perm;
@p = $p->init (3);
do {
print join(',', @p), "\n";
@p = $p->next;
} while (@p);
=head1 DESCRIPTION
The B<perm> library generates all the permutations of a list of B<N>
ordered numbers, 0..B<N>-1 using E.W.Dijkstra's algorithm, which does not
require nested loops.
=over
=item $p = new perm
Construct a new B<perm> object. It contains the state of the
permutation list. If you want to have multiple lists in different
states, create multiple objects.
=item $p->init (n)
Initialize the B<perm> object to have B<n> items in the initial state,
0..B<n>-1.
Returns the list in the initial state
=item $p->next
Advance to the next permutation.
Returns the list in the new state, or the empty list, () if all permutations
have been already exhausted.
=item fact (n)
Returns the factorial of B<n>, which is the number of permutations you
will get of the set of B<n> numbers.
=back
=head1 SEE ALSO
sets(3), stats(3), stats34(3), histo(3), normaldist(3), Stats(3), Histo(3)
=head1 AUTHOR
Robert Dowling <F<RPNCalcN@gmail.com>>.
=cut
| RobertTDowling/local | local/lib/perm.pm | Perl | bsd-2-clause | 3,364 |
#!/usr/bin/perl -w
# wrapper around flex
# The purpose of this script is basically to "fix" flex's output
# in a number of ways.
#
# 1. It changes a forward declaration of istream into a proper
# #include directive. In current C++ libraries, istream is not
# a class but rather a template specialization.
#
# 2. Fix the "yyclass" option output so that the resulting module
# can be linked with other flex-generated lexers:
#
# 2a. Wrap all yyFlexLexer methods with
# #ifdef WANT_YYFLEXLEXER_METHODS
# #endif
# so that from the Makefile I can control whether the object file
# contains those methods.
#
# 2b. Make copies of two yyFlexLexer methods and rename them to
# be methods of the derived lexer class, as these methods are
# different in each generated lexer. (This is optional.)
#
# 3. Redhat's flex-2.5.4a-29 (actually somewhere between -20 and -23)
# includes a "fix" so its generated output file includes the line:
#
# using namespace std;
#
# This causes a clash for the name 'string'. Long term, I'd like
# to have a good, general way to reconcile this clash. But for the
# short term, this script replaces that line with these two:
#
# using std::istream;
# using std::ostream;
#
# and that solves the problem nicely, as Flex does not use any
# library classes other than those two.
#
# 4. Emit proper #line directives for merged extensions.
# Given that I make so many changes, and they are so dependent on
# the details of the generated file, it might seem easier to just
# hack my own copy of flex and distribute that. I may end up
# doing that, but for now this provides a little portability (I
# will try to make this work with both 2.5.4 and 2.5.31), and
# avoids the need for me to repackage things like flex's configure
# script.
use strict 'subs';
# defaults
$nobackup = 0; # if true, require the scanner to be backup-free
$makeMethodCopies = 0; # if true, do step 2b above
$outputFile = ""; # name of eventual output file
$inputFile = ""; # name if input file
@flexArgs = ("flex"); # arguments to pass to flex
if (@ARGV == 0) {
print(<<"EOF");
usage: $0 [-nobackup] [-copies] -o<fname> [flex-options] input.lex
-nobackup: fail if the scanner can jam
-copies: make copies of methods that use per-lexer state
-o<fname>: specify output file name
For details on other flex options, consult "man flex".
EOF
exit(0);
}
# process command-line arguments; the syntax is basically a superset
# of what flex itself accepts
for (; @ARGV; shift @ARGV) {
# interestingly, both my choices of options are deprecated NOPs
# to flex in their single-letter forms (-n and -c), so there is
# little chance of confusion
if ($ARGV[0] eq "-nobackup") {
$nobackup = 1;
push @flexArgs, ("-b");
next;
}
if ($ARGV[0] eq "-copies") {
$makeMethodCopies = 1;
next;
}
my ($s) = ($ARGV[0] =~ m/^-o(.+)/);
if (defined($s)) {
diagnostic("saw output file: $s\n");
$outputFile = $s;
}
my ($if) = ($ARGV[0] =~ m/([^-].+)/);
$inputFile = $if if defined($if);
push @flexArgs, ($ARGV[0]);
}
if (!$inputFile) {
die("please specify an input file\n");
}
if (!$outputFile) {
die("please specify an output file with -o<file>\n");
}
# run flex
print(join(' ', @flexArgs) . "\n");
if (0!=system(@flexArgs)) {
print("flex failed, so removing output file $outputFile\n");
system("rm -f $outputFile");
exit(2);
}
# check for backing up
if ($nobackup) {
if (0==system("grep non-accepting lex.backup")) {
print("(see lex.backup for details)\n");
print("removing output file $outputFile\n");
system("rm -f $outputFile");
exit(2);
}
else {
unlink("lex.backup");
}
}
# don't want to give the impression that the only thing that was
# done was running flex, as I echoed that command line
print("modifying $outputFile\n");
# read the flex-generated output into memory
open(IN, "<$outputFile") or die("cannot read $outputFile: $!\n");
@lines = <IN>;
close(IN);
# start writing it again
open(OUT, ">$outputFile") or die("cannot write $outputFile: $!\n");
# keep track of what we've done
$state = 1;
# name of derived lexer class (if any)
$derivedClassName = "";
# text (lines) of methods to copy
@methodCopies = ();
# additional lines to move past the end of the methodCopies
@movedLines = ();
# within extension
my $extfilename;
my $extlineno = -1;
# filename as specified by last #line directive (including quotes)
my $linefile = "\"$outputFile\"";
my $lineno = 0; # current line number of processed output
# begin translating the generated file, making the changes outlined above
for ($i=0; $i < @lines; $i++) {
$line = $lines[$i];
# this is stateless for no good reason
my ($s) = ($line =~ m/^\#define YY_DECL int (.*)::yylex/);
if (defined($s) && $s ne "yyFlexLexer") {
$derivedClassName = $s;
}
# this is stateless because it does not occur in the cygwin
# flex output (they have a different fix)
if ($line =~ m/class istream;/) {
$lineno+=2;
print OUT ("#include <iostream> // class istream\n".
"using std::istream;\n");
next;
}
# also stateless for similar reasons
if ($line =~ m/using namespace std;/) {
$lineno++;
print OUT ("using std::istream;\n");
$lineno++;
print OUT ("using std::ostream;\n");
next;
}
# this 'undef' must be moved to after the copied methods because
# those methods refer to 'yytext_ptr', which is just a #define
# for 'yytext'
if ($makeMethodCopies &&
$line =~ m/\#undef yytext_ptr/) {
push @movedLines, ($line);
next;
}
# this is stateless because I don't understand the state stuff
# start of lexical extension
if ($line =~ /\/\* start of (?:extension|base) ([^(]*)\((\d+)\) \*\//) {
$extfilename = $1;
$extlineno = $2;
next;
}
# this is stateless because I don't understand the state stuff
# adjust #line directives for proper pointing into extensions
if ($extlineno != -1 && $line =~ /#line (\d+)\s+("[^"]*"|)/) {
$linefile = $2 unless $2 eq "";
my $filename = $linefile;
my $number = $lineno + 1;
if ($filename eq "\"$inputFile\"") {
$filename = "\"$extfilename\"";
$number = $1 - $extlineno;
} elsif ($filename ne "\"$outputFile\"") {
# if not output file, consider it preprocessed and leave as is
$number = $1;
}
$line = "#line $number $filename\n";
}
# this is stateless because I don't understand the state stuff
# end of lexical extension
if ($line =~ /\/\* end of extension (.*) \*\//) {
$extlineno = -1;
next;
}
if ($state == 1) {
if ($lines[$i+1] =~ m/^(static )?void \*(yy_flex_alloc|yyalloc)/) {
$state++;
$lineno++;
print OUT ("#ifndef NO_YYFLEXLEXER_METHODS\n");
next;
}
}
elsif ($state == 2) {
if ($line =~ m/^(static )?void (yy_flex_free|yyfree)/) {
$state++;
$i++;
$lineno++;
$lineno++;
print OUT ($line .
"#endif // yyflexlexer methods\n");
next;
}
}
elsif ($state == 3) {
if ($line =~ m/^\#include <FlexLexer.h>/) {
$state++;
$lineno++;
print OUT ("#include \"sm_flexlexer.h\"\n");
next;
}
}
elsif ($state == 4) {
if ($line =~ m/^int yyFlexLexer::yywrap/) {
$state++;
$lineno++;
$lineno++;
print OUT ("#ifndef NO_YYFLEXLEXER_METHODS\n" .
$line);
next;
} elsif ($line =~ m/^int yyFlexLexer::yylex/) {
$state++;
$i++; # skip the '{' line, to keep #line numbers in sync
chomp($line);
$lineno += 3;
print OUT ("#ifndef NO_YYFLEXLEXER_METHODS\n" .
$line . " {\n");
next;
}
}
elsif ($state == 5) {
if ($line =~ m/^\s*\}\s*$/) {
$state++;
$i++; # skip subsequent blank line
$lineno++;
$lineno++;
print OUT ($line .
"#endif // yyflexlexer methods\n");
next;
}
}
elsif ($state == 6) {
if ($lines[$i+1] =~ m/^yyFlexLexer::yyFlexLexer/) {
$state++;
$lineno++;
$lineno++;
print OUT ($line .
"#ifndef NO_YYFLEXLEXER_METHODS\n");
next;
}
}
elsif ($state == 7) {
if ($lines[$i+1] =~ m/yyFlexLexer::yy_get_previous_state/) {
$state++;
}
}
elsif ($state == 8) {
push @methodCopies, ($line);
if ($line =~ m/yyFlexLexer::yy_try_NUL_trans/) {
$state++;
# need to see how much this brace is indented, so we can
# find the matching one in the next state
($ind) = ($lines[$i+1] =~ m/^(\s*)\{/);
if (!defined($ind)) {
die("yy_try_NUL_trans not followed by line with left brace\n");
}
}
}
elsif ($state == 9) {
push @methodCopies, ($line);
if ($line =~ m/^$ind\}\s*$/) {
$state++;
}
}
elsif ($state == 10) {
if ($line =~ m/^\#line/) { # #line directive just before section 3
$state++;
# NOTE: This if-endif encloses the redefinition of 'yynext'
# that is appropriate for section 3. I never use yynext in
# section 3 (in fact I rarely use section 3 at all), but if
# someone does then this will need to be adjusted.
$lineno++;
print OUT ("#endif // yyflexlexer methods\n");
if ($makeMethodCopies) {
# emit the copied method text again, this time substituting
# the name of the derived lexer class
if (!$derivedClassName) {
die("$0: did not see a derived lexer class name\n");
}
$lineno++;
print OUT ("// BEGIN method copies for $derivedClassName\n");
foreach $copyLine (@methodCopies) {
$copyLine =~ s/yyFlexLexer/$derivedClassName/;
$lineno++;
print OUT ($copyLine);
}
$lineno++;
print OUT ("// END method copies for $derivedClassName\n");
$lineno += $#movedLines + 1;
print OUT (@movedLines);
}
}
}
elsif ($state == 11) {
# this state prevails until the end of the file; just check
# that the yynext breakage isn't being exposed
if ($line =~ m/yynext/) {
die("$0: unimplemented: 'yynext' used in section 3\n");
}
}
$lineno++;
print OUT ($line);
}
$lastState = 11;
if ($state != $lastState) {
$lineno++;
print OUT ("#error please rebuild $outputFile\n"); # in case not deleted
close(OUT); # flush
die("failed to reach state $lastState; got stuck in state " . $state);
}
close(OUT);
exit(0);
sub diagnostic {
#print(@_);
}
# EOF
| angavrilov/olmar | smbase/run-flex.pl | Perl | bsd-3-clause | 10,597 |
% Frame number: 0
holdsAt( coord( id0 )=( 189, 125 ), 0 ).
holdsAt( coord( id1 )=( 198, 74 ), 0 ).
holdsAt( coord( id2 )=( 26, 48 ), 0 ).
happensAt( walking( id3 ), 0 ). holdsAt( coord( id3 )=( 30, 29 ), 0 ).
% Frame number: 1
holdsAt( coord( id0 )=( 189, 125 ), 40 ).
holdsAt( coord( id1 )=( 198, 73 ), 40 ).
holdsAt( coord( id2 )=( 25, 48 ), 40 ).
holdsAt( coord( id3 )=( 29, 29 ), 40 ).
% Frame number: 2
holdsAt( coord( id0 )=( 189, 125 ), 80 ).
holdsAt( coord( id1 )=( 199, 73 ), 80 ).
holdsAt( coord( id2 )=( 25, 48 ), 80 ).
happensAt( walking( id3 ), 80 ). holdsAt( coord( id3 )=( 29, 29 ), 80 ).
% Frame number: 3
holdsAt( coord( id0 )=( 189, 125 ), 120 ).
happensAt( walking( id1 ), 120 ). holdsAt( coord( id1 )=( 202, 72 ), 120 ).
holdsAt( coord( id2 )=( 25, 48 ), 120 ).
holdsAt( coord( id3 )=( 29, 29 ), 120 ).
% Frame number: 4
holdsAt( coord( id0 )=( 189, 125 ), 160 ).
holdsAt( coord( id1 )=( 205, 71 ), 160 ).
holdsAt( coord( id2 )=( 25, 48 ), 160 ).
holdsAt( coord( id3 )=( 29, 29 ), 160 ).
% Frame number: 5
holdsAt( coord( id0 )=( 189, 125 ), 200 ).
holdsAt( coord( id1 )=( 206, 71 ), 200 ).
holdsAt( coord( id2 )=( 23, 48 ), 200 ).
holdsAt( coord( id3 )=( 29, 29 ), 200 ).
% Frame number: 6
holdsAt( coord( id0 )=( 189, 125 ), 240 ).
holdsAt( coord( id1 )=( 208, 70 ), 240 ).
holdsAt( coord( id2 )=( 22, 49 ), 240 ).
holdsAt( coord( id3 )=( 29, 29 ), 240 ).
% Frame number: 7
holdsAt( coord( id0 )=( 190, 125 ), 280 ).
holdsAt( coord( id1 )=( 210, 69 ), 280 ).
holdsAt( coord( id2 )=( 22, 49 ), 280 ).
holdsAt( coord( id3 )=( 29, 29 ), 280 ).
% Frame number: 8
holdsAt( coord( id0 )=( 190, 125 ), 320 ).
holdsAt( coord( id1 )=( 212, 68 ), 320 ).
holdsAt( coord( id2 )=( 22, 49 ), 320 ).
holdsAt( coord( id3 )=( 29, 30 ), 320 ).
% Frame number: 9
holdsAt( coord( id0 )=( 190, 125 ), 360 ).
holdsAt( coord( id1 )=( 212, 67 ), 360 ).
holdsAt( coord( id2 )=( 22, 49 ), 360 ).
holdsAt( coord( id3 )=( 29, 30 ), 360 ).
% Frame number: 10
holdsAt( coord( id0 )=( 190, 125 ), 400 ).
holdsAt( coord( id1 )=( 213, 65 ), 400 ).
holdsAt( coord( id2 )=( 22, 49 ), 400 ).
holdsAt( coord( id3 )=( 29, 31 ), 400 ).
% Frame number: 11
holdsAt( coord( id0 )=( 190, 125 ), 440 ).
holdsAt( coord( id1 )=( 213, 63 ), 440 ).
holdsAt( coord( id2 )=( 22, 49 ), 440 ).
holdsAt( coord( id3 )=( 29, 31 ), 440 ).
% Frame number: 12
holdsAt( coord( id0 )=( 190, 125 ), 480 ).
holdsAt( coord( id1 )=( 214, 60 ), 480 ).
holdsAt( coord( id2 )=( 22, 49 ), 480 ).
holdsAt( coord( id3 )=( 29, 31 ), 480 ).
% Frame number: 13
holdsAt( coord( id0 )=( 190, 125 ), 520 ).
holdsAt( coord( id1 )=( 214, 58 ), 520 ).
holdsAt( coord( id2 )=( 22, 49 ), 520 ).
happensAt( walking( id3 ), 520 ). holdsAt( coord( id3 )=( 29, 30 ), 520 ).
% Frame number: 14
holdsAt( coord( id0 )=( 190, 125 ), 560 ).
holdsAt( coord( id1 )=( 215, 55 ), 560 ).
holdsAt( coord( id2 )=( 22, 49 ), 560 ).
holdsAt( coord( id3 )=( 29, 31 ), 560 ).
% Frame number: 15
happensAt( inactive( id0 ), 600 ). holdsAt( coord( id0 )=( 190, 125 ), 600 ).
holdsAt( coord( id1 )=( 217, 53 ), 600 ).
holdsAt( coord( id2 )=( 21, 49 ), 600 ).
holdsAt( coord( id3 )=( 29, 31 ), 600 ).
% Frame number: 16
holdsAt( coord( id0 )=( 190, 125 ), 640 ).
holdsAt( coord( id1 )=( 219, 53 ), 640 ).
holdsAt( coord( id2 )=( 21, 49 ), 640 ).
holdsAt( coord( id3 )=( 29, 32 ), 640 ).
% Frame number: 17
holdsAt( coord( id0 )=( 190, 125 ), 680 ).
holdsAt( coord( id1 )=( 221, 52 ), 680 ).
holdsAt( coord( id2 )=( 21, 49 ), 680 ).
happensAt( walking( id3 ), 680 ). holdsAt( coord( id3 )=( 27, 32 ), 680 ).
% Frame number: 18
holdsAt( coord( id0 )=( 190, 125 ), 720 ).
holdsAt( coord( id1 )=( 224, 51 ), 720 ).
holdsAt( coord( id2 )=( 21, 49 ), 720 ).
holdsAt( coord( id3 )=( 27, 32 ), 720 ).
% Frame number: 19
happensAt( inactive( id0 ), 760 ). holdsAt( coord( id0 )=( 190, 125 ), 760 ).
holdsAt( coord( id1 )=( 226, 51 ), 760 ).
holdsAt( coord( id2 )=( 21, 50 ), 760 ).
holdsAt( coord( id3 )=( 26, 33 ), 760 ).
% Frame number: 20
happensAt( inactive( id0 ), 800 ). holdsAt( coord( id0 )=( 190, 125 ), 800 ).
holdsAt( coord( id1 )=( 227, 50 ), 800 ).
holdsAt( coord( id2 )=( 21, 50 ), 800 ).
holdsAt( coord( id3 )=( 25, 33 ), 800 ).
% Frame number: 21
happensAt( inactive( id0 ), 840 ). holdsAt( coord( id0 )=( 190, 125 ), 840 ).
holdsAt( coord( id1 )=( 228, 49 ), 840 ).
holdsAt( coord( id2 )=( 21, 50 ), 840 ).
holdsAt( coord( id3 )=( 25, 33 ), 840 ).
% Frame number: 22
holdsAt( coord( id0 )=( 190, 125 ), 880 ).
holdsAt( coord( id1 )=( 229, 47 ), 880 ).
holdsAt( coord( id2 )=( 21, 50 ), 880 ).
holdsAt( coord( id3 )=( 24, 33 ), 880 ).
% Frame number: 23
holdsAt( coord( id0 )=( 190, 125 ), 920 ).
holdsAt( coord( id1 )=( 230, 46 ), 920 ).
holdsAt( coord( id2 )=( 21, 50 ), 920 ).
holdsAt( coord( id3 )=( 24, 34 ), 920 ).
% Frame number: 24
holdsAt( coord( id0 )=( 190, 125 ), 960 ).
holdsAt( coord( id1 )=( 231, 44 ), 960 ).
holdsAt( coord( id2 )=( 21, 50 ), 960 ).
holdsAt( coord( id3 )=( 23, 34 ), 960 ).
% Frame number: 25
holdsAt( coord( id0 )=( 190, 125 ), 1000 ).
holdsAt( coord( id1 )=( 232, 42 ), 1000 ).
happensAt( walking( id2 ), 1000 ). holdsAt( coord( id2 )=( 20, 51 ), 1000 ).
holdsAt( coord( id3 )=( 22, 35 ), 1000 ).
% Frame number: 26
holdsAt( coord( id0 )=( 190, 125 ), 1040 ).
holdsAt( coord( id1 )=( 232, 39 ), 1040 ).
holdsAt( coord( id2 )=( 21, 52 ), 1040 ).
holdsAt( coord( id3 )=( 22, 35 ), 1040 ).
% Frame number: 27
holdsAt( coord( id0 )=( 190, 125 ), 1080 ).
holdsAt( coord( id1 )=( 233, 36 ), 1080 ).
holdsAt( coord( id2 )=( 21, 52 ), 1080 ).
holdsAt( coord( id3 )=( 22, 35 ), 1080 ).
% Frame number: 28
holdsAt( coord( id0 )=( 190, 125 ), 1120 ).
holdsAt( coord( id1 )=( 233, 34 ), 1120 ).
holdsAt( coord( id2 )=( 21, 52 ), 1120 ).
happensAt( walking( id3 ), 1120 ). holdsAt( coord( id3 )=( 22, 37 ), 1120 ).
% Frame number: 29
holdsAt( coord( id0 )=( 190, 125 ), 1160 ).
holdsAt( coord( id1 )=( 233, 33 ), 1160 ).
holdsAt( coord( id2 )=( 20, 52 ), 1160 ).
happensAt( walking( id3 ), 1160 ). holdsAt( coord( id3 )=( 23, 37 ), 1160 ).
% Frame number: 30
happensAt( active( id0 ), 1200 ). holdsAt( coord( id0 )=( 190, 125 ), 1200 ).
holdsAt( coord( id1 )=( 234, 33 ), 1200 ).
happensAt( walking( id2 ), 1200 ). holdsAt( coord( id2 )=( 20, 52 ), 1200 ).
holdsAt( coord( id3 )=( 24, 38 ), 1200 ).
% Frame number: 31
holdsAt( coord( id0 )=( 190, 125 ), 1240 ).
holdsAt( coord( id1 )=( 235, 32 ), 1240 ).
holdsAt( coord( id2 )=( 20, 53 ), 1240 ).
happensAt( walking( id3 ), 1240 ). holdsAt( coord( id3 )=( 24, 39 ), 1240 ).
% Frame number: 32
holdsAt( coord( id0 )=( 190, 125 ), 1280 ).
holdsAt( coord( id1 )=( 236, 32 ), 1280 ).
holdsAt( coord( id2 )=( 20, 53 ), 1280 ).
holdsAt( coord( id3 )=( 24, 39 ), 1280 ).
% Frame number: 33
happensAt( active( id0 ), 1320 ). holdsAt( coord( id0 )=( 190, 125 ), 1320 ).
holdsAt( coord( id1 )=( 237, 31 ), 1320 ).
happensAt( walking( id2 ), 1320 ). holdsAt( coord( id2 )=( 20, 53 ), 1320 ).
holdsAt( coord( id3 )=( 24, 39 ), 1320 ).
% Frame number: 34
holdsAt( coord( id0 )=( 191, 125 ), 1360 ).
holdsAt( coord( id1 )=( 238, 30 ), 1360 ).
holdsAt( coord( id2 )=( 20, 53 ), 1360 ).
holdsAt( coord( id3 )=( 24, 39 ), 1360 ).
% Frame number: 35
holdsAt( coord( id0 )=( 191, 125 ), 1400 ).
holdsAt( coord( id1 )=( 239, 29 ), 1400 ).
holdsAt( coord( id2 )=( 20, 53 ), 1400 ).
holdsAt( coord( id3 )=( 23, 40 ), 1400 ).
% Frame number: 36
holdsAt( coord( id0 )=( 191, 125 ), 1440 ).
holdsAt( coord( id1 )=( 240, 28 ), 1440 ).
holdsAt( coord( id2 )=( 20, 53 ), 1440 ).
happensAt( walking( id3 ), 1440 ). holdsAt( coord( id3 )=( 23, 40 ), 1440 ).
% Frame number: 37
holdsAt( coord( id0 )=( 191, 125 ), 1480 ).
holdsAt( coord( id1 )=( 241, 27 ), 1480 ).
holdsAt( coord( id2 )=( 20, 53 ), 1480 ).
holdsAt( coord( id3 )=( 23, 40 ), 1480 ).
% Frame number: 38
holdsAt( coord( id0 )=( 191, 125 ), 1520 ).
holdsAt( coord( id1 )=( 242, 25 ), 1520 ).
holdsAt( coord( id2 )=( 20, 54 ), 1520 ).
holdsAt( coord( id3 )=( 21, 39 ), 1520 ).
% Frame number: 39
holdsAt( coord( id0 )=( 191, 125 ), 1560 ).
holdsAt( coord( id1 )=( 242, 24 ), 1560 ).
holdsAt( coord( id2 )=( 20, 53 ), 1560 ).
holdsAt( coord( id3 )=( 21, 40 ), 1560 ).
% Frame number: 40
holdsAt( coord( id0 )=( 191, 125 ), 1600 ).
holdsAt( coord( id1 )=( 242, 22 ), 1600 ).
holdsAt( coord( id2 )=( 20, 53 ), 1600 ).
holdsAt( coord( id3 )=( 20, 40 ), 1600 ).
% Frame number: 41
holdsAt( coord( id0 )=( 191, 125 ), 1640 ).
holdsAt( coord( id1 )=( 243, 20 ), 1640 ).
happensAt( walking( id2 ), 1640 ). holdsAt( coord( id2 )=( 20, 53 ), 1640 ).
holdsAt( coord( id3 )=( 20, 40 ), 1640 ).
% Frame number: 42
holdsAt( coord( id0 )=( 191, 125 ), 1680 ).
holdsAt( coord( id1 )=( 243, 19 ), 1680 ).
holdsAt( coord( id2 )=( 20, 54 ), 1680 ).
holdsAt( coord( id3 )=( 20, 40 ), 1680 ).
% Frame number: 43
holdsAt( coord( id0 )=( 191, 125 ), 1720 ).
holdsAt( coord( id1 )=( 245, 18 ), 1720 ).
holdsAt( coord( id2 )=( 19, 54 ), 1720 ).
holdsAt( coord( id3 )=( 20, 40 ), 1720 ).
% Frame number: 44
holdsAt( coord( id0 )=( 191, 125 ), 1760 ).
holdsAt( coord( id1 )=( 246, 18 ), 1760 ).
holdsAt( coord( id2 )=( 19, 54 ), 1760 ).
holdsAt( coord( id3 )=( 20, 40 ), 1760 ).
% Frame number: 45
holdsAt( coord( id0 )=( 191, 125 ), 1800 ).
happensAt( walking( id1 ), 1800 ). holdsAt( coord( id1 )=( 246, 18 ), 1800 ).
holdsAt( coord( id2 )=( 19, 54 ), 1800 ).
holdsAt( coord( id3 )=( 20, 40 ), 1800 ).
% Frame number: 46
holdsAt( coord( id0 )=( 191, 125 ), 1840 ).
happensAt( walking( id1 ), 1840 ). holdsAt( coord( id1 )=( 247, 18 ), 1840 ).
holdsAt( coord( id2 )=( 19, 54 ), 1840 ).
holdsAt( coord( id3 )=( 20, 40 ), 1840 ).
% Frame number: 47
holdsAt( coord( id0 )=( 191, 125 ), 1880 ).
holdsAt( coord( id1 )=( 248, 18 ), 1880 ).
happensAt( walking( id2 ), 1880 ). holdsAt( coord( id2 )=( 19, 54 ), 1880 ).
holdsAt( coord( id3 )=( 20, 40 ), 1880 ).
% Frame number: 48
holdsAt( coord( id0 )=( 191, 125 ), 1920 ).
holdsAt( coord( id1 )=( 249, 18 ), 1920 ).
holdsAt( coord( id2 )=( 19, 54 ), 1920 ).
holdsAt( coord( id3 )=( 19, 40 ), 1920 ).
% Frame number: 49
holdsAt( coord( id0 )=( 191, 125 ), 1960 ).
holdsAt( coord( id1 )=( 250, 18 ), 1960 ).
happensAt( walking( id2 ), 1960 ). holdsAt( coord( id2 )=( 19, 54 ), 1960 ).
holdsAt( coord( id3 )=( 19, 41 ), 1960 ).
% Frame number: 50
holdsAt( coord( id0 )=( 191, 125 ), 2000 ).
holdsAt( coord( id1 )=( 251, 18 ), 2000 ).
holdsAt( coord( id2 )=( 19, 54 ), 2000 ).
holdsAt( coord( id3 )=( 19, 42 ), 2000 ).
% Frame number: 51
holdsAt( coord( id0 )=( 191, 125 ), 2040 ).
holdsAt( coord( id1 )=( 252, 17 ), 2040 ).
holdsAt( coord( id2 )=( 19, 54 ), 2040 ).
holdsAt( coord( id3 )=( 18, 42 ), 2040 ).
% Frame number: 52
holdsAt( coord( id0 )=( 191, 125 ), 2080 ).
holdsAt( coord( id1 )=( 252, 16 ), 2080 ).
holdsAt( coord( id2 )=( 19, 54 ), 2080 ).
holdsAt( coord( id3 )=( 18, 43 ), 2080 ).
% Frame number: 53
holdsAt( coord( id0 )=( 191, 125 ), 2120 ).
holdsAt( coord( id1 )=( 253, 15 ), 2120 ).
holdsAt( coord( id2 )=( 19, 54 ), 2120 ).
holdsAt( coord( id3 )=( 18, 43 ), 2120 ).
% Frame number: 54
holdsAt( coord( id0 )=( 191, 125 ), 2160 ).
holdsAt( coord( id1 )=( 255, 13 ), 2160 ).
holdsAt( coord( id2 )=( 19, 54 ), 2160 ).
holdsAt( coord( id3 )=( 17, 44 ), 2160 ).
% Frame number: 55
holdsAt( coord( id0 )=( 191, 125 ), 2200 ).
holdsAt( coord( id1 )=( 255, 12 ), 2200 ).
holdsAt( coord( id2 )=( 19, 54 ), 2200 ).
happensAt( walking( id3 ), 2200 ). holdsAt( coord( id3 )=( 17, 45 ), 2200 ).
% Frame number: 56
holdsAt( coord( id0 )=( 191, 125 ), 2240 ).
holdsAt( coord( id1 )=( 256, 10 ), 2240 ).
holdsAt( coord( id2 )=( 19, 54 ), 2240 ).
holdsAt( coord( id3 )=( 17, 45 ), 2240 ).
% Frame number: 57
holdsAt( coord( id0 )=( 192, 125 ), 2280 ).
holdsAt( coord( id1 )=( 256, 10 ), 2280 ).
holdsAt( coord( id2 )=( 19, 54 ), 2280 ).
holdsAt( coord( id3 )=( 17, 45 ), 2280 ).
% Frame number: 58
holdsAt( coord( id0 )=( 192, 125 ), 2320 ).
holdsAt( coord( id1 )=( 256, 10 ), 2320 ).
holdsAt( coord( id2 )=( 19, 54 ), 2320 ).
holdsAt( coord( id3 )=( 17, 45 ), 2320 ).
% Frame number: 59
holdsAt( coord( id0 )=( 193, 125 ), 2360 ).
holdsAt( coord( id1 )=( 256, 10 ), 2360 ).
holdsAt( coord( id2 )=( 19, 54 ), 2360 ).
holdsAt( coord( id3 )=( 18, 45 ), 2360 ).
% Frame number: 60
holdsAt( coord( id0 )=( 193, 124 ), 2400 ).
holdsAt( coord( id1 )=( 257, 10 ), 2400 ).
holdsAt( coord( id2 )=( 19, 54 ), 2400 ).
happensAt( walking( id3 ), 2400 ). holdsAt( coord( id3 )=( 18, 45 ), 2400 ).
% Frame number: 61
holdsAt( coord( id0 )=( 193, 124 ), 2440 ).
holdsAt( coord( id1 )=( 261, 10 ), 2440 ).
happensAt( walking( id3 ), 2440 ). holdsAt( coord( id3 )=( 18, 45 ), 2440 ).
% Frame number: 62
holdsAt( coord( id0 )=( 193, 124 ), 2480 ).
holdsAt( coord( id1 )=( 260, 10 ), 2480 ).
holdsAt( coord( id3 )=( 17, 46 ), 2480 ).
% Frame number: 63
happensAt( active( id0 ), 2520 ). holdsAt( coord( id0 )=( 193, 124 ), 2520 ).
holdsAt( coord( id1 )=( 260, 9 ), 2520 ).
holdsAt( coord( id3 )=( 17, 46 ), 2520 ).
% Frame number: 64
holdsAt( coord( id0 )=( 193, 124 ), 2560 ).
holdsAt( coord( id1 )=( 262, 9 ), 2560 ).
holdsAt( coord( id3 )=( 17, 46 ), 2560 ).
% Frame number: 65
holdsAt( coord( id0 )=( 193, 124 ), 2600 ).
holdsAt( coord( id1 )=( 262, 9 ), 2600 ).
holdsAt( coord( id3 )=( 17, 46 ), 2600 ).
% Frame number: 66
happensAt( active( id0 ), 2640 ). holdsAt( coord( id0 )=( 193, 124 ), 2640 ).
holdsAt( coord( id1 )=( 262, 7 ), 2640 ).
holdsAt( coord( id3 )=( 16, 46 ), 2640 ).
% Frame number: 67
holdsAt( coord( id0 )=( 193, 124 ), 2680 ).
holdsAt( coord( id1 )=( 265, 7 ), 2680 ).
holdsAt( coord( id3 )=( 16, 46 ), 2680 ).
% Frame number: 68
holdsAt( coord( id0 )=( 193, 124 ), 2720 ).
holdsAt( coord( id1 )=( 265, 5 ), 2720 ).
holdsAt( coord( id3 )=( 15, 46 ), 2720 ).
% Frame number: 69
holdsAt( coord( id0 )=( 193, 124 ), 2760 ).
holdsAt( coord( id3 )=( 15, 46 ), 2760 ).
% Frame number: 70
holdsAt( coord( id0 )=( 193, 124 ), 2800 ).
holdsAt( coord( id3 )=( 15, 46 ), 2800 ).
% Frame number: 71
holdsAt( coord( id0 )=( 193, 124 ), 2840 ).
holdsAt( coord( id3 )=( 15, 46 ), 2840 ).
% Frame number: 72
holdsAt( coord( id0 )=( 193, 124 ), 2880 ).
holdsAt( coord( id3 )=( 14, 46 ), 2880 ).
% Frame number: 73
holdsAt( coord( id0 )=( 193, 124 ), 2920 ).
holdsAt( coord( id3 )=( 14, 46 ), 2920 ).
% Frame number: 74
holdsAt( coord( id0 )=( 193, 124 ), 2960 ).
holdsAt( coord( id3 )=( 14, 46 ), 2960 ).
% Frame number: 75
holdsAt( coord( id0 )=( 193, 124 ), 3000 ).
holdsAt( coord( id3 )=( 14, 46 ), 3000 ).
% Frame number: 76
holdsAt( coord( id0 )=( 193, 124 ), 3040 ).
holdsAt( coord( id3 )=( 14, 46 ), 3040 ).
% Frame number: 77
holdsAt( coord( id0 )=( 193, 124 ), 3080 ).
holdsAt( coord( id3 )=( 14, 46 ), 3080 ).
% Frame number: 78
holdsAt( coord( id0 )=( 193, 124 ), 3120 ).
happensAt( walking( id3 ), 3120 ). holdsAt( coord( id3 )=( 14, 47 ), 3120 ).
% Frame number: 79
holdsAt( coord( id0 )=( 193, 124 ), 3160 ).
holdsAt( coord( id3 )=( 14, 47 ), 3160 ).
% Frame number: 80
holdsAt( coord( id0 )=( 193, 124 ), 3200 ).
holdsAt( coord( id3 )=( 14, 47 ), 3200 ).
% Frame number: 81
holdsAt( coord( id0 )=( 193, 124 ), 3240 ).
holdsAt( coord( id3 )=( 13, 48 ), 3240 ).
% Frame number: 82
holdsAt( coord( id0 )=( 193, 124 ), 3280 ).
holdsAt( coord( id3 )=( 13, 49 ), 3280 ).
% Frame number: 83
holdsAt( coord( id0 )=( 193, 124 ), 3320 ).
happensAt( walking( id3 ), 3320 ). holdsAt( coord( id3 )=( 13, 49 ), 3320 ).
% Frame number: 84
holdsAt( coord( id0 )=( 193, 124 ), 3360 ).
holdsAt( coord( id3 )=( 13, 49 ), 3360 ).
% Frame number: 85
holdsAt( coord( id0 )=( 193, 124 ), 3400 ).
holdsAt( coord( id3 )=( 12, 49 ), 3400 ).
% Frame number: 86
holdsAt( coord( id0 )=( 193, 124 ), 3440 ).
holdsAt( coord( id3 )=( 13, 49 ), 3440 ).
% Frame number: 87
holdsAt( coord( id0 )=( 193, 124 ), 3480 ).
holdsAt( coord( id3 )=( 13, 49 ), 3480 ).
% Frame number: 88
holdsAt( coord( id0 )=( 193, 124 ), 3520 ).
holdsAt( coord( id3 )=( 13, 49 ), 3520 ).
% Frame number: 89
holdsAt( coord( id0 )=( 193, 124 ), 3560 ).
holdsAt( coord( id3 )=( 13, 50 ), 3560 ).
% Frame number: 90
holdsAt( coord( id0 )=( 193, 124 ), 3600 ).
holdsAt( coord( id3 )=( 12, 50 ), 3600 ).
% Frame number: 91
holdsAt( coord( id0 )=( 193, 124 ), 3640 ).
holdsAt( coord( id3 )=( 12, 50 ), 3640 ).
% Frame number: 92
holdsAt( coord( id0 )=( 193, 124 ), 3680 ).
happensAt( walking( id3 ), 3680 ). holdsAt( coord( id3 )=( 12, 50 ), 3680 ).
% Frame number: 93
holdsAt( coord( id0 )=( 193, 123 ), 3720 ).
holdsAt( coord( id3 )=( 12, 50 ), 3720 ).
% Frame number: 94
holdsAt( coord( id0 )=( 193, 123 ), 3760 ).
holdsAt( coord( id3 )=( 12, 50 ), 3760 ).
% Frame number: 95
holdsAt( coord( id0 )=( 193, 123 ), 3800 ).
holdsAt( coord( id3 )=( 12, 50 ), 3800 ).
% Frame number: 96
holdsAt( coord( id0 )=( 193, 123 ), 3840 ).
holdsAt( coord( id3 )=( 11, 51 ), 3840 ).
% Frame number: 97
holdsAt( coord( id0 )=( 193, 123 ), 3880 ).
holdsAt( coord( id3 )=( 11, 51 ), 3880 ).
% Frame number: 98
holdsAt( coord( id0 )=( 194, 123 ), 3920 ).
holdsAt( coord( id3 )=( 11, 51 ), 3920 ).
% Frame number: 99
holdsAt( coord( id0 )=( 194, 123 ), 3960 ).
holdsAt( coord( id3 )=( 11, 51 ), 3960 ).
% Frame number: 100
holdsAt( coord( id0 )=( 194, 123 ), 4000 ).
holdsAt( coord( id3 )=( 11, 52 ), 4000 ).
% Frame number: 101
holdsAt( coord( id0 )=( 194, 123 ), 4040 ).
holdsAt( coord( id3 )=( 11, 52 ), 4040 ).
% Frame number: 102
holdsAt( coord( id0 )=( 194, 123 ), 4080 ).
holdsAt( coord( id3 )=( 11, 52 ), 4080 ).
% Frame number: 103
holdsAt( coord( id0 )=( 194, 123 ), 4120 ).
holdsAt( coord( id3 )=( 10, 52 ), 4120 ).
% Frame number: 104
holdsAt( coord( id0 )=( 194, 123 ), 4160 ).
holdsAt( coord( id3 )=( 10, 52 ), 4160 ).
% Frame number: 105
holdsAt( coord( id0 )=( 194, 123 ), 4200 ).
holdsAt( coord( id3 )=( 10, 52 ), 4200 ).
% Frame number: 106
happensAt( active( id0 ), 4240 ). holdsAt( coord( id0 )=( 194, 123 ), 4240 ).
holdsAt( coord( id3 )=( 10, 52 ), 4240 ).
% Frame number: 107
holdsAt( coord( id0 )=( 194, 123 ), 4280 ).
holdsAt( coord( id3 )=( 10, 52 ), 4280 ).
% Frame number: 108
holdsAt( coord( id0 )=( 194, 123 ), 4320 ).
holdsAt( coord( id3 )=( 10, 53 ), 4320 ).
% Frame number: 109
holdsAt( coord( id0 )=( 194, 123 ), 4360 ).
holdsAt( coord( id3 )=( 10, 53 ), 4360 ).
% Frame number: 110
holdsAt( coord( id0 )=( 194, 123 ), 4400 ).
holdsAt( coord( id3 )=( 10, 54 ), 4400 ).
% Frame number: 111
happensAt( active( id0 ), 4440 ). holdsAt( coord( id0 )=( 194, 123 ), 4440 ).
holdsAt( coord( id3 )=( 10, 54 ), 4440 ).
% Frame number: 112
holdsAt( coord( id0 )=( 194, 123 ), 4480 ).
holdsAt( coord( id3 )=( 10, 54 ), 4480 ).
% Frame number: 113
holdsAt( coord( id0 )=( 194, 123 ), 4520 ).
holdsAt( coord( id3 )=( 10, 54 ), 4520 ).
% Frame number: 114
holdsAt( coord( id0 )=( 194, 123 ), 4560 ).
holdsAt( coord( id3 )=( 10, 54 ), 4560 ).
% Frame number: 115
holdsAt( coord( id0 )=( 194, 123 ), 4600 ).
holdsAt( coord( id3 )=( 10, 54 ), 4600 ).
% Frame number: 116
holdsAt( coord( id0 )=( 194, 123 ), 4640 ).
holdsAt( coord( id3 )=( 9, 55 ), 4640 ).
% Frame number: 117
holdsAt( coord( id0 )=( 194, 123 ), 4680 ).
holdsAt( coord( id3 )=( 9, 55 ), 4680 ).
% Frame number: 118
holdsAt( coord( id0 )=( 194, 123 ), 4720 ).
holdsAt( coord( id3 )=( 9, 56 ), 4720 ).
% Frame number: 119
holdsAt( coord( id0 )=( 194, 123 ), 4760 ).
holdsAt( coord( id3 )=( 9, 56 ), 4760 ).
% Frame number: 120
holdsAt( coord( id0 )=( 194, 123 ), 4800 ).
holdsAt( coord( id3 )=( 9, 56 ), 4800 ).
% Frame number: 121
holdsAt( coord( id0 )=( 194, 123 ), 4840 ).
holdsAt( coord( id3 )=( 8, 56 ), 4840 ).
% Frame number: 122
holdsAt( coord( id0 )=( 194, 123 ), 4880 ).
holdsAt( coord( id3 )=( 8, 56 ), 4880 ).
% Frame number: 123
holdsAt( coord( id0 )=( 194, 123 ), 4920 ).
holdsAt( coord( id3 )=( 7, 57 ), 4920 ).
% Frame number: 124
holdsAt( coord( id0 )=( 194, 123 ), 4960 ).
holdsAt( coord( id3 )=( 7, 57 ), 4960 ).
% Frame number: 125
holdsAt( coord( id0 )=( 194, 123 ), 5000 ).
happensAt( walking( id3 ), 5000 ). holdsAt( coord( id3 )=( 7, 57 ), 5000 ).
% Frame number: 126
holdsAt( coord( id0 )=( 194, 123 ), 5040 ).
holdsAt( coord( id3 )=( 7, 57 ), 5040 ).
% Frame number: 127
holdsAt( coord( id0 )=( 194, 123 ), 5080 ).
holdsAt( coord( id3 )=( 7, 58 ), 5080 ).
% Frame number: 128
holdsAt( coord( id0 )=( 194, 123 ), 5120 ).
holdsAt( coord( id3 )=( 7, 58 ), 5120 ).
% Frame number: 129
holdsAt( coord( id0 )=( 194, 125 ), 5160 ).
holdsAt( coord( id3 )=( 7, 58 ), 5160 ).
% Frame number: 130
holdsAt( coord( id0 )=( 194, 125 ), 5200 ).
holdsAt( coord( id3 )=( 7, 59 ), 5200 ).
% Frame number: 131
holdsAt( coord( id0 )=( 194, 126 ), 5240 ).
holdsAt( coord( id3 )=( 7, 59 ), 5240 ).
% Frame number: 132
holdsAt( coord( id0 )=( 193, 126 ), 5280 ).
holdsAt( coord( id3 )=( 7, 59 ), 5280 ).
% Frame number: 133
holdsAt( coord( id0 )=( 192, 125 ), 5320 ).
holdsAt( coord( id3 )=( 7, 59 ), 5320 ).
% Frame number: 134
holdsAt( coord( id0 )=( 191, 125 ), 5360 ).
holdsAt( coord( id3 )=( 7, 60 ), 5360 ).
% Frame number: 135
holdsAt( coord( id0 )=( 190, 123 ), 5400 ).
holdsAt( coord( id3 )=( 7, 60 ), 5400 ).
% Frame number: 136
holdsAt( coord( id0 )=( 189, 121 ), 5440 ).
holdsAt( coord( id3 )=( 6, 60 ), 5440 ).
% Frame number: 137
holdsAt( coord( id0 )=( 188, 120 ), 5480 ).
holdsAt( coord( id3 )=( 6, 60 ), 5480 ).
% Frame number: 138
holdsAt( coord( id0 )=( 187, 120 ), 5520 ).
holdsAt( coord( id3 )=( 6, 60 ), 5520 ).
% Frame number: 139
holdsAt( coord( id0 )=( 187, 119 ), 5560 ).
happensAt( walking( id3 ), 5560 ). holdsAt( coord( id3 )=( 6, 60 ), 5560 ).
% Frame number: 140
holdsAt( coord( id0 )=( 186, 119 ), 5600 ).
holdsAt( coord( id3 )=( 6, 60 ), 5600 ).
% Frame number: 141
holdsAt( coord( id0 )=( 186, 118 ), 5640 ).
holdsAt( coord( id3 )=( 6, 61 ), 5640 ).
% Frame number: 142
happensAt( active( id0 ), 5680 ). holdsAt( coord( id0 )=( 185, 118 ), 5680 ).
holdsAt( coord( id3 )=( 6, 61 ), 5680 ).
% Frame number: 143
holdsAt( coord( id0 )=( 185, 117 ), 5720 ).
holdsAt( coord( id3 )=( 6, 61 ), 5720 ).
% Frame number: 144
holdsAt( coord( id0 )=( 185, 117 ), 5760 ).
holdsAt( coord( id3 )=( 6, 61 ), 5760 ).
% Frame number: 145
happensAt( active( id0 ), 5800 ). holdsAt( coord( id0 )=( 184, 117 ), 5800 ).
holdsAt( coord( id3 )=( 6, 62 ), 5800 ).
% Frame number: 146
holdsAt( coord( id0 )=( 184, 117 ), 5840 ).
holdsAt( coord( id3 )=( 6, 63 ), 5840 ).
% Frame number: 147
holdsAt( coord( id0 )=( 184, 117 ), 5880 ).
holdsAt( coord( id3 )=( 6, 63 ), 5880 ).
% Frame number: 148
holdsAt( coord( id0 )=( 184, 117 ), 5920 ).
holdsAt( coord( id3 )=( 6, 63 ), 5920 ).
% Frame number: 149
holdsAt( coord( id0 )=( 184, 117 ), 5960 ).
holdsAt( coord( id3 )=( 6, 65 ), 5960 ).
% Frame number: 150
holdsAt( coord( id0 )=( 184, 116 ), 6000 ).
holdsAt( coord( id3 )=( 6, 65 ), 6000 ).
% Frame number: 151
happensAt( active( id0 ), 6040 ). holdsAt( coord( id0 )=( 184, 116 ), 6040 ).
holdsAt( coord( id3 )=( 6, 65 ), 6040 ).
% Frame number: 152
holdsAt( coord( id0 )=( 184, 116 ), 6080 ).
holdsAt( coord( id3 )=( 6, 66 ), 6080 ).
% Frame number: 153
holdsAt( coord( id0 )=( 184, 116 ), 6120 ).
holdsAt( coord( id3 )=( 6, 66 ), 6120 ).
% Frame number: 154
holdsAt( coord( id0 )=( 185, 116 ), 6160 ).
holdsAt( coord( id3 )=( 6, 66 ), 6160 ).
% Frame number: 155
happensAt( active( id0 ), 6200 ). holdsAt( coord( id0 )=( 185, 116 ), 6200 ).
holdsAt( coord( id3 )=( 6, 66 ), 6200 ).
% Frame number: 156
holdsAt( coord( id0 )=( 185, 116 ), 6240 ).
happensAt( walking( id3 ), 6240 ). holdsAt( coord( id3 )=( 5, 67 ), 6240 ).
% Frame number: 157
holdsAt( coord( id0 )=( 185, 116 ), 6280 ).
holdsAt( coord( id3 )=( 5, 67 ), 6280 ).
% Frame number: 158
holdsAt( coord( id0 )=( 185, 116 ), 6320 ).
holdsAt( coord( id3 )=( 5, 67 ), 6320 ).
% Frame number: 159
holdsAt( coord( id0 )=( 185, 116 ), 6360 ).
holdsAt( coord( id3 )=( 5, 67 ), 6360 ).
% Frame number: 160
holdsAt( coord( id0 )=( 185, 116 ), 6400 ).
holdsAt( coord( id3 )=( 5, 67 ), 6400 ).
% Frame number: 161
holdsAt( coord( id0 )=( 185, 116 ), 6440 ).
holdsAt( coord( id3 )=( 5, 67 ), 6440 ).
% Frame number: 162
holdsAt( coord( id0 )=( 185, 116 ), 6480 ).
holdsAt( coord( id3 )=( 5, 68 ), 6480 ).
% Frame number: 163
holdsAt( coord( id0 )=( 185, 116 ), 6520 ).
holdsAt( coord( id3 )=( 5, 68 ), 6520 ).
% Frame number: 164
holdsAt( coord( id0 )=( 186, 116 ), 6560 ).
holdsAt( coord( id3 )=( 5, 68 ), 6560 ).
% Frame number: 165
holdsAt( coord( id0 )=( 186, 116 ), 6600 ).
holdsAt( coord( id3 )=( 5, 68 ), 6600 ).
% Frame number: 166
holdsAt( coord( id0 )=( 186, 116 ), 6640 ).
holdsAt( coord( id3 )=( 5, 68 ), 6640 ).
% Frame number: 167
holdsAt( coord( id0 )=( 186, 116 ), 6680 ).
happensAt( walking( id3 ), 6680 ). holdsAt( coord( id3 )=( 5, 68 ), 6680 ).
% Frame number: 168
holdsAt( coord( id0 )=( 187, 117 ), 6720 ).
holdsAt( coord( id3 )=( 5, 68 ), 6720 ).
% Frame number: 169
happensAt( active( id0 ), 6760 ). holdsAt( coord( id0 )=( 187, 117 ), 6760 ).
holdsAt( coord( id3 )=( 5, 68 ), 6760 ).
% Frame number: 170
holdsAt( coord( id0 )=( 187, 117 ), 6800 ).
happensAt( walking( id3 ), 6800 ). holdsAt( coord( id3 )=( 5, 68 ), 6800 ).
% Frame number: 171
happensAt( active( id0 ), 6840 ). holdsAt( coord( id0 )=( 187, 117 ), 6840 ).
holdsAt( coord( id3 )=( 5, 68 ), 6840 ).
% Frame number: 172
holdsAt( coord( id0 )=( 187, 117 ), 6880 ).
holdsAt( coord( id3 )=( 4, 69 ), 6880 ).
% Frame number: 173
holdsAt( coord( id0 )=( 188, 118 ), 6920 ).
holdsAt( coord( id3 )=( 4, 69 ), 6920 ).
% Frame number: 174
holdsAt( coord( id0 )=( 188, 118 ), 6960 ).
holdsAt( coord( id3 )=( 4, 69 ), 6960 ).
% Frame number: 175
holdsAt( coord( id0 )=( 188, 118 ), 7000 ).
holdsAt( coord( id3 )=( 4, 69 ), 7000 ).
% Frame number: 176
holdsAt( coord( id0 )=( 189, 119 ), 7040 ).
holdsAt( coord( id3 )=( 4, 69 ), 7040 ).
% Frame number: 177
holdsAt( coord( id0 )=( 189, 120 ), 7080 ).
holdsAt( coord( id3 )=( 4, 69 ), 7080 ).
% Frame number: 178
happensAt( active( id0 ), 7120 ). holdsAt( coord( id0 )=( 189, 121 ), 7120 ).
holdsAt( coord( id3 )=( 4, 69 ), 7120 ).
% Frame number: 179
holdsAt( coord( id0 )=( 191, 122 ), 7160 ).
holdsAt( coord( id3 )=( 4, 69 ), 7160 ).
% Frame number: 180
holdsAt( coord( id0 )=( 192, 124 ), 7200 ).
happensAt( walking( id3 ), 7200 ). holdsAt( coord( id3 )=( 4, 71 ), 7200 ).
% Frame number: 181
holdsAt( coord( id0 )=( 194, 125 ), 7240 ).
holdsAt( coord( id3 )=( 4, 71 ), 7240 ).
% Frame number: 182
holdsAt( coord( id0 )=( 196, 127 ), 7280 ).
holdsAt( coord( id3 )=( 4, 71 ), 7280 ).
% Frame number: 183
holdsAt( coord( id0 )=( 198, 128 ), 7320 ).
holdsAt( coord( id3 )=( 4, 71 ), 7320 ).
% Frame number: 184
holdsAt( coord( id0 )=( 199, 130 ), 7360 ).
holdsAt( coord( id3 )=( 3, 73 ), 7360 ).
% Frame number: 185
holdsAt( coord( id0 )=( 201, 132 ), 7400 ).
holdsAt( coord( id3 )=( 3, 73 ), 7400 ).
% Frame number: 186
holdsAt( coord( id0 )=( 204, 134 ), 7440 ).
% Frame number: 187
holdsAt( coord( id0 )=( 206, 135 ), 7480 ).
% Frame number: 188
holdsAt( coord( id0 )=( 207, 137 ), 7520 ).
% Frame number: 189
holdsAt( coord( id0 )=( 208, 138 ), 7560 ).
% Frame number: 190
holdsAt( coord( id0 )=( 209, 139 ), 7600 ).
% Frame number: 191
holdsAt( coord( id0 )=( 210, 140 ), 7640 ).
% Frame number: 192
holdsAt( coord( id0 )=( 211, 141 ), 7680 ).
% Frame number: 193
holdsAt( coord( id0 )=( 213, 142 ), 7720 ).
% Frame number: 194
holdsAt( coord( id0 )=( 216, 144 ), 7760 ).
% Frame number: 195
holdsAt( coord( id0 )=( 219, 146 ), 7800 ).
% Frame number: 196
holdsAt( coord( id0 )=( 223, 147 ), 7840 ).
% Frame number: 197
happensAt( walking( id0 ), 7880 ). holdsAt( coord( id0 )=( 226, 149 ), 7880 ).
% Frame number: 198
holdsAt( coord( id0 )=( 228, 152 ), 7920 ).
% Frame number: 199
holdsAt( coord( id0 )=( 231, 155 ), 7960 ).
% Frame number: 200
holdsAt( coord( id0 )=( 232, 157 ), 8000 ).
% Frame number: 201
happensAt( walking( id0 ), 8040 ). holdsAt( coord( id0 )=( 233, 159 ), 8040 ).
% Frame number: 202
holdsAt( coord( id0 )=( 235, 161 ), 8080 ).
% Frame number: 203
holdsAt( coord( id0 )=( 236, 162 ), 8120 ).
% Frame number: 204
happensAt( walking( id0 ), 8160 ). holdsAt( coord( id0 )=( 237, 165 ), 8160 ).
% Frame number: 205
holdsAt( coord( id0 )=( 238, 166 ), 8200 ).
% Frame number: 206
holdsAt( coord( id0 )=( 239, 168 ), 8240 ).
% Frame number: 207
holdsAt( coord( id0 )=( 241, 172 ), 8280 ).
% Frame number: 208
holdsAt( coord( id0 )=( 243, 176 ), 8320 ).
% Frame number: 209
holdsAt( coord( id0 )=( 244, 179 ), 8360 ).
% Frame number: 210
holdsAt( coord( id0 )=( 246, 183 ), 8400 ).
% Frame number: 211
holdsAt( coord( id0 )=( 247, 188 ), 8440 ).
% Frame number: 212
holdsAt( coord( id0 )=( 248, 191 ), 8480 ).
% Frame number: 213
holdsAt( coord( id0 )=( 251, 194 ), 8520 ).
% Frame number: 214
holdsAt( coord( id0 )=( 253, 195 ), 8560 ).
% Frame number: 215
holdsAt( coord( id0 )=( 255, 197 ), 8600 ).
% Frame number: 216
holdsAt( coord( id0 )=( 258, 199 ), 8640 ).
% Frame number: 217
holdsAt( coord( id0 )=( 259, 201 ), 8680 ).
% Frame number: 218
holdsAt( coord( id0 )=( 261, 205 ), 8720 ).
% Frame number: 219
holdsAt( coord( id0 )=( 264, 210 ), 8760 ).
% Frame number: 220
holdsAt( coord( id0 )=( 267, 214 ), 8800 ).
% Frame number: 221
holdsAt( coord( id0 )=( 270, 217 ), 8840 ).
% Frame number: 222
holdsAt( coord( id0 )=( 273, 220 ), 8880 ).
% Frame number: 223
holdsAt( coord( id0 )=( 276, 223 ), 8920 ).
% Frame number: 224
holdsAt( coord( id0 )=( 278, 225 ), 8960 ).
% Frame number: 225
holdsAt( coord( id0 )=( 280, 227 ), 9000 ).
% Frame number: 226
holdsAt( coord( id0 )=( 281, 231 ), 9040 ).
% Frame number: 227
holdsAt( coord( id0 )=( 282, 233 ), 9080 ).
% Frame number: 228
happensAt( walking( id0 ), 9120 ). holdsAt( coord( id0 )=( 284, 238 ), 9120 ).
% Frame number: 229
holdsAt( coord( id0 )=( 284, 242 ), 9160 ).
% Frame number: 230
holdsAt( coord( id0 )=( 284, 247 ), 9200 ).
% Frame number: 231
holdsAt( coord( id0 )=( 285, 252 ), 9240 ).
% Frame number: 232
holdsAt( coord( id0 )=( 287, 253 ), 9280 ).
% Frame number: 233
holdsAt( coord( id0 )=( 287, 255 ), 9320 ).
% Frame number: 234
holdsAt( coord( id0 )=( 288, 257 ), 9360 ).
% Frame number: 235
happensAt( walking( id0 ), 9400 ). holdsAt( coord( id0 )=( 289, 258 ), 9400 ).
% Frame number: 236
holdsAt( coord( id0 )=( 289, 260 ), 9440 ).
% Frame number: 237
holdsAt( coord( id0 )=( 289, 261 ), 9480 ).
% Frame number: 238
holdsAt( coord( id0 )=( 290, 263 ), 9520 ).
holdsAt( coord( id4 )=( 283, 4 ), 9520 ).
% Frame number: 239
holdsAt( coord( id0 )=( 290, 265 ), 9560 ).
holdsAt( coord( id4 )=( 281, 5 ), 9560 ).
% Frame number: 240
happensAt( walking( id0 ), 9600 ). holdsAt( coord( id0 )=( 292, 267 ), 9600 ).
holdsAt( coord( id4 )=( 279, 6 ), 9600 ).
% Frame number: 241
holdsAt( coord( id0 )=( 293, 270 ), 9640 ).
holdsAt( coord( id4 )=( 279, 7 ), 9640 ).
% Frame number: 242
holdsAt( coord( id0 )=( 294, 273 ), 9680 ).
happensAt( walking( id4 ), 9680 ). holdsAt( coord( id4 )=( 278, 7 ), 9680 ).
% Frame number: 243
holdsAt( coord( id0 )=( 294, 276 ), 9720 ).
holdsAt( coord( id4 )=( 278, 8 ), 9720 ).
% Frame number: 244
holdsAt( coord( id0 )=( 294, 277 ), 9760 ).
holdsAt( coord( id4 )=( 278, 8 ), 9760 ).
% Frame number: 245
holdsAt( coord( id0 )=( 295, 277 ), 9800 ).
holdsAt( coord( id4 )=( 276, 8 ), 9800 ).
% Frame number: 246
happensAt( walking( id0 ), 9840 ). holdsAt( coord( id0 )=( 296, 277 ), 9840 ).
holdsAt( coord( id4 )=( 275, 8 ), 9840 ).
% Frame number: 247
happensAt( walking( id0 ), 9880 ). holdsAt( coord( id0 )=( 296, 278 ), 9880 ).
holdsAt( coord( id4 )=( 279, 8 ), 9880 ).
% Frame number: 248
holdsAt( coord( id0 )=( 298, 278 ), 9920 ).
holdsAt( coord( id4 )=( 278, 8 ), 9920 ).
% Frame number: 249
holdsAt( coord( id0 )=( 299, 278 ), 9960 ).
holdsAt( coord( id4 )=( 276, 8 ), 9960 ).
% Frame number: 250
happensAt( walking( id0 ), 10000 ). holdsAt( coord( id0 )=( 300, 280 ), 10000 ).
holdsAt( coord( id4 )=( 276, 8 ), 10000 ).
% Frame number: 251
holdsAt( coord( id0 )=( 301, 282 ), 10040 ).
holdsAt( coord( id4 )=( 274, 10 ), 10040 ).
% Frame number: 252
holdsAt( coord( id0 )=( 301, 284 ), 10080 ).
holdsAt( coord( id4 )=( 272, 12 ), 10080 ).
% Frame number: 253
holdsAt( coord( id4 )=( 271, 13 ), 10120 ).
% Frame number: 254
holdsAt( coord( id4 )=( 270, 14 ), 10160 ).
% Frame number: 255
holdsAt( coord( id4 )=( 270, 14 ), 10200 ).
% Frame number: 256
holdsAt( coord( id4 )=( 269, 15 ), 10240 ).
% Frame number: 257
holdsAt( coord( id4 )=( 268, 16 ), 10280 ).
% Frame number: 258
holdsAt( coord( id4 )=( 267, 16 ), 10320 ).
% Frame number: 259
happensAt( walking( id4 ), 10360 ). holdsAt( coord( id4 )=( 266, 16 ), 10360 ).
% Frame number: 260
happensAt( walking( id4 ), 10400 ). holdsAt( coord( id4 )=( 264, 16 ), 10400 ).
% Frame number: 261
holdsAt( coord( id4 )=( 262, 16 ), 10440 ).
% Frame number: 262
holdsAt( coord( id4 )=( 260, 16 ), 10480 ).
% Frame number: 263
holdsAt( coord( id4 )=( 259, 16 ), 10520 ).
% Frame number: 264
holdsAt( coord( id4 )=( 258, 16 ), 10560 ).
% Frame number: 265
holdsAt( coord( id4 )=( 258, 18 ), 10600 ).
% Frame number: 266
holdsAt( coord( id4 )=( 257, 19 ), 10640 ).
% Frame number: 267
holdsAt( coord( id4 )=( 256, 20 ), 10680 ).
% Frame number: 268
holdsAt( coord( id4 )=( 254, 21 ), 10720 ).
% Frame number: 269
holdsAt( coord( id4 )=( 254, 22 ), 10760 ).
% Frame number: 270
holdsAt( coord( id4 )=( 253, 23 ), 10800 ).
% Frame number: 271
holdsAt( coord( id4 )=( 251, 24 ), 10840 ).
% Frame number: 272
holdsAt( coord( id4 )=( 250, 25 ), 10880 ).
% Frame number: 273
holdsAt( coord( id4 )=( 248, 25 ), 10920 ).
% Frame number: 274
holdsAt( coord( id4 )=( 245, 25 ), 10960 ).
% Frame number: 275
holdsAt( coord( id4 )=( 243, 26 ), 11000 ).
% Frame number: 276
holdsAt( coord( id4 )=( 241, 26 ), 11040 ).
% Frame number: 277
holdsAt( coord( id4 )=( 239, 27 ), 11080 ).
% Frame number: 278
holdsAt( coord( id4 )=( 237, 29 ), 11120 ).
% Frame number: 279
holdsAt( coord( id4 )=( 237, 31 ), 11160 ).
% Frame number: 280
holdsAt( coord( id4 )=( 235, 34 ), 11200 ).
% Frame number: 281
holdsAt( coord( id4 )=( 235, 35 ), 11240 ).
% Frame number: 282
holdsAt( coord( id4 )=( 234, 36 ), 11280 ).
% Frame number: 283
holdsAt( coord( id4 )=( 233, 38 ), 11320 ).
% Frame number: 284
holdsAt( coord( id4 )=( 231, 39 ), 11360 ).
% Frame number: 285
holdsAt( coord( id4 )=( 230, 40 ), 11400 ).
% Frame number: 286
holdsAt( coord( id4 )=( 228, 41 ), 11440 ).
% Frame number: 287
holdsAt( coord( id4 )=( 226, 42 ), 11480 ).
% Frame number: 288
holdsAt( coord( id4 )=( 223, 42 ), 11520 ).
% Frame number: 289
holdsAt( coord( id4 )=( 220, 43 ), 11560 ).
% Frame number: 290
holdsAt( coord( id4 )=( 218, 42 ), 11600 ).
% Frame number: 291
holdsAt( coord( id4 )=( 217, 43 ), 11640 ).
% Frame number: 292
holdsAt( coord( id4 )=( 216, 44 ), 11680 ).
% Frame number: 293
holdsAt( coord( id4 )=( 216, 45 ), 11720 ).
% Frame number: 294
holdsAt( coord( id4 )=( 215, 47 ), 11760 ).
% Frame number: 295
holdsAt( coord( id4 )=( 214, 48 ), 11800 ).
% Frame number: 296
holdsAt( coord( id4 )=( 214, 50 ), 11840 ).
% Frame number: 297
holdsAt( coord( id4 )=( 212, 51 ), 11880 ).
% Frame number: 298
holdsAt( coord( id4 )=( 212, 51 ), 11920 ).
% Frame number: 299
holdsAt( coord( id4 )=( 209, 53 ), 11960 ).
% Frame number: 300
holdsAt( coord( id4 )=( 207, 53 ), 12000 ).
% Frame number: 301
holdsAt( coord( id4 )=( 205, 54 ), 12040 ).
% Frame number: 302
holdsAt( coord( id4 )=( 201, 54 ), 12080 ).
% Frame number: 303
holdsAt( coord( id4 )=( 199, 55 ), 12120 ).
% Frame number: 304
holdsAt( coord( id4 )=( 196, 55 ), 12160 ).
% Frame number: 305
holdsAt( coord( id4 )=( 194, 56 ), 12200 ).
% Frame number: 306
holdsAt( coord( id4 )=( 193, 58 ), 12240 ).
% Frame number: 307
holdsAt( coord( id4 )=( 192, 60 ), 12280 ).
% Frame number: 308
holdsAt( coord( id4 )=( 192, 63 ), 12320 ).
% Frame number: 309
happensAt( walking( id4 ), 12360 ). holdsAt( coord( id4 )=( 191, 64 ), 12360 ).
% Frame number: 310
holdsAt( coord( id4 )=( 190, 65 ), 12400 ).
% Frame number: 311
holdsAt( coord( id4 )=( 189, 66 ), 12440 ).
% Frame number: 312
holdsAt( coord( id4 )=( 188, 67 ), 12480 ).
% Frame number: 313
holdsAt( coord( id4 )=( 186, 68 ), 12520 ).
% Frame number: 314
holdsAt( coord( id4 )=( 184, 69 ), 12560 ).
% Frame number: 315
holdsAt( coord( id4 )=( 181, 70 ), 12600 ).
% Frame number: 316
holdsAt( coord( id4 )=( 178, 70 ), 12640 ).
% Frame number: 317
holdsAt( coord( id4 )=( 176, 71 ), 12680 ).
% Frame number: 318
holdsAt( coord( id4 )=( 174, 71 ), 12720 ).
% Frame number: 319
holdsAt( coord( id4 )=( 173, 71 ), 12760 ).
% Frame number: 320
holdsAt( coord( id4 )=( 172, 72 ), 12800 ).
% Frame number: 321
holdsAt( coord( id4 )=( 171, 73 ), 12840 ).
% Frame number: 322
holdsAt( coord( id4 )=( 170, 75 ), 12880 ).
% Frame number: 323
holdsAt( coord( id4 )=( 170, 76 ), 12920 ).
% Frame number: 324
holdsAt( coord( id4 )=( 169, 78 ), 12960 ).
% Frame number: 325
happensAt( walking( id4 ), 13000 ). holdsAt( coord( id4 )=( 168, 79 ), 13000 ).
% Frame number: 326
holdsAt( coord( id4 )=( 166, 80 ), 13040 ).
% Frame number: 327
holdsAt( coord( id4 )=( 165, 81 ), 13080 ).
% Frame number: 328
holdsAt( coord( id4 )=( 163, 81 ), 13120 ).
% Frame number: 329
holdsAt( coord( id4 )=( 160, 81 ), 13160 ).
% Frame number: 330
holdsAt( coord( id4 )=( 158, 82 ), 13200 ).
% Frame number: 331
happensAt( walking( id4 ), 13240 ). holdsAt( coord( id4 )=( 155, 83 ), 13240 ).
% Frame number: 332
holdsAt( coord( id4 )=( 153, 83 ), 13280 ).
% Frame number: 333
holdsAt( coord( id4 )=( 151, 84 ), 13320 ).
% Frame number: 334
holdsAt( coord( id4 )=( 150, 86 ), 13360 ).
% Frame number: 335
holdsAt( coord( id4 )=( 150, 87 ), 13400 ).
% Frame number: 336
holdsAt( coord( id4 )=( 149, 89 ), 13440 ).
% Frame number: 337
holdsAt( coord( id4 )=( 149, 90 ), 13480 ).
% Frame number: 338
holdsAt( coord( id4 )=( 148, 91 ), 13520 ).
% Frame number: 339
happensAt( walking( id4 ), 13560 ). holdsAt( coord( id4 )=( 147, 92 ), 13560 ).
% Frame number: 340
holdsAt( coord( id4 )=( 146, 93 ), 13600 ).
% Frame number: 341
happensAt( walking( id4 ), 13640 ). holdsAt( coord( id4 )=( 145, 94 ), 13640 ).
% Frame number: 342
holdsAt( coord( id4 )=( 143, 94 ), 13680 ).
% Frame number: 343
holdsAt( coord( id4 )=( 141, 95 ), 13720 ).
% Frame number: 344
holdsAt( coord( id4 )=( 139, 95 ), 13760 ).
% Frame number: 345
holdsAt( coord( id4 )=( 136, 96 ), 13800 ).
% Frame number: 346
holdsAt( coord( id4 )=( 134, 96 ), 13840 ).
% Frame number: 347
holdsAt( coord( id4 )=( 133, 96 ), 13880 ).
% Frame number: 348
holdsAt( coord( id4 )=( 133, 96 ), 13920 ).
% Frame number: 349
holdsAt( coord( id4 )=( 132, 97 ), 13960 ).
% Frame number: 350
holdsAt( coord( id4 )=( 132, 98 ), 14000 ).
% Frame number: 351
holdsAt( coord( id4 )=( 131, 99 ), 14040 ).
% Frame number: 352
holdsAt( coord( id4 )=( 131, 100 ), 14080 ).
% Frame number: 353
holdsAt( coord( id4 )=( 130, 101 ), 14120 ).
% Frame number: 354
holdsAt( coord( id4 )=( 129, 102 ), 14160 ).
% Frame number: 355
holdsAt( coord( id4 )=( 128, 102 ), 14200 ).
% Frame number: 356
holdsAt( coord( id4 )=( 127, 103 ), 14240 ).
% Frame number: 357
holdsAt( coord( id4 )=( 124, 104 ), 14280 ).
% Frame number: 358
holdsAt( coord( id4 )=( 122, 104 ), 14320 ).
% Frame number: 359
holdsAt( coord( id4 )=( 120, 104 ), 14360 ).
% Frame number: 360
holdsAt( coord( id4 )=( 118, 104 ), 14400 ).
% Frame number: 361
holdsAt( coord( id4 )=( 117, 105 ), 14440 ).
% Frame number: 362
holdsAt( coord( id4 )=( 117, 107 ), 14480 ).
% Frame number: 363
holdsAt( coord( id4 )=( 116, 108 ), 14520 ).
% Frame number: 364
holdsAt( coord( id4 )=( 115, 109 ), 14560 ).
% Frame number: 365
holdsAt( coord( id4 )=( 115, 110 ), 14600 ).
% Frame number: 366
holdsAt( coord( id4 )=( 115, 110 ), 14640 ).
% Frame number: 367
holdsAt( coord( id4 )=( 114, 111 ), 14680 ).
% Frame number: 368
holdsAt( coord( id4 )=( 113, 112 ), 14720 ).
% Frame number: 369
happensAt( walking( id4 ), 14760 ). holdsAt( coord( id4 )=( 112, 112 ), 14760 ).
% Frame number: 370
holdsAt( coord( id4 )=( 111, 113 ), 14800 ).
% Frame number: 371
happensAt( walking( id4 ), 14840 ). holdsAt( coord( id4 )=( 109, 113 ), 14840 ).
% Frame number: 372
holdsAt( coord( id4 )=( 107, 113 ), 14880 ).
% Frame number: 373
holdsAt( coord( id4 )=( 105, 113 ), 14920 ).
% Frame number: 374
holdsAt( coord( id4 )=( 103, 113 ), 14960 ).
% Frame number: 375
happensAt( walking( id4 ), 15000 ). holdsAt( coord( id4 )=( 103, 114 ), 15000 ).
% Frame number: 376
holdsAt( coord( id4 )=( 102, 114 ), 15040 ).
% Frame number: 377
holdsAt( coord( id4 )=( 102, 114 ), 15080 ).
% Frame number: 378
holdsAt( coord( id4 )=( 102, 115 ), 15120 ).
% Frame number: 379
happensAt( walking( id4 ), 15160 ). holdsAt( coord( id4 )=( 101, 116 ), 15160 ).
% Frame number: 380
holdsAt( coord( id4 )=( 101, 117 ), 15200 ).
% Frame number: 381
happensAt( walking( id4 ), 15240 ). holdsAt( coord( id4 )=( 101, 117 ), 15240 ).
% Frame number: 382
holdsAt( coord( id4 )=( 100, 117 ), 15280 ).
% Frame number: 383
holdsAt( coord( id4 )=( 98, 117 ), 15320 ).
% Frame number: 384
holdsAt( coord( id4 )=( 97, 118 ), 15360 ).
% Frame number: 385
holdsAt( coord( id4 )=( 95, 118 ), 15400 ).
% Frame number: 386
holdsAt( coord( id4 )=( 94, 118 ), 15440 ).
% Frame number: 387
holdsAt( coord( id4 )=( 93, 118 ), 15480 ).
% Frame number: 388
holdsAt( coord( id4 )=( 92, 119 ), 15520 ).
% Frame number: 389
holdsAt( coord( id4 )=( 91, 120 ), 15560 ).
% Frame number: 390
holdsAt( coord( id4 )=( 91, 121 ), 15600 ).
% Frame number: 391
holdsAt( coord( id4 )=( 91, 121 ), 15640 ).
% Frame number: 392
holdsAt( coord( id4 )=( 91, 122 ), 15680 ).
% Frame number: 393
holdsAt( coord( id4 )=( 90, 123 ), 15720 ).
% Frame number: 394
holdsAt( coord( id4 )=( 90, 123 ), 15760 ).
% Frame number: 395
holdsAt( coord( id4 )=( 89, 123 ), 15800 ).
% Frame number: 396
holdsAt( coord( id4 )=( 88, 124 ), 15840 ).
% Frame number: 397
holdsAt( coord( id4 )=( 87, 124 ), 15880 ).
% Frame number: 398
holdsAt( coord( id4 )=( 86, 124 ), 15920 ).
% Frame number: 399
holdsAt( coord( id4 )=( 85, 124 ), 15960 ).
% Frame number: 400
holdsAt( coord( id4 )=( 83, 124 ), 16000 ).
% Frame number: 401
holdsAt( coord( id4 )=( 82, 124 ), 16040 ).
% Frame number: 402
holdsAt( coord( id4 )=( 81, 124 ), 16080 ).
% Frame number: 403
holdsAt( coord( id4 )=( 81, 124 ), 16120 ).
% Frame number: 404
holdsAt( coord( id4 )=( 81, 124 ), 16160 ).
% Frame number: 405
holdsAt( coord( id4 )=( 81, 125 ), 16200 ).
% Frame number: 406
holdsAt( coord( id4 )=( 80, 125 ), 16240 ).
% Frame number: 407
happensAt( walking( id4 ), 16280 ). holdsAt( coord( id4 )=( 80, 125 ), 16280 ).
% Frame number: 408
holdsAt( coord( id4 )=( 80, 126 ), 16320 ).
% Frame number: 409
holdsAt( coord( id4 )=( 80, 126 ), 16360 ).
% Frame number: 410
holdsAt( coord( id4 )=( 79, 126 ), 16400 ).
% Frame number: 411
holdsAt( coord( id4 )=( 78, 126 ), 16440 ).
% Frame number: 412
holdsAt( coord( id4 )=( 77, 126 ), 16480 ).
% Frame number: 413
holdsAt( coord( id4 )=( 75, 126 ), 16520 ).
% Frame number: 414
holdsAt( coord( id4 )=( 74, 126 ), 16560 ).
% Frame number: 415
holdsAt( coord( id4 )=( 73, 127 ), 16600 ).
% Frame number: 416
holdsAt( coord( id4 )=( 73, 127 ), 16640 ).
% Frame number: 417
holdsAt( coord( id4 )=( 72, 127 ), 16680 ).
% Frame number: 418
holdsAt( coord( id4 )=( 72, 128 ), 16720 ).
% Frame number: 419
holdsAt( coord( id4 )=( 72, 128 ), 16760 ).
% Frame number: 420
holdsAt( coord( id4 )=( 72, 128 ), 16800 ).
% Frame number: 421
holdsAt( coord( id4 )=( 72, 128 ), 16840 ).
% Frame number: 422
holdsAt( coord( id4 )=( 72, 128 ), 16880 ).
% Frame number: 423
happensAt( walking( id4 ), 16920 ). holdsAt( coord( id4 )=( 72, 128 ), 16920 ).
% Frame number: 424
holdsAt( coord( id4 )=( 71, 128 ), 16960 ).
% Frame number: 425
holdsAt( coord( id4 )=( 70, 128 ), 17000 ).
% Frame number: 426
holdsAt( coord( id4 )=( 69, 129 ), 17040 ).
% Frame number: 427
holdsAt( coord( id4 )=( 69, 129 ), 17080 ).
% Frame number: 428
holdsAt( coord( id4 )=( 68, 129 ), 17120 ).
% Frame number: 429
holdsAt( coord( id4 )=( 67, 129 ), 17160 ).
% Frame number: 430
holdsAt( coord( id4 )=( 66, 129 ), 17200 ).
% Frame number: 431
holdsAt( coord( id4 )=( 66, 129 ), 17240 ).
% Frame number: 432
holdsAt( coord( id4 )=( 66, 129 ), 17280 ).
% Frame number: 433
happensAt( walking( id4 ), 17320 ). holdsAt( coord( id4 )=( 66, 129 ), 17320 ).
% Frame number: 434
holdsAt( coord( id4 )=( 66, 129 ), 17360 ).
% Frame number: 435
holdsAt( coord( id4 )=( 66, 129 ), 17400 ).
% Frame number: 436
holdsAt( coord( id4 )=( 66, 129 ), 17440 ).
% Frame number: 437
holdsAt( coord( id4 )=( 66, 129 ), 17480 ).
% Frame number: 438
holdsAt( coord( id4 )=( 65, 129 ), 17520 ).
% Frame number: 439
holdsAt( coord( id4 )=( 64, 129 ), 17560 ).
% Frame number: 440
holdsAt( coord( id4 )=( 63, 130 ), 17600 ).
% Frame number: 441
holdsAt( coord( id4 )=( 63, 130 ), 17640 ).
% Frame number: 442
holdsAt( coord( id4 )=( 63, 131 ), 17680 ).
% Frame number: 443
holdsAt( coord( id4 )=( 63, 131 ), 17720 ).
% Frame number: 444
happensAt( walking( id4 ), 17760 ). holdsAt( coord( id4 )=( 62, 131 ), 17760 ).
% Frame number: 445
holdsAt( coord( id4 )=( 62, 131 ), 17800 ).
% Frame number: 446
holdsAt( coord( id4 )=( 62, 130 ), 17840 ).
% Frame number: 447
holdsAt( coord( id4 )=( 62, 130 ), 17880 ).
% Frame number: 448
holdsAt( coord( id4 )=( 62, 129 ), 17920 ).
% Frame number: 449
happensAt( walking( id4 ), 17960 ). holdsAt( coord( id4 )=( 62, 129 ), 17960 ).
% Frame number: 450
holdsAt( coord( id4 )=( 62, 129 ), 18000 ).
% Frame number: 451
holdsAt( coord( id4 )=( 62, 128 ), 18040 ).
% Frame number: 452
holdsAt( coord( id4 )=( 62, 128 ), 18080 ).
% Frame number: 453
holdsAt( coord( id4 )=( 62, 128 ), 18120 ).
% Frame number: 454
holdsAt( coord( id4 )=( 62, 128 ), 18160 ).
% Frame number: 455
holdsAt( coord( id4 )=( 62, 128 ), 18200 ).
holdsAt( coord( id6 )=( 68, 127 ), 18200 ).
% Frame number: 456
happensAt( walking( id4 ), 18240 ). holdsAt( coord( id4 )=( 62, 128 ), 18240 ).
holdsAt( coord( id6 )=( 68, 126 ), 18240 ).
% Frame number: 457
holdsAt( coord( id4 )=( 63, 127 ), 18280 ).
holdsAt( coord( id6 )=( 69, 125 ), 18280 ).
% Frame number: 458
holdsAt( coord( id4 )=( 63, 127 ), 18320 ).
holdsAt( coord( id6 )=( 69, 125 ), 18320 ).
% Frame number: 459
holdsAt( coord( id4 )=( 63, 127 ), 18360 ).
holdsAt( coord( id6 )=( 69, 125 ), 18360 ).
% Frame number: 460
holdsAt( coord( id4 )=( 63, 126 ), 18400 ).
holdsAt( coord( id6 )=( 69, 124 ), 18400 ).
% Frame number: 461
happensAt( walking( id4 ), 18440 ). holdsAt( coord( id4 )=( 63, 126 ), 18440 ).
holdsAt( coord( id6 )=( 69, 124 ), 18440 ).
% Frame number: 462
holdsAt( coord( id4 )=( 63, 126 ), 18480 ).
happensAt( inactive( id6 ), 18480 ). holdsAt( coord( id6 )=( 69, 124 ), 18480 ).
% Frame number: 463
holdsAt( coord( id4 )=( 64, 125 ), 18520 ).
holdsAt( coord( id6 )=( 70, 123 ), 18520 ).
% Frame number: 464
holdsAt( coord( id4 )=( 64, 125 ), 18560 ).
holdsAt( coord( id6 )=( 71, 123 ), 18560 ).
% Frame number: 465
holdsAt( coord( id4 )=( 64, 125 ), 18600 ).
holdsAt( coord( id6 )=( 72, 122 ), 18600 ).
% Frame number: 466
holdsAt( coord( id4 )=( 64, 123 ), 18640 ).
holdsAt( coord( id6 )=( 72, 122 ), 18640 ).
% Frame number: 467
holdsAt( coord( id4 )=( 65, 123 ), 18680 ).
holdsAt( coord( id6 )=( 72, 122 ), 18680 ).
% Frame number: 468
holdsAt( coord( id4 )=( 65, 123 ), 18720 ).
holdsAt( coord( id6 )=( 72, 122 ), 18720 ).
% Frame number: 469
holdsAt( coord( id4 )=( 66, 122 ), 18760 ).
holdsAt( coord( id6 )=( 72, 122 ), 18760 ).
% Frame number: 470
holdsAt( coord( id4 )=( 66, 122 ), 18800 ).
holdsAt( coord( id6 )=( 72, 122 ), 18800 ).
% Frame number: 471
holdsAt( coord( id4 )=( 66, 122 ), 18840 ).
holdsAt( coord( id6 )=( 72, 122 ), 18840 ).
% Frame number: 472
holdsAt( coord( id4 )=( 66, 122 ), 18880 ).
holdsAt( coord( id6 )=( 72, 122 ), 18880 ).
% Frame number: 473
holdsAt( coord( id4 )=( 67, 121 ), 18920 ).
holdsAt( coord( id6 )=( 72, 122 ), 18920 ).
% Frame number: 474
holdsAt( coord( id4 )=( 67, 121 ), 18960 ).
holdsAt( coord( id6 )=( 72, 122 ), 18960 ).
% Frame number: 475
holdsAt( coord( id4 )=( 67, 121 ), 19000 ).
holdsAt( coord( id6 )=( 72, 122 ), 19000 ).
% Frame number: 476
holdsAt( coord( id4 )=( 67, 121 ), 19040 ).
holdsAt( coord( id6 )=( 72, 122 ), 19040 ).
% Frame number: 477
holdsAt( coord( id4 )=( 67, 120 ), 19080 ).
holdsAt( coord( id6 )=( 72, 122 ), 19080 ).
% Frame number: 478
holdsAt( coord( id4 )=( 68, 119 ), 19120 ).
holdsAt( coord( id6 )=( 72, 122 ), 19120 ).
% Frame number: 479
happensAt( walking( id4 ), 19160 ). holdsAt( coord( id4 )=( 68, 118 ), 19160 ).
holdsAt( coord( id6 )=( 72, 122 ), 19160 ).
% Frame number: 480
holdsAt( coord( id4 )=( 68, 118 ), 19200 ).
happensAt( inactive( id6 ), 19200 ). holdsAt( coord( id6 )=( 72, 122 ), 19200 ).
% Frame number: 481
holdsAt( coord( id4 )=( 68, 116 ), 19240 ).
holdsAt( coord( id6 )=( 72, 122 ), 19240 ).
% Frame number: 482
holdsAt( coord( id4 )=( 68, 115 ), 19280 ).
holdsAt( coord( id6 )=( 72, 122 ), 19280 ).
% Frame number: 483
holdsAt( coord( id4 )=( 68, 115 ), 19320 ).
holdsAt( coord( id6 )=( 72, 122 ), 19320 ).
% Frame number: 484
holdsAt( coord( id4 )=( 68, 115 ), 19360 ).
holdsAt( coord( id6 )=( 72, 122 ), 19360 ).
% Frame number: 485
holdsAt( coord( id4 )=( 68, 114 ), 19400 ).
holdsAt( coord( id6 )=( 72, 122 ), 19400 ).
% Frame number: 486
holdsAt( coord( id4 )=( 69, 114 ), 19440 ).
holdsAt( coord( id6 )=( 72, 122 ), 19440 ).
% Frame number: 487
holdsAt( coord( id4 )=( 69, 113 ), 19480 ).
holdsAt( coord( id6 )=( 72, 122 ), 19480 ).
% Frame number: 488
holdsAt( coord( id4 )=( 70, 113 ), 19520 ).
holdsAt( coord( id6 )=( 72, 122 ), 19520 ).
% Frame number: 489
holdsAt( coord( id4 )=( 71, 113 ), 19560 ).
holdsAt( coord( id6 )=( 72, 122 ), 19560 ).
% Frame number: 490
holdsAt( coord( id4 )=( 71, 112 ), 19600 ).
holdsAt( coord( id6 )=( 72, 122 ), 19600 ).
% Frame number: 491
holdsAt( coord( id4 )=( 72, 111 ), 19640 ).
holdsAt( coord( id6 )=( 72, 122 ), 19640 ).
% Frame number: 492
holdsAt( coord( id4 )=( 73, 111 ), 19680 ).
happensAt( inactive( id6 ), 19680 ). holdsAt( coord( id6 )=( 72, 122 ), 19680 ).
% Frame number: 493
holdsAt( coord( id4 )=( 73, 110 ), 19720 ).
holdsAt( coord( id6 )=( 72, 122 ), 19720 ).
% Frame number: 494
holdsAt( coord( id4 )=( 73, 109 ), 19760 ).
holdsAt( coord( id6 )=( 72, 122 ), 19760 ).
% Frame number: 495
holdsAt( coord( id4 )=( 73, 107 ), 19800 ).
holdsAt( coord( id6 )=( 72, 122 ), 19800 ).
% Frame number: 496
holdsAt( coord( id4 )=( 73, 106 ), 19840 ).
holdsAt( coord( id6 )=( 72, 122 ), 19840 ).
% Frame number: 497
happensAt( walking( id4 ), 19880 ). holdsAt( coord( id4 )=( 73, 104 ), 19880 ).
holdsAt( coord( id6 )=( 72, 122 ), 19880 ).
% Frame number: 498
holdsAt( coord( id4 )=( 73, 102 ), 19920 ).
holdsAt( coord( id6 )=( 72, 122 ), 19920 ).
% Frame number: 499
holdsAt( coord( id4 )=( 74, 101 ), 19960 ).
holdsAt( coord( id6 )=( 72, 122 ), 19960 ).
% Frame number: 500
happensAt( walking( id4 ), 20000 ). holdsAt( coord( id4 )=( 75, 101 ), 20000 ).
holdsAt( coord( id6 )=( 72, 122 ), 20000 ).
% Frame number: 501
holdsAt( coord( id4 )=( 76, 100 ), 20040 ).
happensAt( inactive( id6 ), 20040 ). holdsAt( coord( id6 )=( 72, 122 ), 20040 ).
% Frame number: 502
holdsAt( coord( id4 )=( 78, 100 ), 20080 ).
holdsAt( coord( id6 )=( 72, 122 ), 20080 ).
% Frame number: 503
holdsAt( coord( id4 )=( 79, 99 ), 20120 ).
holdsAt( coord( id6 )=( 72, 122 ), 20120 ).
% Frame number: 504
holdsAt( coord( id4 )=( 80, 99 ), 20160 ).
holdsAt( coord( id6 )=( 72, 122 ), 20160 ).
% Frame number: 505
holdsAt( coord( id4 )=( 81, 98 ), 20200 ).
holdsAt( coord( id6 )=( 72, 122 ), 20200 ).
% Frame number: 506
holdsAt( coord( id4 )=( 82, 98 ), 20240 ).
holdsAt( coord( id6 )=( 72, 122 ), 20240 ).
% Frame number: 507
holdsAt( coord( id4 )=( 82, 97 ), 20280 ).
holdsAt( coord( id6 )=( 72, 122 ), 20280 ).
% Frame number: 508
holdsAt( coord( id4 )=( 82, 96 ), 20320 ).
holdsAt( coord( id6 )=( 72, 122 ), 20320 ).
% Frame number: 509
holdsAt( coord( id4 )=( 82, 94 ), 20360 ).
holdsAt( coord( id6 )=( 72, 122 ), 20360 ).
% Frame number: 510
holdsAt( coord( id4 )=( 82, 92 ), 20400 ).
holdsAt( coord( id6 )=( 72, 122 ), 20400 ).
% Frame number: 511
holdsAt( coord( id4 )=( 83, 91 ), 20440 ).
holdsAt( coord( id6 )=( 72, 122 ), 20440 ).
% Frame number: 512
holdsAt( coord( id4 )=( 83, 90 ), 20480 ).
holdsAt( coord( id6 )=( 72, 122 ), 20480 ).
% Frame number: 513
holdsAt( coord( id4 )=( 83, 89 ), 20520 ).
holdsAt( coord( id6 )=( 72, 122 ), 20520 ).
% Frame number: 514
holdsAt( coord( id4 )=( 84, 89 ), 20560 ).
happensAt( inactive( id6 ), 20560 ). holdsAt( coord( id6 )=( 72, 122 ), 20560 ).
% Frame number: 515
holdsAt( coord( id4 )=( 85, 88 ), 20600 ).
holdsAt( coord( id6 )=( 72, 122 ), 20600 ).
% Frame number: 516
holdsAt( coord( id4 )=( 86, 87 ), 20640 ).
happensAt( inactive( id6 ), 20640 ). holdsAt( coord( id6 )=( 72, 122 ), 20640 ).
% Frame number: 517
holdsAt( coord( id4 )=( 88, 87 ), 20680 ).
holdsAt( coord( id6 )=( 72, 122 ), 20680 ).
% Frame number: 518
holdsAt( coord( id4 )=( 89, 86 ), 20720 ).
holdsAt( coord( id6 )=( 72, 122 ), 20720 ).
% Frame number: 519
happensAt( walking( id4 ), 20760 ). holdsAt( coord( id4 )=( 89, 85 ), 20760 ).
holdsAt( coord( id6 )=( 72, 122 ), 20760 ).
% Frame number: 520
holdsAt( coord( id4 )=( 89, 84 ), 20800 ).
holdsAt( coord( id6 )=( 72, 122 ), 20800 ).
% Frame number: 521
holdsAt( coord( id4 )=( 90, 83 ), 20840 ).
holdsAt( coord( id6 )=( 72, 122 ), 20840 ).
% Frame number: 522
holdsAt( coord( id4 )=( 90, 82 ), 20880 ).
holdsAt( coord( id6 )=( 72, 122 ), 20880 ).
% Frame number: 523
holdsAt( coord( id4 )=( 91, 81 ), 20920 ).
holdsAt( coord( id6 )=( 72, 122 ), 20920 ).
% Frame number: 524
happensAt( walking( id4 ), 20960 ). holdsAt( coord( id4 )=( 91, 79 ), 20960 ).
holdsAt( coord( id6 )=( 72, 122 ), 20960 ).
% Frame number: 525
holdsAt( coord( id4 )=( 92, 77 ), 21000 ).
holdsAt( coord( id6 )=( 72, 122 ), 21000 ).
% Frame number: 526
holdsAt( coord( id4 )=( 92, 76 ), 21040 ).
holdsAt( coord( id6 )=( 72, 122 ), 21040 ).
% Frame number: 527
holdsAt( coord( id4 )=( 93, 74 ), 21080 ).
holdsAt( coord( id6 )=( 72, 122 ), 21080 ).
% Frame number: 528
holdsAt( coord( id4 )=( 94, 74 ), 21120 ).
happensAt( inactive( id6 ), 21120 ). holdsAt( coord( id6 )=( 72, 122 ), 21120 ).
% Frame number: 529
holdsAt( coord( id4 )=( 96, 73 ), 21160 ).
holdsAt( coord( id6 )=( 72, 122 ), 21160 ).
% Frame number: 530
holdsAt( coord( id4 )=( 97, 73 ), 21200 ).
holdsAt( coord( id6 )=( 72, 122 ), 21200 ).
% Frame number: 531
holdsAt( coord( id4 )=( 99, 72 ), 21240 ).
holdsAt( coord( id6 )=( 72, 122 ), 21240 ).
% Frame number: 532
holdsAt( coord( id4 )=( 100, 72 ), 21280 ).
holdsAt( coord( id6 )=( 72, 122 ), 21280 ).
% Frame number: 533
holdsAt( coord( id4 )=( 100, 71 ), 21320 ).
holdsAt( coord( id6 )=( 72, 122 ), 21320 ).
% Frame number: 534
happensAt( walking( id4 ), 21360 ). holdsAt( coord( id4 )=( 102, 70 ), 21360 ).
holdsAt( coord( id6 )=( 72, 122 ), 21360 ).
% Frame number: 535
holdsAt( coord( id4 )=( 102, 68 ), 21400 ).
holdsAt( coord( id6 )=( 72, 122 ), 21400 ).
% Frame number: 536
holdsAt( coord( id4 )=( 103, 67 ), 21440 ).
holdsAt( coord( id6 )=( 72, 122 ), 21440 ).
% Frame number: 537
holdsAt( coord( id4 )=( 103, 66 ), 21480 ).
holdsAt( coord( id6 )=( 72, 122 ), 21480 ).
% Frame number: 538
holdsAt( coord( id4 )=( 103, 64 ), 21520 ).
holdsAt( coord( id6 )=( 72, 122 ), 21520 ).
% Frame number: 539
holdsAt( coord( id4 )=( 103, 62 ), 21560 ).
holdsAt( coord( id6 )=( 72, 122 ), 21560 ).
% Frame number: 540
holdsAt( coord( id4 )=( 104, 60 ), 21600 ).
holdsAt( coord( id6 )=( 72, 122 ), 21600 ).
% Frame number: 541
holdsAt( coord( id4 )=( 104, 60 ), 21640 ).
holdsAt( coord( id6 )=( 72, 122 ), 21640 ).
% Frame number: 542
holdsAt( coord( id4 )=( 104, 58 ), 21680 ).
happensAt( inactive( id6 ), 21680 ). holdsAt( coord( id6 )=( 72, 122 ), 21680 ).
% Frame number: 543
holdsAt( coord( id4 )=( 104, 58 ), 21720 ).
happensAt( inactive( id6 ), 21720 ). holdsAt( coord( id6 )=( 72, 122 ), 21720 ).
% Frame number: 544
holdsAt( coord( id4 )=( 105, 57 ), 21760 ).
holdsAt( coord( id6 )=( 72, 122 ), 21760 ).
% Frame number: 545
holdsAt( coord( id4 )=( 107, 56 ), 21800 ).
holdsAt( coord( id6 )=( 72, 122 ), 21800 ).
% Frame number: 546
holdsAt( coord( id4 )=( 108, 56 ), 21840 ).
holdsAt( coord( id6 )=( 72, 122 ), 21840 ).
% Frame number: 547
holdsAt( coord( id4 )=( 110, 56 ), 21880 ).
holdsAt( coord( id6 )=( 72, 122 ), 21880 ).
% Frame number: 548
holdsAt( coord( id4 )=( 111, 56 ), 21920 ).
holdsAt( coord( id6 )=( 72, 122 ), 21920 ).
% Frame number: 549
happensAt( walking( id4 ), 21960 ). holdsAt( coord( id4 )=( 113, 56 ), 21960 ).
holdsAt( coord( id6 )=( 72, 122 ), 21960 ).
% Frame number: 550
holdsAt( coord( id4 )=( 113, 55 ), 22000 ).
holdsAt( coord( id6 )=( 72, 122 ), 22000 ).
% Frame number: 551
holdsAt( coord( id4 )=( 113, 54 ), 22040 ).
holdsAt( coord( id6 )=( 72, 122 ), 22040 ).
% Frame number: 552
happensAt( walking( id4 ), 22080 ). holdsAt( coord( id4 )=( 114, 53 ), 22080 ).
holdsAt( coord( id6 )=( 72, 122 ), 22080 ).
% Frame number: 553
holdsAt( coord( id4 )=( 114, 52 ), 22120 ).
holdsAt( coord( id6 )=( 72, 122 ), 22120 ).
% Frame number: 554
holdsAt( coord( id4 )=( 115, 52 ), 22160 ).
holdsAt( coord( id6 )=( 72, 122 ), 22160 ).
% Frame number: 555
holdsAt( coord( id4 )=( 115, 51 ), 22200 ).
holdsAt( coord( id6 )=( 72, 122 ), 22200 ).
% Frame number: 556
holdsAt( coord( id4 )=( 116, 51 ), 22240 ).
holdsAt( coord( id6 )=( 72, 122 ), 22240 ).
% Frame number: 557
holdsAt( coord( id4 )=( 117, 49 ), 22280 ).
holdsAt( coord( id6 )=( 72, 122 ), 22280 ).
% Frame number: 558
holdsAt( coord( id4 )=( 118, 49 ), 22320 ).
holdsAt( coord( id6 )=( 72, 122 ), 22320 ).
% Frame number: 559
holdsAt( coord( id4 )=( 119, 49 ), 22360 ).
holdsAt( coord( id6 )=( 72, 122 ), 22360 ).
% Frame number: 560
holdsAt( coord( id4 )=( 120, 48 ), 22400 ).
happensAt( inactive( id6 ), 22400 ). holdsAt( coord( id6 )=( 72, 122 ), 22400 ).
% Frame number: 561
holdsAt( coord( id4 )=( 122, 47 ), 22440 ).
holdsAt( coord( id6 )=( 72, 122 ), 22440 ).
% Frame number: 562
holdsAt( coord( id4 )=( 124, 47 ), 22480 ).
holdsAt( coord( id6 )=( 72, 122 ), 22480 ).
% Frame number: 563
holdsAt( coord( id4 )=( 124, 47 ), 22520 ).
holdsAt( coord( id6 )=( 72, 122 ), 22520 ).
% Frame number: 564
holdsAt( coord( id4 )=( 125, 47 ), 22560 ).
holdsAt( coord( id6 )=( 72, 122 ), 22560 ).
% Frame number: 565
holdsAt( coord( id4 )=( 125, 46 ), 22600 ).
holdsAt( coord( id6 )=( 72, 122 ), 22600 ).
% Frame number: 566
holdsAt( coord( id4 )=( 126, 46 ), 22640 ).
holdsAt( coord( id6 )=( 72, 122 ), 22640 ).
% Frame number: 567
holdsAt( coord( id4 )=( 126, 45 ), 22680 ).
holdsAt( coord( id6 )=( 72, 122 ), 22680 ).
% Frame number: 568
holdsAt( coord( id4 )=( 126, 45 ), 22720 ).
holdsAt( coord( id6 )=( 72, 122 ), 22720 ).
% Frame number: 569
holdsAt( coord( id4 )=( 127, 44 ), 22760 ).
holdsAt( coord( id6 )=( 72, 122 ), 22760 ).
% Frame number: 570
holdsAt( coord( id4 )=( 128, 44 ), 22800 ).
holdsAt( coord( id6 )=( 72, 122 ), 22800 ).
% Frame number: 571
holdsAt( coord( id4 )=( 130, 43 ), 22840 ).
holdsAt( coord( id6 )=( 72, 122 ), 22840 ).
% Frame number: 572
holdsAt( coord( id4 )=( 131, 43 ), 22880 ).
holdsAt( coord( id6 )=( 72, 122 ), 22880 ).
% Frame number: 573
holdsAt( coord( id4 )=( 133, 43 ), 22920 ).
holdsAt( coord( id6 )=( 72, 122 ), 22920 ).
% Frame number: 574
holdsAt( coord( id4 )=( 133, 43 ), 22960 ).
holdsAt( coord( id6 )=( 72, 122 ), 22960 ).
% Frame number: 575
holdsAt( coord( id4 )=( 133, 42 ), 23000 ).
holdsAt( coord( id6 )=( 72, 122 ), 23000 ).
% Frame number: 576
holdsAt( coord( id4 )=( 134, 41 ), 23040 ).
holdsAt( coord( id6 )=( 72, 122 ), 23040 ).
% Frame number: 577
holdsAt( coord( id4 )=( 134, 40 ), 23080 ).
holdsAt( coord( id6 )=( 72, 122 ), 23080 ).
% Frame number: 578
holdsAt( coord( id4 )=( 134, 40 ), 23120 ).
holdsAt( coord( id6 )=( 72, 122 ), 23120 ).
% Frame number: 579
holdsAt( coord( id4 )=( 134, 39 ), 23160 ).
holdsAt( coord( id6 )=( 72, 122 ), 23160 ).
% Frame number: 580
holdsAt( coord( id4 )=( 136, 38 ), 23200 ).
happensAt( inactive( id6 ), 23200 ). holdsAt( coord( id6 )=( 72, 122 ), 23200 ).
% Frame number: 581
happensAt( walking( id4 ), 23240 ). holdsAt( coord( id4 )=( 137, 38 ), 23240 ).
holdsAt( coord( id6 )=( 72, 122 ), 23240 ).
% Frame number: 582
holdsAt( coord( id4 )=( 138, 38 ), 23280 ).
holdsAt( coord( id6 )=( 72, 122 ), 23280 ).
% Frame number: 583
holdsAt( coord( id4 )=( 139, 38 ), 23320 ).
holdsAt( coord( id6 )=( 72, 122 ), 23320 ).
% Frame number: 584
holdsAt( coord( id4 )=( 140, 37 ), 23360 ).
holdsAt( coord( id6 )=( 72, 122 ), 23360 ).
% Frame number: 585
holdsAt( coord( id4 )=( 140, 37 ), 23400 ).
holdsAt( coord( id6 )=( 72, 122 ), 23400 ).
% Frame number: 586
holdsAt( coord( id4 )=( 141, 37 ), 23440 ).
holdsAt( coord( id6 )=( 72, 122 ), 23440 ).
% Frame number: 587
holdsAt( coord( id4 )=( 142, 36 ), 23480 ).
holdsAt( coord( id6 )=( 72, 122 ), 23480 ).
% Frame number: 588
holdsAt( coord( id4 )=( 143, 36 ), 23520 ).
holdsAt( coord( id6 )=( 72, 122 ), 23520 ).
% Frame number: 589
holdsAt( coord( id4 )=( 143, 36 ), 23560 ).
holdsAt( coord( id6 )=( 72, 122 ), 23560 ).
% Frame number: 590
happensAt( walking( id4 ), 23600 ). holdsAt( coord( id4 )=( 143, 35 ), 23600 ).
holdsAt( coord( id6 )=( 72, 122 ), 23600 ).
% Frame number: 591
holdsAt( coord( id4 )=( 145, 35 ), 23640 ).
holdsAt( coord( id6 )=( 72, 122 ), 23640 ).
% Frame number: 592
holdsAt( coord( id4 )=( 145, 35 ), 23680 ).
holdsAt( coord( id6 )=( 72, 122 ), 23680 ).
% Frame number: 593
holdsAt( coord( id4 )=( 145, 34 ), 23720 ).
holdsAt( coord( id6 )=( 72, 122 ), 23720 ).
% Frame number: 594
holdsAt( coord( id4 )=( 146, 33 ), 23760 ).
holdsAt( coord( id6 )=( 72, 122 ), 23760 ).
% Frame number: 595
holdsAt( coord( id4 )=( 146, 33 ), 23800 ).
holdsAt( coord( id6 )=( 72, 122 ), 23800 ).
% Frame number: 596
holdsAt( coord( id4 )=( 147, 32 ), 23840 ).
holdsAt( coord( id6 )=( 72, 122 ), 23840 ).
% Frame number: 597
holdsAt( coord( id4 )=( 147, 31 ), 23880 ).
holdsAt( coord( id6 )=( 72, 122 ), 23880 ).
% Frame number: 598
holdsAt( coord( id4 )=( 147, 30 ), 23920 ).
happensAt( inactive( id6 ), 23920 ). holdsAt( coord( id6 )=( 72, 122 ), 23920 ).
% Frame number: 599
holdsAt( coord( id4 )=( 147, 30 ), 23960 ).
happensAt( inactive( id6 ), 23960 ). holdsAt( coord( id6 )=( 72, 122 ), 23960 ).
% Frame number: 600
happensAt( walking( id4 ), 24000 ). holdsAt( coord( id4 )=( 148, 29 ), 24000 ).
holdsAt( coord( id6 )=( 72, 122 ), 24000 ).
% Frame number: 601
happensAt( walking( id4 ), 24040 ). holdsAt( coord( id4 )=( 148, 28 ), 24040 ).
happensAt( inactive( id6 ), 24040 ). holdsAt( coord( id6 )=( 72, 122 ), 24040 ).
% Frame number: 602
holdsAt( coord( id4 )=( 148, 28 ), 24080 ).
happensAt( inactive( id6 ), 24080 ). holdsAt( coord( id6 )=( 72, 122 ), 24080 ).
% Frame number: 603
holdsAt( coord( id4 )=( 149, 27 ), 24120 ).
holdsAt( coord( id6 )=( 72, 122 ), 24120 ).
% Frame number: 604
holdsAt( coord( id4 )=( 149, 26 ), 24160 ).
holdsAt( coord( id6 )=( 72, 122 ), 24160 ).
% Frame number: 605
holdsAt( coord( id4 )=( 150, 26 ), 24200 ).
holdsAt( coord( id6 )=( 72, 122 ), 24200 ).
% Frame number: 606
holdsAt( coord( id4 )=( 151, 25 ), 24240 ).
holdsAt( coord( id6 )=( 72, 122 ), 24240 ).
% Frame number: 607
holdsAt( coord( id4 )=( 151, 25 ), 24280 ).
happensAt( inactive( id6 ), 24280 ). holdsAt( coord( id6 )=( 72, 122 ), 24280 ).
% Frame number: 608
holdsAt( coord( id4 )=( 151, 25 ), 24320 ).
holdsAt( coord( id6 )=( 72, 122 ), 24320 ).
% Frame number: 609
holdsAt( coord( id4 )=( 151, 24 ), 24360 ).
happensAt( inactive( id6 ), 24360 ). holdsAt( coord( id6 )=( 72, 122 ), 24360 ).
% Frame number: 610
holdsAt( coord( id4 )=( 152, 24 ), 24400 ).
happensAt( inactive( id6 ), 24400 ). holdsAt( coord( id6 )=( 72, 122 ), 24400 ).
% Frame number: 611
holdsAt( coord( id4 )=( 152, 24 ), 24440 ).
holdsAt( coord( id6 )=( 72, 122 ), 24440 ).
% Frame number: 612
happensAt( walking( id4 ), 24480 ). holdsAt( coord( id4 )=( 153, 23 ), 24480 ).
holdsAt( coord( id6 )=( 72, 122 ), 24480 ).
% Frame number: 613
holdsAt( coord( id4 )=( 153, 23 ), 24520 ).
holdsAt( coord( id6 )=( 72, 122 ), 24520 ).
% Frame number: 614
holdsAt( coord( id4 )=( 154, 22 ), 24560 ).
holdsAt( coord( id6 )=( 72, 122 ), 24560 ).
% Frame number: 615
holdsAt( coord( id4 )=( 155, 21 ), 24600 ).
holdsAt( coord( id6 )=( 72, 122 ), 24600 ).
% Frame number: 616
holdsAt( coord( id4 )=( 155, 21 ), 24640 ).
holdsAt( coord( id6 )=( 72, 122 ), 24640 ).
% Frame number: 617
holdsAt( coord( id4 )=( 155, 21 ), 24680 ).
holdsAt( coord( id6 )=( 72, 122 ), 24680 ).
% Frame number: 618
holdsAt( coord( id4 )=( 155, 20 ), 24720 ).
holdsAt( coord( id6 )=( 72, 122 ), 24720 ).
% Frame number: 619
holdsAt( coord( id4 )=( 157, 20 ), 24760 ).
holdsAt( coord( id6 )=( 72, 122 ), 24760 ).
% Frame number: 620
holdsAt( coord( id4 )=( 158, 20 ), 24800 ).
holdsAt( coord( id6 )=( 72, 122 ), 24800 ).
% Frame number: 621
holdsAt( coord( id4 )=( 158, 20 ), 24840 ).
holdsAt( coord( id6 )=( 72, 122 ), 24840 ).
% Frame number: 622
holdsAt( coord( id4 )=( 159, 20 ), 24880 ).
holdsAt( coord( id6 )=( 72, 122 ), 24880 ).
% Frame number: 623
holdsAt( coord( id4 )=( 160, 20 ), 24920 ).
holdsAt( coord( id6 )=( 72, 122 ), 24920 ).
% Frame number: 624
holdsAt( coord( id4 )=( 160, 19 ), 24960 ).
holdsAt( coord( id6 )=( 72, 122 ), 24960 ).
% Frame number: 625
holdsAt( coord( id4 )=( 162, 18 ), 25000 ).
holdsAt( coord( id6 )=( 72, 122 ), 25000 ).
% Frame number: 626
happensAt( walking( id4 ), 25040 ). holdsAt( coord( id4 )=( 163, 17 ), 25040 ).
holdsAt( coord( id6 )=( 72, 122 ), 25040 ).
% Frame number: 627
holdsAt( coord( id4 )=( 163, 17 ), 25080 ).
holdsAt( coord( id6 )=( 72, 122 ), 25080 ).
% Frame number: 628
holdsAt( coord( id4 )=( 164, 16 ), 25120 ).
holdsAt( coord( id6 )=( 72, 122 ), 25120 ).
% Frame number: 629
holdsAt( coord( id4 )=( 164, 16 ), 25160 ).
holdsAt( coord( id6 )=( 72, 122 ), 25160 ).
% Frame number: 630
holdsAt( coord( id4 )=( 165, 16 ), 25200 ).
happensAt( inactive( id6 ), 25200 ). holdsAt( coord( id6 )=( 72, 122 ), 25200 ).
% Frame number: 631
holdsAt( coord( id4 )=( 165, 16 ), 25240 ).
holdsAt( coord( id6 )=( 72, 122 ), 25240 ).
% Frame number: 632
holdsAt( coord( id4 )=( 165, 16 ), 25280 ).
holdsAt( coord( id6 )=( 72, 122 ), 25280 ).
% Frame number: 633
holdsAt( coord( id4 )=( 165, 16 ), 25320 ).
holdsAt( coord( id6 )=( 72, 122 ), 25320 ).
% Frame number: 634
holdsAt( coord( id4 )=( 166, 15 ), 25360 ).
holdsAt( coord( id6 )=( 72, 122 ), 25360 ).
% Frame number: 635
holdsAt( coord( id4 )=( 166, 15 ), 25400 ).
holdsAt( coord( id6 )=( 72, 122 ), 25400 ).
% Frame number: 636
holdsAt( coord( id4 )=( 167, 15 ), 25440 ).
holdsAt( coord( id6 )=( 72, 122 ), 25440 ).
% Frame number: 637
holdsAt( coord( id4 )=( 167, 15 ), 25480 ).
holdsAt( coord( id6 )=( 72, 122 ), 25480 ).
% Frame number: 638
holdsAt( coord( id4 )=( 167, 14 ), 25520 ).
holdsAt( coord( id6 )=( 72, 122 ), 25520 ).
% Frame number: 639
holdsAt( coord( id4 )=( 167, 14 ), 25560 ).
holdsAt( coord( id6 )=( 72, 122 ), 25560 ).
% Frame number: 640
holdsAt( coord( id6 )=( 72, 122 ), 25600 ).
% Frame number: 641
holdsAt( coord( id6 )=( 72, 122 ), 25640 ).
% Frame number: 642
happensAt( inactive( id6 ), 25680 ). holdsAt( coord( id6 )=( 72, 122 ), 25680 ).
% Frame number: 643
holdsAt( coord( id6 )=( 72, 122 ), 25720 ).
% Frame number: 644
holdsAt( coord( id6 )=( 72, 122 ), 25760 ).
% Frame number: 645
holdsAt( coord( id6 )=( 72, 122 ), 25800 ).
% Frame number: 646
holdsAt( coord( id6 )=( 72, 122 ), 25840 ).
% Frame number: 647
holdsAt( coord( id6 )=( 72, 122 ), 25880 ).
% Frame number: 648
holdsAt( coord( id6 )=( 72, 122 ), 25920 ).
% Frame number: 649
holdsAt( coord( id6 )=( 72, 122 ), 25960 ).
% Frame number: 650
holdsAt( coord( id6 )=( 72, 122 ), 26000 ).
% Frame number: 651
holdsAt( coord( id6 )=( 72, 122 ), 26040 ).
% Frame number: 652
holdsAt( coord( id6 )=( 72, 122 ), 26080 ).
% Frame number: 653
holdsAt( coord( id6 )=( 72, 122 ), 26120 ).
% Frame number: 654
holdsAt( coord( id6 )=( 72, 122 ), 26160 ).
% Frame number: 655
holdsAt( coord( id6 )=( 72, 122 ), 26200 ).
% Frame number: 656
holdsAt( coord( id6 )=( 72, 122 ), 26240 ).
% Frame number: 657
holdsAt( coord( id6 )=( 72, 122 ), 26280 ).
% Frame number: 658
holdsAt( coord( id6 )=( 72, 122 ), 26320 ).
% Frame number: 659
holdsAt( coord( id6 )=( 72, 122 ), 26360 ).
% Frame number: 660
holdsAt( coord( id6 )=( 72, 122 ), 26400 ).
% Frame number: 661
holdsAt( coord( id6 )=( 72, 122 ), 26440 ).
% Frame number: 662
holdsAt( coord( id6 )=( 72, 122 ), 26480 ).
% Frame number: 663
holdsAt( coord( id6 )=( 72, 122 ), 26520 ).
% Frame number: 664
holdsAt( coord( id6 )=( 72, 122 ), 26560 ).
% Frame number: 665
holdsAt( coord( id6 )=( 72, 122 ), 26600 ).
% Frame number: 666
holdsAt( coord( id6 )=( 72, 122 ), 26640 ).
% Frame number: 667
holdsAt( coord( id6 )=( 72, 122 ), 26680 ).
% Frame number: 668
holdsAt( coord( id6 )=( 72, 122 ), 26720 ).
% Frame number: 669
holdsAt( coord( id6 )=( 72, 122 ), 26760 ).
% Frame number: 670
holdsAt( coord( id6 )=( 72, 122 ), 26800 ).
% Frame number: 671
holdsAt( coord( id6 )=( 72, 122 ), 26840 ).
% Frame number: 672
holdsAt( coord( id6 )=( 72, 122 ), 26880 ).
% Frame number: 673
holdsAt( coord( id6 )=( 72, 122 ), 26920 ).
% Frame number: 674
happensAt( inactive( id6 ), 26960 ). holdsAt( coord( id6 )=( 72, 122 ), 26960 ).
% Frame number: 675
holdsAt( coord( id6 )=( 72, 122 ), 27000 ).
% Frame number: 676
holdsAt( coord( id6 )=( 72, 122 ), 27040 ).
% Frame number: 677
happensAt( inactive( id6 ), 27080 ). holdsAt( coord( id6 )=( 72, 122 ), 27080 ).
% Frame number: 678
holdsAt( coord( id6 )=( 72, 122 ), 27120 ).
% Frame number: 679
holdsAt( coord( id6 )=( 72, 122 ), 27160 ).
% Frame number: 680
happensAt( inactive( id6 ), 27200 ). holdsAt( coord( id6 )=( 72, 122 ), 27200 ).
% Frame number: 681
happensAt( inactive( id6 ), 27240 ). holdsAt( coord( id6 )=( 72, 122 ), 27240 ).
% Frame number: 682
holdsAt( coord( id6 )=( 72, 122 ), 27280 ).
% Frame number: 683
holdsAt( coord( id6 )=( 72, 122 ), 27320 ).
% Frame number: 684
happensAt( inactive( id6 ), 27360 ). holdsAt( coord( id6 )=( 72, 122 ), 27360 ).
% Frame number: 685
holdsAt( coord( id6 )=( 72, 122 ), 27400 ).
% Frame number: 686
happensAt( inactive( id6 ), 27440 ). holdsAt( coord( id6 )=( 72, 122 ), 27440 ).
% Frame number: 687
holdsAt( coord( id6 )=( 72, 122 ), 27480 ).
% Frame number: 688
holdsAt( coord( id6 )=( 72, 122 ), 27520 ).
% Frame number: 689
holdsAt( coord( id6 )=( 72, 122 ), 27560 ).
% Frame number: 690
holdsAt( coord( id6 )=( 72, 122 ), 27600 ).
% Frame number: 691
holdsAt( coord( id6 )=( 72, 122 ), 27640 ).
% Frame number: 692
holdsAt( coord( id6 )=( 72, 122 ), 27680 ).
% Frame number: 693
holdsAt( coord( id6 )=( 72, 122 ), 27720 ).
% Frame number: 694
holdsAt( coord( id6 )=( 72, 122 ), 27760 ).
% Frame number: 695
holdsAt( coord( id6 )=( 72, 122 ), 27800 ).
% Frame number: 696
holdsAt( coord( id6 )=( 72, 122 ), 27840 ).
% Frame number: 697
happensAt( inactive( id6 ), 27880 ). holdsAt( coord( id6 )=( 72, 122 ), 27880 ).
% Frame number: 698
holdsAt( coord( id6 )=( 72, 122 ), 27920 ).
% Frame number: 699
holdsAt( coord( id6 )=( 72, 122 ), 27960 ).
% Frame number: 700
holdsAt( coord( id6 )=( 72, 122 ), 28000 ).
% Frame number: 701
holdsAt( coord( id6 )=( 72, 122 ), 28040 ).
% Frame number: 702
holdsAt( coord( id6 )=( 72, 122 ), 28080 ).
% Frame number: 703
holdsAt( coord( id6 )=( 72, 122 ), 28120 ).
% Frame number: 704
holdsAt( coord( id6 )=( 72, 122 ), 28160 ).
% Frame number: 705
holdsAt( coord( id6 )=( 72, 122 ), 28200 ).
% Frame number: 706
holdsAt( coord( id6 )=( 72, 122 ), 28240 ).
% Frame number: 707
holdsAt( coord( id6 )=( 72, 122 ), 28280 ).
% Frame number: 708
holdsAt( coord( id6 )=( 72, 122 ), 28320 ).
% Frame number: 709
holdsAt( coord( id6 )=( 72, 122 ), 28360 ).
% Frame number: 710
holdsAt( coord( id6 )=( 72, 122 ), 28400 ).
% Frame number: 711
holdsAt( coord( id6 )=( 72, 122 ), 28440 ).
% Frame number: 712
holdsAt( coord( id6 )=( 72, 122 ), 28480 ).
% Frame number: 713
happensAt( inactive( id6 ), 28520 ). holdsAt( coord( id6 )=( 72, 122 ), 28520 ).
% Frame number: 714
holdsAt( coord( id6 )=( 72, 122 ), 28560 ).
% Frame number: 715
holdsAt( coord( id6 )=( 72, 122 ), 28600 ).
% Frame number: 716
holdsAt( coord( id6 )=( 72, 122 ), 28640 ).
% Frame number: 717
holdsAt( coord( id6 )=( 72, 122 ), 28680 ).
% Frame number: 718
holdsAt( coord( id6 )=( 72, 122 ), 28720 ).
% Frame number: 719
holdsAt( coord( id6 )=( 72, 122 ), 28760 ).
% Frame number: 720
holdsAt( coord( id6 )=( 72, 122 ), 28800 ).
% Frame number: 721
holdsAt( coord( id6 )=( 72, 122 ), 28840 ).
% Frame number: 722
holdsAt( coord( id6 )=( 72, 122 ), 28880 ).
% Frame number: 723
holdsAt( coord( id6 )=( 72, 122 ), 28920 ).
% Frame number: 724
holdsAt( coord( id6 )=( 72, 122 ), 28960 ).
% Frame number: 725
holdsAt( coord( id6 )=( 72, 122 ), 29000 ).
% Frame number: 726
happensAt( inactive( id6 ), 29040 ). holdsAt( coord( id6 )=( 72, 122 ), 29040 ).
% Frame number: 727
holdsAt( coord( id6 )=( 72, 122 ), 29080 ).
% Frame number: 728
holdsAt( coord( id6 )=( 72, 122 ), 29120 ).
% Frame number: 729
holdsAt( coord( id6 )=( 72, 122 ), 29160 ).
% Frame number: 730
holdsAt( coord( id6 )=( 72, 122 ), 29200 ).
% Frame number: 731
holdsAt( coord( id6 )=( 72, 122 ), 29240 ).
% Frame number: 732
holdsAt( coord( id6 )=( 72, 122 ), 29280 ).
% Frame number: 733
holdsAt( coord( id6 )=( 72, 122 ), 29320 ).
% Frame number: 734
holdsAt( coord( id6 )=( 72, 122 ), 29360 ).
% Frame number: 735
holdsAt( coord( id6 )=( 72, 122 ), 29400 ).
% Frame number: 736
holdsAt( coord( id6 )=( 72, 122 ), 29440 ).
% Frame number: 737
holdsAt( coord( id6 )=( 72, 122 ), 29480 ).
% Frame number: 738
happensAt( inactive( id6 ), 29520 ). holdsAt( coord( id6 )=( 72, 122 ), 29520 ).
% Frame number: 739
holdsAt( coord( id6 )=( 72, 122 ), 29560 ).
% Frame number: 740
holdsAt( coord( id6 )=( 72, 122 ), 29600 ).
% Frame number: 741
holdsAt( coord( id6 )=( 72, 122 ), 29640 ).
% Frame number: 742
holdsAt( coord( id6 )=( 72, 122 ), 29680 ).
% Frame number: 743
happensAt( inactive( id6 ), 29720 ). holdsAt( coord( id6 )=( 72, 122 ), 29720 ).
% Frame number: 744
holdsAt( coord( id6 )=( 72, 122 ), 29760 ).
% Frame number: 745
holdsAt( coord( id6 )=( 72, 122 ), 29800 ).
% Frame number: 746
holdsAt( coord( id6 )=( 72, 122 ), 29840 ).
% Frame number: 747
holdsAt( coord( id5 )=( 168, 21 ), 29880 ).
holdsAt( coord( id6 )=( 72, 122 ), 29880 ).
% Frame number: 748
holdsAt( coord( id5 )=( 168, 21 ), 29920 ).
holdsAt( coord( id6 )=( 72, 122 ), 29920 ).
% Frame number: 749
holdsAt( coord( id5 )=( 168, 24 ), 29960 ).
happensAt( inactive( id6 ), 29960 ). holdsAt( coord( id6 )=( 72, 122 ), 29960 ).
% Frame number: 750
holdsAt( coord( id5 )=( 167, 26 ), 30000 ).
happensAt( inactive( id6 ), 30000 ). holdsAt( coord( id6 )=( 72, 122 ), 30000 ).
% Frame number: 751
happensAt( walking( id5 ), 30040 ). holdsAt( coord( id5 )=( 167, 26 ), 30040 ).
holdsAt( coord( id6 )=( 72, 122 ), 30040 ).
% Frame number: 752
holdsAt( coord( id5 )=( 167, 27 ), 30080 ).
holdsAt( coord( id6 )=( 72, 122 ), 30080 ).
% Frame number: 753
holdsAt( coord( id5 )=( 167, 28 ), 30120 ).
happensAt( inactive( id6 ), 30120 ). holdsAt( coord( id6 )=( 72, 122 ), 30120 ).
% Frame number: 754
holdsAt( coord( id5 )=( 166, 29 ), 30160 ).
holdsAt( coord( id6 )=( 72, 122 ), 30160 ).
% Frame number: 755
happensAt( walking( id5 ), 30200 ). holdsAt( coord( id5 )=( 166, 29 ), 30200 ).
holdsAt( coord( id6 )=( 72, 122 ), 30200 ).
% Frame number: 756
happensAt( walking( id5 ), 30240 ). holdsAt( coord( id5 )=( 165, 29 ), 30240 ).
holdsAt( coord( id6 )=( 72, 122 ), 30240 ).
% Frame number: 757
holdsAt( coord( id5 )=( 165, 29 ), 30280 ).
holdsAt( coord( id6 )=( 72, 122 ), 30280 ).
% Frame number: 758
holdsAt( coord( id5 )=( 164, 29 ), 30320 ).
happensAt( inactive( id6 ), 30320 ). holdsAt( coord( id6 )=( 72, 122 ), 30320 ).
% Frame number: 759
holdsAt( coord( id5 )=( 164, 29 ), 30360 ).
holdsAt( coord( id6 )=( 72, 122 ), 30360 ).
% Frame number: 760
holdsAt( coord( id5 )=( 164, 29 ), 30400 ).
holdsAt( coord( id6 )=( 72, 122 ), 30400 ).
% Frame number: 761
holdsAt( coord( id5 )=( 163, 30 ), 30440 ).
holdsAt( coord( id6 )=( 72, 122 ), 30440 ).
% Frame number: 762
holdsAt( coord( id5 )=( 163, 30 ), 30480 ).
holdsAt( coord( id6 )=( 72, 122 ), 30480 ).
% Frame number: 763
holdsAt( coord( id5 )=( 162, 30 ), 30520 ).
happensAt( inactive( id6 ), 30520 ). holdsAt( coord( id6 )=( 72, 122 ), 30520 ).
% Frame number: 764
holdsAt( coord( id5 )=( 162, 30 ), 30560 ).
happensAt( inactive( id6 ), 30560 ). holdsAt( coord( id6 )=( 72, 122 ), 30560 ).
% Frame number: 765
holdsAt( coord( id5 )=( 162, 32 ), 30600 ).
holdsAt( coord( id6 )=( 72, 122 ), 30600 ).
% Frame number: 766
holdsAt( coord( id5 )=( 162, 33 ), 30640 ).
holdsAt( coord( id6 )=( 72, 122 ), 30640 ).
% Frame number: 767
holdsAt( coord( id5 )=( 161, 34 ), 30680 ).
holdsAt( coord( id6 )=( 72, 122 ), 30680 ).
% Frame number: 768
holdsAt( coord( id5 )=( 161, 35 ), 30720 ).
holdsAt( coord( id6 )=( 72, 122 ), 30720 ).
% Frame number: 769
happensAt( walking( id5 ), 30760 ). holdsAt( coord( id5 )=( 159, 34 ), 30760 ).
holdsAt( coord( id6 )=( 72, 122 ), 30760 ).
% Frame number: 770
holdsAt( coord( id5 )=( 159, 34 ), 30800 ).
holdsAt( coord( id6 )=( 72, 122 ), 30800 ).
% Frame number: 771
holdsAt( coord( id5 )=( 159, 34 ), 30840 ).
happensAt( inactive( id6 ), 30840 ). holdsAt( coord( id6 )=( 72, 122 ), 30840 ).
% Frame number: 772
holdsAt( coord( id5 )=( 158, 35 ), 30880 ).
holdsAt( coord( id6 )=( 72, 122 ), 30880 ).
% Frame number: 773
holdsAt( coord( id5 )=( 157, 35 ), 30920 ).
holdsAt( coord( id6 )=( 72, 122 ), 30920 ).
% Frame number: 774
holdsAt( coord( id5 )=( 155, 35 ), 30960 ).
holdsAt( coord( id6 )=( 72, 122 ), 30960 ).
% Frame number: 775
holdsAt( coord( id5 )=( 154, 35 ), 31000 ).
holdsAt( coord( id6 )=( 72, 122 ), 31000 ).
% Frame number: 776
holdsAt( coord( id5 )=( 153, 35 ), 31040 ).
holdsAt( coord( id6 )=( 72, 122 ), 31040 ).
% Frame number: 777
holdsAt( coord( id5 )=( 152, 35 ), 31080 ).
holdsAt( coord( id6 )=( 72, 122 ), 31080 ).
% Frame number: 778
holdsAt( coord( id5 )=( 152, 36 ), 31120 ).
holdsAt( coord( id6 )=( 72, 122 ), 31120 ).
% Frame number: 779
holdsAt( coord( id5 )=( 152, 36 ), 31160 ).
holdsAt( coord( id6 )=( 72, 122 ), 31160 ).
% Frame number: 780
holdsAt( coord( id5 )=( 152, 38 ), 31200 ).
holdsAt( coord( id6 )=( 72, 122 ), 31200 ).
% Frame number: 781
holdsAt( coord( id5 )=( 152, 39 ), 31240 ).
happensAt( inactive( id6 ), 31240 ). holdsAt( coord( id6 )=( 72, 122 ), 31240 ).
% Frame number: 782
holdsAt( coord( id5 )=( 152, 39 ), 31280 ).
holdsAt( coord( id6 )=( 72, 122 ), 31280 ).
% Frame number: 783
holdsAt( coord( id5 )=( 151, 40 ), 31320 ).
holdsAt( coord( id6 )=( 72, 122 ), 31320 ).
% Frame number: 784
holdsAt( coord( id5 )=( 151, 40 ), 31360 ).
holdsAt( coord( id6 )=( 72, 122 ), 31360 ).
% Frame number: 785
holdsAt( coord( id5 )=( 151, 41 ), 31400 ).
holdsAt( coord( id6 )=( 72, 122 ), 31400 ).
% Frame number: 786
holdsAt( coord( id5 )=( 150, 41 ), 31440 ).
holdsAt( coord( id6 )=( 72, 122 ), 31440 ).
% Frame number: 787
holdsAt( coord( id5 )=( 149, 41 ), 31480 ).
holdsAt( coord( id6 )=( 72, 122 ), 31480 ).
% Frame number: 788
holdsAt( coord( id5 )=( 149, 42 ), 31520 ).
holdsAt( coord( id6 )=( 72, 122 ), 31520 ).
% Frame number: 789
holdsAt( coord( id5 )=( 147, 42 ), 31560 ).
holdsAt( coord( id6 )=( 72, 122 ), 31560 ).
% Frame number: 790
holdsAt( coord( id5 )=( 145, 42 ), 31600 ).
holdsAt( coord( id6 )=( 72, 122 ), 31600 ).
% Frame number: 791
holdsAt( coord( id5 )=( 145, 42 ), 31640 ).
holdsAt( coord( id6 )=( 72, 122 ), 31640 ).
% Frame number: 792
holdsAt( coord( id5 )=( 144, 43 ), 31680 ).
holdsAt( coord( id6 )=( 72, 122 ), 31680 ).
% Frame number: 793
holdsAt( coord( id5 )=( 143, 43 ), 31720 ).
holdsAt( coord( id6 )=( 72, 122 ), 31720 ).
% Frame number: 794
holdsAt( coord( id5 )=( 142, 44 ), 31760 ).
holdsAt( coord( id6 )=( 72, 122 ), 31760 ).
% Frame number: 795
happensAt( walking( id5 ), 31800 ). holdsAt( coord( id5 )=( 142, 44 ), 31800 ).
holdsAt( coord( id6 )=( 72, 122 ), 31800 ).
% Frame number: 796
holdsAt( coord( id5 )=( 141, 46 ), 31840 ).
holdsAt( coord( id6 )=( 72, 122 ), 31840 ).
% Frame number: 797
holdsAt( coord( id5 )=( 139, 46 ), 31880 ).
holdsAt( coord( id6 )=( 72, 122 ), 31880 ).
% Frame number: 798
holdsAt( coord( id5 )=( 139, 47 ), 31920 ).
holdsAt( coord( id6 )=( 72, 122 ), 31920 ).
% Frame number: 799
holdsAt( coord( id5 )=( 137, 47 ), 31960 ).
holdsAt( coord( id6 )=( 72, 122 ), 31960 ).
% Frame number: 800
happensAt( walking( id5 ), 32000 ). holdsAt( coord( id5 )=( 135, 47 ), 32000 ).
holdsAt( coord( id6 )=( 72, 122 ), 32000 ).
% Frame number: 801
holdsAt( coord( id5 )=( 133, 48 ), 32040 ).
holdsAt( coord( id6 )=( 72, 122 ), 32040 ).
% Frame number: 802
holdsAt( coord( id5 )=( 131, 48 ), 32080 ).
holdsAt( coord( id6 )=( 72, 122 ), 32080 ).
% Frame number: 803
happensAt( walking( id5 ), 32120 ). holdsAt( coord( id5 )=( 131, 49 ), 32120 ).
holdsAt( coord( id6 )=( 72, 122 ), 32120 ).
% Frame number: 804
holdsAt( coord( id5 )=( 130, 49 ), 32160 ).
happensAt( inactive( id6 ), 32160 ). holdsAt( coord( id6 )=( 72, 122 ), 32160 ).
% Frame number: 805
holdsAt( coord( id5 )=( 129, 50 ), 32200 ).
holdsAt( coord( id6 )=( 72, 122 ), 32200 ).
% Frame number: 806
holdsAt( coord( id5 )=( 129, 51 ), 32240 ).
holdsAt( coord( id6 )=( 72, 122 ), 32240 ).
% Frame number: 807
holdsAt( coord( id5 )=( 128, 52 ), 32280 ).
holdsAt( coord( id6 )=( 72, 122 ), 32280 ).
% Frame number: 808
holdsAt( coord( id5 )=( 126, 53 ), 32320 ).
holdsAt( coord( id6 )=( 72, 122 ), 32320 ).
% Frame number: 809
holdsAt( coord( id5 )=( 125, 53 ), 32360 ).
happensAt( inactive( id6 ), 32360 ). holdsAt( coord( id6 )=( 72, 122 ), 32360 ).
% Frame number: 810
holdsAt( coord( id5 )=( 125, 54 ), 32400 ).
holdsAt( coord( id6 )=( 72, 122 ), 32400 ).
% Frame number: 811
holdsAt( coord( id5 )=( 123, 54 ), 32440 ).
holdsAt( coord( id6 )=( 72, 122 ), 32440 ).
% Frame number: 812
holdsAt( coord( id5 )=( 122, 54 ), 32480 ).
holdsAt( coord( id6 )=( 72, 122 ), 32480 ).
% Frame number: 813
holdsAt( coord( id5 )=( 121, 54 ), 32520 ).
holdsAt( coord( id6 )=( 72, 122 ), 32520 ).
% Frame number: 814
holdsAt( coord( id5 )=( 120, 54 ), 32560 ).
holdsAt( coord( id6 )=( 72, 122 ), 32560 ).
% Frame number: 815
holdsAt( coord( id5 )=( 120, 55 ), 32600 ).
holdsAt( coord( id6 )=( 72, 122 ), 32600 ).
% Frame number: 816
holdsAt( coord( id5 )=( 119, 56 ), 32640 ).
holdsAt( coord( id6 )=( 72, 122 ), 32640 ).
% Frame number: 817
holdsAt( coord( id5 )=( 119, 58 ), 32680 ).
happensAt( inactive( id6 ), 32680 ). holdsAt( coord( id6 )=( 72, 122 ), 32680 ).
% Frame number: 818
holdsAt( coord( id5 )=( 119, 60 ), 32720 ).
holdsAt( coord( id6 )=( 72, 122 ), 32720 ).
% Frame number: 819
holdsAt( coord( id5 )=( 118, 61 ), 32760 ).
holdsAt( coord( id6 )=( 72, 122 ), 32760 ).
% Frame number: 820
holdsAt( coord( id5 )=( 117, 62 ), 32800 ).
holdsAt( coord( id6 )=( 72, 122 ), 32800 ).
% Frame number: 821
holdsAt( coord( id5 )=( 117, 63 ), 32840 ).
holdsAt( coord( id6 )=( 72, 122 ), 32840 ).
% Frame number: 822
holdsAt( coord( id5 )=( 117, 64 ), 32880 ).
holdsAt( coord( id6 )=( 72, 122 ), 32880 ).
% Frame number: 823
holdsAt( coord( id5 )=( 116, 65 ), 32920 ).
holdsAt( coord( id6 )=( 72, 122 ), 32920 ).
% Frame number: 824
happensAt( walking( id5 ), 32960 ). holdsAt( coord( id5 )=( 116, 65 ), 32960 ).
holdsAt( coord( id6 )=( 72, 122 ), 32960 ).
% Frame number: 825
holdsAt( coord( id5 )=( 114, 66 ), 33000 ).
holdsAt( coord( id6 )=( 72, 122 ), 33000 ).
% Frame number: 826
holdsAt( coord( id5 )=( 112, 66 ), 33040 ).
holdsAt( coord( id6 )=( 72, 122 ), 33040 ).
% Frame number: 827
holdsAt( coord( id5 )=( 110, 66 ), 33080 ).
holdsAt( coord( id6 )=( 72, 122 ), 33080 ).
% Frame number: 828
holdsAt( coord( id5 )=( 110, 67 ), 33120 ).
happensAt( inactive( id6 ), 33120 ). holdsAt( coord( id6 )=( 72, 122 ), 33120 ).
% Frame number: 829
holdsAt( coord( id5 )=( 108, 68 ), 33160 ).
holdsAt( coord( id6 )=( 72, 122 ), 33160 ).
% Frame number: 830
holdsAt( coord( id5 )=( 108, 70 ), 33200 ).
happensAt( inactive( id6 ), 33200 ). holdsAt( coord( id6 )=( 72, 122 ), 33200 ).
% Frame number: 831
holdsAt( coord( id5 )=( 108, 72 ), 33240 ).
holdsAt( coord( id6 )=( 72, 122 ), 33240 ).
% Frame number: 832
holdsAt( coord( id5 )=( 107, 73 ), 33280 ).
holdsAt( coord( id6 )=( 72, 122 ), 33280 ).
% Frame number: 833
holdsAt( coord( id5 )=( 106, 75 ), 33320 ).
holdsAt( coord( id6 )=( 72, 122 ), 33320 ).
% Frame number: 834
holdsAt( coord( id5 )=( 106, 76 ), 33360 ).
holdsAt( coord( id6 )=( 72, 122 ), 33360 ).
% Frame number: 835
holdsAt( coord( id5 )=( 105, 77 ), 33400 ).
holdsAt( coord( id6 )=( 72, 122 ), 33400 ).
% Frame number: 836
holdsAt( coord( id5 )=( 105, 78 ), 33440 ).
holdsAt( coord( id6 )=( 72, 122 ), 33440 ).
% Frame number: 837
holdsAt( coord( id5 )=( 104, 79 ), 33480 ).
holdsAt( coord( id6 )=( 72, 122 ), 33480 ).
% Frame number: 838
holdsAt( coord( id5 )=( 102, 79 ), 33520 ).
holdsAt( coord( id6 )=( 72, 122 ), 33520 ).
% Frame number: 839
holdsAt( coord( id5 )=( 102, 80 ), 33560 ).
holdsAt( coord( id6 )=( 72, 122 ), 33560 ).
% Frame number: 840
holdsAt( coord( id5 )=( 100, 81 ), 33600 ).
holdsAt( coord( id6 )=( 72, 122 ), 33600 ).
% Frame number: 841
holdsAt( coord( id5 )=( 98, 81 ), 33640 ).
holdsAt( coord( id6 )=( 72, 122 ), 33640 ).
% Frame number: 842
holdsAt( coord( id5 )=( 97, 82 ), 33680 ).
holdsAt( coord( id6 )=( 72, 122 ), 33680 ).
% Frame number: 843
holdsAt( coord( id5 )=( 97, 82 ), 33720 ).
holdsAt( coord( id6 )=( 72, 122 ), 33720 ).
% Frame number: 844
holdsAt( coord( id5 )=( 96, 83 ), 33760 ).
holdsAt( coord( id6 )=( 72, 122 ), 33760 ).
% Frame number: 845
holdsAt( coord( id5 )=( 96, 83 ), 33800 ).
holdsAt( coord( id6 )=( 72, 122 ), 33800 ).
% Frame number: 846
holdsAt( coord( id5 )=( 96, 85 ), 33840 ).
holdsAt( coord( id6 )=( 72, 122 ), 33840 ).
% Frame number: 847
holdsAt( coord( id5 )=( 95, 86 ), 33880 ).
holdsAt( coord( id6 )=( 72, 122 ), 33880 ).
% Frame number: 848
holdsAt( coord( id5 )=( 95, 87 ), 33920 ).
holdsAt( coord( id6 )=( 72, 122 ), 33920 ).
% Frame number: 849
holdsAt( coord( id5 )=( 94, 89 ), 33960 ).
holdsAt( coord( id6 )=( 72, 122 ), 33960 ).
% Frame number: 850
holdsAt( coord( id5 )=( 93, 89 ), 34000 ).
holdsAt( coord( id6 )=( 72, 122 ), 34000 ).
% Frame number: 851
holdsAt( coord( id5 )=( 92, 90 ), 34040 ).
holdsAt( coord( id6 )=( 72, 122 ), 34040 ).
% Frame number: 852
holdsAt( coord( id5 )=( 91, 90 ), 34080 ).
holdsAt( coord( id6 )=( 72, 122 ), 34080 ).
% Frame number: 853
holdsAt( coord( id5 )=( 90, 90 ), 34120 ).
holdsAt( coord( id6 )=( 72, 122 ), 34120 ).
% Frame number: 854
holdsAt( coord( id5 )=( 88, 91 ), 34160 ).
happensAt( inactive( id6 ), 34160 ). holdsAt( coord( id6 )=( 72, 122 ), 34160 ).
% Frame number: 855
holdsAt( coord( id5 )=( 87, 91 ), 34200 ).
holdsAt( coord( id6 )=( 72, 122 ), 34200 ).
% Frame number: 856
holdsAt( coord( id5 )=( 86, 92 ), 34240 ).
happensAt( inactive( id6 ), 34240 ). holdsAt( coord( id6 )=( 72, 122 ), 34240 ).
% Frame number: 857
holdsAt( coord( id5 )=( 85, 93 ), 34280 ).
holdsAt( coord( id6 )=( 72, 122 ), 34280 ).
% Frame number: 858
holdsAt( coord( id5 )=( 85, 94 ), 34320 ).
holdsAt( coord( id6 )=( 72, 122 ), 34320 ).
% Frame number: 859
holdsAt( coord( id5 )=( 85, 96 ), 34360 ).
holdsAt( coord( id6 )=( 72, 122 ), 34360 ).
% Frame number: 860
holdsAt( coord( id5 )=( 85, 98 ), 34400 ).
holdsAt( coord( id6 )=( 72, 122 ), 34400 ).
% Frame number: 861
holdsAt( coord( id5 )=( 84, 99 ), 34440 ).
holdsAt( coord( id6 )=( 72, 122 ), 34440 ).
% Frame number: 862
holdsAt( coord( id5 )=( 84, 100 ), 34480 ).
holdsAt( coord( id6 )=( 72, 122 ), 34480 ).
% Frame number: 863
holdsAt( coord( id5 )=( 83, 100 ), 34520 ).
holdsAt( coord( id6 )=( 72, 122 ), 34520 ).
% Frame number: 864
holdsAt( coord( id5 )=( 82, 101 ), 34560 ).
holdsAt( coord( id6 )=( 72, 122 ), 34560 ).
% Frame number: 865
holdsAt( coord( id5 )=( 81, 101 ), 34600 ).
holdsAt( coord( id6 )=( 72, 122 ), 34600 ).
% Frame number: 866
holdsAt( coord( id5 )=( 81, 102 ), 34640 ).
holdsAt( coord( id6 )=( 72, 122 ), 34640 ).
% Frame number: 867
holdsAt( coord( id5 )=( 80, 102 ), 34680 ).
happensAt( inactive( id6 ), 34680 ). holdsAt( coord( id6 )=( 72, 122 ), 34680 ).
% Frame number: 868
holdsAt( coord( id5 )=( 78, 102 ), 34720 ).
holdsAt( coord( id6 )=( 72, 122 ), 34720 ).
% Frame number: 869
holdsAt( coord( id5 )=( 76, 102 ), 34760 ).
holdsAt( coord( id6 )=( 72, 122 ), 34760 ).
% Frame number: 870
holdsAt( coord( id5 )=( 76, 103 ), 34800 ).
holdsAt( coord( id6 )=( 72, 122 ), 34800 ).
% Frame number: 871
holdsAt( coord( id5 )=( 75, 104 ), 34840 ).
holdsAt( coord( id6 )=( 72, 122 ), 34840 ).
% Frame number: 872
holdsAt( coord( id5 )=( 75, 105 ), 34880 ).
holdsAt( coord( id6 )=( 72, 122 ), 34880 ).
% Frame number: 873
holdsAt( coord( id5 )=( 75, 106 ), 34920 ).
holdsAt( coord( id6 )=( 72, 122 ), 34920 ).
% Frame number: 874
holdsAt( coord( id5 )=( 75, 108 ), 34960 ).
holdsAt( coord( id6 )=( 72, 122 ), 34960 ).
% Frame number: 875
holdsAt( coord( id5 )=( 75, 108 ), 35000 ).
holdsAt( coord( id6 )=( 72, 122 ), 35000 ).
% Frame number: 876
holdsAt( coord( id5 )=( 75, 109 ), 35040 ).
holdsAt( coord( id6 )=( 72, 122 ), 35040 ).
% Frame number: 877
holdsAt( coord( id5 )=( 74, 110 ), 35080 ).
holdsAt( coord( id6 )=( 72, 122 ), 35080 ).
% Frame number: 878
holdsAt( coord( id5 )=( 74, 111 ), 35120 ).
holdsAt( coord( id6 )=( 72, 122 ), 35120 ).
% Frame number: 879
holdsAt( coord( id5 )=( 73, 111 ), 35160 ).
holdsAt( coord( id6 )=( 72, 122 ), 35160 ).
% Frame number: 880
holdsAt( coord( id5 )=( 72, 111 ), 35200 ).
holdsAt( coord( id6 )=( 72, 122 ), 35200 ).
% Frame number: 881
holdsAt( coord( id5 )=( 72, 111 ), 35240 ).
holdsAt( coord( id6 )=( 72, 122 ), 35240 ).
% Frame number: 882
holdsAt( coord( id5 )=( 72, 112 ), 35280 ).
holdsAt( coord( id6 )=( 72, 122 ), 35280 ).
% Frame number: 883
holdsAt( coord( id5 )=( 72, 112 ), 35320 ).
holdsAt( coord( id6 )=( 72, 122 ), 35320 ).
% Frame number: 884
holdsAt( coord( id5 )=( 72, 112 ), 35360 ).
holdsAt( coord( id6 )=( 72, 122 ), 35360 ).
% Frame number: 885
holdsAt( coord( id5 )=( 72, 112 ), 35400 ).
holdsAt( coord( id6 )=( 72, 122 ), 35400 ).
% Frame number: 886
holdsAt( coord( id5 )=( 72, 112 ), 35440 ).
holdsAt( coord( id6 )=( 72, 122 ), 35440 ).
% Frame number: 887
holdsAt( coord( id5 )=( 72, 112 ), 35480 ).
holdsAt( coord( id6 )=( 72, 122 ), 35480 ).
% Frame number: 888
holdsAt( coord( id5 )=( 72, 112 ), 35520 ).
holdsAt( coord( id6 )=( 72, 122 ), 35520 ).
% Frame number: 889
holdsAt( coord( id5 )=( 72, 112 ), 35560 ).
happensAt( inactive( id6 ), 35560 ). holdsAt( coord( id6 )=( 72, 122 ), 35560 ).
% Frame number: 890
holdsAt( coord( id5 )=( 72, 112 ), 35600 ).
holdsAt( coord( id6 )=( 72, 122 ), 35600 ).
% Frame number: 891
holdsAt( coord( id5 )=( 72, 112 ), 35640 ).
holdsAt( coord( id6 )=( 72, 122 ), 35640 ).
% Frame number: 892
holdsAt( coord( id5 )=( 72, 112 ), 35680 ).
holdsAt( coord( id6 )=( 72, 122 ), 35680 ).
% Frame number: 893
holdsAt( coord( id5 )=( 71, 112 ), 35720 ).
holdsAt( coord( id6 )=( 72, 122 ), 35720 ).
% Frame number: 894
holdsAt( coord( id5 )=( 71, 112 ), 35760 ).
happensAt( inactive( id6 ), 35760 ). holdsAt( coord( id6 )=( 72, 122 ), 35760 ).
% Frame number: 895
holdsAt( coord( id5 )=( 71, 113 ), 35800 ).
holdsAt( coord( id6 )=( 72, 122 ), 35800 ).
% Frame number: 896
holdsAt( coord( id5 )=( 71, 113 ), 35840 ).
holdsAt( coord( id6 )=( 72, 122 ), 35840 ).
% Frame number: 897
holdsAt( coord( id5 )=( 71, 112 ), 35880 ).
holdsAt( coord( id6 )=( 72, 122 ), 35880 ).
% Frame number: 898
holdsAt( coord( id5 )=( 71, 113 ), 35920 ).
holdsAt( coord( id6 )=( 72, 122 ), 35920 ).
% Frame number: 899
holdsAt( coord( id5 )=( 71, 113 ), 35960 ).
holdsAt( coord( id6 )=( 72, 122 ), 35960 ).
% Frame number: 900
holdsAt( coord( id5 )=( 70, 113 ), 36000 ).
holdsAt( coord( id6 )=( 72, 122 ), 36000 ).
% Frame number: 901
holdsAt( coord( id5 )=( 71, 113 ), 36040 ).
holdsAt( coord( id6 )=( 71, 122 ), 36040 ).
% Frame number: 902
holdsAt( coord( id5 )=( 71, 112 ), 36080 ).
holdsAt( coord( id6 )=( 71, 122 ), 36080 ).
% Frame number: 903
holdsAt( coord( id5 )=( 71, 113 ), 36120 ).
holdsAt( coord( id6 )=( 71, 122 ), 36120 ).
% Frame number: 904
holdsAt( coord( id5 )=( 71, 113 ), 36160 ).
holdsAt( coord( id6 )=( 71, 122 ), 36160 ).
% Frame number: 905
holdsAt( coord( id5 )=( 71, 113 ), 36200 ).
holdsAt( coord( id6 )=( 71, 121 ), 36200 ).
% Frame number: 906
holdsAt( coord( id5 )=( 71, 113 ), 36240 ).
happensAt( inactive( id6 ), 36240 ). holdsAt( coord( id6 )=( 71, 121 ), 36240 ).
% Frame number: 907
holdsAt( coord( id5 )=( 72, 113 ), 36280 ).
holdsAt( coord( id6 )=( 71, 121 ), 36280 ).
% Frame number: 908
holdsAt( coord( id5 )=( 72, 112 ), 36320 ).
holdsAt( coord( id6 )=( 71, 121 ), 36320 ).
% Frame number: 909
holdsAt( coord( id5 )=( 72, 112 ), 36360 ).
holdsAt( coord( id6 )=( 71, 121 ), 36360 ).
% Frame number: 910
holdsAt( coord( id5 )=( 72, 112 ), 36400 ).
holdsAt( coord( id6 )=( 71, 121 ), 36400 ).
% Frame number: 911
holdsAt( coord( id5 )=( 72, 112 ), 36440 ).
holdsAt( coord( id6 )=( 71, 121 ), 36440 ).
% Frame number: 912
holdsAt( coord( id5 )=( 72, 112 ), 36480 ).
holdsAt( coord( id6 )=( 72, 121 ), 36480 ).
% Frame number: 913
holdsAt( coord( id5 )=( 72, 112 ), 36520 ).
holdsAt( coord( id6 )=( 72, 121 ), 36520 ).
% Frame number: 914
holdsAt( coord( id5 )=( 73, 112 ), 36560 ).
holdsAt( coord( id6 )=( 73, 122 ), 36560 ).
% Frame number: 915
holdsAt( coord( id5 )=( 73, 112 ), 36600 ).
holdsAt( coord( id6 )=( 73, 122 ), 36600 ).
% Frame number: 916
holdsAt( coord( id5 )=( 73, 113 ), 36640 ).
holdsAt( coord( id6 )=( 74, 122 ), 36640 ).
% Frame number: 917
holdsAt( coord( id5 )=( 73, 113 ), 36680 ).
holdsAt( coord( id6 )=( 75, 122 ), 36680 ).
% Frame number: 918
holdsAt( coord( id5 )=( 74, 114 ), 36720 ).
holdsAt( coord( id6 )=( 75, 122 ), 36720 ).
% Frame number: 919
holdsAt( coord( id5 )=( 75, 114 ), 36760 ).
holdsAt( coord( id6 )=( 76, 122 ), 36760 ).
% Frame number: 920
holdsAt( coord( id5 )=( 76, 113 ), 36800 ).
holdsAt( coord( id6 )=( 77, 122 ), 36800 ).
% Frame number: 921
happensAt( walking( id5 ), 36840 ). holdsAt( coord( id5 )=( 76, 114 ), 36840 ).
holdsAt( coord( id6 )=( 77, 122 ), 36840 ).
% Frame number: 922
holdsAt( coord( id5 )=( 76, 114 ), 36880 ).
holdsAt( coord( id6 )=( 78, 122 ), 36880 ).
% Frame number: 923
holdsAt( coord( id5 )=( 77, 115 ), 36920 ).
holdsAt( coord( id6 )=( 79, 122 ), 36920 ).
% Frame number: 924
holdsAt( coord( id5 )=( 77, 115 ), 36960 ).
holdsAt( coord( id6 )=( 80, 122 ), 36960 ).
% Frame number: 925
holdsAt( coord( id5 )=( 77, 115 ), 37000 ).
holdsAt( coord( id6 )=( 80, 123 ), 37000 ).
% Frame number: 926
holdsAt( coord( id5 )=( 77, 115 ), 37040 ).
% Frame number: 927
holdsAt( coord( id5 )=( 77, 115 ), 37080 ).
% Frame number: 928
holdsAt( coord( id5 )=( 77, 115 ), 37120 ).
% Frame number: 929
holdsAt( coord( id5 )=( 77, 115 ), 37160 ).
% Frame number: 930
holdsAt( coord( id5 )=( 77, 115 ), 37200 ).
% Frame number: 931
holdsAt( coord( id5 )=( 79, 115 ), 37240 ).
% Frame number: 932
holdsAt( coord( id5 )=( 80, 115 ), 37280 ).
% Frame number: 933
holdsAt( coord( id5 )=( 81, 116 ), 37320 ).
% Frame number: 934
holdsAt( coord( id5 )=( 83, 116 ), 37360 ).
% Frame number: 935
holdsAt( coord( id5 )=( 83, 116 ), 37400 ).
% Frame number: 936
holdsAt( coord( id5 )=( 83, 116 ), 37440 ).
% Frame number: 937
holdsAt( coord( id5 )=( 84, 116 ), 37480 ).
% Frame number: 938
holdsAt( coord( id5 )=( 85, 116 ), 37520 ).
% Frame number: 939
holdsAt( coord( id5 )=( 85, 116 ), 37560 ).
% Frame number: 940
happensAt( walking( id5 ), 37600 ). holdsAt( coord( id5 )=( 85, 116 ), 37600 ).
% Frame number: 941
holdsAt( coord( id5 )=( 85, 116 ), 37640 ).
% Frame number: 942
happensAt( walking( id5 ), 37680 ). holdsAt( coord( id5 )=( 85, 116 ), 37680 ).
% Frame number: 943
holdsAt( coord( id5 )=( 85, 116 ), 37720 ).
% Frame number: 944
holdsAt( coord( id5 )=( 85, 117 ), 37760 ).
% Frame number: 945
holdsAt( coord( id5 )=( 86, 117 ), 37800 ).
% Frame number: 946
holdsAt( coord( id5 )=( 87, 118 ), 37840 ).
holdsAt( coord( id7 )=( 110, 267 ), 37840 ).
% Frame number: 947
holdsAt( coord( id5 )=( 88, 119 ), 37880 ).
holdsAt( coord( id7 )=( 110, 267 ), 37880 ).
% Frame number: 948
happensAt( walking( id5 ), 37920 ). holdsAt( coord( id5 )=( 89, 119 ), 37920 ).
holdsAt( coord( id7 )=( 110, 267 ), 37920 ).
% Frame number: 949
holdsAt( coord( id5 )=( 90, 120 ), 37960 ).
holdsAt( coord( id7 )=( 110, 266 ), 37960 ).
% Frame number: 950
holdsAt( coord( id5 )=( 91, 120 ), 38000 ).
holdsAt( coord( id7 )=( 110, 266 ), 38000 ).
% Frame number: 951
holdsAt( coord( id5 )=( 91, 120 ), 38040 ).
holdsAt( coord( id7 )=( 110, 266 ), 38040 ).
% Frame number: 952
holdsAt( coord( id5 )=( 92, 121 ), 38080 ).
holdsAt( coord( id7 )=( 110, 266 ), 38080 ).
% Frame number: 953
holdsAt( coord( id5 )=( 92, 121 ), 38120 ).
happensAt( walking( id7 ), 38120 ). holdsAt( coord( id7 )=( 110, 266 ), 38120 ).
% Frame number: 954
holdsAt( coord( id5 )=( 92, 121 ), 38160 ).
holdsAt( coord( id7 )=( 110, 265 ), 38160 ).
% Frame number: 955
holdsAt( coord( id5 )=( 92, 122 ), 38200 ).
holdsAt( coord( id7 )=( 110, 265 ), 38200 ).
% Frame number: 956
holdsAt( coord( id5 )=( 92, 122 ), 38240 ).
holdsAt( coord( id7 )=( 110, 265 ), 38240 ).
% Frame number: 957
holdsAt( coord( id5 )=( 92, 122 ), 38280 ).
holdsAt( coord( id7 )=( 110, 265 ), 38280 ).
% Frame number: 958
holdsAt( coord( id5 )=( 93, 122 ), 38320 ).
holdsAt( coord( id7 )=( 110, 265 ), 38320 ).
% Frame number: 959
holdsAt( coord( id5 )=( 94, 122 ), 38360 ).
holdsAt( coord( id7 )=( 109, 264 ), 38360 ).
% Frame number: 960
holdsAt( coord( id5 )=( 97, 122 ), 38400 ).
holdsAt( coord( id7 )=( 109, 264 ), 38400 ).
% Frame number: 961
holdsAt( coord( id5 )=( 98, 123 ), 38440 ).
holdsAt( coord( id7 )=( 109, 264 ), 38440 ).
% Frame number: 962
holdsAt( coord( id5 )=( 98, 123 ), 38480 ).
holdsAt( coord( id7 )=( 109, 263 ), 38480 ).
% Frame number: 963
holdsAt( coord( id5 )=( 99, 124 ), 38520 ).
holdsAt( coord( id7 )=( 109, 263 ), 38520 ).
% Frame number: 964
holdsAt( coord( id5 )=( 100, 124 ), 38560 ).
holdsAt( coord( id7 )=( 109, 263 ), 38560 ).
% Frame number: 965
holdsAt( coord( id5 )=( 101, 125 ), 38600 ).
holdsAt( coord( id7 )=( 109, 263 ), 38600 ).
% Frame number: 966
holdsAt( coord( id5 )=( 101, 125 ), 38640 ).
holdsAt( coord( id7 )=( 108, 263 ), 38640 ).
% Frame number: 967
holdsAt( coord( id5 )=( 101, 125 ), 38680 ).
holdsAt( coord( id7 )=( 108, 262 ), 38680 ).
% Frame number: 968
holdsAt( coord( id5 )=( 101, 125 ), 38720 ).
holdsAt( coord( id7 )=( 107, 262 ), 38720 ).
% Frame number: 969
happensAt( walking( id5 ), 38760 ). holdsAt( coord( id5 )=( 101, 127 ), 38760 ).
happensAt( walking( id7 ), 38760 ). holdsAt( coord( id7 )=( 107, 262 ), 38760 ).
% Frame number: 970
holdsAt( coord( id5 )=( 102, 127 ), 38800 ).
holdsAt( coord( id7 )=( 106, 262 ), 38800 ).
% Frame number: 971
holdsAt( coord( id5 )=( 102, 127 ), 38840 ).
happensAt( walking( id7 ), 38840 ). holdsAt( coord( id7 )=( 105, 262 ), 38840 ).
% Frame number: 972
holdsAt( coord( id5 )=( 102, 127 ), 38880 ).
holdsAt( coord( id7 )=( 104, 262 ), 38880 ).
% Frame number: 973
holdsAt( coord( id5 )=( 103, 128 ), 38920 ).
happensAt( walking( id7 ), 38920 ). holdsAt( coord( id7 )=( 104, 262 ), 38920 ).
% Frame number: 974
holdsAt( coord( id5 )=( 104, 129 ), 38960 ).
holdsAt( coord( id7 )=( 103, 262 ), 38960 ).
% Frame number: 975
holdsAt( coord( id5 )=( 106, 130 ), 39000 ).
holdsAt( coord( id7 )=( 102, 263 ), 39000 ).
% Frame number: 976
holdsAt( coord( id5 )=( 107, 131 ), 39040 ).
holdsAt( coord( id7 )=( 102, 263 ), 39040 ).
% Frame number: 977
holdsAt( coord( id5 )=( 108, 131 ), 39080 ).
holdsAt( coord( id7 )=( 101, 263 ), 39080 ).
% Frame number: 978
holdsAt( coord( id5 )=( 109, 131 ), 39120 ).
holdsAt( coord( id7 )=( 100, 263 ), 39120 ).
% Frame number: 979
holdsAt( coord( id5 )=( 110, 132 ), 39160 ).
holdsAt( coord( id7 )=( 100, 263 ), 39160 ).
% Frame number: 980
holdsAt( coord( id5 )=( 110, 132 ), 39200 ).
holdsAt( coord( id7 )=( 100, 263 ), 39200 ).
% Frame number: 981
holdsAt( coord( id5 )=( 110, 133 ), 39240 ).
holdsAt( coord( id7 )=( 100, 263 ), 39240 ).
% Frame number: 982
holdsAt( coord( id5 )=( 110, 133 ), 39280 ).
holdsAt( coord( id7 )=( 100, 263 ), 39280 ).
% Frame number: 983
holdsAt( coord( id5 )=( 111, 133 ), 39320 ).
holdsAt( coord( id7 )=( 100, 263 ), 39320 ).
% Frame number: 984
holdsAt( coord( id5 )=( 111, 133 ), 39360 ).
holdsAt( coord( id7 )=( 99, 263 ), 39360 ).
% Frame number: 985
holdsAt( coord( id5 )=( 111, 133 ), 39400 ).
holdsAt( coord( id7 )=( 99, 263 ), 39400 ).
% Frame number: 986
holdsAt( coord( id5 )=( 112, 133 ), 39440 ).
holdsAt( coord( id7 )=( 99, 263 ), 39440 ).
% Frame number: 987
holdsAt( coord( id5 )=( 114, 133 ), 39480 ).
holdsAt( coord( id7 )=( 99, 263 ), 39480 ).
% Frame number: 988
holdsAt( coord( id5 )=( 116, 135 ), 39520 ).
holdsAt( coord( id7 )=( 99, 263 ), 39520 ).
% Frame number: 989
holdsAt( coord( id5 )=( 118, 135 ), 39560 ).
holdsAt( coord( id7 )=( 99, 263 ), 39560 ).
% Frame number: 990
holdsAt( coord( id5 )=( 119, 135 ), 39600 ).
holdsAt( coord( id7 )=( 99, 263 ), 39600 ).
% Frame number: 991
holdsAt( coord( id5 )=( 120, 135 ), 39640 ).
holdsAt( coord( id7 )=( 99, 263 ), 39640 ).
% Frame number: 992
holdsAt( coord( id5 )=( 122, 136 ), 39680 ).
holdsAt( coord( id7 )=( 99, 263 ), 39680 ).
% Frame number: 993
holdsAt( coord( id5 )=( 123, 136 ), 39720 ).
holdsAt( coord( id7 )=( 99, 263 ), 39720 ).
% Frame number: 994
holdsAt( coord( id5 )=( 124, 137 ), 39760 ).
holdsAt( coord( id7 )=( 99, 263 ), 39760 ).
% Frame number: 995
holdsAt( coord( id5 )=( 124, 137 ), 39800 ).
holdsAt( coord( id7 )=( 99, 264 ), 39800 ).
% Frame number: 996
holdsAt( coord( id5 )=( 124, 137 ), 39840 ).
holdsAt( coord( id7 )=( 99, 264 ), 39840 ).
% Frame number: 997
holdsAt( coord( id5 )=( 124, 137 ), 39880 ).
holdsAt( coord( id7 )=( 99, 264 ), 39880 ).
% Frame number: 998
holdsAt( coord( id5 )=( 125, 137 ), 39920 ).
holdsAt( coord( id7 )=( 99, 264 ), 39920 ).
% Frame number: 999
holdsAt( coord( id5 )=( 125, 138 ), 39960 ).
holdsAt( coord( id7 )=( 98, 264 ), 39960 ).
% Frame number: 1000
holdsAt( coord( id5 )=( 125, 139 ), 40000 ).
holdsAt( coord( id7 )=( 98, 264 ), 40000 ).
% Frame number: 1001
holdsAt( coord( id5 )=( 128, 140 ), 40040 ).
holdsAt( coord( id7 )=( 98, 264 ), 40040 ).
% Frame number: 1002
holdsAt( coord( id5 )=( 130, 141 ), 40080 ).
holdsAt( coord( id7 )=( 98, 264 ), 40080 ).
% Frame number: 1003
happensAt( walking( id5 ), 40120 ). holdsAt( coord( id5 )=( 131, 141 ), 40120 ).
holdsAt( coord( id7 )=( 98, 263 ), 40120 ).
% Frame number: 1004
holdsAt( coord( id5 )=( 133, 142 ), 40160 ).
holdsAt( coord( id7 )=( 98, 263 ), 40160 ).
% Frame number: 1005
holdsAt( coord( id5 )=( 135, 143 ), 40200 ).
holdsAt( coord( id7 )=( 98, 263 ), 40200 ).
% Frame number: 1006
holdsAt( coord( id5 )=( 135, 143 ), 40240 ).
holdsAt( coord( id7 )=( 98, 263 ), 40240 ).
% Frame number: 1007
holdsAt( coord( id5 )=( 137, 144 ), 40280 ).
holdsAt( coord( id7 )=( 97, 264 ), 40280 ).
% Frame number: 1008
holdsAt( coord( id5 )=( 137, 144 ), 40320 ).
holdsAt( coord( id7 )=( 97, 264 ), 40320 ).
% Frame number: 1009
holdsAt( coord( id5 )=( 138, 145 ), 40360 ).
happensAt( walking( id7 ), 40360 ). holdsAt( coord( id7 )=( 97, 264 ), 40360 ).
% Frame number: 1010
holdsAt( coord( id5 )=( 138, 145 ), 40400 ).
holdsAt( coord( id7 )=( 96, 264 ), 40400 ).
% Frame number: 1011
holdsAt( coord( id5 )=( 139, 145 ), 40440 ).
holdsAt( coord( id7 )=( 96, 265 ), 40440 ).
% Frame number: 1012
holdsAt( coord( id5 )=( 139, 145 ), 40480 ).
holdsAt( coord( id7 )=( 96, 265 ), 40480 ).
% Frame number: 1013
holdsAt( coord( id5 )=( 139, 145 ), 40520 ).
holdsAt( coord( id7 )=( 96, 265 ), 40520 ).
% Frame number: 1014
holdsAt( coord( id5 )=( 142, 145 ), 40560 ).
holdsAt( coord( id7 )=( 95, 266 ), 40560 ).
% Frame number: 1015
holdsAt( coord( id5 )=( 144, 146 ), 40600 ).
holdsAt( coord( id7 )=( 95, 266 ), 40600 ).
% Frame number: 1016
holdsAt( coord( id5 )=( 147, 146 ), 40640 ).
holdsAt( coord( id7 )=( 95, 267 ), 40640 ).
% Frame number: 1017
holdsAt( coord( id5 )=( 149, 147 ), 40680 ).
holdsAt( coord( id7 )=( 94, 267 ), 40680 ).
% Frame number: 1018
holdsAt( coord( id5 )=( 151, 148 ), 40720 ).
holdsAt( coord( id7 )=( 94, 268 ), 40720 ).
% Frame number: 1019
holdsAt( coord( id5 )=( 152, 148 ), 40760 ).
holdsAt( coord( id7 )=( 94, 268 ), 40760 ).
% Frame number: 1020
holdsAt( coord( id5 )=( 154, 150 ), 40800 ).
holdsAt( coord( id7 )=( 94, 268 ), 40800 ).
% Frame number: 1021
holdsAt( coord( id5 )=( 155, 150 ), 40840 ).
holdsAt( coord( id7 )=( 94, 269 ), 40840 ).
% Frame number: 1022
holdsAt( coord( id5 )=( 156, 151 ), 40880 ).
holdsAt( coord( id7 )=( 94, 269 ), 40880 ).
% Frame number: 1023
holdsAt( coord( id5 )=( 156, 151 ), 40920 ).
holdsAt( coord( id7 )=( 94, 269 ), 40920 ).
% Frame number: 1024
happensAt( walking( id5 ), 40960 ). holdsAt( coord( id5 )=( 157, 152 ), 40960 ).
holdsAt( coord( id7 )=( 94, 269 ), 40960 ).
% Frame number: 1025
holdsAt( coord( id5 )=( 157, 152 ), 41000 ).
holdsAt( coord( id7 )=( 93, 268 ), 41000 ).
% Frame number: 1026
holdsAt( coord( id5 )=( 157, 152 ), 41040 ).
holdsAt( coord( id7 )=( 93, 268 ), 41040 ).
% Frame number: 1027
holdsAt( coord( id5 )=( 157, 153 ), 41080 ).
holdsAt( coord( id7 )=( 93, 269 ), 41080 ).
% Frame number: 1028
happensAt( walking( id5 ), 41120 ). holdsAt( coord( id5 )=( 159, 154 ), 41120 ).
holdsAt( coord( id7 )=( 93, 269 ), 41120 ).
% Frame number: 1029
holdsAt( coord( id5 )=( 161, 156 ), 41160 ).
holdsAt( coord( id7 )=( 93, 268 ), 41160 ).
% Frame number: 1030
holdsAt( coord( id5 )=( 164, 158 ), 41200 ).
happensAt( walking( id7 ), 41200 ). holdsAt( coord( id7 )=( 89, 268 ), 41200 ).
% Frame number: 1031
holdsAt( coord( id5 )=( 166, 160 ), 41240 ).
holdsAt( coord( id7 )=( 89, 268 ), 41240 ).
% Frame number: 1032
holdsAt( coord( id5 )=( 168, 161 ), 41280 ).
holdsAt( coord( id7 )=( 89, 268 ), 41280 ).
% Frame number: 1033
happensAt( walking( id5 ), 41320 ). holdsAt( coord( id5 )=( 169, 162 ), 41320 ).
holdsAt( coord( id7 )=( 89, 267 ), 41320 ).
% Frame number: 1034
holdsAt( coord( id5 )=( 170, 163 ), 41360 ).
holdsAt( coord( id7 )=( 88, 267 ), 41360 ).
% Frame number: 1035
holdsAt( coord( id5 )=( 171, 164 ), 41400 ).
holdsAt( coord( id7 )=( 88, 267 ), 41400 ).
% Frame number: 1036
holdsAt( coord( id5 )=( 172, 164 ), 41440 ).
holdsAt( coord( id7 )=( 88, 267 ), 41440 ).
% Frame number: 1037
holdsAt( coord( id5 )=( 172, 165 ), 41480 ).
happensAt( walking( id7 ), 41480 ). holdsAt( coord( id7 )=( 88, 268 ), 41480 ).
% Frame number: 1038
holdsAt( coord( id5 )=( 173, 166 ), 41520 ).
holdsAt( coord( id7 )=( 88, 267 ), 41520 ).
% Frame number: 1039
holdsAt( coord( id5 )=( 173, 166 ), 41560 ).
holdsAt( coord( id7 )=( 88, 267 ), 41560 ).
% Frame number: 1040
holdsAt( coord( id5 )=( 173, 167 ), 41600 ).
holdsAt( coord( id7 )=( 88, 266 ), 41600 ).
% Frame number: 1041
holdsAt( coord( id5 )=( 175, 168 ), 41640 ).
happensAt( walking( id7 ), 41640 ). holdsAt( coord( id7 )=( 88, 266 ), 41640 ).
% Frame number: 1042
holdsAt( coord( id5 )=( 177, 169 ), 41680 ).
holdsAt( coord( id7 )=( 88, 266 ), 41680 ).
% Frame number: 1043
holdsAt( coord( id5 )=( 181, 170 ), 41720 ).
holdsAt( coord( id7 )=( 88, 266 ), 41720 ).
% Frame number: 1044
holdsAt( coord( id5 )=( 183, 174 ), 41760 ).
holdsAt( coord( id7 )=( 88, 266 ), 41760 ).
% Frame number: 1045
holdsAt( coord( id5 )=( 184, 176 ), 41800 ).
holdsAt( coord( id7 )=( 88, 267 ), 41800 ).
% Frame number: 1046
holdsAt( coord( id5 )=( 186, 178 ), 41840 ).
holdsAt( coord( id7 )=( 88, 267 ), 41840 ).
% Frame number: 1047
holdsAt( coord( id5 )=( 187, 180 ), 41880 ).
holdsAt( coord( id7 )=( 87, 267 ), 41880 ).
% Frame number: 1048
holdsAt( coord( id5 )=( 189, 182 ), 41920 ).
happensAt( walking( id7 ), 41920 ). holdsAt( coord( id7 )=( 87, 266 ), 41920 ).
% Frame number: 1049
holdsAt( coord( id5 )=( 189, 183 ), 41960 ).
holdsAt( coord( id7 )=( 87, 266 ), 41960 ).
% Frame number: 1050
holdsAt( coord( id5 )=( 190, 184 ), 42000 ).
holdsAt( coord( id7 )=( 87, 266 ), 42000 ).
% Frame number: 1051
holdsAt( coord( id5 )=( 190, 185 ), 42040 ).
holdsAt( coord( id7 )=( 87, 266 ), 42040 ).
% Frame number: 1052
holdsAt( coord( id5 )=( 191, 185 ), 42080 ).
holdsAt( coord( id7 )=( 87, 266 ), 42080 ).
% Frame number: 1053
holdsAt( coord( id5 )=( 191, 187 ), 42120 ).
holdsAt( coord( id7 )=( 87, 266 ), 42120 ).
% Frame number: 1054
happensAt( walking( id5 ), 42160 ). holdsAt( coord( id5 )=( 191, 188 ), 42160 ).
holdsAt( coord( id7 )=( 86, 266 ), 42160 ).
% Frame number: 1055
holdsAt( coord( id5 )=( 192, 190 ), 42200 ).
holdsAt( coord( id7 )=( 86, 266 ), 42200 ).
% Frame number: 1056
holdsAt( coord( id5 )=( 193, 192 ), 42240 ).
holdsAt( coord( id7 )=( 86, 266 ), 42240 ).
% Frame number: 1057
holdsAt( coord( id5 )=( 196, 196 ), 42280 ).
holdsAt( coord( id7 )=( 85, 264 ), 42280 ).
% Frame number: 1058
holdsAt( coord( id5 )=( 198, 198 ), 42320 ).
holdsAt( coord( id7 )=( 84, 264 ), 42320 ).
% Frame number: 1059
holdsAt( coord( id5 )=( 199, 201 ), 42360 ).
holdsAt( coord( id7 )=( 83, 263 ), 42360 ).
% Frame number: 1060
holdsAt( coord( id5 )=( 201, 203 ), 42400 ).
holdsAt( coord( id7 )=( 83, 263 ), 42400 ).
% Frame number: 1061
holdsAt( coord( id5 )=( 203, 204 ), 42440 ).
holdsAt( coord( id7 )=( 83, 262 ), 42440 ).
% Frame number: 1062
holdsAt( coord( id5 )=( 204, 205 ), 42480 ).
holdsAt( coord( id7 )=( 81, 262 ), 42480 ).
% Frame number: 1063
holdsAt( coord( id5 )=( 205, 206 ), 42520 ).
holdsAt( coord( id7 )=( 80, 262 ), 42520 ).
% Frame number: 1064
holdsAt( coord( id5 )=( 205, 206 ), 42560 ).
holdsAt( coord( id7 )=( 80, 262 ), 42560 ).
% Frame number: 1065
holdsAt( coord( id5 )=( 206, 208 ), 42600 ).
holdsAt( coord( id7 )=( 80, 261 ), 42600 ).
% Frame number: 1066
holdsAt( coord( id5 )=( 206, 210 ), 42640 ).
holdsAt( coord( id7 )=( 79, 260 ), 42640 ).
% Frame number: 1067
holdsAt( coord( id5 )=( 206, 211 ), 42680 ).
holdsAt( coord( id7 )=( 79, 260 ), 42680 ).
% Frame number: 1068
happensAt( walking( id5 ), 42720 ). holdsAt( coord( id5 )=( 207, 212 ), 42720 ).
holdsAt( coord( id7 )=( 78, 260 ), 42720 ).
% Frame number: 1069
holdsAt( coord( id5 )=( 211, 214 ), 42760 ).
holdsAt( coord( id7 )=( 78, 259 ), 42760 ).
% Frame number: 1070
holdsAt( coord( id5 )=( 213, 216 ), 42800 ).
happensAt( walking( id7 ), 42800 ). holdsAt( coord( id7 )=( 77, 259 ), 42800 ).
% Frame number: 1071
holdsAt( coord( id5 )=( 216, 219 ), 42840 ).
holdsAt( coord( id7 )=( 76, 259 ), 42840 ).
% Frame number: 1072
holdsAt( coord( id5 )=( 219, 220 ), 42880 ).
holdsAt( coord( id7 )=( 77, 258 ), 42880 ).
% Frame number: 1073
holdsAt( coord( id5 )=( 220, 222 ), 42920 ).
holdsAt( coord( id7 )=( 77, 258 ), 42920 ).
% Frame number: 1074
holdsAt( coord( id5 )=( 222, 225 ), 42960 ).
holdsAt( coord( id7 )=( 77, 257 ), 42960 ).
% Frame number: 1075
holdsAt( coord( id5 )=( 224, 226 ), 43000 ).
% Frame number: 1076
holdsAt( coord( id5 )=( 224, 228 ), 43040 ).
% Frame number: 1077
holdsAt( coord( id5 )=( 225, 230 ), 43080 ).
% Frame number: 1078
holdsAt( coord( id5 )=( 226, 231 ), 43120 ).
% Frame number: 1079
holdsAt( coord( id5 )=( 226, 233 ), 43160 ).
% Frame number: 1080
holdsAt( coord( id5 )=( 227, 235 ), 43200 ).
% Frame number: 1081
happensAt( walking( id5 ), 43240 ). holdsAt( coord( id5 )=( 227, 237 ), 43240 ).
% Frame number: 1082
holdsAt( coord( id5 )=( 228, 238 ), 43280 ).
% Frame number: 1083
holdsAt( coord( id5 )=( 228, 239 ), 43320 ).
% Frame number: 1084
holdsAt( coord( id5 )=( 230, 241 ), 43360 ).
% Frame number: 1085
holdsAt( coord( id5 )=( 233, 242 ), 43400 ).
% Frame number: 1086
holdsAt( coord( id5 )=( 236, 243 ), 43440 ).
% Frame number: 1087
holdsAt( coord( id5 )=( 238, 244 ), 43480 ).
% Frame number: 1088
holdsAt( coord( id5 )=( 239, 245 ), 43520 ).
% Frame number: 1089
holdsAt( coord( id5 )=( 241, 245 ), 43560 ).
% Frame number: 1090
holdsAt( coord( id5 )=( 242, 247 ), 43600 ).
% Frame number: 1091
happensAt( walking( id5 ), 43640 ). holdsAt( coord( id5 )=( 244, 248 ), 43640 ).
% Frame number: 1092
holdsAt( coord( id5 )=( 244, 251 ), 43680 ).
% Frame number: 1093
holdsAt( coord( id5 )=( 245, 253 ), 43720 ).
% Frame number: 1094
holdsAt( coord( id5 )=( 246, 256 ), 43760 ).
% Frame number: 1095
holdsAt( coord( id5 )=( 248, 258 ), 43800 ).
% Frame number: 1096
holdsAt( coord( id5 )=( 250, 261 ), 43840 ).
% Frame number: 1097
holdsAt( coord( id5 )=( 251, 262 ), 43880 ).
% Frame number: 1098
holdsAt( coord( id5 )=( 255, 263 ), 43920 ).
% Frame number: 1099
holdsAt( coord( id5 )=( 258, 264 ), 43960 ).
% Frame number: 1100
holdsAt( coord( id5 )=( 260, 265 ), 44000 ).
% Frame number: 1101
holdsAt( coord( id5 )=( 262, 265 ), 44040 ).
% Frame number: 1102
holdsAt( coord( id5 )=( 264, 265 ), 44080 ).
% Frame number: 1103
holdsAt( coord( id5 )=( 265, 266 ), 44120 ).
% Frame number: 1104
holdsAt( coord( id5 )=( 266, 268 ), 44160 ).
% Frame number: 1105
holdsAt( coord( id5 )=( 267, 270 ), 44200 ).
% Frame number: 1106
holdsAt( coord( id5 )=( 268, 272 ), 44240 ).
% Frame number: 1107
happensAt( walking( id5 ), 44280 ). holdsAt( coord( id5 )=( 269, 273 ), 44280 ).
% Frame number: 1108
holdsAt( coord( id5 )=( 269, 275 ), 44320 ).
% Frame number: 1109
holdsAt( coord( id5 )=( 270, 275 ), 44360 ).
% Frame number: 1110
happensAt( walking( id5 ), 44400 ). holdsAt( coord( id5 )=( 271, 275 ), 44400 ).
% Frame number: 1111
holdsAt( coord( id5 )=( 273, 275 ), 44440 ).
% Frame number: 1112
holdsAt( coord( id5 )=( 274, 275 ), 44480 ).
% Frame number: 1113
holdsAt( coord( id5 )=( 275, 275 ), 44520 ).
% Frame number: 1114
holdsAt( coord( id5 )=( 276, 275 ), 44560 ).
| JasonFil/Prob-EC | dataset/smooth-noise/15-LeftBag_AtChair/lb2gtMovementIndv_new.pl | Perl | bsd-3-clause | 116,064 |
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
my $megaraid = "bash -c /apps/Linux64/bin/megasasctl";
my @output = `$megaraid 2>&1`;
if ($? ne 0) {
unknown($output[0]);
}
foreach my $line (@output) {
# Ensure volumes are optimal
if ($line =~ /^a\dd/) {
my @volume = split(/\s+/, $line);
critical("volume $volume[0] is $volume[5]") unless ($volume[5] eq "optimal");
}
# Output physical disk errors
if ($line =~ /^a\de/) {
# skip online disk
next if $line =~ /^a\de.*online/;
my @disk = split(/\s+/, $line);
critical("disk $disk[0] is $disk[2]") unless ($disk[2] eq "hotspare");
}
}
print "Everything OK\n";
exit 0;
sub critical {
my $message = shift;
print "CRITICAL: $message\n";
exit 2;
}
sub unknown {
my $message = shift;
print "UNKNOWN: $message\n";
exit 3;
}
| dneg/nagios | check_megaraid.pl | Perl | mit | 837 |
package AliTV::Base;
use AliTV::Base::Version;
use Log::Log4perl;
sub new
{
my $class = shift;
my $self = {};
bless $self, $class;
# create a logger for the object
$self->{logger} = Log::Log4perl->get_logger(ref($self));
# call the private _inititialize method providing the parameters
$self->_initialize(@_);
if (@_%2!=0)
{
$self->_logdie("The number of arguments was odd!");
}
my %named_parameter = @_;
foreach my $attribute (keys %named_parameter)
{
# ignore all key without leading dash
my $method = $attribute;
if ($attribute !~ /^-/)
{
#$self->_logdie("The attribute '$attribute' does not start with a leading dash!");
} else {
$method =~ s/^-//;
my $class = ref($self);
if ($class->can($method))
{
$self->$method($named_parameter{$attribute});
} else {
$self->_logdie("The attribute '$method' has no setter in class '".__PACKAGE__."'");
}
}
}
return $self;
}
sub _logdie
{
my $self = shift;
my $msg = shift;
$self->_logging($msg, "logcroak");
}
sub _logwarn
{
my $self = shift;
my $msg = shift;
$self->_logging($msg, "logwarn");
}
sub _debug
{
my $self = shift;
my $msg = shift;
$self->_logging($msg, "debug");
}
sub _info
{
my $self = shift;
my $msg = shift;
$self->_logging($msg, "info");
}
sub _warn
{
my $self = shift;
my $msg = shift;
$self->_logging($msg, "warn");
}
sub _error
{
my $self = shift;
my $msg = shift;
$self->_logging($msg, "error");
}
sub _fatal
{
my $self = shift;
my $msg = shift;
$self->_logging($msg, "fatal");
}
sub _logging
{
my $self = shift;
my $msg = shift;
my $level = shift;
unless (ref($self) &&
exists $self->{logger} &&
ref($self->{logger}) &&
$self->{logger}->can($level))
{
# without a Log::Log4perl instance we can not use its
# functionality, therefore we need to use Carp instead
require Carp;
Carp::croak($msg);
} else {
$self->{logger}->$level($msg);
}
}
sub _initialize
{
my $self = shift;
$self->_logdie("You need to overwrite the method ".__PACKAGE__."::_initialize()");
}
sub DESTROY
{
my $self = shift;
# currently nothing to do
}
sub clone
{
my $self = shift;
unless (ref $self)
{
# this is a class function, therefore no logger is defined,
# use Carp instead
require Carp;
Carp::croak("Cannot clone class '$self'");
}
# CODE items can not be dcloned... Therefore delete the logger
delete $self->{logger};
# we require the dclone function from Storable
require Storable;
# clone the object
my $deep_copy = Storable::dclone($self);
# restore the logger object
$deep_copy->{logger} = Log::Log4perl->get_logger(ref($deep_copy));
return $deep_copy;
}
sub file
{
my $self = shift;
my $return_val = undef;
# check if other arguments are given
if (@_)
{
$return_val = shift; # first parameter is the filename
$self->{file} = $return_val;
# call the check for existing files
$self->_file_check();
} elsif (exists $self->{file})
{
# return the current value if the object has a attribute 'file'
$return_val = $self->{file};
} else {
# otherwise generate the attribute and assign the value undef
$self->{file} = $return_val;
}
return $return_val;
}
sub _file_check
{
my $self = shift;
# check if the attribute 'file' exists and is defined
if (exists $self->{file} && defined $self->{file})
{
unless (-e $self->{file})
{
$self->_logdie("The file '$self->{file}' does not exist!");
}
}
}
# This class method returns the name for link features. This can be
# used in other classes to avoid inconsistencies with link feature
# naming
sub _link_feature_name
{
return "link";
}
1;
=head1 AliTV::Base class
AliTV::Base - basic class for all all other AliTV classes
=head1 SYNOPSIS
package AliTV::Class;
use parent qw(AliTV::Base)
package main;
use AliTV::Class;
# VERSION is already available from AliTV::Base
print $AliTV::Class::VERSION;
=head1 DESCRIPTION
This class is the basic class for all other AliTV classes and provides
some fundamental methods and a central version numbering. Those
methods comprise:
=over 4
=item * Consistent and global version numbering
Therefore the module utilizes L<AliTV::Base::Version> to generate a
single version number for all files.
=item * A basic constructor
=item * A basic destructor
=item * A basic clone method
=back
=head1 AUTHOR
Frank Foerster, E<lt>foersterfrank@gmx.deE<gt>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2015 by Frank Foerster
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.10 or,
at your option, any later version of Perl 5 you may have available.
=cut
| greatfireball/AliTV-perl-interface | lib/AliTV/Base.pm | Perl | mit | 5,032 |
package DDG::Goodie::Ascii;
# ABSTRACT: ASCII
use DDG::Goodie;
triggers end => "ascii";
primary_example_queries '0110100001100101011011000110110001101111 to ascii';
description 'convert binary data to readable characters';
name 'Ascii';
code_url 'https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/Binary.pm';
category 'transformations';
topics 'cryptography';
zci answer_type => "ascii_conversion";
zci is_cached => 1;
handle remainder => sub {
my $ascii = pack("B*", $1) if /^(([0-1]{8})*)\s+(in|to)$/;
my $binary = $1;
return unless $ascii;
return "$binary in binary is \"$ascii\" in ASCII",
structured_answer => {
input => [$binary],
operation => 'Binary to ASCII',
result => html_enc($ascii),
};
};
1;
| Acidburn0zzz/zeroclickinfo-goodies | lib/DDG/Goodie/Ascii.pm | Perl | apache-2.0 | 805 |
#
# Copyright 2016 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package centreon::common::aruba::snmp::mode::components::psu;
use strict;
use warnings;
my %map_psu_status = (
1 => 'active',
2 => 'inactive',
);
# In MIB 'aruba-systemext'
my $mapping = {
sysExtPowerSupplyStatus => { oid => '.1.3.6.1.4.1.14823.2.2.1.2.1.18.1.2', map => \%map_psu_status },
};
my $oid_wlsxSysExtPowerSupplyEntry = '.1.3.6.1.4.1.14823.2.2.1.2.1.18.1.2';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_wlsxSysExtPowerSupplyEntry };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking power supplies");
$self->{components}->{psu} = {name => 'power supplies', total => 0, skip => 0};
return if ($self->check_filter(section => 'psu'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_wlsxSysExtPowerSupplyEntry}})) {
next if ($oid !~ /^$mapping->{sysExtPowerSupplyStatus}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_wlsxSysExtPowerSupplyEntry}, instance => $instance);
next if ($self->check_filter(section => 'psu', instance => $instance));
$self->{components}->{psu}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Power supply '%s' status is %s [instance: %s].",
$instance, $result->{sysExtPowerSupplyStatus},
$instance
));
my $exit = $self->get_severity(section => 'psu', value => $result->{sysExtPowerSupplyStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Power supply '%s' status is %s",
$instance, $result->{sysExtPowerSupplyStatus}));
}
}
}
1; | bcournaud/centreon-plugins | centreon/common/aruba/snmp/mode/components/psu.pm | Perl | apache-2.0 | 2,770 |
package Paws::DS::DeleteSnapshotResult;
use Moose;
has SnapshotId => (is => 'ro', isa => 'Str');
has _request_id => (is => 'ro', isa => 'Str');
### main pod documentation begin ###
=head1 NAME
Paws::DS::DeleteSnapshotResult
=head1 ATTRIBUTES
=head2 SnapshotId => Str
The identifier of the directory snapshot that was deleted.
=head2 _request_id => Str
=cut
1; | ioanrogers/aws-sdk-perl | auto-lib/Paws/DS/DeleteSnapshotResult.pm | Perl | apache-2.0 | 379 |
#-----------------------------------------------------------
# esent
# Get contents of Esent\Process key from Software hive
#
# Note: Not sure why I wrote this one; just thought it might come
# in handy as info about this key is developed.
#
# copyright 2010 Quantum Analytics Research, LLC
#-----------------------------------------------------------
package esent;
use strict;
my %config = (hive => "Software",
osmask => 22,
hasShortDescr => 1,
hasDescr => 0,
hasRefs => 1,
version => 20101202);
sub getConfig{return %config}
sub getShortDescr {
return "Get ESENT\\Process key contents";
}
sub getDescr{}
sub getRefs {}
sub getHive {return $config{hive};}
sub getVersion {return $config{version};}
my $VERSION = getVersion();
sub pluginmain {
my $class = shift;
my $hive = shift;
::logMsg("Launching esent v.".$VERSION);
::rptMsg("esent v.".$VERSION); # banner
::rptMsg("(".$config{hive}.") ".getShortDescr()."\n"); # banner
my $reg = Parse::Win32Registry->new($hive);
my $root_key = $reg->get_root_key;
my $key_path = "Microsoft\\ESENT\\Process";
my $key;
if ($key = $root_key->get_subkey($key_path)) {
::rptMsg($key_path);
# ::rptMsg("LastWrite Time ".gmtime($key->get_timestamp())." (UTC)");
::rptMsg("");
my @sk = $key->get_list_of_subkeys();
if (scalar(@sk) > 0) {
my %esent;
foreach my $s (@sk) {
my $sk = $s->get_subkey("DEBUG");
# my $lw = $s->get_timestamp();
my $lw = $sk->get_timestamp();
my $name = $s->get_name();
push(@{$esent{$lw}},$name);
}
foreach my $t (reverse sort {$a <=> $b} keys %esent) {
::rptMsg(gmtime($t)." (UTC)");
foreach my $item (@{$esent{$t}}) {
::rptMsg(" $item");
}
}
}
else {
::rptMsg($key_path." has no subkeys.");
}
}
else {
::rptMsg($key_path." not found.");
}
}
1; | kefir-/autopsy | RecentActivity/release/rr-full/plugins/esent.pl | Perl | apache-2.0 | 2,013 |
#!/usr/local/bin/perl
# (C) Hans Wolfgang Loidl, July 1995
#############################################################################
# Time-stamp: <Thu Oct 26 1995 18:23:00 Stardate: [-31]6498.62 hwloidl>
#
# Usage: SPLIT [options] <gr-file>
#
# Generate a set of granularity graphs out of the GrAnSim profile <gr-file>.
# The granularity graphs are put into subdirs of the structure:
# <basename of gr-file>-<spark-name>
#
# Options:
# -s <list> ... a perl list of spark names; the given <gr-file> is scanned
# for each given name in turn and granularity graphs are
# generated for each of these sparks
# -O ... use gr2RTS and RTS2gran instead of gran-extr;
# this generates fewer output files (only granularity graphs)
# but should be faster and far less memory consuming
# -d <dir> ... use <dir> as basename for the sub-directories
# -o <file> ... use <file> as basename for the generated latex files;
# the overall result is in <file>.ps
# -t <file> ... use <file> as gran-extr type template file
# ('.' for local template, ',' for global template)
# -A ... surpress generation of granularity profiles for overall .gr
# -h ... help; print this text.
# -v ... verbose mode.
#
#############################################################################
require "getopts.pl";
&Getopts('hvOAd:o:s:t:');
do process_options();
if ( $opt_v ) { do print_verbose_message(); }
# ---------------------------------------------------------------------------
# Init
# ---------------------------------------------------------------------------
$latex = "/usr/local/tex/bin/latex2e"; # or "/usr/local/tex/bin/latex2e"
do all() if !$opt_A;
foreach $s (@sparks) {
if ( -f $tmp_file ) { system "rm -f $tmp_file"; }
system "tf -H -s $s $gr_file > $tmp_file"
|| die "Can't open pipe: tf -s $s $gr_file > $tmp_file\n";
if ( $opt_d ) {
$dir = $opt_d;
} else {
$dir = $gr_file;
}
$dir =~ s/\.gr//g;
$dir .= "-$s";
if ( ! -d $dir ) {
mkdir($dir,"755"); # system "mkdir $dir";
system "chmod u+rwx $dir";
}
system "mv $tmp_file $dir/$gr_file";
chdir $dir;
do print_template();
do print_va("Title",$s);
if ( -f $va_ps_file ) {
local ($old) = $va_ps_file;
$old =~ s/\.ps/-o.ps/g;
system "mv $va_ps_file $old";
}
if ( $opt_O ) {
system "gr2RTS -o $rts_file $gr_file; " .
"RTS2gran -t $template_file $rts_file; " .
"$latex $va_file; dvips $va_dvi_file > $va_ps_file";
} else {
system "gran-extr -t $template_file $gr_file; " .
"$latex $va_file; dvips $va_dvi_file > $va_ps_file";
}
chdir ".."; # system "cd ..";
}
exit 0;
# -----------------------------------------------------------------------------
sub all {
$dir = $gr_file;
$dir =~ s/\.gr//g;
$dir .= "-all";
if ( ! -d $dir ) {
mkdir($dir,"755"); # system "mkdir $dir";
system "chmod u+rwx $dir";
}
system "cp $gr_file $dir/$gr_file";
chdir $dir;
do print_template();
do print_va("All","all");
if ( -f $va_ps_file ) {
local ($old) = $va_ps_file;
$old =~ s/\.ps/-o.ps/g;
system "mv $va_ps_file $old";
}
if ( $opt_O ) {
system "gr2RTS -o $rts_file $gr_file; " .
"RTS2gran -t $template_file $rts_file; " .
"$latex $va_file; dvips $va_dvi_file > $va_ps_file";
} else {
system "gran-extr -t $template_file $gr_file; " .
"$latex $va_file; dvips $va_dvi_file > $va_ps_file";
}
chdir ".."; # system "cd ..";
}
# ---------------------------------------------------------------------------
sub print_template {
open (TEMPL,">$template_file") || die "Can't open $template_file\n";
print TEMPL <<EOF;
-- Originally copied from the master template: GrAn/bin/TEMPL
-- Intervals for pure exec. times
G: (1000, 2000, 3000, 4000, 5000, 10000, 20000, 30000, 40000, 50000, 100000, 200000, 300000)
-- Intervals for communication (i.e. fetch) times
F: (1000, 2000, 3000, 4000, 5000, 10000, 20000, 30000, 40000, 50000, 100000, 200000, 300000)
-- Intervals for communication percentages
C: (0, 1, 2, 5, 8, 10, 20, 30, 40, 50, 100)
-- Intervals for no. of sparks
S: (1, 2, 5)
-- Intervals for heap allocations
A: (10,20,30,40,50,100,200,300,400,500,1000,2000,3000)
-- A: (100, 50000, 66000, 100000)
g: g.dat
f: f.dat
c: c.dat
s: s.dat
a: a.dat
-- Select file name corr coeff file
Xcorr: CORR
-- Select file names for GNUPLOT data files for cumulative runtime and
-- cluster graphs
Xcumulat-rts: cumu-rts.dat
Xcumulat-fts: cumu-fts.dat
Xcumulat-has: cumu-has.dat
Xcumulat-cps: cumu-cps.dat
Xclust-rts: clust-rts.dat
Xclust-has: clust-has.dat
Xclust-cps: clust-cps.dat
-- Select file names for GNUPLOT data files for per proc. runnable time
-- and per spark site runtime
Xpe: pe.dat
Xsn: sn.dat
-- Select file names for sorted lists of runtimes, heap allocs, number of
-- local and global sparks and communication percentage
XRTS: RTS
XFTS: FTS
XHAS: HAS
XLSPS: LSPS
XGSPS: GSPS
XCPS: CPS
XCCPS: CPS
-- Std log scaling
L: .
-- ('g',"xy",'Cg',"xy",'Ca',"xy")
-- Gray level of impulses in the graph (0=black)
i: 0.3
-- Number of clusters
k: 2
-- Width of impulses (needed for gp-ext-imp)
e: 150
-- Input file
-- -: soda.gr
EOF
close(TEMPL);
}
# -----------------------------------------------------------------------------
# NB: different file must be generated for $opt_O and default setup.
# -----------------------------------------------------------------------------
sub print_va {
local ($title, $spark) = @_;
open (VA,">$va_file") || die "Can't open $va_file\n";
if ( $opt_O ) {
print VA <<EOF;
% Originally copied from master va-file: grasp/tests/va.tex
\\documentstyle[11pt,psfig]{article}
% Page Format
\\topmargin=0cm %0.5cm
\\textheight=24cm %22cm
\\footskip=0cm
\\oddsidemargin=0cm %0.75cm
\\evensidemargin=0cm %0.75cm
\\rightmargin=0cm %0.75cm
\\leftmargin=0cm %0.75cm
\\textwidth=16cm %14.5cm
\\title{SPLIT}
\\author{Me}
\\date{Today}
\\pssilent
\\begin{document}
\\pagestyle{empty}
\%\\maketitle
\\nopagebreak
\\begin{figure}[t]
\\begin{center}
\\begin{tabular}{c}
\\centerline{\\psfig{angle=270,width=7cm,file=$gran_file}}
\\end{tabular}
\\end{center}
\\caption{Granularity {\\bf $spark}}
\\end{figure}
\\begin{figure}[t]
\\begin{center}
\\begin{tabular}{cc}
\\psfig{angle=270,width=7cm,file=cumu-rts.ps} &
\\psfig{angle=270,width=7cm,file=cumu-rts0.ps}
\\end{tabular}
\\end{center}
\\caption{Cumulative Execution Times {\\bf $spark}}
\\end{figure}
\\end{document}
EOF
} else {
print VA <<EOF;
% Originally copied from master va-file: grasp/tests/va.tex
\\documentstyle[11pt,psfig]{article}
% Page Format
\\topmargin=0cm %0.5cm
\\textheight=24cm %22cm
\\footskip=0cm
\\oddsidemargin=0cm %0.75cm
\\evensidemargin=0cm %0.75cm
\\rightmargin=0cm %0.75cm
\\leftmargin=0cm %0.75cm
\\textwidth=16cm %14.5cm
\\title{$title; Spark: $spark}
\\author{}
\\date{}
\\begin{document}
\\pagestyle{empty}
%\\maketitle
\\nopagebreak
\\begin{figure}[t]
\\begin{center}
\\begin{tabular}{cc}
\\psfig{angle=270,width=7cm,file=$gran_file} &
\\psfig{angle=270,width=7cm,file=a.ps}
\\end{tabular}
\\end{center}
\\caption{Granularity \\& Heap Allocations {\\bf $spark}}
\\end{figure}
\\begin{figure}[t]
\\begin{center}
\\begin{tabular}{cc}
\\psfig{angle=270,width=7cm,file=f.ps} &
\\psfig{angle=270,width=7cm,file=c.ps}
\\end{tabular}
\\end{center}
\\caption{Fetching Profile {\\bf $spark}}
\\end{figure}
\\begin{figure}[t]
\\begin{center}
\\begin{tabular}{cc}
\\psfig{angle=270,width=7cm,file=cumu-rts.ps} &
\\psfig{angle=270,width=7cm,file=cumu-rts0.ps}
\\end{tabular}
\\end{center}
\\caption{Cumulative Execution Times {\\bf $spark}}
\\end{figure}
\\end{document}
EOF
}
close (VA);
}
# -----------------------------------------------------------------------------
sub process_options {
if ( $opt_h ) {
open(ME,$0) || die "Can't open myself ($0): $!\n";
$n = 0;
while (<ME>) {
last if $_ =~ /^$/;
print $_;
$n++;
}
close(ME);
exit ;
}
if ( $opt_s ) {
$opt_s =~ s/[\(\)\[\]]//g;
@sparks = split(/[,;. ]+/, $opt_s);
} else {
@sparks = ( 3, 4, 5, 6, 7, 8, 11, 12, 13, 14, 15);
}
if ( $#ARGV != 0 ) {
print "Usage: $0 [options] <gr-file>\n;";
print "Use -h option to get details\n";
exit 1;
}
$gr_file = $ARGV[0];
($basename = $gr_file) =~ s/\.gr//;
$rts_file = $basename . ".rts"; # "RTS";
$gran_file = "g.ps"; # $basename . ".ps";
#$rts_file = $gr_file;
#$rts_file =~ s/\.gr/.rts/g;
if ( $opt_o ) {
$va_file = $opt_o;
$va_dvi_file = $va_file;
$va_dvi_file =~ s/\.tex/.dvi/g;
$va_ps_file = $va_file;
$va_ps_file =~ s/\.tex/.ps/g;
} else {
$va_file = "va.tex";
$va_dvi_file = "va.dvi";
$va_ps_file = "va.ps";
}
if ( $opt_t ) {
$template_file = $opt_t;
} else {
$template_file = "TEMPL";
}
$tmp_file = ",t";
}
# -----------------------------------------------------------------------------
sub print_verbose_message {
print "Sparks: (" . join(',',@sparks) . ")\n";
print "Files: .gr " . $gr_file . " template " . $template_file .
" va " . $va_file . "\n";
}
# -----------------------------------------------------------------------------
| nomeata/ghc | utils/parallel/SPLIT.pl | Perl | bsd-3-clause | 9,636 |
#! /usr/bin/env perl
##**************************************************************
##
## Copyright (C) 1990-2007, Condor Team, Computer Sciences Department,
## University of Wisconsin-Madison, WI.
##
## Licensed under the Apache License, Version 2.0 (the "License"); you
## may not use this file except in compliance with the License. You may
## obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
##
##**************************************************************
use CondorTest;
$cmd = 'job_core_perremove-true_sched.cmd';
$testdesc = 'Condor submit policy test for PERIODIC_REMOVE - scheduler U';
$testname = "job_core_perremove_sched";
my $killedchosen = 0;
my %args;
my $cluster;
$aborted = sub {
CondorTest::debug("Abort event expected from periodic_remove policy evaluating to true\n",1);
CondorTest::debug("Policy test worked.\n",1);
};
$executed = sub
{
%args = @_;
$cluster = $args{"cluster"};
CondorTest::debug("Good. for on_exit_remove cluster $cluster must run first\n",1);
};
CondorTest::RegisterExecute($testname, $executed);
CondorTest::RegisterAbort( $testname, $aborted );
if( CondorTest::RunTest($testname, $cmd, 0) ) {
CondorTest::debug("$testname: SUCCESS\n",1);
exit(0);
} else {
die "$testname: CondorTest::RunTest() failed\n";
}
| djw8605/condor | src/condor_tests/job_core_perremove-true_sched.pl | Perl | apache-2.0 | 1,635 |
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
package qpid::messaging;
sub encode {
my $content = $_[0];
my $message = $_[1];
my $impl = $message->get_implementation();
if(UNIVERSAL::isa($content, "HASH")) {
cqpid_perl::encode($content, $impl, "amqp/map");
} elsif(UNIVERSAL::isa($content, "ARRAY")) {
cqpid_perl::encode($content, $impl, "amqp/list");
} else {
$message->get_implementation()->setContent($content);
}
}
sub decode {
my $message = $_[0];
my $impl = $message->get_implementation();
my $content_type = $impl->getContentType();
if($content_type eq "amqp/map") {
$result = cqpid_perl::decodeMap($impl);
} elsif($content_type eq "amqp/list") {
$result = cqpid_perl::decodeList($impl);
} else {
$result = $impl->getContent();
}
return $result;
}
1;
| irinabov/debian-qpid-cpp-1.35.0 | bindings/qpid/perl/lib/qpid/messaging.pm | Perl | apache-2.0 | 1,630 |
=pod
=head1 NAME
PKCS12_add1_attr_by_NID, PKCS12_add1_attr_by_txt - Add an attribute to a PKCS#12
safeBag structure
=head1 SYNOPSIS
#include <openssl/pkcs12.h>
int PKCS12_add1_attr_by_NID(PKCS12_SAFEBAG *bag, int nid, int type,
const unsigned char *bytes, int len);
int PKCS12_add1_attr_by_txt(PKCS12_SAFEBAG *bag, const char *attrname, int type,
const unsigned char *bytes, int len);
=head1 DESCRIPTION
These functions add a PKCS#12 Attribute to the Attribute Set of the B<bag>.
PKCS12_add1_attr_by_NID() adds an attribute of type B<nid> with a value of ASN1
type B<type> constructed using B<len> bytes from B<bytes>.
PKCS12_add1_attr_by_txt() adds an attribute of type B<attrname> with a value of
ASN1 type B<type> constructed using B<len> bytes from B<bytes>.
=head1 NOTES
These functions do not check whether an existing attribute of the same type is
present. There can be multiple attributes with the same type assigned to a
safeBag.
Both functions were added in OpenSSL 3.0.
=head1 RETURN VALUES
A return value of 1 indicates success, 0 indicates failure.
=head1 SEE ALSO
L<PKCS12_create(3)>
=head1 COPYRIGHT
Copyright 2020 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use
this file except in compliance with the License. You can obtain a copy
in the file LICENSE in the source distribution or at
L<https://www.openssl.org/source/license.html>.
=cut
| jens-maus/amissl | openssl/doc/man3/PKCS12_add1_attr_by_NID.pod | Perl | bsd-3-clause | 1,511 |
package Moose::Meta::Attribute::Native::Trait::Array;
BEGIN {
$Moose::Meta::Attribute::Native::Trait::Array::AUTHORITY = 'cpan:STEVAN';
}
{
$Moose::Meta::Attribute::Native::Trait::Array::VERSION = '2.0602';
}
use Moose::Role;
with 'Moose::Meta::Attribute::Native::Trait';
sub _helper_type { 'ArrayRef' }
no Moose::Role;
1;
# ABSTRACT: Helper trait for ArrayRef attributes
=pod
=head1 NAME
Moose::Meta::Attribute::Native::Trait::Array - Helper trait for ArrayRef attributes
=head1 VERSION
version 2.0602
=head1 SYNOPSIS
package Stuff;
use Moose;
has 'options' => (
traits => ['Array'],
is => 'ro',
isa => 'ArrayRef[Str]',
default => sub { [] },
handles => {
all_options => 'elements',
add_option => 'push',
map_options => 'map',
filter_options => 'grep',
find_option => 'first',
get_option => 'get',
join_options => 'join',
count_options => 'count',
has_options => 'count',
has_no_options => 'is_empty',
sorted_options => 'sort',
},
);
no Moose;
1;
=head1 DESCRIPTION
This trait provides native delegation methods for array references.
=head1 DEFAULT TYPE
If you don't provide an C<isa> value for your attribute, it will default to
C<ArrayRef>.
=head1 PROVIDED METHODS
=over 4
=item * B<count>
Returns the number of elements in the array.
$stuff = Stuff->new;
$stuff->options( [ "foo", "bar", "baz", "boo" ] );
print $stuff->count_options; # prints 4
This method does not accept any arguments.
=item * B<is_empty>
Returns a boolean value that is true when the array has no elements.
$stuff->has_no_options ? die "No options!\n" : print "Good boy.\n";
This method does not accept any arguments.
=item * B<elements>
Returns all of the elements of the array as an array (not an array reference).
my @option = $stuff->all_options;
print "@options\n"; # prints "foo bar baz boo"
This method does not accept any arguments.
=item * B<get($index)>
Returns an element of the array by its index. You can also use negative index
numbers, just as with Perl's core array handling.
my $option = $stuff->get_option(1);
print "$option\n"; # prints "bar"
If the specified element does not exist, this will return C<undef>.
This method accepts just one argument.
=item * B<pop>
Just like Perl's builtin C<pop>.
This method does not accept any arguments.
=item * B<push($value1, $value2, value3 ...)>
Just like Perl's builtin C<push>. Returns the number of elements in the new
array.
This method accepts any number of arguments.
=item * B<shift>
Just like Perl's builtin C<shift>.
This method does not accept any arguments.
=item * B<unshift($value1, $value2, value3 ...)>
Just like Perl's builtin C<unshift>. Returns the number of elements in the new
array.
This method accepts any number of arguments.
=item * B<splice($offset, $length, @values)>
Just like Perl's builtin C<splice>. In scalar context, this returns the last
element removed, or C<undef> if no elements were removed. In list context,
this returns all the elements removed from the array.
This method requires at least one argument.
=item * B<first( sub { ... } )>
This method returns the first matching item in the array, just like
L<List::Util>'s C<first> function. The matching is done with a subroutine
reference you pass to this method. The subroutine will be called against each
element in the array until one matches or all elements have been checked.
my $found = $stuff->find_option( sub {/^b/} );
print "$found\n"; # prints "bar"
This method requires a single argument.
=item * B<first_index( sub { ... } )>
This method returns the index of the first matching item in the array, just
like L<List::MoreUtils>'s C<first_index> function. The matching is done with a
subroutine reference you pass to this method. The subroutine will be called
against each element in the array until one matches or all elements have been
checked.
This method requires a single argument.
=item * B<grep( sub { ... } )>
This method returns every element matching a given criteria, just like Perl's
core C<grep> function. This method requires a subroutine which implements the
matching logic.
my @found = $stuff->filter_options( sub {/^b/} );
print "@found\n"; # prints "bar baz boo"
This method requires a single argument.
=item * B<map( sub { ... } )>
This method transforms every element in the array and returns a new array,
just like Perl's core C<map> function. This method requires a subroutine which
implements the transformation.
my @mod_options = $stuff->map_options( sub { $_ . "-tag" } );
print "@mod_options\n"; # prints "foo-tag bar-tag baz-tag boo-tag"
This method requires a single argument.
=item * B<reduce( sub { ... } )>
This method turns an array into a single value, by passing a function the
value so far and the next value in the array, just like L<List::Util>'s
C<reduce> function. The reducing is done with a subroutine reference you pass
to this method.
my $found = $stuff->reduce_options( sub { $_[0] . $_[1] } );
print "$found\n"; # prints "foobarbazboo"
This method requires a single argument.
=item * B<sort>
=item * B<sort( sub { ... } )>
Returns the elements of the array in sorted order.
You can provide an optional subroutine reference to sort with (as you can with
Perl's core C<sort> function). However, instead of using C<$a> and C<$b> in
this subroutine, you will need to use C<$_[0]> and C<$_[1]>.
# ascending ASCIIbetical
my @sorted = $stuff->sort_options();
# Descending alphabetical order
my @sorted_options = $stuff->sort_options( sub { lc $_[1] cmp lc $_[0] } );
print "@sorted_options\n"; # prints "foo boo baz bar"
This method accepts a single argument.
=item * B<sort_in_place>
=item * B<sort_in_place( sub { ... } )>
Sorts the array I<in place>, modifying the value of the attribute.
You can provide an optional subroutine reference to sort with (as you can with
Perl's core C<sort> function). However, instead of using C<$a> and C<$b>, you
will need to use C<$_[0]> and C<$_[1]> instead.
This method does not define a return value.
This method accepts a single argument.
=item * B<shuffle>
Returns the elements of the array in random order, like C<shuffle> from
L<List::Util>.
This method does not accept any arguments.
=item * B<uniq>
Returns the array with all duplicate elements removed, like C<uniq> from
L<List::MoreUtils>.
This method does not accept any arguments.
=item * B<join($str)>
Joins every element of the array using the separator given as argument, just
like Perl's core C<join> function.
my $joined = $stuff->join_options(':');
print "$joined\n"; # prints "foo:bar:baz:boo"
This method requires a single argument.
=item * B<set($index, $value)>
Given an index and a value, sets the specified array element's value.
This method returns the value at C<$index> after the set.
This method requires two arguments.
=item * B<delete($index)>
Removes the element at the given index from the array.
This method returns the deleted value. Note that if no value exists, it will
return C<undef>.
This method requires one argument.
=item * B<insert($index, $value)>
Inserts a new element into the array at the given index.
This method returns the new value at C<$index>.
This method requires two arguments.
=item * B<clear>
Empties the entire array, like C<@array = ()>.
This method does not define a return value.
This method does not accept any arguments.
=item * B<accessor($index)>
=item * B<accessor($index, $value)>
This method provides a get/set accessor for the array, based on array indexes.
If passed one argument, it returns the value at the specified index. If
passed two arguments, it sets the value of the specified index.
When called as a setter, this method returns the new value at C<$index>.
This method accepts one or two arguments.
=item * B<natatime($n)>
=item * B<natatime($n, $code)>
This method returns an iterator which, on each call, returns C<$n> more items
from the array, in order, like C<natatime> from L<List::MoreUtils>. A coderef
can optionally be provided; it will be called on each group of C<$n> elements
in the array.
This method accepts one or two arguments.
=item * B<shallow_clone>
This method returns a shallow clone of the array reference. The return value
is a reference to a new array with the same elements. It is I<shallow>
because any elements that were references in the original will be the I<same>
references in the clone.
=back
=head1 BUGS
See L<Moose/BUGS> for details on reporting bugs.
=head1 AUTHOR
Moose is maintained by the Moose Cabal, along with the help of many contributors. See L<Moose/CABAL> and L<Moose/CONTRIBUTORS> for details.
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Infinity Interactive, Inc..
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
__END__
| leighpauls/k2cro4 | third_party/perl/perl/vendor/lib/Moose/Meta/Attribute/Native/Trait/Array.pm | Perl | bsd-3-clause | 9,175 |
/* ------------------------------------------------------------------------
> FILENAME: mkparser_sicstus
> PURPOSE: create and dump saved state ready to process command
> line when restored
> AUTHORS: Kevin Humphreys, Hamish Cunningham
> NOTES:
------------------------------------------------------------------------ */
cvsid_mkparser_sicstus("$Id: mkparser_sicstus.pl 9628 2008-05-09 14:50:14Z ian_roberts $").
% COMMAND LINE OPTIONS
/*
parse [-v] be verbose
[-d] show debugging info
[-level n] parse up to level n grammar & don't do semantics
[-m markup_file] write NE markup to markup_file
[-p parse_file] write best parses to parse_file in tree form
[-b parse_file] write best parses to parse_file in bracketed form
[-c chart_file] write chart to chart_file
[-o output_file] write gdm output to output_file instead of stdout
file
NOTE: -n reserved for mkparser script (it triggers assertion of
non_interactive/0, which triggers saving of state and halting).
*/
:- dynamic verbose/0, chart/3, grammar_file/1, filter_grammar/1,
output_file/1, chart_file/1, markup_file/1,
best_parse_file/1, bracketed_parses/0.
:- prolog_flag(redefine_warnings,_,off).
:- prolog_flag(single_var_warnings,_,off).
% compile either sicstus3_utils or sicstus4_utils, depending on SICStus major
% version number. The 'version' prolog_flag on SICStus starts 'SICStus
% major.minor.patch', we extract the major version and condition on that.
:- (prolog_flag(version, V),
atom_concat('SICStus ', Vtail, V),
atom_codes(Vtail, [Major|_]),
number_codes(Major, [MajorVersion]),
MajorVersion =< 3,
compile('sicstus3_utils.pl'))
; compile('sicstus4_utils.pl').
:- dynamic non_interactive/0.
?- ((prolog_flag(argv,A,A), member('-n', A), assert(non_interactive))
% replace compile with consult if interactive
; prolog_flag(compiling,_,debugcode)).
%:- use_module(library(gauge)), prolog_flag(compiling,_,profiledcode).
:- compile('compile_grammar.pl').
:- compile('parse_file.pl').
:- compile('supple.pl').
:- compile('supple_io.pl').
:- compile('best_parse.pl').
:- compile('semantics.pl').
% load and compile default set of grammars
:- consult('grammar/load.pl').
% top-level control
parse :-
prolog_flag(argv,Args,Args),
on_exception(Error,parse(Args),(write(Error),nl)),
flush_output, halt(0).
% compile any grammars on cmd line
?- non_interactive, prolog_flag(argv,Args,Args), parse(Args).
:- prolog_flag(redefine_warnings,_,on).
% save current state, ready to restart with parse/0.
?- non_interactive, save_program('supple.sicstus', parse), flush_output, halt(0).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% $Log$
% Revision 1.1 2005/12/05 16:32:02 ian_roberts
% SUPPLE - the Sheffield University Prolog Parser for Language Engineering.
%
% SUPPLE replaces the old Buchart plugin, which should now be considered
% deprecated.
%
% Revision 1.1.1.1 2005/10/06 10:02:05 saggion
% Supple Project
%
% Revision 1.1.1.1 2004/11/25 08:17:49 saggion
% Buchart-Gate Integration
%
% Revision 1.17 1998/04/04 22:19:16 kwh
% syntax error
%
% Revision 1.16 1998/04/04 22:01:27 kwh
% exit on error
%
% Revision 1.15 1998/03/25 18:51:46 kwh
% affixes passed into chart
%
% Revision 1.14 1998/02/20 16:07:33 kwh
% sicstus3 changes
%
% Revision 1.13 1997/11/28 14:57:04 kwh
% use single load file to specify grammars
%
% Revision 1.12 1997/09/30 17:24:43 kwh
% merge buchart_cascade changes back in
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
| Network-of-BioThings/GettinCRAFTy | src/main/resources/gate/plugins/Parser_SUPPLE/prolog/mkparser_sicstus.pl | Perl | apache-2.0 | 3,689 |
package platform;
use strict;
use warnings;
use vars qw(@ISA);
# Callers must make sure @INC has the build directory
use configdata;
my $module = $target{perl_platform} || 'Unix';
(my $module_path = $module) =~ s|::|/|g;
require "platform/$module_path.pm";
@ISA = ("platform::$module");
1;
__END__
| jens-maus/amissl | openssl/Configurations/platform.pm | Perl | bsd-3-clause | 304 |
=pod
=head1 NAME
i2t_ASN1_OBJECT,
OBJ_length, OBJ_get0_data, OBJ_nid2obj, OBJ_nid2ln,
OBJ_nid2sn, OBJ_obj2nid, OBJ_txt2nid, OBJ_ln2nid, OBJ_sn2nid, OBJ_cmp,
OBJ_dup, OBJ_txt2obj, OBJ_obj2txt, OBJ_create, OBJ_cleanup
- ASN1 object utility functions
=head1 SYNOPSIS
#include <openssl/objects.h>
ASN1_OBJECT *OBJ_nid2obj(int n);
const char *OBJ_nid2ln(int n);
const char *OBJ_nid2sn(int n);
int OBJ_obj2nid(const ASN1_OBJECT *o);
int OBJ_ln2nid(const char *ln);
int OBJ_sn2nid(const char *sn);
int OBJ_txt2nid(const char *s);
ASN1_OBJECT *OBJ_txt2obj(const char *s, int no_name);
int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name);
int i2t_ASN1_OBJECT(char *buf, int buf_len, const ASN1_OBJECT *a);
int OBJ_cmp(const ASN1_OBJECT *a, const ASN1_OBJECT *b);
ASN1_OBJECT *OBJ_dup(const ASN1_OBJECT *o);
int OBJ_create(const char *oid, const char *sn, const char *ln);
size_t OBJ_length(const ASN1_OBJECT *obj);
const unsigned char *OBJ_get0_data(const ASN1_OBJECT *obj);
Deprecated:
#if OPENSSL_API_COMPAT < 0x10100000L
void OBJ_cleanup(void)
#endif
=head1 DESCRIPTION
The ASN1 object utility functions process ASN1_OBJECT structures which are
a representation of the ASN1 OBJECT IDENTIFIER (OID) type.
For convenience, OIDs are usually represented in source code as numeric
identifiers, or B<NID>s. OpenSSL has an internal table of OIDs that
are generated when the library is built, and their corresponding NIDs
are available as defined constants. For the functions below, application
code should treat all returned values -- OIDs, NIDs, or names -- as
constants.
OBJ_nid2obj(), OBJ_nid2ln() and OBJ_nid2sn() convert the NID B<n> to
an ASN1_OBJECT structure, its long name and its short name respectively,
or B<NULL> is an error occurred.
OBJ_obj2nid(), OBJ_ln2nid(), OBJ_sn2nid() return the corresponding NID
for the object B<o>, the long name <ln> or the short name <sn> respectively
or NID_undef if an error occurred.
OBJ_txt2nid() returns NID corresponding to text string <s>. B<s> can be
a long name, a short name or the numerical representation of an object.
OBJ_txt2obj() converts the text string B<s> into an ASN1_OBJECT structure.
If B<no_name> is 0 then long names and short names will be interpreted
as well as numerical forms. If B<no_name> is 1 only the numerical form
is acceptable.
OBJ_obj2txt() converts the B<ASN1_OBJECT> B<a> into a textual representation.
The representation is written as a null terminated string to B<buf>
at most B<buf_len> bytes are written, truncating the result if necessary.
The total amount of space required is returned. If B<no_name> is 0 then
if the object has a long or short name then that will be used, otherwise
the numerical form will be used. If B<no_name> is 1 then the numerical
form will always be used.
i2t_ASN1_OBJECT() is the same as OBJ_obj2txt() with the B<no_name> set to zero.
OBJ_cmp() compares B<a> to B<b>. If the two are identical 0 is returned.
OBJ_dup() returns a copy of B<o>.
OBJ_create() adds a new object to the internal table. B<oid> is the
numerical form of the object, B<sn> the short name and B<ln> the
long name. A new NID is returned for the created object.
OBJ_length() returns the size of the content octets of B<obj>.
OBJ_get0_data() returns a pointer to the content octets of B<obj>.
The returned pointer is an internal pointer which B<must not> be freed.
In OpenSSL versions prior to 1.1.0 OBJ_cleanup() cleaned up OpenSSLs internal
object table and was called before an application exits if any new objects were
added using OBJ_create(). This function is deprecated in version 1.1.0 and now
does nothing if called. No explicit de-initialisation is now required. See
L<OPENSSL_init_crypto(3)> for further information.
=head1 NOTES
Objects in OpenSSL can have a short name, a long name and a numerical
identifier (NID) associated with them. A standard set of objects is
represented in an internal table. The appropriate values are defined
in the header file B<objects.h>.
For example the OID for commonName has the following definitions:
#define SN_commonName "CN"
#define LN_commonName "commonName"
#define NID_commonName 13
New objects can be added by calling OBJ_create().
Table objects have certain advantages over other objects: for example
their NIDs can be used in a C language switch statement. They are
also static constant structures which are shared: that is there
is only a single constant structure for each table object.
Objects which are not in the table have the NID value NID_undef.
Objects do not need to be in the internal tables to be processed,
the functions OBJ_txt2obj() and OBJ_obj2txt() can process the numerical
form of an OID.
Some objects are used to represent algorithms which do not have a
corresponding ASN.1 OBJECT IDENTIFIER encoding (for example no OID currently
exists for a particular algorithm). As a result they B<cannot> be encoded or
decoded as part of ASN.1 structures. Applications can determine if there
is a corresponding OBJECT IDENTIFIER by checking OBJ_length() is not zero.
These functions cannot return B<const> because an B<ASN1_OBJECT> can
represent both an internal, constant, OID and a dynamically-created one.
The latter cannot be constant because it needs to be freed after use.
=head1 EXAMPLES
Create an object for B<commonName>:
ASN1_OBJECT *o;
o = OBJ_nid2obj(NID_commonName);
Check if an object is B<commonName>
if (OBJ_obj2nid(obj) == NID_commonName)
/* Do something */
Create a new NID and initialize an object from it:
int new_nid;
ASN1_OBJECT *obj;
new_nid = OBJ_create("1.2.3.4", "NewOID", "New Object Identifier");
obj = OBJ_nid2obj(new_nid);
Create a new object directly:
obj = OBJ_txt2obj("1.2.3.4", 1);
=head1 BUGS
OBJ_obj2txt() is awkward and messy to use: it doesn't follow the
convention of other OpenSSL functions where the buffer can be set
to B<NULL> to determine the amount of data that should be written.
Instead B<buf> must point to a valid buffer and B<buf_len> should
be set to a positive value. A buffer length of 80 should be more
than enough to handle any OID encountered in practice.
=head1 RETURN VALUES
OBJ_nid2obj() returns an B<ASN1_OBJECT> structure or B<NULL> is an
error occurred.
OBJ_nid2ln() and OBJ_nid2sn() returns a valid string or B<NULL>
on error.
OBJ_obj2nid(), OBJ_ln2nid(), OBJ_sn2nid() and OBJ_txt2nid() return
a NID or B<NID_undef> on error.
=head1 SEE ALSO
L<ERR_get_error(3)>
=head1 HISTORY
OBJ_cleanup() was deprecated in OpenSSL 1.1.0.
=head1 COPYRIGHT
Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the OpenSSL license (the "License"). You may not use
this file except in compliance with the License. You can obtain a copy
in the file LICENSE in the source distribution or at
L<https://www.openssl.org/source/license.html>.
=cut
| openweave/openweave-core | third_party/openssl/openssl/doc/crypto/OBJ_nid2obj.pod | Perl | apache-2.0 | 6,933 |
sub test {
my $i;
for ($i = 0; $i < 1e8; $i++) {
}
}
test();
| kphillisjr/duktape | tests/perf/test-empty-loop.pl | Perl | mit | 75 |
#!/usr/bin/perl
use warnings;
use strict;
use DBI;
require "approx_search.pl";
my $brainz_db = DBI->connect("dbi:Pg:dbname=musicbrainz_db","sunny","")
or die "Couldnot open database\n";
my @artist_album_song;
my $artist_name = "The Beatles";
@artist_album_song = &get_track_by_artist($brainz_db , $artist_name);
my %result = &find_track( "hey jude" , @artist_album_song);
my @sorted_hash = sort {$result{$b} <=> $result{$a}} keys %result;
while ( $#sorted_hash >= 0){
my $temp1 = shift @sorted_hash;
print "$result{$temp1} <---> $temp1 \n";
}
#### Printing area #####
#{
#print "Artist Name: $artist_album_song[0] \n";
#for my $i (1..$#artist_album_song){
# print "\t$artist_album_song[$i][0] : $artist_album_song[$i][1] : $artist_album_song[$i][2] : $artist_album_song[$i][3]\n";
# for my $j (4..$#{$artist_album_song[$i]}){
# print "\t\t@{$artist_album_song[$i][$j]}\n";
# }
#}
#}
$brainz_db->disconnect();
| sunnyraj10411/musopia | approx_search_stub.pl | Perl | mit | 947 |
/** <module> Collection handling.
*/
:- module(_,
[
new_collection/3,
collection_database/2,
collection_name/2,
collection_namespace/2,
collection_connection/2
]).
:- include(include/common).
%% new_collection(+Database, +CollectionName, -Collection) is det.
%
% True if Collection is a handle to the collection named
% CollectionName within Database. No communication is performed,
% so the collection might or might not already exist.
new_collection(Database, CollectionName, Collection) :-
mongo_database:database_name(Database, DatabaseName),
namespace_atom(DatabaseName, CollectionName, Namespace),
Collection = collection(Database,Namespace).
%% collection_database(+Collection, -Database) is det.
%
% True if Database is a handle to the database containing Collection.
collection_database(Collection, Database) :-
mongo_util:get_nth1_arg(Collection, 1, Database).
%% collection_name(+Collection, -CollectionName) is det.
%
% True if CollectionName is the name of Collection.
collection_name(Collection, CollectionName) :-
collection_namespace(Collection, Namespace),
collection_without_namespace(Namespace, CollectionName).
collection_without_namespace(NamespaceCollection, Collection) :-
namespace_parts(NamespaceCollection, [_Namespace|Rest]),
namespace_parts(Collection, Rest).
namespace_parts(Atom, Parts) :-
core:atomic_list_concat(Parts, '.', Atom).
%% collection_namespace(+Collection, -Namespace) is det.
%
% True if Namespace is the namespace name for Collection.
collection_namespace(Collection, Namespace) :-
mongo_util:get_nth1_arg(Collection, 2, Namespace).
%% collection_connection(+Collection, -Connection) is det.
%
% True if Connection is a handle to the connection used to access
% Collection.
collection_connection(Collection, Connection) :-
collection_database(Collection, Database),
mongo_database:database_connection(Database, Connection).
namespace_atom(DatabaseName, CollectionName, Namespace) :-
namespace_parts(Namespace, [DatabaseName,CollectionName]).
| dakerfp/prolongo | src/mongo_collection.pl | Perl | mit | 2,124 |
# Time-stamp: "Sat Jul 14 00:27:31 2001 by Automatic Bizooty (__blocks2pm.plx)"
$Text::\SEPA\Unicode\Unidecode::Char[0x65] = [
'Pan ', 'Yang ', 'Lei ', 'Sa ', 'Shu ', 'Zan ', 'Nian ', 'Xian ', 'Jun ', 'Huo ', 'Li ', 'La ', 'Han ', 'Ying ', 'Lu ', 'Long ',
'Qian ', 'Qian ', 'Zan ', 'Qian ', 'Lan ', 'San ', 'Ying ', 'Mei ', 'Rang ', 'Chan ', qq{[?] }, 'Cuan ', 'Xi ', 'She ', 'Luo ', 'Jun ',
'Mi ', 'Li ', 'Zan ', 'Luan ', 'Tan ', 'Zuan ', 'Li ', 'Dian ', 'Wa ', 'Dang ', 'Jiao ', 'Jue ', 'Lan ', 'Li ', 'Nang ', 'Zhi ',
'Gui ', 'Gui ', 'Qi ', 'Xin ', 'Pu ', 'Sui ', 'Shou ', 'Kao ', 'You ', 'Gai ', 'Yi ', 'Gong ', 'Gan ', 'Ban ', 'Fang ', 'Zheng ',
'Bo ', 'Dian ', 'Kou ', 'Min ', 'Wu ', 'Gu ', 'He ', 'Ce ', 'Xiao ', 'Mi ', 'Chu ', 'Ge ', 'Di ', 'Xu ', 'Jiao ', 'Min ',
'Chen ', 'Jiu ', 'Zhen ', 'Duo ', 'Yu ', 'Chi ', 'Ao ', 'Bai ', 'Xu ', 'Jiao ', 'Duo ', 'Lian ', 'Nie ', 'Bi ', 'Chang ', 'Dian ',
'Duo ', 'Yi ', 'Gan ', 'San ', 'Ke ', 'Yan ', 'Dun ', 'Qi ', 'Dou ', 'Xiao ', 'Duo ', 'Jiao ', 'Jing ', 'Yang ', 'Xia ', 'Min ',
'Shu ', 'Ai ', 'Qiao ', 'Ai ', 'Zheng ', 'Di ', 'Zhen ', 'Fu ', 'Shu ', 'Liao ', 'Qu ', 'Xiong ', 'Xi ', 'Jiao ', 'Sen ', 'Jiao ',
'Zhuo ', 'Yi ', 'Lian ', 'Bi ', 'Li ', 'Xiao ', 'Xiao ', 'Wen ', 'Xue ', 'Qi ', 'Qi ', 'Zhai ', 'Bin ', 'Jue ', 'Zhai ', qq{[?] },
'Fei ', 'Ban ', 'Ban ', 'Lan ', 'Yu ', 'Lan ', 'Wei ', 'Dou ', 'Sheng ', 'Liao ', 'Jia ', 'Hu ', 'Xie ', 'Jia ', 'Yu ', 'Zhen ',
'Jiao ', 'Wo ', 'Tou ', 'Chu ', 'Jin ', 'Chi ', 'Yin ', 'Fu ', 'Qiang ', 'Zhan ', 'Qu ', 'Zhuo ', 'Zhan ', 'Duan ', 'Zhuo ', 'Si ',
'Xin ', 'Zhuo ', 'Zhuo ', 'Qin ', 'Lin ', 'Zhuo ', 'Chu ', 'Duan ', 'Zhu ', 'Fang ', 'Xie ', 'Hang ', 'Yu ', 'Shi ', 'Pei ', 'You ',
'Mye ', 'Pang ', 'Qi ', 'Zhan ', 'Mao ', 'Lu ', 'Pei ', 'Pi ', 'Liu ', 'Fu ', 'Fang ', 'Xuan ', 'Jing ', 'Jing ', 'Ni ', 'Zu ',
'Zhao ', 'Yi ', 'Liu ', 'Shao ', 'Jian ', 'Es ', 'Yi ', 'Qi ', 'Zhi ', 'Fan ', 'Piao ', 'Fan ', 'Zhan ', 'Guai ', 'Sui ', 'Yu ',
'Wu ', 'Ji ', 'Ji ', 'Ji ', 'Huo ', 'Ri ', 'Dan ', 'Jiu ', 'Zhi ', 'Zao ', 'Xie ', 'Tiao ', 'Xun ', 'Xu ', 'Xu ', 'Xu ',
'Gan ', 'Han ', 'Tai ', 'Di ', 'Xu ', 'Chan ', 'Shi ', 'Kuang ', 'Yang ', 'Shi ', 'Wang ', 'Min ', 'Min ', 'Tun ', 'Chun ', 'Wu ',
];
1;
| dmitrirussu/php-sepa-xml-generator | src/Unicode/data/perl_source/x65.pm | Perl | mit | 2,204 |
package #
Date::Manip::Offset::off070;
# Copyright (c) 2008-2015 Sullivan Beck. All rights reserved.
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
# This file was automatically generated. Any changes to this file will
# be lost the next time 'tzdata' is run.
# Generated on: Wed Nov 25 11:44:43 EST 2015
# Data version: tzdata2015g
# Code version: tzcode2015g
# This module contains data from the zoneinfo time zone database. The original
# data was obtained from the URL:
# ftp://ftp.iana.org/tz
use strict;
use warnings;
require 5.010000;
our ($VERSION);
$VERSION='6.52';
END { undef $VERSION; }
our ($Offset,%Offset);
END {
undef $Offset;
undef %Offset;
}
$Offset = '+02:36:34';
%Offset = (
1 => [
'europe/riga',
],
);
1;
| jkb78/extrajnm | local/lib/perl5/Date/Manip/Offset/off070.pm | Perl | mit | 850 |
package Acme::Xyzzy;
# ABSTRACT: Nothing happens.
use strict;
use warnings;
use Exporter;
use vars qw(@ISA @EXPORT);
our $VERSION = "0.001";
@ISA = ('Exporter');
@EXPORT = ('xyzzy');
sub xyzzy {
print "Nothing happens.\n";
}
1;
=head1 SYNOPSIS
use Acme::Xyzzy;
xyzzy;
=head1 DESCRIPTION
Nothing happens.
=head2 Methods
=over 12
=item C<< xyzzy() >>
Nothing happens.
=back
=head1 SEE ALSO
L<https://en.wikipedia.org/wiki/Xyzzy_%28computing%29>
=cut
| woodruffw/Acme-Xyzzy | lib/Acme/Xyzzy.pm | Perl | mit | 472 |
% File: /opt/PrologMUD/pack/logicmoo_base/prolog/logicmoo/util/logicmoo_util_no_repeats.pl
:- module(no_repeats,
[ /*memberchk_pred/3,
memberchk_pred_rev/3,
memberchk_same/2,
memberchk_same0/2,
memberchk_same1/2,
memberchk_same2/2,
memberchk_same3/2,
memberchk_cmp/3,
memb_r/2,*/
must_not_repeat/1,
no_repeats/1,
no_repeats/2,
/*
no_repeats_av/0,
no_repeats_findall5/5,
no_repeats_findall_r/5,
no_repeats_old/1,
no_repeats_old/2,
no_repeats_cmp/3,
no_repeats_save/2,
no_repeats_save/4,
no_repeats_u/2,
subtract_eq/3,
succeeds_n_times/2,
nr_test/2,
*/
no_repeats_var/1
% loop_check_nr/1
]).
:- meta_predicate
memberchk_pred(2, ?, ?),
memberchk_pred_rev(2, ?, ?),
must_not_repeat(0),
no_repeats(0),
no_repeats(+, 0),
no_repeats_findall5(+, 0, -, -, -),
no_repeats_findall_r(+, 0, -, -, -),
no_repeats_old(0),
no_repeats_old(+, 0),
no_repeats_cmp(2, +, 0),
no_repeats_save(+, 0),
no_repeats_save(+, 0, -, -),
no_repeats_u(+, 0),
loop_check_nr(0),
succeeds_n_times(0, -).
:- module_transparent
memberchk_same/2,
no_repeats_av/0,
no_repeats_cmp/3,
subtract_eq/3,
nr_test/2.
:- set_module(class(library)).
:- prolog_load_context(directory,Dir),add_file_search_path_safe(library,Dir).
% % % OFF :- system:use_module(library(logicmoo/misc_terms)).
%% loop_check_nr( ?CL) is semidet.
%
% Loop Check Nr.
%
loop_check_nr(CL):- loop_check(no_repeats(CL)).
% ===================================================================
:- thread_local tlbugger:attributedVars/0.
% tlbugger:attributedVars.
:- export(must_not_repeat/1).
% = :- meta_predicate(must_not_repeat(0)).
%% must_not_repeat( :GoalC) is semidet.
%
% Must Be Successfull Not Repeat.
%
must_not_repeat(C):-call(C).
% ===================================================
%
% no_repeats(:Call)
%
% Like call/1 but ony succeeds only unique variabes
%
% logicmoo_mud: ?- no_repeats(member(X,[3,1,1,1,3,2])).
% X = 3 ;
% X = 1 ;
% X = 2.
% ===================================================
%% no_repeats_av is semidet.
%
% No Repeats Attributed Variables.
%
no_repeats_av:-tlbugger:attributedVars.
:- export(no_repeats/1).
:- meta_predicate no_repeats(0).
% no_repeats(Call):- tlbugger:old_no_repeats,!, no_repeats_old(Call).
%no_repeats(Call):- no_repeats_av,!,no_repeats_av(Call).
%% no_repeats( :Goal) is semidet.
%
% No Repeats.
%
no_repeats(Call):- no_repeats_old(Call).
:- export(no_repeats/2).
:- meta_predicate no_repeats(+,0).
%no_repeats(Vs,Call):- tlbugger:old_no_repeats,!,no_repeats_old(Vs,Call).
%no_repeats(Vs,Call):- no_repeats_av,!,no_repeats_av(Vs,Call).
%% no_repeats( +Vs, :Goal) is semidet.
%
% No Repeats.
%
no_repeats(Vs,Call):- no_repeats_old(Vs,Call).
/*
no_repeats_dif(Vs,Call):- dif(Vs,_), get_attr(Vs,dif,vardif(CONS,_)),!,
Call,copy_term_nat(Vs,C),nb_setarg(2, CONS, [_-C|CONS]).
*/
% ===================================================
%
% no_repeats_old([+Vars,]:Call)
%
% Like call/1 but ony succeeds on unique free variabes
%
% logicmoo_mud: ?- no_repeats( X , member(X-Y,[3-2,1-4,1-5,2-1])).
% X = 3, Y = 2 ;
% X = 1, Y = 4 ;
% X = 2, Y = 1.
% ===================================================
:- export(no_repeats_old/1).
:- meta_predicate no_repeats_old(0).
%% no_repeats_old( :Goal) is semidet.
%
% No Repeats Old.
%
no_repeats_old(Call):- no_repeats_old(Call,Call).
% % % % OFF :- system:use_module(rec_lambda).
%% memberchk_same( ?X, :TermY0) is semidet.
%
% Memberchk Same.
%
memberchk_same(X, List) :- is_list(List),!, \+ atomic(List), C=..[v|List],(var(X)-> (arg(_,C,YY),X==YY) ; (arg(_,C,YY),X =@= YY)),!.
memberchk_same(X, Ys) :- nonvar(Ys), var(X)->memberchk_same0(X, Ys);memberchk_same1(X,Ys).
memberchk_same0(X, [Y|Ys]) :- X==Y ; (nonvar(Ys),memberchk_same0(X, Ys)).
memberchk_same1(X, [Y|Ys]) :- X =@= Y ; (nonvar(Ys),memberchk_same1(X, Ys)).
memberchk_same2(X, List) :- Hold=hold(List), !,
repeat, (arg(1,Hold,[Y0|Y0s]) ->
( X==Y0-> true; (nb_setarg(1,Hold,Y0s),fail)) ; (! , fail)).
memberchk_same3(X, List) :- Hold=hold(List), !,
repeat, (arg(1,Hold,[Y0|Y0s]) ->
( X=@=Y0-> true; (nb_setarg(1,Hold,Y0s),fail)) ; (! , fail)).
memb_r(X, List) :- Hold=hold(List), !, trace_or_throw(broken_memb_r(X, List)),
repeat,
((arg(1,Hold,[Y|Ys]),nb_setarg(1,Hold,Ys)) -> X=Y ; (! , fail)).
%% memberchk_pred( :PRED2Pred, ?X, ?Y0) is semidet.
%
% Memberchk Predicate.
%
memberchk_pred(Pred, X, [Y0|Ys]) :- is_list(Ys),C=..[v,Y0|Ys],!, arg(_,C,Y), call(Pred,X,Y),!.
memberchk_pred(Pred, X, [Y|Ys]) :- ( call(Pred,X,Y) -> true ; (nonvar(Ys),memberchk_pred(Pred, X, Ys) )).
%% memberchk_pred_rev( :PRED2Pred, ?X, ?Y0) is semidet.
%
% Memberchk Predicate Rev.
%
memberchk_pred_rev(Pred, X, [Y0|Ys]) :- is_list(Ys),C=..[v,Y0|Ys],!, arg(_,C,Y), call(Pred,Y,X),!.
memberchk_pred_rev(Pred, X, [Y|Ys]) :- ( call(Pred,Y,X) -> true ; (nonvar(Ys),memberchk_pred_rev(Pred,X, Ys) )).
:- export(no_repeats_old/2).
:- meta_predicate no_repeats_old(+,0).
%% no_repeats_old( +Vs, :Goal) is semidet.
%
% No Repeats Old.
%
no_repeats_old(Vs,Call):- ground(Vs),!,Call,!.
no_repeats_old(Vs,Call):- CONS = [_], (Call),
quietly(( \+ memberchk_same(Vs,CONS), copy_term(Vs,CVs), CONS=[_|T], nb_setarg(2, CONS, [CVs|T]))).
% mcs_t2(A,B) :- call(lambda(X, [Y|Ys], ( X =@= Y -> (var(X) -> X==Y ; true) ; (nonvar(Ys),reenter_lambda(X, Ys) ))),A,B).
% mcs_t(A,B) :- call(lambda(X, [Y|Ys], ( X =@= Y -> (var(X) -> X==Y ; true) ; (nonvar(Ys),reenter_lambda(X, Ys) ))),A,B).
no_repeats_cmp(_,Vs,Call):- ground(Vs),!,Call,!.
no_repeats_cmp(Cmp,Vs,Call):- CONS = [zzzZZZZzzzzZZZ], (Call),
quietly(( \+ memberchk_cmp(Cmp,Vs,CONS), copy_term(Vs,CVs), CONS=[_|T], nb_setarg(2, CONS, [CVs|T]))).
memberchk_cmp(Cmp,Vs,CONS):-
member(XY,CONS),call(Cmp,Vs,XY),!.
/*
:- meta_predicate no_repeats_t(?,0).
no_repeats_t(Vs,Call):- CONS = [_], (Call), (( \+ call(lambda(X, [Y|Ys], ( X =@= Y -> (var(X) -> X==Y ; true) ; (nonvar(Ys),reenter_lambda(X, Ys) ))),Vs,CONS), copy_term(Vs,CVs), CONS=[_|T], nb_linkarg(2, CONS, [CVs|T]))).
*/
%
:- export(no_repeats_u/2).
:- meta_predicate no_repeats_u(+,0).
%% no_repeats_u( +Vs, :Goal) is semidet.
%
% No Repeats For User Code.
%
no_repeats_u(Vs,Call):- CONS = [_], (Call), /*quietly*/(( CONS=[_|T],
\+ memberchk_pred_rev(subsumes_term,Vs,T), copy_term(Vs,CVs), nb_setarg(2, CONS, [CVs|T]))).
% for dont-care vars
/*
:- export(no_repeats_dc/2).
:- meta_predicate no_repeats_dc(+,0).
no_repeats_dc(Vs,Call):- term_variables(Call,CV),term_variables(Vs,VsL),subtract_eq(CV,VsL,NewVs),no_repeats(NewVs,Call).
*/
%% subtract_eq(+Set, +Delete, -Result) is det.
% Delete all elements in Delete from Set. Deletion is based on unification using ==/2. The complexity is |Delete|*|Set|.
%% subtract_eq( :TermE, ?Delete, ?Result) is semidet.
%
% Subtract Using (==/2) (or =@=/2) ).
%
subtract_eq([],_,[]) :- !.
subtract_eq([E|Set], Delete, Result) :-
subtract_eq(Set, Delete, Mid),
(identical_memberchk(E,Delete)-> Result = Mid ; Result = [E|Mid]).
% ===================================================
%
% no_repeats_av/1 - Filter repeats using coroutining
%
% Same as no_repeats(:Call) (so same as call/1 but fitered)
%
% (everytime we see new value.. we add it to was/2 in an attributed variable that we have a refernce in a compound)
% Cehcked via ?- was(AVar,Foo), get_attrs(AVar,ATTRS1), get_attrs(AVar,ATTRS2), ATTRS1==ATTRS2.
%
% So the variable binding gerts rejected several frames below your code? ( are we nipping away futile bindings?)
%
% however ..
% does that mess with anything in code that we are calling?
% Could some peice of code been required to see some binding to make a side effect come about?
%
% logicmoo_mud: ?- no_repeats_av(member(X,[3,1,1,1,3,2])).
% X = 3 ;
% X = 1 ;
% X = 2.
%
% attributed variable verson of getting filtered bindings
% ===================================================
/*
:- export(no_repeats_av/1).
% = :- meta_predicate(no_repeats_av(0)).
:- export(no_repeats_av/2).
% = :- meta_predicate(no_repeats_av(+,0)).
:- export(no_repeats_av_l/2).
% = :- meta_predicate(no_repeats_av_l(+,0)).
no_repeats_av(AVar,Call):- var(AVar),!,
Call):-term_variables(Call,Vs),!,no_repeats_av_l(Vs,Call).
no_repeats_av_l([],Call):-!,Call,!.
no_repeats_av_l([AVar],Call):-!,
no_repeats_av(AVar,Call).
no_repeats_av_l([AVar|List],Call):- each_call_cleanup(
(was(AVar,iNEVER),asserta(tlbugger:cannot_save_table,Ref),get_attr(AVar,waz,varwaz(CONS,_))),
(Call,copy_term_nat(AVar,C),nb_linkarg(2, CONS, [_-C|CONS])),
(del_attr(AVar,was),erase_safe(tlbugger:cannot_save_table,Ref))).
no_repeats_av(List,Call):- is_list(List),!,no_repeats_av_l(List,Call).
no_repeats_av(Term,Call):-term_variables(Term,List),!,no_repeats_av_l(List,Call).
*/
% =========================================================================
:- meta_predicate succeeds_n_times(0, -).
% =========================================================================
%% succeeds_n_times( :Goal, -Times) is semidet.
%
% Succeeds N Times.
%
succeeds_n_times(Goal, Times) :-
Counter = counter(0),
( Goal,
arg(1, Counter, N0),
N is N0 + 1,
nb_setarg(1, Counter, N),
fail
; arg(1, Counter, Times)
).
:- export(no_repeats_findall5/5).
:- meta_predicate no_repeats_findall5(+,0,-,-,-).
%% no_repeats_findall5( +Vs, :Goal, -ExitDET, -USE, -NEW) is semidet.
%
% No Repeats Findall5.
%
no_repeats_findall5(Vs,Call,ExitDET,USE,NEW):-
(((HOLDER = fa([]),
Call,arg(1,HOLDER,CONS),
((
(( \+ memberchk_same(Vs,CONS),
copy_term(Vs,CVs),
append(CONS,[CVs],NEW),
nb_setarg(1, HOLDER, NEW)))
->
USE=true;
((USE=(false),CONS=NEW))
)),
deterministic(ExitDET),true))
*-> true;
(NEW=[],ExitDET=true,USE=(false))).
:- export(no_repeats_save/4).
:- meta_predicate no_repeats_save(+,0,-,-).
%% no_repeats_save( +Vs, :Goal, -Saved, -USE) is semidet.
%
% No Repeats Save.
%
no_repeats_save(Vs,Call,Saved,USE):-
SavedHolder = saved(_),
no_repeats_findall5(Vs,Call,ExitDET,USE,NEW),
( ExitDET==true -> (nb_linkarg(1,SavedHolder,NEW),!) ; true),
arg(1,SavedHolder,Saved).
:- export(no_repeats_save/2).
:- meta_predicate no_repeats_save(+,0).
%% no_repeats_save( +Vs, :Goal) is semidet.
%
% No Repeats Save.
%
no_repeats_save(Vs,Call):-
call_cleanup(
(( no_repeats_save(Vs,Call,SavedList,USE),
(USE==true -> true ; fail))),
(is_list(SavedList) -> writeln(saving(SavedList)) ; writeln(givingup_on(Call)))).
:- export(no_repeats_findall_r/5).
:- meta_predicate no_repeats_findall_r(+,0,-,-,-).
%% no_repeats_findall_r( +Vs, :Goal, -CONS, -ExitDET, -List) is semidet.
%
% No Repeats Findall R.
%
no_repeats_findall_r(Vs,Call,CONS,ExitDET,List):-
CONS = [ExitDET],
(Call,once(( \+ memberchk_same(Vs,CONS), copy_term(Vs,CVs), CONS=[_|T],List=[CVs|T], nb_linkarg(2, CONS, List)))),
deterministic(ExitDET).
%% no_repeats_var(+Var) is det.
%
% Attribute a varaible to never be bound to the same value twice
%
% ==
% ?- no_repeats_var(X),member(X,[1,2,3,3,3,1,2,3]).
% X = 1;
% X = 2;
% X = 3;
% No.
% ==
no_repeats_var(Var):- nonvar(Var) ->true; (get_attr(Var,nr,_)->true;put_attr(Var,nr,old_vals(Var,same_forms,[]))).
no_repeats_var(Cmp,Var):- nonvar(Var) ->true; (get_attr(Var,nr,_)->true;put_attr(Var,nr,old_vals(Var,Cmp,[]))).
nr:attr_unify_hook(AttValue,VarValue):- AttValue=old_vals(_Var,Cmp,Waz), \+ memberchk_pred(Cmp,VarValue,Waz),nb_setarg(1,AttValue,[VarValue|Waz]).
same_forms(F1,F2):- get_attrs(F1,A1),!,get_attrs(F2,A2),A1=@=A2.
same_forms(F1,F2):- get_attrs(F2,A1),!,get_attrs(F1,A2),A1=@=A2.
same_forms(F1,F2):- var(F1),!,F2==F1.
same_forms(F1,F2):- var(F2),!,F2==F1.
same_forms(F1,F2):- F1=@=F2.
% WAS OFF :- system:use_module(library(logicmoo_startup)).
:- if(current_predicate(fixup_exports/0)).
:- fixup_exports.
:- endif.
%% nr_test( :PRED-1VALUE1, :PRED1VALUE2) is semidet.
%
% Term.
%
nr_test((-7), 3).
nr_test(2,10).
nr_test((-8), 5).
nr_test((-8), 2).
nr_test(42,11).
nr_test(42,14).
nr_test(1,3).
nr_test(77,2).
nr_test(80,10).
nr_test(80,0).
nr_test((-3),12).
nr_test((-4), 14).
nr_test((-4), 0).
nr_test(45,0).
nr_test(45,9).
nr_test((-1),1).
| TeamSPoon/logicmoo_workspace | packs_sys/logicmoo_utils/prolog/logicmoo/no_repeats.pl | Perl | mit | 12,747 |
# <@LICENSE>
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to you under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at:
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# </@LICENSE>
=head1 NAME
Mail::SpamAssassin::DnsResolver - DNS resolution engine
=head1 DESCRIPTION
This is a DNS resolution engine for SpamAssassin, implemented in order to
reduce file descriptor usage by Net::DNS and avoid a response collision bug in
that module.
=head1 METHODS
=over 4
=cut
# TODO: caching in this layer instead of in callers.
package Mail::SpamAssassin::DnsResolver;
use strict;
use warnings;
use bytes;
use Mail::SpamAssassin;
use Mail::SpamAssassin::Logger;
use Socket;
use IO::Socket::INET;
use Errno qw(EADDRINUSE EACCES);
use constant HAS_SOCKET_INET6 => eval { require IO::Socket::INET6; };
our @ISA = qw();
# Load Time::HiRes if it's available
BEGIN {
eval { require Time::HiRes };
Time::HiRes->import( qw(time) ) unless $@;
}
###########################################################################
sub new {
my $class = shift;
$class = ref($class) || $class;
my ($main) = @_;
my $self = {
'main' => $main,
'conf' => $main->{conf},
'id_to_callback' => { },
};
bless ($self, $class);
$self->load_resolver();
$self;
}
###########################################################################
=item $res->load_resolver()
Load the C<Net::DNS::Resolver> object. Returns 0 if Net::DNS cannot be used,
1 if it is available.
=cut
sub load_resolver {
my ($self) = @_;
if (defined $self->{res}) { return 1; }
$self->{no_resolver} = 1;
# force only ipv4 if no IO::Socket::INET6 or ipv6 doesn't work
# to be safe test both ipv6 and ipv4 addresses in INET6
my $force_ipv4 = (!HAS_SOCKET_INET6) || $self->{main}->{force_ipv4} ||
!eval {
my $sock6 = IO::Socket::INET6->new(
LocalAddr => "::",
Proto => 'udp',
);
if ($sock6) {
$sock6->close();
1;
}
} ||
!eval {
my $sock6 = IO::Socket::INET6->new(
LocalAddr => "0.0.0.0",
PeerAddr => "0.0.0.0",
PeerPort => 53,
Proto => 'udp',
);
if ($sock6) {
$sock6->close();
1;
}
};
eval {
require Net::DNS;
# force_v4 is set in new() to avoid error in older versions of Net::DNS that don't have it
# other options are set by function calls so a typo or API change will cause an error here
$self->{res} = Net::DNS::Resolver->new(force_v4 => $force_ipv4);
if (defined $self->{res}) {
$self->{no_resolver} = 0;
$self->{force_ipv4} = $force_ipv4;
$self->{retry} = 1; # retries for non-backgrounded query
$self->{retrans} = 3; # initial timeout for "non-backgrounded" query run in background
$self->{res}->retry(1); # If it fails, it fails
$self->{res}->retrans(0); # If it fails, it fails
$self->{res}->dnsrch(0); # ignore domain search-list
$self->{res}->defnames(0); # don't append stuff to end of query
$self->{res}->tcp_timeout(3); # timeout of 3 seconds only
$self->{res}->udp_timeout(3); # timeout of 3 seconds only
$self->{res}->persistent_tcp(0); # bug 3997
$self->{res}->persistent_udp(0); # bug 3997
}
1;
}; # or warn "dns: eval failed: $@ $!\n";
dbg("dns: no ipv6") if $force_ipv4;
dbg("dns: is Net::DNS::Resolver available? " .
($self->{no_resolver} ? "no" : "yes"));
if (!$self->{no_resolver} && defined $Net::DNS::VERSION) {
dbg("dns: Net::DNS version: ".$Net::DNS::VERSION);
}
return (!$self->{no_resolver});
}
=item $resolver = $res->get_resolver()
Return the C<Net::DNS::Resolver> object.
=cut
sub get_resolver {
my ($self) = @_;
return $self->{res};
}
=item $res->nameservers()
Wrapper for Net::DNS::Resolver->nameservers to get or set list of nameservers
=cut
sub nameservers {
my $self = shift;
my $res = $self->{res};
$self->connect_sock_if_reqd();
return $res->nameservers(@_) if $res;
}
=item $res->connect_sock()
Re-connect to the first nameserver listed in C</etc/resolv.conf> or similar
platform-dependent source, as provided by C<Net::DNS>.
=cut
sub connect_sock {
my ($self) = @_;
return if $self->{no_resolver};
$self->{sock}->close() if $self->{sock};
my $sock;
my $errno;
# IO::Socket::INET6 may choose wrong LocalAddr if family is unspecified,
# causing EINVAL failure when automatically assigned local IP address
# and remote address do not belong to the same address family:
use Mail::SpamAssassin::Constants qw(:ip);
my $ip64 = IP_ADDRESS;
my $ip4 = IPV4_ADDRESS;
my $ns = $self->{res}->{nameservers}[0];
my $ipv6opt = !($self->{force_ipv4});
# ensure families of src and dest addresses match (bug 4412 comment 29)
my $srcaddr;
if ($ipv6opt && $ns=~/^${ip64}$/o && $ns!~/^${ip4}$/o) {
$srcaddr = "::";
} else {
$srcaddr = "0.0.0.0";
}
dbg("dns: name server: $ns, LocalAddr: $srcaddr");
# find next available unprivileged port (1024 - 65535)
# starting at a random value to spread out use of ports
my $port_offset = int(rand(64511)); # 65535 - 1024
for (my $i = 0; $i<64511; $i++) {
my $lport = 1024 + (($port_offset + $i) % 64511);
my %args = (
PeerAddr => $ns,
PeerPort => $self->{res}->{port},
Proto => 'udp',
LocalPort => $lport,
Type => SOCK_DGRAM,
LocalAddr => $srcaddr,
);
if ($ipv6opt) {
$sock = IO::Socket::INET6->new(%args);
} else {
$sock = IO::Socket::INET->new(%args);
}
$errno = $!;
if (defined $sock) { # ok, got it
last;
} elsif ($! == EADDRINUSE || $! == EACCES) { # in use, let's try another source port
dbg("dns: UDP port $lport already in use, trying another port");
} else {
warn "Error creating a DNS resolver socket: $errno";
goto no_sock;
}
}
if (!defined $sock) {
warn "Can't create a DNS resolver socket: $errno";
goto no_sock;
}
eval {
my($bufsiz,$newbufsiz);
$bufsiz = $sock->sockopt(Socket::SO_RCVBUF)
or die "Can't get a resolver socket rx buffer size: $!";
if ($bufsiz >= 32*1024) {
dbg("dns: resolver socket rx buffer size is %d bytes", $bufsiz);
} else {
$sock->sockopt(Socket::SO_RCVBUF, 32*1024)
or die "Can't set a resolver socket rx buffer size: $!";
$newbufsiz = $sock->sockopt(Socket::SO_RCVBUF)
or die "Can't get a resolver socket rx buffer size: $!";
dbg("dns: resolver socket rx buffer size changed from %d to %d bytes",
$bufsiz, $newbufsiz);
}
1;
} or do {
my $eval_stat = $@ ne '' ? $@ : "errno=$!"; chomp $eval_stat;
info("dns: socket buffer size error: $eval_stat");
};
$self->{sock} = $sock;
$self->{sock_as_vec} = $self->fhs_to_vec($self->{sock});
return;
no_sock:
$self->{no_resolver} = 1;
}
sub connect_sock_if_reqd {
my ($self) = @_;
$self->connect_sock() if !$self->{sock};
}
=item $res->get_sock()
Return the C<IO::Socket::INET> object used to communicate with
the nameserver.
=cut
sub get_sock {
my ($self) = @_;
$self->connect_sock_if_reqd();
return $self->{sock};
}
###########################################################################
=item $packet = new_dns_packet ($host, $type, $class)
A wrapper for C<Net::DNS::Packet::new()> which traps a die thrown by it.
To use this, change calls to C<Net::DNS::Resolver::bgsend> from:
$res->bgsend($hostname, $type);
to:
$res->bgsend(Mail::SpamAssassin::DnsResolver::new_dns_packet($hostname, $type, $class));
=cut
sub new_dns_packet {
my ($self, $host, $type, $class) = @_;
return if $self->{no_resolver};
# construct a PTR query if it looks like an IPv4 address
if ((!defined($type) || $type eq 'PTR') && $host =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/) {
$host = "$4.$3.$2.$1.in-addr.arpa.";
$type = 'PTR';
}
$self->connect_sock_if_reqd();
my $packet;
eval {
$packet = Net::DNS::Packet->new($host, $type, $class);
# a bit noisy, so commented by default...
#dbg("dns: new DNS packet time=".time()." host=$host type=$type id=".$packet->id);
1;
} or do {
my $eval_stat = $@ ne '' ? $@ : "errno=$!"; chomp $eval_stat;
# this can happen if Net::DNS isn't available -- but in this
# case this function should never be called!
warn "dns: cannot create Net::DNS::Packet, but new_dns_packet() was called: $eval_stat";
};
return $packet;
}
# Internal function used only in this file
## compute an unique ID for a packet to match the query to the reply
## It must use only data that is returned unchanged by the nameserver.
## Argument is a Net::DNS::Packet that has a non-empty question section
## return is an object that can be used as a hash key
sub _packet_id {
my ($self, $packet) = @_;
my $header = $packet->header;
my $id = $header->id;
my @questions = $packet->question;
my $ques = $questions[0];
if (defined $ques) {
return join '/', $id, $ques->qname, $ques->qtype, $ques->qclass;
} else {
# odd. this should not happen, but clearly some DNS servers
# can return something that Net::DNS interprets as having no
# question section. Better support it; just return the
# (safe) ID part, along with a text token indicating that
# the packet had no question part.
return $id . "NO_QUESTION_IN_PACKET";
}
}
###########################################################################
=item $id = $res->bgsend($host, $type, $class, $cb)
Quite similar to C<Net::DNS::Resolver::bgsend>, except that when a response
packet eventually arrives, and C<poll_responses> is called, the callback
sub reference C<$cb> will be called.
Note that C<$type> and C<$class> may be C<undef>, in which case they
will default to C<A> and C<IN>, respectively.
The callback sub will be called with three arguments -- the packet that was
delivered, and an id string that fingerprints the query packet and the expected
reply. The third argument is a timestamp (Unix time, floating point), captured
at the time the packet was collected. It is expected that a closure callback
be used, like so:
my $id = $self->{resolver}->bgsend($host, $type, undef, sub {
my ($reply, $reply_id, $timestamp) = @_;
$self->got_a_reply ($reply, $reply_id);
});
The callback can ignore the reply as an invalid packet sent to the listening
port if the reply id does not match the return value from bgsend.
=cut
sub bgsend {
my ($self, $host, $type, $class, $cb) = @_;
return if $self->{no_resolver};
$self->{send_timed_out} = 0;
my $pkt = $self->new_dns_packet($host, $type, $class);
$self->connect_sock_if_reqd();
if (!defined($self->{sock}->send($pkt->data, 0))) {
warn "dns: sendto() failed: $!";
return;
}
my $id = $self->_packet_id($pkt);
$self->{id_to_callback}->{$id} = $cb;
return $id;
}
###########################################################################
=item $nfound = $res->poll_responses()
See if there are any C<bgsend> response packets ready, and return
the number of such packets delivered to their callbacks.
=cut
sub poll_responses {
my ($self, $timeout) = @_;
return if $self->{no_resolver};
return if !$self->{sock};
my $cnt = 0;
my $waiting_time = 0;
my $rin = $self->{sock_as_vec};
my $rout;
for (;;) {
my $now_before = time;
my ($nfound, $timeleft) = select($rout=$rin, undef, undef, $timeout);
if (!defined $nfound || $nfound < 0) {
warn "dns: select failed: $!";
return;
}
my $now = time;
if ($now > $now_before && (!defined($timeout) || $timeout > 0)) {
$waiting_time += $now - $now_before;
}
$timeout = 0; # next time around collect whatever is available, then exit
last if $nfound == 0;
my $packet = $self->{res}->bgread($self->{sock});
my $err = $self->{res}->errorstring;
if (defined $packet &&
defined $packet->header &&
defined $packet->question &&
defined $packet->answer)
{
my $id = $self->_packet_id($packet);
my $cb = delete $self->{id_to_callback}->{$id};
if (!$cb) {
dbg("dns: no callback for id: %s, ignored; packet: %s",
$id, $packet ? $packet->string : "undef" );
} else {
$cb->($packet, $id, $now);
$cnt++;
}
}
else {
dbg("dns: no packet! err=%s packet=%s",
$err, $packet ? $packet->string : "undef" );
}
}
return wantarray ? ($cnt, $waiting_time) : $cnt;
}
###########################################################################
=item $res->bgabort()
Call this to release pending requests from memory, when aborting backgrounded
requests, or when the scan is complete.
C<Mail::SpamAssassin::PerMsgStatus::check> calls this before returning.
=cut
sub bgabort {
my ($self) = @_;
$self->{id_to_callback} = {};
}
###########################################################################
=item $packet = $res->send($name, $type, $class)
Emulates C<Net::DNS::Resolver::send()>.
=cut
sub send {
my ($self, $name, $type, $class) = @_;
return if $self->{no_resolver};
my $retrans = $self->{retrans};
my $retries = $self->{retry};
my $timeout = $retrans;
my $answerpkt;
my $answerpkt_avail = 0;
for (my $i = 0;
(($i < $retries) && !defined($answerpkt));
++$i, $retrans *= 2, $timeout = $retrans) {
$timeout = 1 if ($timeout < 1);
# note nifty use of a closure here. I love closures ;)
$self->bgsend($name, $type, $class, sub {
my ($reply, $reply_id, $timestamp) = @_;
$answerpkt = $reply; $answerpkt_avail = 1;
});
my $now = time;
my $deadline = $now + $timeout;
while (!$answerpkt_avail) {
if ($now >= $deadline) { $self->{send_timed_out} = 1; last }
$self->poll_responses(1);
$now = time;
}
}
return $answerpkt;
}
###########################################################################
=item $res->errorstring()
Little more than a stub for callers expecting this from C<Net::DNS::Resolver>.
If called immediately after a call to $res->send this will return
C<query timed out> if the $res->send DNS query timed out. Otherwise
C<unknown error or no error> will be returned.
No other errors are reported.
=cut
sub errorstring {
my ($self) = @_;
return 'query timed out' if $self->{send_timed_out};
return 'unknown error or no error';
}
###########################################################################
=item $res->finish_socket()
Reset socket when done with it.
=cut
sub finish_socket {
my ($self) = @_;
if ($self->{sock}) {
$self->{sock}->close();
delete $self->{sock};
}
}
###########################################################################
=item $res->finish()
Clean up for destruction.
=cut
sub finish {
my ($self) = @_;
$self->finish_socket();
%{$self} = ();
}
###########################################################################
# non-public methods.
# should move to Util.pm (TODO)
sub fhs_to_vec {
my ($self, @fhlist) = @_;
my $rin = '';
foreach my $sock (@fhlist) {
my $fno = fileno($sock);
if (!defined $fno) {
warn "dns: oops! fileno now undef for $sock";
} else {
vec ($rin, $fno, 1) = 1;
}
}
return $rin;
}
# call Mail::SA::init() instead
sub reinit_post_fork {
my ($self) = @_;
# and a new socket, so we don't have 5 spamds sharing the same
# socket
$self->connect_sock();
}
1;
=back
=cut
| carlgao/lenga | images/lenny64-peon/usr/share/perl5/Mail/SpamAssassin/DnsResolver.pm | Perl | mit | 16,455 |
# This file is auto-generated by the Perl DateTime Suite time zone
# code generator (0.07) This code generator comes with the
# DateTime::TimeZone module distribution in the tools/ directory
#
# Generated from debian/tzdata/europe. Olson data version 2008c
#
# Do not edit this file directly.
#
package DateTime::TimeZone::Europe::Vaduz;
use strict;
use Class::Singleton;
use DateTime::TimeZone;
use DateTime::TimeZone::OlsonDB;
@DateTime::TimeZone::Europe::Vaduz::ISA = ( 'Class::Singleton', 'DateTime::TimeZone' );
my $spans =
[
[
DateTime::TimeZone::NEG_INFINITY,
59750436116,
DateTime::TimeZone::NEG_INFINITY,
59750438400,
2284,
0,
'LMT'
],
[
59750436116,
62482834800,
59750439716,
62482838400,
3600,
0,
'CET'
],
[
62482834800,
62490358800,
62482838400,
62490362400,
3600,
0,
'CET'
],
[
62490358800,
62506083600,
62490366000,
62506090800,
7200,
1,
'CEST'
],
[
62506083600,
62521808400,
62506087200,
62521812000,
3600,
0,
'CET'
],
[
62521808400,
62537533200,
62521815600,
62537540400,
7200,
1,
'CEST'
],
[
62537533200,
62553258000,
62537536800,
62553261600,
3600,
0,
'CET'
],
[
62553258000,
62568982800,
62553265200,
62568990000,
7200,
1,
'CEST'
],
[
62568982800,
62584707600,
62568986400,
62584711200,
3600,
0,
'CET'
],
[
62584707600,
62601037200,
62584714800,
62601044400,
7200,
1,
'CEST'
],
[
62601037200,
62616762000,
62601040800,
62616765600,
3600,
0,
'CET'
],
[
62616762000,
62632486800,
62616769200,
62632494000,
7200,
1,
'CEST'
],
[
62632486800,
62648211600,
62632490400,
62648215200,
3600,
0,
'CET'
],
[
62648211600,
62663936400,
62648218800,
62663943600,
7200,
1,
'CEST'
],
[
62663936400,
62679661200,
62663940000,
62679664800,
3600,
0,
'CET'
],
[
62679661200,
62695386000,
62679668400,
62695393200,
7200,
1,
'CEST'
],
[
62695386000,
62711110800,
62695389600,
62711114400,
3600,
0,
'CET'
],
[
62711110800,
62726835600,
62711118000,
62726842800,
7200,
1,
'CEST'
],
[
62726835600,
62742560400,
62726839200,
62742564000,
3600,
0,
'CET'
],
[
62742560400,
62758285200,
62742567600,
62758292400,
7200,
1,
'CEST'
],
[
62758285200,
62774010000,
62758288800,
62774013600,
3600,
0,
'CET'
],
[
62774010000,
62790339600,
62774017200,
62790346800,
7200,
1,
'CEST'
],
[
62790339600,
62806064400,
62790343200,
62806068000,
3600,
0,
'CET'
],
[
62806064400,
62821789200,
62806071600,
62821796400,
7200,
1,
'CEST'
],
[
62821789200,
62837514000,
62821792800,
62837517600,
3600,
0,
'CET'
],
[
62837514000,
62853238800,
62837521200,
62853246000,
7200,
1,
'CEST'
],
[
62853238800,
62868963600,
62853242400,
62868967200,
3600,
0,
'CET'
],
[
62868963600,
62884688400,
62868970800,
62884695600,
7200,
1,
'CEST'
],
[
62884688400,
62900413200,
62884692000,
62900416800,
3600,
0,
'CET'
],
[
62900413200,
62916138000,
62900420400,
62916145200,
7200,
1,
'CEST'
],
[
62916138000,
62931862800,
62916141600,
62931866400,
3600,
0,
'CET'
],
[
62931862800,
62947587600,
62931870000,
62947594800,
7200,
1,
'CEST'
],
[
62947587600,
62963917200,
62947591200,
62963920800,
3600,
0,
'CET'
],
[
62963917200,
62982061200,
62963924400,
62982068400,
7200,
1,
'CEST'
],
[
62982061200,
62995366800,
62982064800,
62995370400,
3600,
0,
'CET'
],
[
62995366800,
63013510800,
62995374000,
63013518000,
7200,
1,
'CEST'
],
[
63013510800,
63026816400,
63013514400,
63026820000,
3600,
0,
'CET'
],
[
63026816400,
63044960400,
63026823600,
63044967600,
7200,
1,
'CEST'
],
[
63044960400,
63058266000,
63044964000,
63058269600,
3600,
0,
'CET'
],
[
63058266000,
63077014800,
63058273200,
63077022000,
7200,
1,
'CEST'
],
[
63077014800,
63089715600,
63077018400,
63089719200,
3600,
0,
'CET'
],
[
63089715600,
63108464400,
63089722800,
63108471600,
7200,
1,
'CEST'
],
[
63108464400,
63121165200,
63108468000,
63121168800,
3600,
0,
'CET'
],
[
63121165200,
63139914000,
63121172400,
63139921200,
7200,
1,
'CEST'
],
[
63139914000,
63153219600,
63139917600,
63153223200,
3600,
0,
'CET'
],
[
63153219600,
63171363600,
63153226800,
63171370800,
7200,
1,
'CEST'
],
[
63171363600,
63184669200,
63171367200,
63184672800,
3600,
0,
'CET'
],
[
63184669200,
63202813200,
63184676400,
63202820400,
7200,
1,
'CEST'
],
[
63202813200,
63216118800,
63202816800,
63216122400,
3600,
0,
'CET'
],
[
63216118800,
63234867600,
63216126000,
63234874800,
7200,
1,
'CEST'
],
[
63234867600,
63247568400,
63234871200,
63247572000,
3600,
0,
'CET'
],
[
63247568400,
63266317200,
63247575600,
63266324400,
7200,
1,
'CEST'
],
[
63266317200,
63279018000,
63266320800,
63279021600,
3600,
0,
'CET'
],
[
63279018000,
63297766800,
63279025200,
63297774000,
7200,
1,
'CEST'
],
[
63297766800,
63310467600,
63297770400,
63310471200,
3600,
0,
'CET'
],
[
63310467600,
63329216400,
63310474800,
63329223600,
7200,
1,
'CEST'
],
[
63329216400,
63342522000,
63329220000,
63342525600,
3600,
0,
'CET'
],
[
63342522000,
63360666000,
63342529200,
63360673200,
7200,
1,
'CEST'
],
[
63360666000,
63373971600,
63360669600,
63373975200,
3600,
0,
'CET'
],
[
63373971600,
63392115600,
63373978800,
63392122800,
7200,
1,
'CEST'
],
[
63392115600,
63405421200,
63392119200,
63405424800,
3600,
0,
'CET'
],
[
63405421200,
63424170000,
63405428400,
63424177200,
7200,
1,
'CEST'
],
[
63424170000,
63436870800,
63424173600,
63436874400,
3600,
0,
'CET'
],
[
63436870800,
63455619600,
63436878000,
63455626800,
7200,
1,
'CEST'
],
[
63455619600,
63468320400,
63455623200,
63468324000,
3600,
0,
'CET'
],
[
63468320400,
63487069200,
63468327600,
63487076400,
7200,
1,
'CEST'
],
[
63487069200,
63500374800,
63487072800,
63500378400,
3600,
0,
'CET'
],
[
63500374800,
63518518800,
63500382000,
63518526000,
7200,
1,
'CEST'
],
[
63518518800,
63531824400,
63518522400,
63531828000,
3600,
0,
'CET'
],
[
63531824400,
63549968400,
63531831600,
63549975600,
7200,
1,
'CEST'
],
[
63549968400,
63563274000,
63549972000,
63563277600,
3600,
0,
'CET'
],
[
63563274000,
63581418000,
63563281200,
63581425200,
7200,
1,
'CEST'
],
[
63581418000,
63594723600,
63581421600,
63594727200,
3600,
0,
'CET'
],
[
63594723600,
63613472400,
63594730800,
63613479600,
7200,
1,
'CEST'
],
[
63613472400,
63626173200,
63613476000,
63626176800,
3600,
0,
'CET'
],
[
63626173200,
63644922000,
63626180400,
63644929200,
7200,
1,
'CEST'
],
[
63644922000,
63657622800,
63644925600,
63657626400,
3600,
0,
'CET'
],
[
63657622800,
63676371600,
63657630000,
63676378800,
7200,
1,
'CEST'
],
[
63676371600,
63689677200,
63676375200,
63689680800,
3600,
0,
'CET'
],
[
63689677200,
63707821200,
63689684400,
63707828400,
7200,
1,
'CEST'
],
];
sub olson_version { '2008c' }
sub has_dst_changes { 39 }
sub _max_year { 2018 }
sub _new_instance
{
return shift->_init( @_, spans => $spans );
}
sub _last_offset { 3600 }
my $last_observance = bless( {
'format' => 'CE%sT',
'gmtoff' => '1:00',
'local_start_datetime' => bless( {
'formatter' => undef,
'local_rd_days' => 723181,
'local_rd_secs' => 0,
'offset_modifier' => 0,
'rd_nanosecs' => 0,
'tz' => bless( {
'name' => 'floating',
'offset' => 0
}, 'DateTime::TimeZone::Floating' ),
'utc_rd_days' => 723181,
'utc_rd_secs' => 0,
'utc_year' => 1982
}, 'DateTime' ),
'offset_from_std' => 0,
'offset_from_utc' => 3600,
'until' => [],
'utc_start_datetime' => bless( {
'formatter' => undef,
'local_rd_days' => 723180,
'local_rd_secs' => 82800,
'offset_modifier' => 0,
'rd_nanosecs' => 0,
'tz' => bless( {
'name' => 'floating',
'offset' => 0
}, 'DateTime::TimeZone::Floating' ),
'utc_rd_days' => 723180,
'utc_rd_secs' => 82800,
'utc_year' => 1981
}, 'DateTime' )
}, 'DateTime::TimeZone::OlsonDB::Observance' )
;
sub _last_observance { $last_observance }
my $rules = [
bless( {
'at' => '1:00u',
'from' => '1996',
'in' => 'Oct',
'letter' => '',
'name' => 'EU',
'offset_from_std' => 0,
'on' => 'lastSun',
'save' => '0',
'to' => 'max',
'type' => undef
}, 'DateTime::TimeZone::OlsonDB::Rule' ),
bless( {
'at' => '1:00u',
'from' => '1981',
'in' => 'Mar',
'letter' => 'S',
'name' => 'EU',
'offset_from_std' => 3600,
'on' => 'lastSun',
'save' => '1:00',
'to' => 'max',
'type' => undef
}, 'DateTime::TimeZone::OlsonDB::Rule' )
]
;
sub _rules { $rules }
1;
| carlgao/lenga | images/lenny64-peon/usr/share/perl5/DateTime/TimeZone/Europe/Vaduz.pm | Perl | mit | 8,786 |
%%% test_gui.pl
:- module(test_gui, [main/0,my_predicate/2]).
:- use_module(library(prologbeans)).
:- use_module(library(charsio),[read_from_chars/2]).
:- use_module('$REGULUS/PrologLib/utilities').
:- use_module(library(system)).
%% Register acceptable queries and start the server (using default port)
main:-
register_query(evaluate(C, P),
write_dummy_file(C, P)),
format('~N~nReady to receive requests.~n~n', []),
start.
%% In this case we know that we have received a list of characters
%% that needs to be converted into an expression!
write_dummy_file(Chars, P) :-
( is_prolog_string(Chars) ->
format('~N~nReceived request: "~s"~n', [Chars])
;
otherwise ->
format('~N~nReceived request (not string - error!): "~w"~n', [Chars]),
fail
),
read_from_chars(Chars, X),
X = [NumberOfLines, NumberToCountToPerLine],
write_dummy_file1(NumberOfLines, NumberToCountToPerLine),
format_to_atom('Wrote file "tmp.txt" with ~d lines, counted to ~d each time',
[NumberOfLines, NumberToCountToPerLine],
P),
!.
write_dummy_file1(NumberOfLines, NumberToCountToPerLine) :-
open('c:/java/regulus/java/tmp.txt', write, S),
write_dummy_file1(1, NumberOfLines, NumberToCountToPerLine, S),
close(S),
sleep(1).
write_dummy_file1(I, NumberOfLines, _NumberToCountToPerLine, _S) :-
I > NumberOfLines,
!.
write_dummy_file1(I, NumberOfLines, NumberToCountToPerLine, S) :-
I =< NumberOfLines,
count_to_n(NumberToCountToPerLine),
format(S, '~NLine ~d: counted to ~d~n', [I, NumberToCountToPerLine]),
flush_output(S),
I1 is I + 1,
!,
write_dummy_file1(I1, NumberOfLines, NumberToCountToPerLine, S).
count_to_n(N) :-
N =< 0.
count_to_n(N) :-
N1 is N - 1,
count_to_n(N1).
| TeamSPoon/logicmoo_workspace | packs_sys/logicmoo_nlu/ext/regulus/Java/test_gui.pl | Perl | mit | 1,753 |
package MIP::Recipes::Build::Star_prerequisites;
use 5.026;
use Carp;
use charnames qw{ :full :short };
use English qw{ -no_match_vars };
use File::Spec::Functions qw{ catdir catfile };
use open qw{ :encoding(UTF-8) :std };
use Params::Check qw{ check allow last_error };
use utf8;
use warnings;
use warnings qw{ FATAL utf8 };
## CPANM
use autodie qw{ :all };
use Readonly;
## MIPs lib/
use MIP::Constants qw{ $NEWLINE $UNDERSCORE };
BEGIN {
require Exporter;
use base qw{ Exporter };
# Functions and variables which can be optionally exported
our @EXPORT_OK = qw{ build_star_prerequisites };
}
sub build_star_prerequisites {
## Function : Creates the Star prerequisites for the human genome
## Returns :
## Arguments: $active_parameter_href => Active parameters for this analysis hash {REF}
## : $case_id => Family id
## : $file_info_href => File info hash {REF}
## : $human_genome_reference => Human genome reference
## : $job_id_href => Job id hash {REF}
## : $log => Log object
## : $parameter_href => Parameter hash {REF}
## : $recipe_name => Program name
## : $parameter_build_suffixes_ref => The rtg reference associated directory suffixes {REF}
## : $profile_base_command => Submission profile base command
## : $sample_info_href => Info on samples and case hash {REF}
## : $temp_directory => Temporary directory
my ($arg_href) = @_;
## Flatten argument(s)
my $active_parameter_href;
my $file_info_href;
my $job_id_href;
my $log;
my $parameter_href;
my $recipe_name;
my $parameter_build_suffixes_ref;
my $sample_info_href;
## Default(s)
my $case_id;
my $human_genome_reference;
my $profile_base_command;
my $temp_directory;
my $tmpl = {
active_parameter_href => {
default => {},
defined => 1,
required => 1,
store => \$active_parameter_href,
strict_type => 1,
},
case_id => {
default => $arg_href->{active_parameter_href}{case_id},
store => \$case_id,
strict_type => 1,
},
file_info_href => {
default => {},
defined => 1,
required => 1,
store => \$file_info_href,
strict_type => 1,
},
human_genome_reference => {
default => $arg_href->{active_parameter_href}{human_genome_reference},
store => \$human_genome_reference,
strict_type => 1,
},
job_id_href => {
default => {},
defined => 1,
required => 1,
store => \$job_id_href,
strict_type => 1,
},
log => {
defined => 1,
required => 1,
store => \$log,
},
parameter_href => {
default => {},
defined => 1,
required => 1,
store => \$parameter_href,
strict_type => 1,
},
recipe_name => {
defined => 1,
required => 1,
store => \$recipe_name,
strict_type => 1,
},
parameter_build_suffixes_ref => {
default => [],
defined => 1,
required => 1,
store => \$parameter_build_suffixes_ref,
strict_type => 1,
},
profile_base_command => {
default => q{sbatch},
store => \$profile_base_command,
strict_type => 1,
},
sample_info_href => {
default => {},
defined => 1,
required => 1,
store => \$sample_info_href,
strict_type => 1,
},
temp_directory => {
default => $arg_href->{active_parameter_href}{temp_directory},
store => \$temp_directory,
strict_type => 1,
},
};
check( $tmpl, $arg_href, 1 ) or croak q{Could not parse arguments!};
use MIP::Program::Gnu::Coreutils qw{ gnu_mkdir };
use MIP::Language::Shell qw{ check_exist_and_move_file };
use MIP::Processmanagement::Processes qw{ submit_recipe };
use MIP::Program::Star qw{ star_genome_generate };
use MIP::Recipe qw{ parse_recipe_prerequisites };
use MIP::Script::Setup_script qw{ setup_script };
## Constants
Readonly my $NUMBER_OF_CORES => $active_parameter_href->{max_cores_per_node};
Readonly my $MAX_RANDOM_NUMBER => 100_00;
Readonly my $PROCESSING_TIME => 3;
Readonly my $READ_LENGTH => 150;
## Unpack parameters
my %recipe = parse_recipe_prerequisites(
{
active_parameter_href => $active_parameter_href,
parameter_href => $parameter_href,
recipe_name => $recipe_name,
}
);
## filehandleS
# Create anonymous filehandle
my $filehandle = IO::Handle->new();
## Generate a random integer between 0-10,000.
my $random_integer = int rand $MAX_RANDOM_NUMBER;
## Creates recipe directories (info & data & script), recipe script filenames and writes sbatch header
my ($recipe_file_path) = setup_script(
{
active_parameter_href => $active_parameter_href,
filehandle => $filehandle,
directory_id => $case_id,
core_number => $NUMBER_OF_CORES,
job_id_href => $job_id_href,
memory_allocation => $recipe{memory},
recipe_directory => $recipe_name,
recipe_name => $recipe_name,
process_time => $PROCESSING_TIME,
source_environment_commands_ref => $recipe{load_env_ref},
}
);
$log->warn( q{Will try to create required }
. $human_genome_reference
. q{ Star files before executing }
. $recipe_name );
say {$filehandle} q{## Building Star dir files};
## Get parameters
my $star_directory_tmp =
$active_parameter_href->{star_aln_reference_genome} . $UNDERSCORE . $random_integer;
# Create temp dir
gnu_mkdir(
{
filehandle => $filehandle,
indirectory_path => $star_directory_tmp,
parents => 1,
}
);
say {$filehandle} $NEWLINE;
star_genome_generate(
{
filehandle => $filehandle,
fasta_path => $human_genome_reference,
genome_dir_path => $star_directory_tmp,
gtf_path => $active_parameter_href->{transcript_annotation},
read_length => $READ_LENGTH,
}
);
say {$filehandle} $NEWLINE;
PREREQ:
foreach my $suffix ( @{$parameter_build_suffixes_ref} ) {
my $intended_file_path = $active_parameter_href->{star_aln_reference_genome} . $suffix;
## Checks if a file exists and moves the file in place if file is lacking or has a size of 0 bytes.
check_exist_and_move_file(
{
filehandle => $filehandle,
intended_file_path => $intended_file_path,
temporary_file_path => $star_directory_tmp,
}
);
}
close $filehandle or $log->logcroak(q{Could not close filehandle});
if ( $recipe{mode} == 1 ) {
submit_recipe(
{
base_command => $profile_base_command,
dependency_method => q{island_to_samples},
case_id => $case_id,
job_id_href => $job_id_href,
log => $log,
job_id_chain => $recipe{job_id_chain},
recipe_file_path => $recipe_file_path,
sample_ids_ref => \@{ $active_parameter_href->{sample_ids} },
submission_profile => $active_parameter_href->{submission_profile},
}
);
}
return 1;
}
1;
| henrikstranneheim/MIP | lib/MIP/Recipes/Build/Star_prerequisites.pm | Perl | mit | 8,442 |
package Maillog::Parser::SMTPAuth;
use 5.006;
use strict;
use warnings FATAL => 'all';
=head1 NAME
Maillog::Parser::SMTPAuth - The great new Maillog::Parser::SMTPAuth!
=head1 VERSION
Version 0.01
=cut
our $VERSION = '0.01';
=head1 SYNOPSIS
Quick summary of what the module does.
Perhaps a little code snippet.
use Maillog::Parser::SMTPAuth;
my $foo = Maillog::Parser::SMTPAuth->new();
...
=head1 EXPORT
A list of functions that can be exported. You can delete this section
if you don't export anything, such as for a purely object-oriented module.
=head1 SUBROUTINES/METHODS
=head2 function1
=cut
sub function1 {
}
=head2 function2
=cut
sub function2 {
}
=head1 AUTHOR
Toshifumi Sakaguchi, C<< <sischkg at gmail.com> >>
=head1 BUGS
Please report any bugs or feature requests to C<bug-maillog-parser at rt.cpan.org>, or through
the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Maillog-Parser>. I will be notified, and then you'll
automatically be notified of progress on your bug as I make changes.
=head1 SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Maillog::Parser::SMTPAuth
You can also look for information at:
=over 4
=item * RT: CPAN's request tracker (report bugs here)
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Maillog-Parser>
=item * AnnoCPAN: Annotated CPAN documentation
L<http://annocpan.org/dist/Maillog-Parser>
=item * CPAN Ratings
L<http://cpanratings.perl.org/d/Maillog-Parser>
=item * Search CPAN
L<http://search.cpan.org/dist/Maillog-Parser/>
=back
=head1 ACKNOWLEDGEMENTS
=head1 LICENSE AND COPYRIGHT
Copyright 2014 Toshifumi Sakaguchi.
This program is free software; you can redistribute it and/or modify it
under the terms of the the Artistic License (2.0). You may obtain a
copy of the full license at:
L<http://www.perlfoundation.org/artistic_license_2_0>
Any use, modification, and distribution of the Standard or Modified
Versions is governed by this Artistic License. By using, modifying or
distributing the Package, you accept this license. Do not use, modify,
or distribute the Package, if you do not accept this license.
If your Modified Version has been derived from a Modified Version made
by someone other than you, you are nevertheless required to ensure that
your Modified Version complies with the requirements of this license.
This license does not grant you the right to use any trademark, service
mark, tradename, or logo of the Copyright Holder.
This license includes the non-exclusive, worldwide, free-of-charge
patent license to make, have made, use, offer to sell, sell, import and
otherwise transfer the Package with respect to any patent claims
licensable by the Copyright Holder that are necessarily infringed by the
Package. If you institute patent litigation (including a cross-claim or
counterclaim) against any party alleging that the Package constitutes
direct or contributory patent infringement, then this Artistic License
to you shall terminate on the date that such litigation is filed.
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=cut
1; # End of Maillog::Parser::SMTPAuth
| sischkg/Maillog-Parser | lib/Maillog/Parser/SMTPAuth.pm | Perl | mit | 3,659 |
#!/usr/bin/perl
# lenticulate.pl
# Usage: perl lenticulate.pl inputFile1 inputFile2 outputFile
# This can be used to read strips from two input images and alternately
# write them to an output image. The output image can then be
# manually folded to create a crude lenticular picture.
# A description of the overall process can be found at:
# http://photojojo.com/content/diy/how-to-make-lenticular-images/
#
# This depends on the perl GD image manipulation module.
#
# 1-Jul-2007 Doug Toppin - initial
# 24-Nov-2016 Doug Toppin - updating
# uncomment the following and the var declarations later
# for debug if needed
#use strict;
# perl image manipulation module
use GD;
#my $width1;
#my $height1;
#my $width2;
#my $height2;
#my $widthout;
#my $heightout;
#my $jpg_data;
#my $imagein1;
#my $imagein2;
#my $slice;
#my $i;
#my $outfile;
#my $infile1;
#my $infile2;
#my $srcX = 0;
#my $srcY = 0;
#my $dstX = 0;
#my $dstY = 0;
# percent of the input images used for each slice
my $sliceSize = 10;
if ( @ARGV != 3) {
print "error: incorrect number of arguments\n";
usage($0);
exit(1);
}
($infile1, $infile2, $outfile) = @ARGV;
if (! -e $infile1) {
print "error: input file not found: ", $infile1, "\n";
usage($0);
exit(1);
}
if (! -e $infile2) {
print "error: input file not found: ", $infile2, "\n";
usage($0);
exit(1);
}
# if output file exists make the user remove it
if (-e $outfile) {
print "error: output file ", $outfile, " must not exist\n";
usage($0);
exit(1);
}
# open the input files and read into memory
$imagein1 = GD::Image->new($infile1) || die;
$imagein2 = GD::Image->new($infile2) || die;
# get image width/height of both input files
($width1, $height1) = $imagein1->getBounds();
($width2, $height2) = $imagein2->getBounds();
# the input images must have the same width/height
if (($width1 != $width2) || ($height1 != $height2)) {
print("error: widths/heights not the same\n");
usage($0);
exit(1);
}
# the output image will be twice as wide as the input
$widthout = $width1 * 2;
# the output image will be the same height as the input
$heightout = $height1;
# each slice of the input files to copy will be 10% of the width
$slice = $width1 / $sliceSize;
# create the output image object
my $imageout = GD::Image->new($widthout, $heightout) || die;
# now we are going to loop through each strip of the input
# images and copy a slice to the output image, alternating
# between each input file
for ($i=0; $i < $sliceSize; $i++) {
# use the GD copy function to copy a slice of input to
# the output file, the arguments are:
# copy(sourceimage, dstX, dstY, srcX, srcY, width, height)
$imageout->copy($imagein1, $dstX, $dstY, $srcX, $srcY, $slice, $heightout);
# move to the next slice location in the output image
$dstX += $slice;
# copy image 2 strip
$imageout->copy($imagein2, $dstX, $dstY, $srcX, $srcY, $slice, $heightout);
$dstX += $slice;
# now move to the next start point for the input file x,y coords
$srcX += $slice;
}
# convert the output images to jpeg
$jpg_data = $imageout->jpeg || die "error converting to jpeg";
# create the output file and write the binary image to it
open FILEOUT, "> $outfile" || die;
binmode FILEOUT || die;
print FILEOUT $jpg_data || die;
close FILEOUT || die;
exit(0);
sub usage() {
print "Usage: perl $0 inputFile1 inputFile2 outputFile\n";
print " Example: perl $0 infile1.jpg infile2.jpg outfile.jpg\n";
print " Combine two images in strips to produces a third image.\n";
print " The output image will be twice the width as the input.\n";
print " The input images must be the same width/height.\n";
}
| dougtoppin/lenticular | lenticulate.pl | Perl | mit | 3,690 |
use strict;
use warnings;
package KinoSearch::Build;
use base qw( Lucy::Build );
BEGIN { Lucy::Build->use_kinosearch_mode }
1;
__END__
=head1 NAME
KinoSearch::Build -- Module::Build subclass for KinoSearch
=head1 SYNOPSIS
my $builder = KinoSearch::Build->new(
%args_to_module_build_constructor;
);
$builder->create_build_script;
=head1 DESCRIPTION
KinoSearch stores XS code inside .pm files (see L<KinoSearch::Docs::DevGuide>
for the reasoning behind that strategy) and auto-generates a bunch of C code
using devel/boilerplater.pl. This custom Module::Build subclass does some
extra work extracting and writing those files on the fly.
=head1 COPYRIGHT
Copyright 2005-2009 Marvin Humphrey
=head1 LICENSE, DISCLAIMER, BUGS, etc.
See L<KinoSearch|KinoSearch>.
=cut
| robertkrimen/Search-Kino03 | buildlib/KinoSearch/Build.pm | Perl | apache-2.0 | 798 |
package Paws::Config::DescribeConfigRules;
use Moose;
has ConfigRuleNames => (is => 'ro', isa => 'ArrayRef[Str|Undef]');
has NextToken => (is => 'ro', isa => 'Str');
use MooseX::ClassAttribute;
class_has _api_call => (isa => 'Str', is => 'ro', default => 'DescribeConfigRules');
class_has _returns => (isa => 'Str', is => 'ro', default => 'Paws::Config::DescribeConfigRulesResponse');
class_has _result_key => (isa => 'Str', is => 'ro');
1;
### main pod documentation begin ###
=head1 NAME
Paws::Config::DescribeConfigRules - Arguments for method DescribeConfigRules on Paws::Config
=head1 DESCRIPTION
This class represents the parameters used for calling the method DescribeConfigRules on the
AWS Config service. Use the attributes of this class
as arguments to method DescribeConfigRules.
You shouldn't make instances of this class. Each attribute should be used as a named argument in the call to DescribeConfigRules.
As an example:
$service_obj->DescribeConfigRules(Att1 => $value1, Att2 => $value2, ...);
Values for attributes that are native types (Int, String, Float, etc) can passed as-is (scalar values). Values for complex Types (objects) can be passed as a HashRef. The keys and values of the hashref will be used to instance the underlying object.
=head1 ATTRIBUTES
=head2 ConfigRuleNames => ArrayRef[Str|Undef]
The names of the AWS Config rules for which you want details. If you do
not specify any names, AWS Config returns details for all your rules.
=head2 NextToken => Str
The C<NextToken> string returned on a previous page that you use to get
the next page of results in a paginated response.
=head1 SEE ALSO
This class forms part of L<Paws>, documenting arguments for method DescribeConfigRules in L<Paws::Config>
=head1 BUGS and CONTRIBUTIONS
The source code is located here: https://github.com/pplu/aws-sdk-perl
Please report bugs to: https://github.com/pplu/aws-sdk-perl/issues
=cut
| ioanrogers/aws-sdk-perl | auto-lib/Paws/Config/DescribeConfigRules.pm | Perl | apache-2.0 | 1,953 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.