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
#!/usr/bin/perl # prepare Thai cardinal words # @(#) $Id: prepThai.pl 113 2009-04-06 14:57:07Z gfis $ # 2009-04-06: Dr. Georg Fischer #------------------------------------------------------- # # Copyright 2006 Dr. Georg Fischer <punctum at punctum dot kom> # # 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 strict; while (<DATA>) { my ($thai, $phon, @rest) = split; print "\t\t, \"$thai\" // $phon ", join(" ", @rest), "\n"; } # while __DATA__ ศูนย์ suun[y]R zero; the number or quantity zero หนึ่ง neungL one; the number or quantity one สอง saawngR two; the number or quantity two สาม saamR three; the number or quantity three สี่ seeL four; the number or quantity four ห้า haaF five; the number or quantity five หก hohkL six; the number or quantity six เจ็ด jetL seven; the number or quantity seven แปด bpaaetL eight; the number or quantity eight เก้า gaoF nine; the number or quantity nine สิบ sipL ten; the number or quantity ten สิบเอ็ด sipL etL eleven; 11 สิบสอง sipL saawngR twelve; 12 สิบสาม sipL saamR thirteen; 13 สิบสี่ sipL seeL fourteen; 14 สิบห้า sipL haaF firfteen; 15 สิบหก sipL hohkL sixteen; 16 สิบเจ็ด sipL jetL seventeen; 17 สิบแปด sipL bpaaetL eighteen; 18 สิบเก้า sipL gaoF nineteen; 19 ยี่สิบ yeeF sipL twenty; 20 ยี่สิบเอ็ด yeeF sipL etL twenty-one; 21 ยี่สิบสอง yeeF sipL saawngR twenty-two; 22 ยี่สิบสาม yeeF sipL saamR twenty-three; 23 ยี่สิบสี่ yeeF sipL seeL twenty-four; 24 ยี่สิบห้า yeeF sipL haaF twenty-five; 25 ยี่สิบหก yeeF sipL hohkL twenty-six; 26 ยี่สิบเจ็ด yeeF sipL jetL twenty-seven; 27 ยี่สิบแปด yeeF sipL bpaaetL twenty-eight; 28 ยี่สิบเก้า yeeF sipL gaoF twenty-nine; 29 สามสิบ saamR sipL thirty; 30 สามสิบเอ็ด saamR sipL etL [spoken] thirty-one สี่สิบ seeL sipL forty; 40 ห้าสิบ haaF sipL fifty; 50 หกสิบ hohkL sipL sixty; 60 เจ็ดสิบ jetL sipL seventy; 70 แปดสิบ bpaaetL sipL eighty; 80 เก้าสิบ gaoF sipL ninety; 90 ร้อย raawyH hundred; the number one hundred; 100 ร้อยหนึ่ง raawyH neungL one hundred one; 101 พัน phanM thousand; the number one thousand (1,000) สองพัน saawngR phanM two-thousand (2,000) สี่พัน seeL phanM four thousand (4,000) หมื่น meuunL ten-thousand (10,000) แสน saaenR hundred-thousand (100,000) ล้าน laanH million; the number one million (1,000,000) สิบล้าน sipL laanH ten million (10,000,000) ร้อยล้าน raawyH laanH one hundred million (100,000,000) พันล้าน phanM laanH billion (1,000,000,000) หมื่นล้าน meuunL laanH ten-billion (10,000,000,000) แสนล้าน saaenR laanH one hundred-billion (100,000,000,000) ล้านล้าน laanH laanH One trillion (1,000,000,000,000) กัป gapL kalp, or eon, a vast period of time, the period of time between creation and recreation of the world and universe. It is given in Hindu chronology as 4,320,000,000 years กัลป์ gan[p]M eternity; a very long period of time อสงไขย aL sohngR khaiR [a number followed by 140 ciphers or โกฏิ 26 (10 million26)] หนึ่งโกฏิ neungL gohtL [an ancient numeral that equals] ten million ตัวเลขโรมัน dtuaaM laehkF rohM manM Roman numeral(s) หมื่นสองพันสามร้อยสี่สิบห้า meuunL saawngR phanM saamR raawyH seeL sipL haaF twelve thousand, three hundred forty-five
gfis/numword
etc/prepThai.pl
Perl
apache-2.0
4,472
=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::Component::Tools::Blast::GenomicSeq; use strict; use parent qw(EnsEMBL::Web::Component::Tools::Blast::TextSequence); use EnsEMBL::Web::TextSequence::View::GenomicSeq; sub initialize_new { my ($self, $slice, $start, $end) = @_; my $hub = $self->hub; my $species = $self->job->species; my $config = { display_width => $hub->param('display_width') || 60, species => $species, sub_slice_start => $start, sub_slice_end => $end, ambiguity => 1, factorytype => 'Tools', }; for ($self->viewconfig->options) { $config->{$_} = $self->param($_) unless $self->param($_) eq 'off'; } $config->{'slices'} = [{ slice => $slice || $self->get_slice, name => $species }]; if ($config->{'line_numbering'}) { $config->{'number'} = 1; } $config->{'genomic'} = 1; # For styles my ($sequence, $markup) = $self->get_sequence_data($config->{'slices'}, $config); $self->view->markup($sequence,$markup,$config); return ($sequence, $config); } sub get_slice { my $self = shift; my $hub = $self->hub; my $hit = $self->hit; my $slice = $self->object->get_hit_genomic_slice($hit, $hub->param('flank5_display'), $hub->param('flank3_display')); my $ori = $hub->param('orientation'); my $g_ori = $hit->{'gori'}; my $q_ori = $hit->{'qori'}; if ( ($q_ori == 1 && $g_ori == 1 && $ori eq 'rc') || ($q_ori == 1 && $g_ori == -1 && $ori eq 'fc') || ($q_ori == -1 && $g_ori == 1 && $ori ne 'fc') || ($q_ori == -1 && $g_ori == -1 && $ori ne 'rc') ) { $slice = $slice->invert; } return $slice; } sub get_sequence_data { ## @override ## Add HSPs to the sequence data my ($self, $slices, $config) = @_; $config->{'hit'} = $self->hit; $config->{'job'} = $self->job; $config->{'object'} = $self->object; $config->{'slice_type'} = ref($self) =~ /QuerySeq$/ ? 'q' : 'g'; my ($sequence, $markup) = $self->SUPER::get_sequence_data($slices, $config); return ($sequence, $markup); } sub make_view { my ($self) = @_; return EnsEMBL::Web::TextSequence::View::GenomicSeq->new($self->hub); } 1;
Ensembl/public-plugins
tools/modules/EnsEMBL/Web/Component/Tools/Blast/GenomicSeq.pm
Perl
apache-2.0
2,866
#! /usr/bin/env perl # Copyright 2006-2018 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 # https://www.openssl.org/source/license.html # # ==================================================================== # Written by Andy Polyakov <appro@fy.chalmers.se> for the OpenSSL # project. The module is, however, dual licensed under OpenSSL and # CRYPTOGAMS licenses depending on where you obtain it. For further # details see http://www.openssl.org/~appro/cryptogams/. # ==================================================================== # # Wrapper around 'rep montmul', VIA-specific instruction accessing # PadLock Montgomery Multiplier. The wrapper is designed as drop-in # replacement for OpenSSL bn_mul_mont [first implemented in 0.9.9]. # # Below are interleaved outputs from 'openssl speed rsa dsa' for 4 # different software configurations on 1.5GHz VIA Esther processor. # Lines marked with "software integer" denote performance of hand- # coded integer-only assembler found in OpenSSL 0.9.7. "Software SSE2" # refers to hand-coded SSE2 Montgomery multiplication procedure found # OpenSSL 0.9.9. "Hardware VIA SDK" refers to padlock_pmm routine from # Padlock SDK 2.0.1 available for download from VIA, which naturally # utilizes the magic 'repz montmul' instruction. And finally "hardware # this" refers to *this* implementation which also uses 'repz montmul' # # sign verify sign/s verify/s # rsa 512 bits 0.001720s 0.000140s 581.4 7149.7 software integer # rsa 512 bits 0.000690s 0.000086s 1450.3 11606.0 software SSE2 # rsa 512 bits 0.006136s 0.000201s 163.0 4974.5 hardware VIA SDK # rsa 512 bits 0.000712s 0.000050s 1404.9 19858.5 hardware this # # rsa 1024 bits 0.008518s 0.000413s 117.4 2420.8 software integer # rsa 1024 bits 0.004275s 0.000277s 233.9 3609.7 software SSE2 # rsa 1024 bits 0.012136s 0.000260s 82.4 3844.5 hardware VIA SDK # rsa 1024 bits 0.002522s 0.000116s 396.5 8650.9 hardware this # # rsa 2048 bits 0.050101s 0.001371s 20.0 729.6 software integer # rsa 2048 bits 0.030273s 0.001008s 33.0 991.9 software SSE2 # rsa 2048 bits 0.030833s 0.000976s 32.4 1025.1 hardware VIA SDK # rsa 2048 bits 0.011879s 0.000342s 84.2 2921.7 hardware this # # rsa 4096 bits 0.327097s 0.004859s 3.1 205.8 software integer # rsa 4096 bits 0.229318s 0.003859s 4.4 259.2 software SSE2 # rsa 4096 bits 0.233953s 0.003274s 4.3 305.4 hardware VIA SDK # rsa 4096 bits 0.070493s 0.001166s 14.2 857.6 hardware this # # dsa 512 bits 0.001342s 0.001651s 745.2 605.7 software integer # dsa 512 bits 0.000844s 0.000987s 1185.3 1013.1 software SSE2 # dsa 512 bits 0.001902s 0.002247s 525.6 444.9 hardware VIA SDK # dsa 512 bits 0.000458s 0.000524s 2182.2 1909.1 hardware this # # dsa 1024 bits 0.003964s 0.004926s 252.3 203.0 software integer # dsa 1024 bits 0.002686s 0.003166s 372.3 315.8 software SSE2 # dsa 1024 bits 0.002397s 0.002823s 417.1 354.3 hardware VIA SDK # dsa 1024 bits 0.000978s 0.001170s 1022.2 855.0 hardware this # # dsa 2048 bits 0.013280s 0.016518s 75.3 60.5 software integer # dsa 2048 bits 0.009911s 0.011522s 100.9 86.8 software SSE2 # dsa 2048 bits 0.009542s 0.011763s 104.8 85.0 hardware VIA SDK # dsa 2048 bits 0.002884s 0.003352s 346.8 298.3 hardware this # # To give you some other reference point here is output for 2.4GHz P4 # running hand-coded SSE2 bn_mul_mont found in 0.9.9, i.e. "software # SSE2" in above terms. # # rsa 512 bits 0.000407s 0.000047s 2454.2 21137.0 # rsa 1024 bits 0.002426s 0.000141s 412.1 7100.0 # rsa 2048 bits 0.015046s 0.000491s 66.5 2034.9 # rsa 4096 bits 0.109770s 0.002379s 9.1 420.3 # dsa 512 bits 0.000438s 0.000525s 2281.1 1904.1 # dsa 1024 bits 0.001346s 0.001595s 742.7 627.0 # dsa 2048 bits 0.004745s 0.005582s 210.7 179.1 # # Conclusions: # - VIA SDK leaves a *lot* of room for improvement (which this # implementation successfully fills:-); # - 'rep montmul' gives up to >3x performance improvement depending on # key length; # - in terms of absolute performance it delivers approximately as much # as modern out-of-order 32-bit cores [again, for longer keys]. $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; push(@INC,"${dir}","${dir}../../perlasm"); require "x86asm.pl"; $output = pop; open STDOUT,">$output"; &asm_init($ARGV[0],"via-mont.pl"); # int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np,const BN_ULONG *n0, int num); $func="bn_mul_mont_padlock"; $pad=16*1; # amount of reserved bytes on top of every vector # stack layout $mZeroPrime=&DWP(0,"esp"); # these are specified by VIA $A=&DWP(4,"esp"); $B=&DWP(8,"esp"); $T=&DWP(12,"esp"); $M=&DWP(16,"esp"); $scratch=&DWP(20,"esp"); $rp=&DWP(24,"esp"); # these are mine $sp=&DWP(28,"esp"); # &DWP(32,"esp") # 32 byte scratch area # &DWP(64+(4*$num+$pad)*0,"esp") # padded tp[num] # &DWP(64+(4*$num+$pad)*1,"esp") # padded copy of ap[num] # &DWP(64+(4*$num+$pad)*2,"esp") # padded copy of bp[num] # &DWP(64+(4*$num+$pad)*3,"esp") # padded copy of np[num] # Note that SDK suggests to unconditionally allocate 2K per vector. This # has quite an impact on performance. It naturally depends on key length, # but to give an example 1024 bit private RSA key operations suffer >30% # penalty. I allocate only as much as actually required... &function_begin($func); &xor ("eax","eax"); &mov ("ecx",&wparam(5)); # num # meet VIA's limitations for num [note that the specification # expresses them in bits, while we work with amount of 32-bit words] &test ("ecx",3); &jnz (&label("leave")); # num % 4 != 0 &cmp ("ecx",8); &jb (&label("leave")); # num < 8 &cmp ("ecx",1024); &ja (&label("leave")); # num > 1024 &pushf (); &cld (); &mov ("edi",&wparam(0)); # rp &mov ("eax",&wparam(1)); # ap &mov ("ebx",&wparam(2)); # bp &mov ("edx",&wparam(3)); # np &mov ("esi",&wparam(4)); # n0 &mov ("esi",&DWP(0,"esi")); # *n0 &lea ("ecx",&DWP($pad,"","ecx",4)); # ecx becomes vector size in bytes &lea ("ebp",&DWP(64,"","ecx",4)); # allocate 4 vectors + 64 bytes &neg ("ebp"); &add ("ebp","esp"); &and ("ebp",-64); # align to cache-line &xchg ("ebp","esp"); # alloca &mov ($rp,"edi"); # save rp &mov ($sp,"ebp"); # save esp &mov ($mZeroPrime,"esi"); &lea ("esi",&DWP(64,"esp")); # tp &mov ($T,"esi"); &lea ("edi",&DWP(32,"esp")); # scratch area &mov ($scratch,"edi"); &mov ("esi","eax"); &lea ("ebp",&DWP(-$pad,"ecx")); &shr ("ebp",2); # restore original num value in ebp &xor ("eax","eax"); &mov ("ecx","ebp"); &lea ("ecx",&DWP((32+$pad)/4,"ecx"));# padded tp + scratch &data_byte(0xf3,0xab); # rep stosl, bzero &mov ("ecx","ebp"); &lea ("edi",&DWP(64+$pad,"esp","ecx",4));# pointer to ap copy &mov ($A,"edi"); &data_byte(0xf3,0xa5); # rep movsl, memcpy &mov ("ecx",$pad/4); &data_byte(0xf3,0xab); # rep stosl, bzero pad # edi points at the end of padded ap copy... &mov ("ecx","ebp"); &mov ("esi","ebx"); &mov ($B,"edi"); &data_byte(0xf3,0xa5); # rep movsl, memcpy &mov ("ecx",$pad/4); &data_byte(0xf3,0xab); # rep stosl, bzero pad # edi points at the end of padded bp copy... &mov ("ecx","ebp"); &mov ("esi","edx"); &mov ($M,"edi"); &data_byte(0xf3,0xa5); # rep movsl, memcpy &mov ("ecx",$pad/4); &data_byte(0xf3,0xab); # rep stosl, bzero pad # edi points at the end of padded np copy... # let magic happen... &mov ("ecx","ebp"); &mov ("esi","esp"); &shl ("ecx",5); # convert word counter to bit counter &align (4); &data_byte(0xf3,0x0f,0xa6,0xc0);# rep montmul &mov ("ecx","ebp"); &lea ("esi",&DWP(64,"esp")); # tp # edi still points at the end of padded np copy... &neg ("ebp"); &lea ("ebp",&DWP(-$pad,"edi","ebp",4)); # so just "rewind" &mov ("edi",$rp); # restore rp &xor ("edx","edx"); # i=0 and clear CF &set_label("sub",8); &mov ("eax",&DWP(0,"esi","edx",4)); &sbb ("eax",&DWP(0,"ebp","edx",4)); &mov (&DWP(0,"edi","edx",4),"eax"); # rp[i]=tp[i]-np[i] &lea ("edx",&DWP(1,"edx")); # i++ &loop (&label("sub")); # doesn't affect CF! &mov ("eax",&DWP(0,"esi","edx",4)); # upmost overflow bit &sbb ("eax",0); &mov ("ecx","edx"); # num &mov ("edx",0); # i=0 &set_label("copy",8); &mov ("ebx",&DWP(0,"esi","edx",4)); &mov ("eax",&DWP(0,"edi","edx",4)); &mov (&DWP(0,"esi","edx",4),"ecx"); # zap tp &cmovc ("eax","ebx"); &mov (&DWP(0,"edi","edx",4),"eax"); &lea ("edx",&DWP(1,"edx")); # i++ &loop (&label("copy")); &mov ("ebp",$sp); &xor ("eax","eax"); &mov ("ecx",64/4); &mov ("edi","esp"); # zap frame including scratch area &data_byte(0xf3,0xab); # rep stosl, bzero # zap copies of ap, bp and np &lea ("edi",&DWP(64+$pad,"esp","edx",4));# pointer to ap &lea ("ecx",&DWP(3*$pad/4,"edx","edx",2)); &data_byte(0xf3,0xab); # rep stosl, bzero &mov ("esp","ebp"); &inc ("eax"); # signal "done" &popf (); &set_label("leave"); &function_end($func); &asciz("Padlock Montgomery Multiplication, CRYPTOGAMS by <appro\@openssl.org>"); &asm_finish(); close STDOUT;
google/google-ctf
third_party/edk2/CryptoPkg/Library/OpensslLib/openssl/crypto/bn/asm/via-mont.pl
Perl
apache-2.0
9,305
#!/usr/bin/perl -w use strict; my @inputs = (); while (<>) { if (/^\s+(\S+.*)$/) { chomp $inputs[-1]; $inputs[-1] .= " $1\n"; next; } push @inputs, $_; } my $last_tok = ""; foreach (@inputs) { my $line = $_; my $line_bak = ""; while ($line ne $line_bak) { $line_bak = $line; $line =~ s/(\s+|^)([a-zA-Z_]+)(\s+|$)/$1<$2>$3/g; } $line =~ s/"""/`\\"'/g; $line =~ s/"([^"`]+)"/`$1'/g; ($line =~ /^(<[a-zA-Z_]+>\s+::)(=)/) or die "$line was unexpected\n"; if ($1 eq $last_tok) { my $blanks = $1; $blanks =~ s/./ /g; $line =~ s/$last_tok=/$blanks|/; } else { $last_tok = $1; } $line =~ s/^/"/; $line =~ s/$/" << ::std::endl << \\/; print $line; } print "\"\"\n";
tautschnig/fshell
config/y2l-postproc.pl
Perl
apache-2.0
733
# # 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 storage::dell::me4::restapi::plugin; use strict; use warnings; use base qw(centreon::plugins::script_custom); sub new { my ( $class, %options ) = @_; my $self = $class->SUPER::new( package => __PACKAGE__, %options ); bless $self, $class; $self->{version} = '0.1'; $self->{modes} = { 'controller-statistics' => 'storage::dell::me4::restapi::mode::controllerstatistics', 'hardware' => 'storage::dell::me4::restapi::mode::hardware', 'interfaces' => 'storage::dell::me4::restapi::mode::interfaces', 'list-controllers' => 'storage::dell::me4::restapi::mode::listcontrollers', 'list-volumes' => 'storage::dell::me4::restapi::mode::listvolumes', 'volume-statistics' => 'storage::dell::me4::restapi::mode::volumestatistics' }; $self->{custom_modes}->{api} = 'storage::dell::me4::restapi::custom::api'; return $self; } 1; __END__ =head1 PLUGIN DESCRIPTION Check Dell ME4 series using API. =cut
centreon/centreon-plugins
storage/dell/me4/restapi/plugin.pm
Perl
apache-2.0
1,784
=head1 NAME Search::Kino03::KinoSearch::Docs::Tutorial - Step-by-step introduction to KinoSearch toolset. =head1 ABSTRACT Explore KinoSearch's basic functionality by starting with a minimalist CGI search app based on L<Search::Kino03::KSx::Simple> and transforming it, step by step, into an "advanced search" interface utilizing more flexible core modules like L<Search::Kino03::KinoSearch::Indexer> and L<Search::Kino03::KinoSearch::Searcher>. =head1 DESCRIPTION =head2 Chapters =over =item * L<Search::Kino03::KinoSearch::Docs::Tutorial::Simple> - Build a bare-bones search app using L<Search::Kino03::KSx::Simple>. =item * L<Search::Kino03::KinoSearch::Docs::Tutorial::BeyondSimple> - Rebuild the app using core classes like L<Indexer|Search::Kino03::KinoSearch::Indexer> and L<Searcher|Search::Kino03::KinoSearch::Searcher> in place of Search::Kino03::KSx::Simple. =item * L<Search::Kino03::KinoSearch::Docs::Tutorial::FieldType> - Experiment with different field characteristics using subclasses of L<Search::Kino03::KinoSearch::FieldType>. =item * L<Search::Kino03::KinoSearch::Docs::Tutorial::Analysis> - Examine how the choice of L<Search::Kino03::KinoSearch::Analysis::Analyzer> subclass affects search results. =item * L<Search::Kino03::KinoSearch::Docs::Tutorial::Highlighter> - Augment search results with highlighted excerpts. =item * L<Search::Kino03::KinoSearch::Docs::Tutorial::QueryObjects> - Unlock advanced search features by using Query objects instead of query strings. =back =head2 Source materials The source material used by the tutorial app -- an html presentation of the United States constitution -- can be found in the C<sample> directory at the root of the KinoSearch distribution, along with finished indexing and search apps. sample/indexer.pl # indexing app sample/search.cgi # search app sample/us_constitution # html documents =head2 Conventions The user is expected to be familiar with OO Perl and basic CGI programming. The code in this tutorial assumes a Unix-flavored operating system and the Apache webserver, but will work with minor modifications on other setups. =head1 SEE ALSO More advanced and esoteric subjects are covered in L<Search::Kino03::KinoSearch::Docs::Cookbook>. =head1 COPYRIGHT Copyright 2005-2009 Marvin Humphrey =head1 LICENSE, DISCLAIMER, BUGS, etc. See L<KinoSearch> version 0.30.
robertkrimen/Search-Kino03
lib/Search/Kino03/KinoSearch/Docs/Tutorial.pod
Perl
apache-2.0
2,404
package Paws::SQS::ListQueuesResult; use Moose; has QueueUrls => (is => 'ro', isa => 'ArrayRef[Str|Undef]', request_name => 'QueueUrl', traits => ['NameInRequest',]); has _request_id => (is => 'ro', isa => 'Str'); 1; ### main pod documentation begin ### =head1 NAME Paws::SQS::ListQueuesResult =head1 ATTRIBUTES =head2 QueueUrls => ArrayRef[Str|Undef] A list of queue URLs, up to 1,000 entries. =head2 _request_id => Str =cut
ioanrogers/aws-sdk-perl
auto-lib/Paws/SQS/ListQueuesResult.pm
Perl
apache-2.0
446
# Copyright 2016, Mitchell Cooper package F::PropertyOwner; use warnings; use strict; use parent 'F::Element'; # PropertyOwners are nodes that can be traced back to a property on an object. # They must be able to provide code to access this object as well as either # a string property name or some code which evaluates to a property name. sub property_name { } # one of ->property_name or ->property_name_code sub property_name_code { } # must be implemented. sub property_owner_code { } # ->property_owner_code must be implemented. 1
cooper/ferret
lib/F/PropertyOwner.pm
Perl
bsd-3-clause
547
###################################################################### # Copyright (c) 2012, Yahoo! Inc. All rights reserved. # # This program is free software. You may copy or redistribute it under # the same terms as Perl itself. Please see the LICENSE.Artistic file # included with this project for the terms of the Artistic License # under which this project is licensed. ###################################################################### #!/usr/bin/perl use strict; use warnings 'all'; use YAML qw(); use lib '/sysbuilder/lib'; use SysBuilder::Utils qw(run_local printbold); use SysBuilder::Network; my $cfg = YAML::LoadFile('/sysbuilder/etc/config.yaml'); my $dhclient = YAML::LoadFile('/sysbuilder/etc/dhclient.yaml'); my $net = SysBuilder::Network->new( cfg => $cfg ); my $err = 1; my $iface_name = $net->primary_iface; my $ntp_servers = $dhclient->{$iface_name}{ntp_servers}; if ($ntp_servers) { foreach my $server ( split ' ', $ntp_servers ) { $err = run_local("ntpdate $server"); last unless $err; } } unless ($err) { run_local("hwclock --systohc"); } # warn on ntp errors if we can't reach an ntp server. if ($err) { printbold("ALERT! no working ntp server found! Unable to set the correct date and time.\n"); } exit 0;
eam/ysysbuilder
steps/std-rhel/010_fix_clock.pl
Perl
bsd-3-clause
1,290
#ExStart:1 use lib 'lib'; use strict; use warnings; use utf8; use File::Slurp; # From CPAN use JSON; use AsposeStorageCloud::StorageApi; use AsposeStorageCloud::ApiClient; use AsposeStorageCloud::Configuration; use AsposeCellsCloud::CellsApi; use AsposeCellsCloud::ApiClient; use AsposeCellsCloud::Configuration; my $configFile = '../Config/config.json'; my $configPropsText = read_file($configFile); my $configProps = decode_json($configPropsText); my $data_path = '../../../Data/'; my $out_path = $configProps->{'out_folder'}; $AsposeCellsCloud::Configuration::app_sid = $configProps->{'app_sid'}; $AsposeCellsCloud::Configuration::api_key = $configProps->{'api_key'}; $AsposeCellsCloud::Configuration::debug = 1; $AsposeStorageCloud::Configuration::app_sid = $configProps->{'app_sid'}; $AsposeStorageCloud::Configuration::api_key = $configProps->{'api_key'}; # Instantiate Aspose.Storage and Aspose.Cells API SDK my $storageApi = AsposeStorageCloud::StorageApi->new(); my $cellsApi = AsposeCellsCloud::CellsApi->new(); # Set input file name my $name = 'Sample_Test_Book.xls'; my $sheetName = 'Sheet3'; # Upload file to aspose cloud storage my $response = $storageApi->PutCreate(Path => $name, file => $data_path.$name); # Invoke Aspose.Cells Cloud SDK API to remove a worksheet from a workbook $response = $cellsApi->DeleteWorksheet(name=> $name, sheetName=>$sheetName); if($response->{'Status'} eq 'OK'){ # Download updated Workbook from storage server my $output_file = $out_path. $name; $response = $storageApi->GetDownload(Path => $name);; write_file($output_file, { binmode => ":raw" }, $response->{'Content'}); } #ExEnd:1
aspose-cells/Aspose.Cells-for-Cloud
Examples/Perl/Worksheet/RemoveWorksheet.pl
Perl
mit
1,688
package VMOMI::GuestAuthManager; use parent 'VMOMI::ManagedObject'; use strict; use warnings; our @class_ancestors = ( 'ManagedObject', ); our @class_members = ( ); 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/GuestAuthManager.pm
Perl
apache-2.0
389
#!/usr/bin/perl ## This program is distributed under the free software ## licensing model. You have a right to use, modify and ## and redistribute this software in any way you like. ## This program is implemented by Anton Valouev, Ph.D. ## as a part of QuEST analytical pipeline. If you use ## this software as a part of another software or for publication ## purposes, you must cite the publication anouncing ## QuEST release: ## the citation goes here ## This program is a wrapper that runs peak_caller program ## on the entire genome one contig at a time use strict; use warnings; use diagnostics; my $usage = qq{ run_report_bad_control_regions_with_param_file.pl This program is a wrapper for the reprort_bad_control_regions executable ----------------------- mandatory parameters: -p <params_file> a file containing parameters calibrate_peak_shift ----------------------- optional parameters: -e <exec_path> path to the calibrate_peak_shift executable -h to display this help }; my $citation = qq{\#\# please cite: \#\# Valouev A, Johnson DS, Sundquist A, Medina C, Anton E, Batzoglou S, \#\# Myers RM, Sidow A. \#\# Genome-wide analysis of transcription factor binding sites based on \#\# ChIP-Seq data. \#\# Nat Methods 5, 829-834 (2008) }; if(scalar(@ARGV) == 0){ print $usage; exit(0); } ## mandatory argmuments my $params_fname = ""; ## /mandatory arguments ## setting optional arguments use Cwd qw(realpath); my $fullpath = realpath($0); my @fullpath_fields = split(/\//,$fullpath); my $exec_path = ""; for(my $i=0; $i<scalar(@fullpath_fields)-1; $i++){ if($fullpath_fields[$i] ne ""){ $exec_path = $exec_path."/".$fullpath_fields[$i]; } } $exec_path = $exec_path."/report_bad_control_regions"; ## /setting optional arguments ## reading arguments while(scalar(@ARGV) > 0){ my $this_arg = shift @ARGV; if ( $this_arg eq '-h') {die "$usage\n";} elsif ( $this_arg eq '-p') {$params_fname = shift @ARGV;} elsif ( $this_arg eq '-e') {$exec_path = shift @ARGV;} else{ print "Warning: unknown parameter: $this_arg\n"; } } my $die_pars_bad = "false"; ## die if parameters are bad my $bad_par = ""; ## store bad parameter here print "\n=====================\n\n"; print "mandatory parameters: \n\n"; print "params_file: $params_fname\n"; print "exec_path: $exec_path\n"; if( $params_fname eq ''){ $die_pars_bad = "true"; $bad_par." "."$params_fname"; } if( $exec_path eq ''){ $die_pars_bad = "true"; $bad_par." "."$exec_path"; } print "\n=====================\n\n"; if( $die_pars_bad eq "true"){ print "$usage"; print "Bad parameters: $bad_par\n"; exit(0); } ## /reading arguments ## top-level script open params_file, "< $params_fname" || die "$params_fname: $\n"; my @params = <params_file>; close params_file; my $missing = "** missing **"; my $background_score_path = $missing; my $output_fname = $missing; my $region_seeding_threshold = $missing; my $region_extension_threshold = $missing; my $score_normalizer = $missing; my $genome_table_fname = "** missing **"; for(my $i=0; $i<scalar(@params); $i++){ my $cur_param = $params[$i]; chomp($cur_param); my @cur_par_fields = split(/ /, $cur_param); if(scalar(@cur_par_fields >= 2)){ my $cur_par_name = $cur_par_fields[0]; if ($cur_par_name eq "background_score_path"){ $background_score_path = $cur_par_fields[2]; } elsif ($cur_par_name eq "output_file"){ $output_fname = $cur_par_fields[2]; } elsif ($cur_par_name eq "region_seeding_threshold"){ $region_seeding_threshold = $cur_par_fields[2]; } elsif ($cur_par_name eq "region_extension_threshold"){ $region_extension_threshold = $cur_par_fields[2]; } elsif($cur_par_name eq "genome_table"){ $genome_table_fname = $cur_par_fields[2]; } elsif ($cur_par_name eq "score_normalizer"){ $score_normalizer = $cur_par_fields[2]; } else{ if($params[$i] ne ""){ print "Warning: unrecognized parameter: $cur_par_name\n"; exit(1); } } } } print "Read the following parameters: \n\n"; print "background_score_path: $background_score_path\n"; print "output_file: $output_fname\n"; print "region_seeding_threshold: $region_seeding_threshold\n"; print "region_extension_threshold: $region_extension_threshold\n"; print "genome_table_file: $genome_table_fname\n"; print "score_normalizer: $score_normalizer\n"; print "\n"; #my $optional_param_string = ""; if($background_score_path eq "NA"){ if(-e $output_fname){ unlink($output_fname); } system("touch $output_fname"); } my @files_to_trash; my $files_to_trash_counter = 0; my @region_files; my $region_files_counter = 0; ## read genome table if( ! -e $genome_table_fname){ print "Error in run peak caller script: couldn't find genome table $genome_table_fname.\n"; print "Aborting.\n"; exit(0); } open genome_table_file, "< $genome_table_fname" || die "$genome_table_fname: $\n"; my @genome_table = <genome_table_file>; my @contigs; my $contig_counter = 0; for(my $i=0; $i<scalar(@genome_table); $i++){ my $cur_genome_table_entry = $genome_table[$i]; chomp($cur_genome_table_entry); my @cur_genome_table_entry_fields = split(/ /, $cur_genome_table_entry); if( scalar(@cur_genome_table_entry_fields) == 2){ $contigs[$contig_counter] = $cur_genome_table_entry_fields[0]; $contig_counter++; } } ## /read genome table for(my $i=0; $i<scalar(@contigs); $i++){ my $cur_contig = $contigs[$i]; my $system_command; my $cur_contig_regions_file = $output_fname . "." . $cur_contig . ".tmp"; $system_command = $exec_path . " score_file=$background_score_path/$cur_contig.score" . " output_file=$cur_contig_regions_file" . " region_seeding_threshold=$region_seeding_threshold" . " region_extension_threshold=$region_extension_threshold" . " score_normalizer=$score_normalizer" . " contig_id=$cur_contig"; print "\nsystem_command: $system_command\n"; $files_to_trash[$files_to_trash_counter] = $cur_contig_regions_file; $files_to_trash_counter++; $region_files[$region_files_counter] = $cur_contig_regions_file; $region_files_counter++; my $error_code = 0; $error_code = system("$system_command"); if($error_code != 0){ print "run_report_bad_control_regions_with_param_file.pl: Caught an error message (code $error_code), passing the error message to the top script.\n"; exit(2); } } # merging print "\n"; print "Merging artifactual regions into a single file\n"; my $cat_string = ""; # # #my $output_regions_fname = $output_fname_prefix; # . ".regions.no_metrics"; my $merged_regions_fname = $output_fname . ".tmp1"; my $sorted_regions_fname = $output_fname; #my $extended_tmp2_fname = $output_fname_prefix . ".tmp2"; #my $extended_tmp3_fname = $output_fname_prefix . ".tmp3"; $files_to_trash[$files_to_trash_counter] = $merged_regions_fname; $files_to_trash_counter++; if(-e $merged_regions_fname){ unlink($merged_regions_fname); } system("touch $merged_regions_fname"); #if(-e $extended_tmp1_fname){ # unlink($extended_tmp1_fname); #} #system("touch $extended_tmp1_fname"); # #if(-e $extended_tmp2_fname){ # unlink($extended_tmp2_fname); #} #system("touch $extended_tmp2_fname"); # #if(-e $extended_tmp3_fname){ # unlink($extended_tmp3_fname); #} #system("touch $extended_tmp3_fname"); for(my $i=0; $i<scalar(@region_files); $i++){ if($i!=0){ $cat_string = $cat_string . " "; } $cat_string = $cat_string . "$region_files[$i]"; } system("cat $cat_string > $merged_regions_fname"); # /merging # # sorting regions print "Sorting artifactual regions\n"; open sorted_regions_file, "> $sorted_regions_fname" or die "can't open $sorted_regions_fname: $!\n"; open merged_regions_file, "< $merged_regions_fname" or die "can't open $merged_regions_fname: $!\n"; my @regions; my $region_counter = 0; while(<merged_regions_file>){ my $cur_region = $_; if(length($cur_region) > 0){ if(substr($cur_region, 0, 1) eq "R"){ chomp($cur_region); my $cur_region_output_string = $cur_region; my @cur_region_entries = split(/ /, $cur_region); my $cur_region_max_score = $cur_region_entries[6]; # my $end_of_region_output_found = "false"; # while($end_of_region_output_found eq "false"){ # my $cur_peak = <extended_tmp1_file>; # if( length($cur_peak) > 0 ){ # if(substr($cur_peak, 0, 1) eq "P"){ # $cur_region_output_string = $cur_region_output_string . $cur_peak; # } # else{ # $end_of_region_output_found = "true"; # } # } # else{ # $end_of_region_output_found = "true"; # } # } # my $cur_region = { entry => $cur_region_output_string, score => $cur_region_max_score, }; $regions[$region_counter] = $cur_region; $region_counter++; } } } print "\nA total of $region_counter artifactual region(s) were detected from control data\n\n"; close merged_regions_file; my @regions_sorted = reverse sort{ $a->{score} <=> $b->{score} } @regions; for (my $i=0; $i<scalar(@regions_sorted); $i++){ printf sorted_regions_file "%s\n", $regions_sorted[$i]->{entry}; } close sorted_regions_file; # /sorting regions # adding count tags to the regions and peaks #open extended_tmp2_file, "< $extended_tmp2_fname" or die "can't open $extended_tmp2_fname: $!\n"; #open extended_tmp3_file, "> $extended_tmp3_fname" or die "can't open $extended_tmp3_fname: $!\n"; # #$region_counter = 1; #while(<extended_tmp2_file>){ # my $cur_region = $_; # if(length($cur_region) > 0){ # if(substr($cur_region, 0, 1) eq "R"){ # # chomp($cur_region); # my @cur_region_entries = split(/ /, $cur_region); # $cur_region_entries[0] = $cur_region_entries[0] . "-$region_counter"; # # for(my $i=0; $i<scalar(@cur_region_entries); $i++){ # if($i>0){ print extended_tmp3_file " "; } # print extended_tmp3_file "$cur_region_entries[$i]"; # } # print extended_tmp3_file "\n"; # # my $peak_counter = 1; # my $end_of_region_output_found = "false"; # while($end_of_region_output_found eq "false"){ # my $cur_peak = <extended_tmp2_file>; # chomp($cur_peak); # if( length($cur_peak) > 0 ){ # if(substr($cur_peak, 0, 1) eq "P"){ # my @cur_peak_entries = split(/ /, $cur_peak); # $cur_peak_entries[0] = $cur_peak_entries[0] . "-$region_counter-$peak_counter"; # $peak_counter++; # for(my $i=0; $i<scalar(@cur_peak_entries); $i++){ # if($i>0){ print extended_tmp3_file " "; } # print extended_tmp3_file "$cur_peak_entries[$i]"; # } # print extended_tmp3_file "\n"; # } # else{ # $end_of_region_output_found = "true"; # } # } # else{ # $end_of_region_output_found = "true"; # } # } # $region_counter++; # print extended_tmp3_file "\n"; # } # } #} # # /adding count tags to the regions and peaks #close extended_tmp2_file; #close extended_tmp3_file; # /sorting regions # output # #open output_regions_file, "> $output_regions_fname" or die "can't open $output_regions_fname: $!\n"; # #open extended_tmp3_file, "< $extended_tmp3_fname" or die "can't open $extended_tmp3_fname: $!\n"; # #my @peaks; #my $peak_count = 0; # #while(<extended_tmp3_file>){ # chomp; # # my $cur_entry = $_; # if(length($cur_entry) > 0){ # if(substr($cur_entry, 0, 1) eq "R" || substr($cur_entry, 0, 1) eq "P"){ # my @cur_entry_fields = split(/ /, $cur_entry); # if(scalar(@cur_entry_fields) >= 7){ # my $cur_ChIP_score = $cur_entry_fields[4]; # my $cur_control_score = $cur_entry_fields[6]; # # my $cur_ef = "inf"; # if($cur_control_score != 0 && $ChIP_reads > 0 && $background_reads > 0){ # $cur_ef = ($cur_ChIP_score/$ChIP_reads) / ($cur_control_score/$background_reads); # # printf output_regions_file "%s ef: %.3f\n", $cur_entry, $cur_ef; # } # else{ # $cur_ef = $cur_ChIP_score / $ChIP_basal_level; # } # printf output_regions_file "%s ef: %.3f\n", $cur_entry, $cur_ef; # } # # if(substr($cur_entry, 0, 1) eq "P"){ # my @cur_entry_fields = split(/ /, $cur_entry); # if(scalar(@cur_entry_fields) >= 7){ # my $cur_ChIP_score = $cur_entry_fields[4]; # my $cur_control_score = $cur_entry_fields[6]; # # my $cur_peak = { # entry => $cur_entry, # ChIP_score => $cur_ChIP_score, # control_score => $cur_control_score, # }; # $peaks[$peak_count] = $cur_peak; # $peak_count++; # } # else{ # print "Error: couldn't understand the peak entry:\n$cur_entry\n"; # print "Skipping\n\n"; # } # } # } # else{ print output_regions_file "$cur_entry\n"; } # } # else{ print output_regions_file "$cur_entry\n"; } #} # #close output_regions_file;# # #system("rm $extended_tmp1_fname"); #system("rm $extended_tmp2_fname"); #system("rm $extended_tmp3_fname"); print "Removing temporarary files.\n"; for(my $i=0; $i<scalar(@files_to_trash); $i++){ unlink($files_to_trash[$i]); } print "done\n";
verdurin/biobench2
QuEST/run_report_bad_control_regions_with_param_file.pl
Perl
apache-2.0
13,196
package VMOMI::HostFirewallSystem; use parent 'VMOMI::ExtensibleManagedObject'; use strict; use warnings; our @class_ancestors = ( 'ExtensibleManagedObject', 'ManagedObject', ); our @class_members = ( ['firewallInfo', 'HostFirewallInfo', 0, 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/HostFirewallSystem.pm
Perl
apache-2.0
479
# 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 /tmp/rnClxBLdxJ/northamerica. Olson data version 2013a # # Do not edit this file directly. # package DateTime::TimeZone::America::Vancouver; { $DateTime::TimeZone::America::Vancouver::VERSION = '1.57'; } use strict; use Class::Singleton 1.03; use DateTime::TimeZone; use DateTime::TimeZone::OlsonDB; @DateTime::TimeZone::America::Vancouver::ISA = ( 'Class::Singleton', 'DateTime::TimeZone' ); my $spans = [ [ DateTime::TimeZone::NEG_INFINITY, # utc_start 59421802348, # utc_end 1884-01-01 08:12:28 (Tue) DateTime::TimeZone::NEG_INFINITY, # local_start 59421772800, # local_end 1884-01-01 00:00:00 (Tue) -29548, 0, 'LMT', ], [ 59421802348, # utc_start 1884-01-01 08:12:28 (Tue) 60503623200, # utc_end 1918-04-14 10:00:00 (Sun) 59421773548, # local_start 1884-01-01 00:12:28 (Tue) 60503594400, # local_end 1918-04-14 02:00:00 (Sun) -28800, 0, 'PST', ], [ 60503623200, # utc_start 1918-04-14 10:00:00 (Sun) 60520554000, # utc_end 1918-10-27 09:00:00 (Sun) 60503598000, # local_start 1918-04-14 03:00:00 (Sun) 60520528800, # local_end 1918-10-27 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 60520554000, # utc_start 1918-10-27 09:00:00 (Sun) 61255476000, # utc_end 1942-02-09 10:00:00 (Mon) 60520525200, # local_start 1918-10-27 01:00:00 (Sun) 61255447200, # local_end 1942-02-09 02:00:00 (Mon) -28800, 0, 'PST', ], [ 61255476000, # utc_start 1942-02-09 10:00:00 (Mon) 61366287600, # utc_end 1945-08-14 23:00:00 (Tue) 61255450800, # local_start 1942-02-09 03:00:00 (Mon) 61366262400, # local_end 1945-08-14 16:00:00 (Tue) -25200, 1, 'PWT', ], [ 61366287600, # utc_start 1945-08-14 23:00:00 (Tue) 61370298000, # utc_end 1945-09-30 09:00:00 (Sun) 61366262400, # local_start 1945-08-14 16:00:00 (Tue) 61370272800, # local_end 1945-09-30 02:00:00 (Sun) -25200, 1, 'PPT', ], [ 61370298000, # utc_start 1945-09-30 09:00:00 (Sun) 61388445600, # utc_end 1946-04-28 10:00:00 (Sun) 61370269200, # local_start 1945-09-30 01:00:00 (Sun) 61388416800, # local_end 1946-04-28 02:00:00 (Sun) -28800, 0, 'PST', ], [ 61388445600, # utc_start 1946-04-28 10:00:00 (Sun) 61402957200, # utc_end 1946-10-13 09:00:00 (Sun) 61388420400, # local_start 1946-04-28 03:00:00 (Sun) 61402932000, # local_end 1946-10-13 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 61402957200, # utc_start 1946-10-13 09:00:00 (Sun) 61419895200, # utc_end 1947-04-27 10:00:00 (Sun) 61402928400, # local_start 1946-10-13 01:00:00 (Sun) 61419866400, # local_end 1947-04-27 02:00:00 (Sun) -28800, 0, 'PST', ], [ 61419895200, # utc_start 1947-04-27 10:00:00 (Sun) 61433197200, # utc_end 1947-09-28 09:00:00 (Sun) 61419870000, # local_start 1947-04-27 03:00:00 (Sun) 61433172000, # local_end 1947-09-28 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 61433197200, # utc_start 1947-09-28 09:00:00 (Sun) 61451344800, # utc_end 1948-04-25 10:00:00 (Sun) 61433168400, # local_start 1947-09-28 01:00:00 (Sun) 61451316000, # local_end 1948-04-25 02:00:00 (Sun) -28800, 0, 'PST', ], [ 61451344800, # utc_start 1948-04-25 10:00:00 (Sun) 61464646800, # utc_end 1948-09-26 09:00:00 (Sun) 61451319600, # local_start 1948-04-25 03:00:00 (Sun) 61464621600, # local_end 1948-09-26 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 61464646800, # utc_start 1948-09-26 09:00:00 (Sun) 61482794400, # utc_end 1949-04-24 10:00:00 (Sun) 61464618000, # local_start 1948-09-26 01:00:00 (Sun) 61482765600, # local_end 1949-04-24 02:00:00 (Sun) -28800, 0, 'PST', ], [ 61482794400, # utc_start 1949-04-24 10:00:00 (Sun) 61496096400, # utc_end 1949-09-25 09:00:00 (Sun) 61482769200, # local_start 1949-04-24 03:00:00 (Sun) 61496071200, # local_end 1949-09-25 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 61496096400, # utc_start 1949-09-25 09:00:00 (Sun) 61514848800, # utc_end 1950-04-30 10:00:00 (Sun) 61496067600, # local_start 1949-09-25 01:00:00 (Sun) 61514820000, # local_end 1950-04-30 02:00:00 (Sun) -28800, 0, 'PST', ], [ 61514848800, # utc_start 1950-04-30 10:00:00 (Sun) 61527546000, # utc_end 1950-09-24 09:00:00 (Sun) 61514823600, # local_start 1950-04-30 03:00:00 (Sun) 61527520800, # local_end 1950-09-24 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 61527546000, # utc_start 1950-09-24 09:00:00 (Sun) 61546298400, # utc_end 1951-04-29 10:00:00 (Sun) 61527517200, # local_start 1950-09-24 01:00:00 (Sun) 61546269600, # local_end 1951-04-29 02:00:00 (Sun) -28800, 0, 'PST', ], [ 61546298400, # utc_start 1951-04-29 10:00:00 (Sun) 61559600400, # utc_end 1951-09-30 09:00:00 (Sun) 61546273200, # local_start 1951-04-29 03:00:00 (Sun) 61559575200, # local_end 1951-09-30 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 61559600400, # utc_start 1951-09-30 09:00:00 (Sun) 61577748000, # utc_end 1952-04-27 10:00:00 (Sun) 61559571600, # local_start 1951-09-30 01:00:00 (Sun) 61577719200, # local_end 1952-04-27 02:00:00 (Sun) -28800, 0, 'PST', ], [ 61577748000, # utc_start 1952-04-27 10:00:00 (Sun) 61591050000, # utc_end 1952-09-28 09:00:00 (Sun) 61577722800, # local_start 1952-04-27 03:00:00 (Sun) 61591024800, # local_end 1952-09-28 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 61591050000, # utc_start 1952-09-28 09:00:00 (Sun) 61609197600, # utc_end 1953-04-26 10:00:00 (Sun) 61591021200, # local_start 1952-09-28 01:00:00 (Sun) 61609168800, # local_end 1953-04-26 02:00:00 (Sun) -28800, 0, 'PST', ], [ 61609197600, # utc_start 1953-04-26 10:00:00 (Sun) 61622499600, # utc_end 1953-09-27 09:00:00 (Sun) 61609172400, # local_start 1953-04-26 03:00:00 (Sun) 61622474400, # local_end 1953-09-27 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 61622499600, # utc_start 1953-09-27 09:00:00 (Sun) 61640647200, # utc_end 1954-04-25 10:00:00 (Sun) 61622470800, # local_start 1953-09-27 01:00:00 (Sun) 61640618400, # local_end 1954-04-25 02:00:00 (Sun) -28800, 0, 'PST', ], [ 61640647200, # utc_start 1954-04-25 10:00:00 (Sun) 61653949200, # utc_end 1954-09-26 09:00:00 (Sun) 61640622000, # local_start 1954-04-25 03:00:00 (Sun) 61653924000, # local_end 1954-09-26 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 61653949200, # utc_start 1954-09-26 09:00:00 (Sun) 61672096800, # utc_end 1955-04-24 10:00:00 (Sun) 61653920400, # local_start 1954-09-26 01:00:00 (Sun) 61672068000, # local_end 1955-04-24 02:00:00 (Sun) -28800, 0, 'PST', ], [ 61672096800, # utc_start 1955-04-24 10:00:00 (Sun) 61685398800, # utc_end 1955-09-25 09:00:00 (Sun) 61672071600, # local_start 1955-04-24 03:00:00 (Sun) 61685373600, # local_end 1955-09-25 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 61685398800, # utc_start 1955-09-25 09:00:00 (Sun) 61704151200, # utc_end 1956-04-29 10:00:00 (Sun) 61685370000, # local_start 1955-09-25 01:00:00 (Sun) 61704122400, # local_end 1956-04-29 02:00:00 (Sun) -28800, 0, 'PST', ], [ 61704151200, # utc_start 1956-04-29 10:00:00 (Sun) 61717453200, # utc_end 1956-09-30 09:00:00 (Sun) 61704126000, # local_start 1956-04-29 03:00:00 (Sun) 61717428000, # local_end 1956-09-30 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 61717453200, # utc_start 1956-09-30 09:00:00 (Sun) 61735600800, # utc_end 1957-04-28 10:00:00 (Sun) 61717424400, # local_start 1956-09-30 01:00:00 (Sun) 61735572000, # local_end 1957-04-28 02:00:00 (Sun) -28800, 0, 'PST', ], [ 61735600800, # utc_start 1957-04-28 10:00:00 (Sun) 61748902800, # utc_end 1957-09-29 09:00:00 (Sun) 61735575600, # local_start 1957-04-28 03:00:00 (Sun) 61748877600, # local_end 1957-09-29 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 61748902800, # utc_start 1957-09-29 09:00:00 (Sun) 61767050400, # utc_end 1958-04-27 10:00:00 (Sun) 61748874000, # local_start 1957-09-29 01:00:00 (Sun) 61767021600, # local_end 1958-04-27 02:00:00 (Sun) -28800, 0, 'PST', ], [ 61767050400, # utc_start 1958-04-27 10:00:00 (Sun) 61780352400, # utc_end 1958-09-28 09:00:00 (Sun) 61767025200, # local_start 1958-04-27 03:00:00 (Sun) 61780327200, # local_end 1958-09-28 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 61780352400, # utc_start 1958-09-28 09:00:00 (Sun) 61798500000, # utc_end 1959-04-26 10:00:00 (Sun) 61780323600, # local_start 1958-09-28 01:00:00 (Sun) 61798471200, # local_end 1959-04-26 02:00:00 (Sun) -28800, 0, 'PST', ], [ 61798500000, # utc_start 1959-04-26 10:00:00 (Sun) 61811802000, # utc_end 1959-09-27 09:00:00 (Sun) 61798474800, # local_start 1959-04-26 03:00:00 (Sun) 61811776800, # local_end 1959-09-27 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 61811802000, # utc_start 1959-09-27 09:00:00 (Sun) 61829949600, # utc_end 1960-04-24 10:00:00 (Sun) 61811773200, # local_start 1959-09-27 01:00:00 (Sun) 61829920800, # local_end 1960-04-24 02:00:00 (Sun) -28800, 0, 'PST', ], [ 61829949600, # utc_start 1960-04-24 10:00:00 (Sun) 61843251600, # utc_end 1960-09-25 09:00:00 (Sun) 61829924400, # local_start 1960-04-24 03:00:00 (Sun) 61843226400, # local_end 1960-09-25 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 61843251600, # utc_start 1960-09-25 09:00:00 (Sun) 61862004000, # utc_end 1961-04-30 10:00:00 (Sun) 61843222800, # local_start 1960-09-25 01:00:00 (Sun) 61861975200, # local_end 1961-04-30 02:00:00 (Sun) -28800, 0, 'PST', ], [ 61862004000, # utc_start 1961-04-30 10:00:00 (Sun) 61874701200, # utc_end 1961-09-24 09:00:00 (Sun) 61861978800, # local_start 1961-04-30 03:00:00 (Sun) 61874676000, # local_end 1961-09-24 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 61874701200, # utc_start 1961-09-24 09:00:00 (Sun) 61893453600, # utc_end 1962-04-29 10:00:00 (Sun) 61874672400, # local_start 1961-09-24 01:00:00 (Sun) 61893424800, # local_end 1962-04-29 02:00:00 (Sun) -28800, 0, 'PST', ], [ 61893453600, # utc_start 1962-04-29 10:00:00 (Sun) 61909174800, # utc_end 1962-10-28 09:00:00 (Sun) 61893428400, # local_start 1962-04-29 03:00:00 (Sun) 61909149600, # local_end 1962-10-28 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 61909174800, # utc_start 1962-10-28 09:00:00 (Sun) 61924903200, # utc_end 1963-04-28 10:00:00 (Sun) 61909146000, # local_start 1962-10-28 01:00:00 (Sun) 61924874400, # local_end 1963-04-28 02:00:00 (Sun) -28800, 0, 'PST', ], [ 61924903200, # utc_start 1963-04-28 10:00:00 (Sun) 61940624400, # utc_end 1963-10-27 09:00:00 (Sun) 61924878000, # local_start 1963-04-28 03:00:00 (Sun) 61940599200, # local_end 1963-10-27 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 61940624400, # utc_start 1963-10-27 09:00:00 (Sun) 61956352800, # utc_end 1964-04-26 10:00:00 (Sun) 61940595600, # local_start 1963-10-27 01:00:00 (Sun) 61956324000, # local_end 1964-04-26 02:00:00 (Sun) -28800, 0, 'PST', ], [ 61956352800, # utc_start 1964-04-26 10:00:00 (Sun) 61972074000, # utc_end 1964-10-25 09:00:00 (Sun) 61956327600, # local_start 1964-04-26 03:00:00 (Sun) 61972048800, # local_end 1964-10-25 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 61972074000, # utc_start 1964-10-25 09:00:00 (Sun) 61987802400, # utc_end 1965-04-25 10:00:00 (Sun) 61972045200, # local_start 1964-10-25 01:00:00 (Sun) 61987773600, # local_end 1965-04-25 02:00:00 (Sun) -28800, 0, 'PST', ], [ 61987802400, # utc_start 1965-04-25 10:00:00 (Sun) 62004128400, # utc_end 1965-10-31 09:00:00 (Sun) 61987777200, # local_start 1965-04-25 03:00:00 (Sun) 62004103200, # local_end 1965-10-31 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 62004128400, # utc_start 1965-10-31 09:00:00 (Sun) 62019252000, # utc_end 1966-04-24 10:00:00 (Sun) 62004099600, # local_start 1965-10-31 01:00:00 (Sun) 62019223200, # local_end 1966-04-24 02:00:00 (Sun) -28800, 0, 'PST', ], [ 62019252000, # utc_start 1966-04-24 10:00:00 (Sun) 62035578000, # utc_end 1966-10-30 09:00:00 (Sun) 62019226800, # local_start 1966-04-24 03:00:00 (Sun) 62035552800, # local_end 1966-10-30 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 62035578000, # utc_start 1966-10-30 09:00:00 (Sun) 62051306400, # utc_end 1967-04-30 10:00:00 (Sun) 62035549200, # local_start 1966-10-30 01:00:00 (Sun) 62051277600, # local_end 1967-04-30 02:00:00 (Sun) -28800, 0, 'PST', ], [ 62051306400, # utc_start 1967-04-30 10:00:00 (Sun) 62067027600, # utc_end 1967-10-29 09:00:00 (Sun) 62051281200, # local_start 1967-04-30 03:00:00 (Sun) 62067002400, # local_end 1967-10-29 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 62067027600, # utc_start 1967-10-29 09:00:00 (Sun) 62082756000, # utc_end 1968-04-28 10:00:00 (Sun) 62066998800, # local_start 1967-10-29 01:00:00 (Sun) 62082727200, # local_end 1968-04-28 02:00:00 (Sun) -28800, 0, 'PST', ], [ 62082756000, # utc_start 1968-04-28 10:00:00 (Sun) 62098477200, # utc_end 1968-10-27 09:00:00 (Sun) 62082730800, # local_start 1968-04-28 03:00:00 (Sun) 62098452000, # local_end 1968-10-27 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 62098477200, # utc_start 1968-10-27 09:00:00 (Sun) 62114205600, # utc_end 1969-04-27 10:00:00 (Sun) 62098448400, # local_start 1968-10-27 01:00:00 (Sun) 62114176800, # local_end 1969-04-27 02:00:00 (Sun) -28800, 0, 'PST', ], [ 62114205600, # utc_start 1969-04-27 10:00:00 (Sun) 62129926800, # utc_end 1969-10-26 09:00:00 (Sun) 62114180400, # local_start 1969-04-27 03:00:00 (Sun) 62129901600, # local_end 1969-10-26 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 62129926800, # utc_start 1969-10-26 09:00:00 (Sun) 62145655200, # utc_end 1970-04-26 10:00:00 (Sun) 62129898000, # local_start 1969-10-26 01:00:00 (Sun) 62145626400, # local_end 1970-04-26 02:00:00 (Sun) -28800, 0, 'PST', ], [ 62145655200, # utc_start 1970-04-26 10:00:00 (Sun) 62161376400, # utc_end 1970-10-25 09:00:00 (Sun) 62145630000, # local_start 1970-04-26 03:00:00 (Sun) 62161351200, # local_end 1970-10-25 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 62161376400, # utc_start 1970-10-25 09:00:00 (Sun) 62177104800, # utc_end 1971-04-25 10:00:00 (Sun) 62161347600, # local_start 1970-10-25 01:00:00 (Sun) 62177076000, # local_end 1971-04-25 02:00:00 (Sun) -28800, 0, 'PST', ], [ 62177104800, # utc_start 1971-04-25 10:00:00 (Sun) 62193430800, # utc_end 1971-10-31 09:00:00 (Sun) 62177079600, # local_start 1971-04-25 03:00:00 (Sun) 62193405600, # local_end 1971-10-31 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 62193430800, # utc_start 1971-10-31 09:00:00 (Sun) 62209159200, # utc_end 1972-04-30 10:00:00 (Sun) 62193402000, # local_start 1971-10-31 01:00:00 (Sun) 62209130400, # local_end 1972-04-30 02:00:00 (Sun) -28800, 0, 'PST', ], [ 62209159200, # utc_start 1972-04-30 10:00:00 (Sun) 62224880400, # utc_end 1972-10-29 09:00:00 (Sun) 62209134000, # local_start 1972-04-30 03:00:00 (Sun) 62224855200, # local_end 1972-10-29 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 62224880400, # utc_start 1972-10-29 09:00:00 (Sun) 62240608800, # utc_end 1973-04-29 10:00:00 (Sun) 62224851600, # local_start 1972-10-29 01:00:00 (Sun) 62240580000, # local_end 1973-04-29 02:00:00 (Sun) -28800, 0, 'PST', ], [ 62240608800, # utc_start 1973-04-29 10:00:00 (Sun) 62256330000, # utc_end 1973-10-28 09:00:00 (Sun) 62240583600, # local_start 1973-04-29 03:00:00 (Sun) 62256304800, # local_end 1973-10-28 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 62256330000, # utc_start 1973-10-28 09:00:00 (Sun) 62272058400, # utc_end 1974-04-28 10:00:00 (Sun) 62256301200, # local_start 1973-10-28 01:00:00 (Sun) 62272029600, # local_end 1974-04-28 02:00:00 (Sun) -28800, 0, 'PST', ], [ 62272058400, # utc_start 1974-04-28 10:00:00 (Sun) 62287779600, # utc_end 1974-10-27 09:00:00 (Sun) 62272033200, # local_start 1974-04-28 03:00:00 (Sun) 62287754400, # local_end 1974-10-27 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 62287779600, # utc_start 1974-10-27 09:00:00 (Sun) 62303508000, # utc_end 1975-04-27 10:00:00 (Sun) 62287750800, # local_start 1974-10-27 01:00:00 (Sun) 62303479200, # local_end 1975-04-27 02:00:00 (Sun) -28800, 0, 'PST', ], [ 62303508000, # utc_start 1975-04-27 10:00:00 (Sun) 62319229200, # utc_end 1975-10-26 09:00:00 (Sun) 62303482800, # local_start 1975-04-27 03:00:00 (Sun) 62319204000, # local_end 1975-10-26 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 62319229200, # utc_start 1975-10-26 09:00:00 (Sun) 62334957600, # utc_end 1976-04-25 10:00:00 (Sun) 62319200400, # local_start 1975-10-26 01:00:00 (Sun) 62334928800, # local_end 1976-04-25 02:00:00 (Sun) -28800, 0, 'PST', ], [ 62334957600, # utc_start 1976-04-25 10:00:00 (Sun) 62351283600, # utc_end 1976-10-31 09:00:00 (Sun) 62334932400, # local_start 1976-04-25 03:00:00 (Sun) 62351258400, # local_end 1976-10-31 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 62351283600, # utc_start 1976-10-31 09:00:00 (Sun) 62366407200, # utc_end 1977-04-24 10:00:00 (Sun) 62351254800, # local_start 1976-10-31 01:00:00 (Sun) 62366378400, # local_end 1977-04-24 02:00:00 (Sun) -28800, 0, 'PST', ], [ 62366407200, # utc_start 1977-04-24 10:00:00 (Sun) 62382733200, # utc_end 1977-10-30 09:00:00 (Sun) 62366382000, # local_start 1977-04-24 03:00:00 (Sun) 62382708000, # local_end 1977-10-30 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 62382733200, # utc_start 1977-10-30 09:00:00 (Sun) 62398461600, # utc_end 1978-04-30 10:00:00 (Sun) 62382704400, # local_start 1977-10-30 01:00:00 (Sun) 62398432800, # local_end 1978-04-30 02:00:00 (Sun) -28800, 0, 'PST', ], [ 62398461600, # utc_start 1978-04-30 10:00:00 (Sun) 62414182800, # utc_end 1978-10-29 09:00:00 (Sun) 62398436400, # local_start 1978-04-30 03:00:00 (Sun) 62414157600, # local_end 1978-10-29 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 62414182800, # utc_start 1978-10-29 09:00:00 (Sun) 62429911200, # utc_end 1979-04-29 10:00:00 (Sun) 62414154000, # local_start 1978-10-29 01:00:00 (Sun) 62429882400, # local_end 1979-04-29 02:00:00 (Sun) -28800, 0, 'PST', ], [ 62429911200, # utc_start 1979-04-29 10:00:00 (Sun) 62445632400, # utc_end 1979-10-28 09:00:00 (Sun) 62429886000, # local_start 1979-04-29 03:00:00 (Sun) 62445607200, # local_end 1979-10-28 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 62445632400, # utc_start 1979-10-28 09:00:00 (Sun) 62461360800, # utc_end 1980-04-27 10:00:00 (Sun) 62445603600, # local_start 1979-10-28 01:00:00 (Sun) 62461332000, # local_end 1980-04-27 02:00:00 (Sun) -28800, 0, 'PST', ], [ 62461360800, # utc_start 1980-04-27 10:00:00 (Sun) 62477082000, # utc_end 1980-10-26 09:00:00 (Sun) 62461335600, # local_start 1980-04-27 03:00:00 (Sun) 62477056800, # local_end 1980-10-26 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 62477082000, # utc_start 1980-10-26 09:00:00 (Sun) 62492810400, # utc_end 1981-04-26 10:00:00 (Sun) 62477053200, # local_start 1980-10-26 01:00:00 (Sun) 62492781600, # local_end 1981-04-26 02:00:00 (Sun) -28800, 0, 'PST', ], [ 62492810400, # utc_start 1981-04-26 10:00:00 (Sun) 62508531600, # utc_end 1981-10-25 09:00:00 (Sun) 62492785200, # local_start 1981-04-26 03:00:00 (Sun) 62508506400, # local_end 1981-10-25 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 62508531600, # utc_start 1981-10-25 09:00:00 (Sun) 62524260000, # utc_end 1982-04-25 10:00:00 (Sun) 62508502800, # local_start 1981-10-25 01:00:00 (Sun) 62524231200, # local_end 1982-04-25 02:00:00 (Sun) -28800, 0, 'PST', ], [ 62524260000, # utc_start 1982-04-25 10:00:00 (Sun) 62540586000, # utc_end 1982-10-31 09:00:00 (Sun) 62524234800, # local_start 1982-04-25 03:00:00 (Sun) 62540560800, # local_end 1982-10-31 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 62540586000, # utc_start 1982-10-31 09:00:00 (Sun) 62555709600, # utc_end 1983-04-24 10:00:00 (Sun) 62540557200, # local_start 1982-10-31 01:00:00 (Sun) 62555680800, # local_end 1983-04-24 02:00:00 (Sun) -28800, 0, 'PST', ], [ 62555709600, # utc_start 1983-04-24 10:00:00 (Sun) 62572035600, # utc_end 1983-10-30 09:00:00 (Sun) 62555684400, # local_start 1983-04-24 03:00:00 (Sun) 62572010400, # local_end 1983-10-30 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 62572035600, # utc_start 1983-10-30 09:00:00 (Sun) 62587764000, # utc_end 1984-04-29 10:00:00 (Sun) 62572006800, # local_start 1983-10-30 01:00:00 (Sun) 62587735200, # local_end 1984-04-29 02:00:00 (Sun) -28800, 0, 'PST', ], [ 62587764000, # utc_start 1984-04-29 10:00:00 (Sun) 62603485200, # utc_end 1984-10-28 09:00:00 (Sun) 62587738800, # local_start 1984-04-29 03:00:00 (Sun) 62603460000, # local_end 1984-10-28 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 62603485200, # utc_start 1984-10-28 09:00:00 (Sun) 62619213600, # utc_end 1985-04-28 10:00:00 (Sun) 62603456400, # local_start 1984-10-28 01:00:00 (Sun) 62619184800, # local_end 1985-04-28 02:00:00 (Sun) -28800, 0, 'PST', ], [ 62619213600, # utc_start 1985-04-28 10:00:00 (Sun) 62634934800, # utc_end 1985-10-27 09:00:00 (Sun) 62619188400, # local_start 1985-04-28 03:00:00 (Sun) 62634909600, # local_end 1985-10-27 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 62634934800, # utc_start 1985-10-27 09:00:00 (Sun) 62650663200, # utc_end 1986-04-27 10:00:00 (Sun) 62634906000, # local_start 1985-10-27 01:00:00 (Sun) 62650634400, # local_end 1986-04-27 02:00:00 (Sun) -28800, 0, 'PST', ], [ 62650663200, # utc_start 1986-04-27 10:00:00 (Sun) 62666384400, # utc_end 1986-10-26 09:00:00 (Sun) 62650638000, # local_start 1986-04-27 03:00:00 (Sun) 62666359200, # local_end 1986-10-26 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 62666384400, # utc_start 1986-10-26 09:00:00 (Sun) 62672169600, # utc_end 1987-01-01 08:00:00 (Thu) 62666355600, # local_start 1986-10-26 01:00:00 (Sun) 62672140800, # local_end 1987-01-01 00:00:00 (Thu) -28800, 0, 'PST', ], [ 62672169600, # utc_start 1987-01-01 08:00:00 (Thu) 62680298400, # utc_end 1987-04-05 10:00:00 (Sun) 62672140800, # local_start 1987-01-01 00:00:00 (Thu) 62680269600, # local_end 1987-04-05 02:00:00 (Sun) -28800, 0, 'PST', ], [ 62680298400, # utc_start 1987-04-05 10:00:00 (Sun) 62697834000, # utc_end 1987-10-25 09:00:00 (Sun) 62680273200, # local_start 1987-04-05 03:00:00 (Sun) 62697808800, # local_end 1987-10-25 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 62697834000, # utc_start 1987-10-25 09:00:00 (Sun) 62711748000, # utc_end 1988-04-03 10:00:00 (Sun) 62697805200, # local_start 1987-10-25 01:00:00 (Sun) 62711719200, # local_end 1988-04-03 02:00:00 (Sun) -28800, 0, 'PST', ], [ 62711748000, # utc_start 1988-04-03 10:00:00 (Sun) 62729888400, # utc_end 1988-10-30 09:00:00 (Sun) 62711722800, # local_start 1988-04-03 03:00:00 (Sun) 62729863200, # local_end 1988-10-30 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 62729888400, # utc_start 1988-10-30 09:00:00 (Sun) 62743197600, # utc_end 1989-04-02 10:00:00 (Sun) 62729859600, # local_start 1988-10-30 01:00:00 (Sun) 62743168800, # local_end 1989-04-02 02:00:00 (Sun) -28800, 0, 'PST', ], [ 62743197600, # utc_start 1989-04-02 10:00:00 (Sun) 62761338000, # utc_end 1989-10-29 09:00:00 (Sun) 62743172400, # local_start 1989-04-02 03:00:00 (Sun) 62761312800, # local_end 1989-10-29 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 62761338000, # utc_start 1989-10-29 09:00:00 (Sun) 62774647200, # utc_end 1990-04-01 10:00:00 (Sun) 62761309200, # local_start 1989-10-29 01:00:00 (Sun) 62774618400, # local_end 1990-04-01 02:00:00 (Sun) -28800, 0, 'PST', ], [ 62774647200, # utc_start 1990-04-01 10:00:00 (Sun) 62792787600, # utc_end 1990-10-28 09:00:00 (Sun) 62774622000, # local_start 1990-04-01 03:00:00 (Sun) 62792762400, # local_end 1990-10-28 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 62792787600, # utc_start 1990-10-28 09:00:00 (Sun) 62806701600, # utc_end 1991-04-07 10:00:00 (Sun) 62792758800, # local_start 1990-10-28 01:00:00 (Sun) 62806672800, # local_end 1991-04-07 02:00:00 (Sun) -28800, 0, 'PST', ], [ 62806701600, # utc_start 1991-04-07 10:00:00 (Sun) 62824237200, # utc_end 1991-10-27 09:00:00 (Sun) 62806676400, # local_start 1991-04-07 03:00:00 (Sun) 62824212000, # local_end 1991-10-27 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 62824237200, # utc_start 1991-10-27 09:00:00 (Sun) 62838151200, # utc_end 1992-04-05 10:00:00 (Sun) 62824208400, # local_start 1991-10-27 01:00:00 (Sun) 62838122400, # local_end 1992-04-05 02:00:00 (Sun) -28800, 0, 'PST', ], [ 62838151200, # utc_start 1992-04-05 10:00:00 (Sun) 62855686800, # utc_end 1992-10-25 09:00:00 (Sun) 62838126000, # local_start 1992-04-05 03:00:00 (Sun) 62855661600, # local_end 1992-10-25 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 62855686800, # utc_start 1992-10-25 09:00:00 (Sun) 62869600800, # utc_end 1993-04-04 10:00:00 (Sun) 62855658000, # local_start 1992-10-25 01:00:00 (Sun) 62869572000, # local_end 1993-04-04 02:00:00 (Sun) -28800, 0, 'PST', ], [ 62869600800, # utc_start 1993-04-04 10:00:00 (Sun) 62887741200, # utc_end 1993-10-31 09:00:00 (Sun) 62869575600, # local_start 1993-04-04 03:00:00 (Sun) 62887716000, # local_end 1993-10-31 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 62887741200, # utc_start 1993-10-31 09:00:00 (Sun) 62901050400, # utc_end 1994-04-03 10:00:00 (Sun) 62887712400, # local_start 1993-10-31 01:00:00 (Sun) 62901021600, # local_end 1994-04-03 02:00:00 (Sun) -28800, 0, 'PST', ], [ 62901050400, # utc_start 1994-04-03 10:00:00 (Sun) 62919190800, # utc_end 1994-10-30 09:00:00 (Sun) 62901025200, # local_start 1994-04-03 03:00:00 (Sun) 62919165600, # local_end 1994-10-30 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 62919190800, # utc_start 1994-10-30 09:00:00 (Sun) 62932500000, # utc_end 1995-04-02 10:00:00 (Sun) 62919162000, # local_start 1994-10-30 01:00:00 (Sun) 62932471200, # local_end 1995-04-02 02:00:00 (Sun) -28800, 0, 'PST', ], [ 62932500000, # utc_start 1995-04-02 10:00:00 (Sun) 62950640400, # utc_end 1995-10-29 09:00:00 (Sun) 62932474800, # local_start 1995-04-02 03:00:00 (Sun) 62950615200, # local_end 1995-10-29 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 62950640400, # utc_start 1995-10-29 09:00:00 (Sun) 62964554400, # utc_end 1996-04-07 10:00:00 (Sun) 62950611600, # local_start 1995-10-29 01:00:00 (Sun) 62964525600, # local_end 1996-04-07 02:00:00 (Sun) -28800, 0, 'PST', ], [ 62964554400, # utc_start 1996-04-07 10:00:00 (Sun) 62982090000, # utc_end 1996-10-27 09:00:00 (Sun) 62964529200, # local_start 1996-04-07 03:00:00 (Sun) 62982064800, # local_end 1996-10-27 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 62982090000, # utc_start 1996-10-27 09:00:00 (Sun) 62996004000, # utc_end 1997-04-06 10:00:00 (Sun) 62982061200, # local_start 1996-10-27 01:00:00 (Sun) 62995975200, # local_end 1997-04-06 02:00:00 (Sun) -28800, 0, 'PST', ], [ 62996004000, # utc_start 1997-04-06 10:00:00 (Sun) 63013539600, # utc_end 1997-10-26 09:00:00 (Sun) 62995978800, # local_start 1997-04-06 03:00:00 (Sun) 63013514400, # local_end 1997-10-26 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 63013539600, # utc_start 1997-10-26 09:00:00 (Sun) 63027453600, # utc_end 1998-04-05 10:00:00 (Sun) 63013510800, # local_start 1997-10-26 01:00:00 (Sun) 63027424800, # local_end 1998-04-05 02:00:00 (Sun) -28800, 0, 'PST', ], [ 63027453600, # utc_start 1998-04-05 10:00:00 (Sun) 63044989200, # utc_end 1998-10-25 09:00:00 (Sun) 63027428400, # local_start 1998-04-05 03:00:00 (Sun) 63044964000, # local_end 1998-10-25 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 63044989200, # utc_start 1998-10-25 09:00:00 (Sun) 63058903200, # utc_end 1999-04-04 10:00:00 (Sun) 63044960400, # local_start 1998-10-25 01:00:00 (Sun) 63058874400, # local_end 1999-04-04 02:00:00 (Sun) -28800, 0, 'PST', ], [ 63058903200, # utc_start 1999-04-04 10:00:00 (Sun) 63077043600, # utc_end 1999-10-31 09:00:00 (Sun) 63058878000, # local_start 1999-04-04 03:00:00 (Sun) 63077018400, # local_end 1999-10-31 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 63077043600, # utc_start 1999-10-31 09:00:00 (Sun) 63090352800, # utc_end 2000-04-02 10:00:00 (Sun) 63077014800, # local_start 1999-10-31 01:00:00 (Sun) 63090324000, # local_end 2000-04-02 02:00:00 (Sun) -28800, 0, 'PST', ], [ 63090352800, # utc_start 2000-04-02 10:00:00 (Sun) 63108493200, # utc_end 2000-10-29 09:00:00 (Sun) 63090327600, # local_start 2000-04-02 03:00:00 (Sun) 63108468000, # local_end 2000-10-29 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 63108493200, # utc_start 2000-10-29 09:00:00 (Sun) 63121802400, # utc_end 2001-04-01 10:00:00 (Sun) 63108464400, # local_start 2000-10-29 01:00:00 (Sun) 63121773600, # local_end 2001-04-01 02:00:00 (Sun) -28800, 0, 'PST', ], [ 63121802400, # utc_start 2001-04-01 10:00:00 (Sun) 63139942800, # utc_end 2001-10-28 09:00:00 (Sun) 63121777200, # local_start 2001-04-01 03:00:00 (Sun) 63139917600, # local_end 2001-10-28 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 63139942800, # utc_start 2001-10-28 09:00:00 (Sun) 63153856800, # utc_end 2002-04-07 10:00:00 (Sun) 63139914000, # local_start 2001-10-28 01:00:00 (Sun) 63153828000, # local_end 2002-04-07 02:00:00 (Sun) -28800, 0, 'PST', ], [ 63153856800, # utc_start 2002-04-07 10:00:00 (Sun) 63171392400, # utc_end 2002-10-27 09:00:00 (Sun) 63153831600, # local_start 2002-04-07 03:00:00 (Sun) 63171367200, # local_end 2002-10-27 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 63171392400, # utc_start 2002-10-27 09:00:00 (Sun) 63185306400, # utc_end 2003-04-06 10:00:00 (Sun) 63171363600, # local_start 2002-10-27 01:00:00 (Sun) 63185277600, # local_end 2003-04-06 02:00:00 (Sun) -28800, 0, 'PST', ], [ 63185306400, # utc_start 2003-04-06 10:00:00 (Sun) 63202842000, # utc_end 2003-10-26 09:00:00 (Sun) 63185281200, # local_start 2003-04-06 03:00:00 (Sun) 63202816800, # local_end 2003-10-26 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 63202842000, # utc_start 2003-10-26 09:00:00 (Sun) 63216756000, # utc_end 2004-04-04 10:00:00 (Sun) 63202813200, # local_start 2003-10-26 01:00:00 (Sun) 63216727200, # local_end 2004-04-04 02:00:00 (Sun) -28800, 0, 'PST', ], [ 63216756000, # utc_start 2004-04-04 10:00:00 (Sun) 63234896400, # utc_end 2004-10-31 09:00:00 (Sun) 63216730800, # local_start 2004-04-04 03:00:00 (Sun) 63234871200, # local_end 2004-10-31 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 63234896400, # utc_start 2004-10-31 09:00:00 (Sun) 63248205600, # utc_end 2005-04-03 10:00:00 (Sun) 63234867600, # local_start 2004-10-31 01:00:00 (Sun) 63248176800, # local_end 2005-04-03 02:00:00 (Sun) -28800, 0, 'PST', ], [ 63248205600, # utc_start 2005-04-03 10:00:00 (Sun) 63266346000, # utc_end 2005-10-30 09:00:00 (Sun) 63248180400, # local_start 2005-04-03 03:00:00 (Sun) 63266320800, # local_end 2005-10-30 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 63266346000, # utc_start 2005-10-30 09:00:00 (Sun) 63279655200, # utc_end 2006-04-02 10:00:00 (Sun) 63266317200, # local_start 2005-10-30 01:00:00 (Sun) 63279626400, # local_end 2006-04-02 02:00:00 (Sun) -28800, 0, 'PST', ], [ 63279655200, # utc_start 2006-04-02 10:00:00 (Sun) 63297795600, # utc_end 2006-10-29 09:00:00 (Sun) 63279630000, # local_start 2006-04-02 03:00:00 (Sun) 63297770400, # local_end 2006-10-29 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 63297795600, # utc_start 2006-10-29 09:00:00 (Sun) 63309290400, # utc_end 2007-03-11 10:00:00 (Sun) 63297766800, # local_start 2006-10-29 01:00:00 (Sun) 63309261600, # local_end 2007-03-11 02:00:00 (Sun) -28800, 0, 'PST', ], [ 63309290400, # utc_start 2007-03-11 10:00:00 (Sun) 63329850000, # utc_end 2007-11-04 09:00:00 (Sun) 63309265200, # local_start 2007-03-11 03:00:00 (Sun) 63329824800, # local_end 2007-11-04 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 63329850000, # utc_start 2007-11-04 09:00:00 (Sun) 63340740000, # utc_end 2008-03-09 10:00:00 (Sun) 63329821200, # local_start 2007-11-04 01:00:00 (Sun) 63340711200, # local_end 2008-03-09 02:00:00 (Sun) -28800, 0, 'PST', ], [ 63340740000, # utc_start 2008-03-09 10:00:00 (Sun) 63361299600, # utc_end 2008-11-02 09:00:00 (Sun) 63340714800, # local_start 2008-03-09 03:00:00 (Sun) 63361274400, # local_end 2008-11-02 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 63361299600, # utc_start 2008-11-02 09:00:00 (Sun) 63372189600, # utc_end 2009-03-08 10:00:00 (Sun) 63361270800, # local_start 2008-11-02 01:00:00 (Sun) 63372160800, # local_end 2009-03-08 02:00:00 (Sun) -28800, 0, 'PST', ], [ 63372189600, # utc_start 2009-03-08 10:00:00 (Sun) 63392749200, # utc_end 2009-11-01 09:00:00 (Sun) 63372164400, # local_start 2009-03-08 03:00:00 (Sun) 63392724000, # local_end 2009-11-01 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 63392749200, # utc_start 2009-11-01 09:00:00 (Sun) 63404244000, # utc_end 2010-03-14 10:00:00 (Sun) 63392720400, # local_start 2009-11-01 01:00:00 (Sun) 63404215200, # local_end 2010-03-14 02:00:00 (Sun) -28800, 0, 'PST', ], [ 63404244000, # utc_start 2010-03-14 10:00:00 (Sun) 63424803600, # utc_end 2010-11-07 09:00:00 (Sun) 63404218800, # local_start 2010-03-14 03:00:00 (Sun) 63424778400, # local_end 2010-11-07 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 63424803600, # utc_start 2010-11-07 09:00:00 (Sun) 63435693600, # utc_end 2011-03-13 10:00:00 (Sun) 63424774800, # local_start 2010-11-07 01:00:00 (Sun) 63435664800, # local_end 2011-03-13 02:00:00 (Sun) -28800, 0, 'PST', ], [ 63435693600, # utc_start 2011-03-13 10:00:00 (Sun) 63456253200, # utc_end 2011-11-06 09:00:00 (Sun) 63435668400, # local_start 2011-03-13 03:00:00 (Sun) 63456228000, # local_end 2011-11-06 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 63456253200, # utc_start 2011-11-06 09:00:00 (Sun) 63467143200, # utc_end 2012-03-11 10:00:00 (Sun) 63456224400, # local_start 2011-11-06 01:00:00 (Sun) 63467114400, # local_end 2012-03-11 02:00:00 (Sun) -28800, 0, 'PST', ], [ 63467143200, # utc_start 2012-03-11 10:00:00 (Sun) 63487702800, # utc_end 2012-11-04 09:00:00 (Sun) 63467118000, # local_start 2012-03-11 03:00:00 (Sun) 63487677600, # local_end 2012-11-04 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 63487702800, # utc_start 2012-11-04 09:00:00 (Sun) 63498592800, # utc_end 2013-03-10 10:00:00 (Sun) 63487674000, # local_start 2012-11-04 01:00:00 (Sun) 63498564000, # local_end 2013-03-10 02:00:00 (Sun) -28800, 0, 'PST', ], [ 63498592800, # utc_start 2013-03-10 10:00:00 (Sun) 63519152400, # utc_end 2013-11-03 09:00:00 (Sun) 63498567600, # local_start 2013-03-10 03:00:00 (Sun) 63519127200, # local_end 2013-11-03 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 63519152400, # utc_start 2013-11-03 09:00:00 (Sun) 63530042400, # utc_end 2014-03-09 10:00:00 (Sun) 63519123600, # local_start 2013-11-03 01:00:00 (Sun) 63530013600, # local_end 2014-03-09 02:00:00 (Sun) -28800, 0, 'PST', ], [ 63530042400, # utc_start 2014-03-09 10:00:00 (Sun) 63550602000, # utc_end 2014-11-02 09:00:00 (Sun) 63530017200, # local_start 2014-03-09 03:00:00 (Sun) 63550576800, # local_end 2014-11-02 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 63550602000, # utc_start 2014-11-02 09:00:00 (Sun) 63561492000, # utc_end 2015-03-08 10:00:00 (Sun) 63550573200, # local_start 2014-11-02 01:00:00 (Sun) 63561463200, # local_end 2015-03-08 02:00:00 (Sun) -28800, 0, 'PST', ], [ 63561492000, # utc_start 2015-03-08 10:00:00 (Sun) 63582051600, # utc_end 2015-11-01 09:00:00 (Sun) 63561466800, # local_start 2015-03-08 03:00:00 (Sun) 63582026400, # local_end 2015-11-01 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 63582051600, # utc_start 2015-11-01 09:00:00 (Sun) 63593546400, # utc_end 2016-03-13 10:00:00 (Sun) 63582022800, # local_start 2015-11-01 01:00:00 (Sun) 63593517600, # local_end 2016-03-13 02:00:00 (Sun) -28800, 0, 'PST', ], [ 63593546400, # utc_start 2016-03-13 10:00:00 (Sun) 63614106000, # utc_end 2016-11-06 09:00:00 (Sun) 63593521200, # local_start 2016-03-13 03:00:00 (Sun) 63614080800, # local_end 2016-11-06 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 63614106000, # utc_start 2016-11-06 09:00:00 (Sun) 63624996000, # utc_end 2017-03-12 10:00:00 (Sun) 63614077200, # local_start 2016-11-06 01:00:00 (Sun) 63624967200, # local_end 2017-03-12 02:00:00 (Sun) -28800, 0, 'PST', ], [ 63624996000, # utc_start 2017-03-12 10:00:00 (Sun) 63645555600, # utc_end 2017-11-05 09:00:00 (Sun) 63624970800, # local_start 2017-03-12 03:00:00 (Sun) 63645530400, # local_end 2017-11-05 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 63645555600, # utc_start 2017-11-05 09:00:00 (Sun) 63656445600, # utc_end 2018-03-11 10:00:00 (Sun) 63645526800, # local_start 2017-11-05 01:00:00 (Sun) 63656416800, # local_end 2018-03-11 02:00:00 (Sun) -28800, 0, 'PST', ], [ 63656445600, # utc_start 2018-03-11 10:00:00 (Sun) 63677005200, # utc_end 2018-11-04 09:00:00 (Sun) 63656420400, # local_start 2018-03-11 03:00:00 (Sun) 63676980000, # local_end 2018-11-04 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 63677005200, # utc_start 2018-11-04 09:00:00 (Sun) 63687895200, # utc_end 2019-03-10 10:00:00 (Sun) 63676976400, # local_start 2018-11-04 01:00:00 (Sun) 63687866400, # local_end 2019-03-10 02:00:00 (Sun) -28800, 0, 'PST', ], [ 63687895200, # utc_start 2019-03-10 10:00:00 (Sun) 63708454800, # utc_end 2019-11-03 09:00:00 (Sun) 63687870000, # local_start 2019-03-10 03:00:00 (Sun) 63708429600, # local_end 2019-11-03 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 63708454800, # utc_start 2019-11-03 09:00:00 (Sun) 63719344800, # utc_end 2020-03-08 10:00:00 (Sun) 63708426000, # local_start 2019-11-03 01:00:00 (Sun) 63719316000, # local_end 2020-03-08 02:00:00 (Sun) -28800, 0, 'PST', ], [ 63719344800, # utc_start 2020-03-08 10:00:00 (Sun) 63739904400, # utc_end 2020-11-01 09:00:00 (Sun) 63719319600, # local_start 2020-03-08 03:00:00 (Sun) 63739879200, # local_end 2020-11-01 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 63739904400, # utc_start 2020-11-01 09:00:00 (Sun) 63751399200, # utc_end 2021-03-14 10:00:00 (Sun) 63739875600, # local_start 2020-11-01 01:00:00 (Sun) 63751370400, # local_end 2021-03-14 02:00:00 (Sun) -28800, 0, 'PST', ], [ 63751399200, # utc_start 2021-03-14 10:00:00 (Sun) 63771958800, # utc_end 2021-11-07 09:00:00 (Sun) 63751374000, # local_start 2021-03-14 03:00:00 (Sun) 63771933600, # local_end 2021-11-07 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 63771958800, # utc_start 2021-11-07 09:00:00 (Sun) 63782848800, # utc_end 2022-03-13 10:00:00 (Sun) 63771930000, # local_start 2021-11-07 01:00:00 (Sun) 63782820000, # local_end 2022-03-13 02:00:00 (Sun) -28800, 0, 'PST', ], [ 63782848800, # utc_start 2022-03-13 10:00:00 (Sun) 63803408400, # utc_end 2022-11-06 09:00:00 (Sun) 63782823600, # local_start 2022-03-13 03:00:00 (Sun) 63803383200, # local_end 2022-11-06 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 63803408400, # utc_start 2022-11-06 09:00:00 (Sun) 63814298400, # utc_end 2023-03-12 10:00:00 (Sun) 63803379600, # local_start 2022-11-06 01:00:00 (Sun) 63814269600, # local_end 2023-03-12 02:00:00 (Sun) -28800, 0, 'PST', ], [ 63814298400, # utc_start 2023-03-12 10:00:00 (Sun) 63834858000, # utc_end 2023-11-05 09:00:00 (Sun) 63814273200, # local_start 2023-03-12 03:00:00 (Sun) 63834832800, # local_end 2023-11-05 02:00:00 (Sun) -25200, 1, 'PDT', ], [ 63834858000, # utc_start 2023-11-05 09:00:00 (Sun) 63845748000, # utc_end 2024-03-10 10:00:00 (Sun) 63834829200, # local_start 2023-11-05 01:00:00 (Sun) 63845719200, # local_end 2024-03-10 02:00:00 (Sun) -28800, 0, 'PST', ], [ 63845748000, # utc_start 2024-03-10 10:00:00 (Sun) 63866307600, # utc_end 2024-11-03 09:00:00 (Sun) 63845722800, # local_start 2024-03-10 03:00:00 (Sun) 63866282400, # local_end 2024-11-03 02:00:00 (Sun) -25200, 1, 'PDT', ], ]; sub olson_version { '2013a' } sub has_dst_changes { 82 } sub _max_year { 2023 } sub _new_instance { return shift->_init( @_, spans => $spans ); } sub _last_offset { -28800 } my $last_observance = bless( { 'format' => 'P%sT', 'gmtoff' => '-8:00', 'local_start_datetime' => bless( { 'formatter' => undef, 'local_rd_days' => 725372, 'local_rd_secs' => 0, 'offset_modifier' => 0, 'rd_nanosecs' => 0, 'tz' => bless( { 'name' => 'floating', 'offset' => 0 }, 'DateTime::TimeZone::Floating' ), 'utc_rd_days' => 725372, 'utc_rd_secs' => 0, 'utc_year' => 1988 }, 'DateTime' ), 'offset_from_std' => 0, 'offset_from_utc' => -28800, 'until' => [], 'utc_start_datetime' => bless( { 'formatter' => undef, 'local_rd_days' => 725372, 'local_rd_secs' => 28800, 'offset_modifier' => 0, 'rd_nanosecs' => 0, 'tz' => bless( { 'name' => 'floating', 'offset' => 0 }, 'DateTime::TimeZone::Floating' ), 'utc_rd_days' => 725372, 'utc_rd_secs' => 28800, 'utc_year' => 1988 }, 'DateTime' ) }, 'DateTime::TimeZone::OlsonDB::Observance' ) ; sub _last_observance { $last_observance } my $rules = [ bless( { 'at' => '2:00', 'from' => '2007', 'in' => 'Nov', 'letter' => 'S', 'name' => 'Canada', 'offset_from_std' => 0, 'on' => 'Sun>=1', 'save' => '0', 'to' => 'max', 'type' => undef }, 'DateTime::TimeZone::OlsonDB::Rule' ), bless( { 'at' => '2:00', 'from' => '2007', 'in' => 'Mar', 'letter' => 'D', 'name' => 'Canada', 'offset_from_std' => 3600, 'on' => 'Sun>=8', 'save' => '1:00', 'to' => 'max', 'type' => undef }, 'DateTime::TimeZone::OlsonDB::Rule' ) ] ; sub _rules { $rules } 1;
liuyangning/WX_web
xampp/perl/vendor/lib/DateTime/TimeZone/America/Vancouver.pm
Perl
mit
43,147
# $Id: Response.pm 1943 2006-06-25 18:59:50Z btrott $ package URI::Fetch::Response; use strict; sub new { my $class = shift; my $feed = bless { }, $class; $feed; } sub _var { my $feed = shift; my $var = shift; $feed->{$var} = shift if @_; $feed->{$var}; } sub status { shift->_var('status', @_) } sub http_status { shift->_var('http_status', @_) } sub http_response { shift->_var('http_response', @_) } sub etag { shift->_var('etag', @_) } sub last_modified { shift->_var('last_modified', @_) } sub uri { shift->_var('uri', @_) } sub content { shift->_var('content', @_) } sub content_type { shift->_var('content_type', @_) } sub is_success { my $response = shift; return $response->http_response->is_success if $response->http_response; return 1; } sub is_redirect { my $response = shift; return $response->http_response->is_redirect if $response->http_response; return; } sub is_error { my $response = shift; return $response->http_response->is_error if $response->http_response; return; } 1; __END__ =head1 NAME URI::Fetch::Response - Feed response for URI::Fetch =head1 SYNOPSIS use URI::Fetch; my $res = URI::Fetch->fetch('http://example.com/atom.xml') or die URI::Fetch->errstr; print $res->content; =head1 DESCRIPTION I<URI::Fetch::Response> encapsulates the response from fetching a feed using I<URI::Fetch>. =head1 USAGE =head2 $res->content The contents of the feed. =head2 $res->uri The URI of the feed. If the feed was moved, this reflects the new URI; otherwise, it will match the URI that you passed to I<fetch>. =head2 $res->etag The ETag that was returned in the response, if any. =head2 $res->last_modified The Last-Modified date (in seconds since the epoch) that was returned in the response, if any. =head2 $res->status The status of the response, which will match one of the following enumerations: =over 4 =item * URI::Fetch::URI_OK() =item * URI::Fetch::URI_MOVED_PERMANENTLY() =item * URI::Fetch::URI_GONE() =item * URI::Fetch::URI_NOT_MODIFIED() =back =head2 $res->http_status The HTTP status code from the response. =head2 $res->http_response The I<HTTP::Response> object returned from the fetch. =head2 $res->is_success =head2 $res->is_redirect =head2 $res->is_error Wrappers around the C<$res-E<gt>response> methods of the same name, for convenience. =head2 $res->content_type The Content-Type header from the response. =head1 AUTHOR & COPYRIGHT Please see the I<URI::Fetch> manpage for author, copyright, and license information. =cut
carlgao/lenga
images/lenny64-peon/usr/share/perl5/URI/Fetch/Response.pm
Perl
mit
2,665
#------------------------------------------------------------------------------ # File: BigTIFF.pm # # Description: Read Big TIFF meta information # # Revisions: 07/03/2007 - P. Harvey Created # # References: 1) http://www.awaresystems.be/imaging/tiff/bigtiff.html #------------------------------------------------------------------------------ package Image::ExifTool::BigTIFF; use strict; use vars qw($VERSION); use Image::ExifTool qw(:DataAccess :Utils); use Image::ExifTool::Exif; $VERSION = '1.06'; my $maxOffset = 0x7fffffff; # currently supported maximum data offset/size #------------------------------------------------------------------------------ # Process Big IFD directory # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref # Returns: 1 on success, otherwise returns 0 and sets a Warning sub ProcessBigIFD($$$) { my ($et, $dirInfo, $tagTablePtr) = @_; my $raf = $$dirInfo{RAF}; my $verbose = $$et{OPTIONS}{Verbose}; my $htmlDump = $$et{HTML_DUMP}; my $dirName = $$dirInfo{DirName}; my $dirStart = $$dirInfo{DirStart}; $verbose = -1 if $htmlDump; # mix htmlDump into verbose so we can test for both at once # loop through IFD chain for (;;) { if ($dirStart > $maxOffset and not $et->Options('LargeFileSupport')) { $et->Warn('Huge offsets not supported (LargeFileSupport not set)'); last; } unless ($raf->Seek($dirStart, 0)) { $et->Warn("Bad $dirName offset"); return 0; } my ($dirBuff, $index); unless ($raf->Read($dirBuff, 8) == 8) { $et->Warn("Truncated $dirName count"); return 0; } my $numEntries = Image::ExifTool::Get64u(\$dirBuff, 0); $verbose > 0 and $et->VerboseDir($dirName, $numEntries); my $bsize = $numEntries * 20; if ($bsize > $maxOffset) { $et->Warn('Huge directory counts not yet supported'); last; } my $bufPos = $raf->Tell(); unless ($raf->Read($dirBuff, $bsize) == $bsize) { $et->Warn("Truncated $dirName directory"); return 0; } my $nextIFD; $raf->Read($nextIFD, 8) == 8 or undef $nextIFD; # try to read next IFD pointer if ($htmlDump) { $et->HDump($bufPos-8, 8, "$dirName entries", "Entry count: $numEntries"); if (defined $nextIFD) { my $tip = sprintf("Offset: 0x%.8x", Image::ExifTool::Get64u(\$nextIFD, 0)); $et->HDump($bufPos + 20 * $numEntries, 8, "Next IFD", $tip, 0); } } # loop through all entries in this BigTIFF IFD for ($index=0; $index<$numEntries; ++$index) { my $entry = 20 * $index; my $tagID = Get16u(\$dirBuff, $entry); my $format = Get16u(\$dirBuff, $entry+2); my $count = Image::ExifTool::Get64u(\$dirBuff, $entry+4); my $formatSize = $Image::ExifTool::Exif::formatSize[$format]; unless (defined $formatSize) { $et->HDump($bufPos+$entry,20,"[invalid IFD entry]", "Bad format value: $format", 1); # warn unless the IFD was just padded with zeros $et->Warn(sprintf("Unknown format ($format) for $dirName tag 0x%x",$tagID)); return 0; # assume corrupted IFD } my $formatStr = $Image::ExifTool::Exif::formatName[$format]; my $size = $count * $formatSize; my $tagInfo = $et->GetTagInfo($tagTablePtr, $tagID); next unless defined $tagInfo or $verbose; my $valuePtr = $entry + 12; my ($valBuff, $valBase, $rational); if ($size > 8) { if ($size > $maxOffset) { $et->Warn("Can't handle $dirName entry $index (huge size)"); next; } $valuePtr = Image::ExifTool::Get64u(\$dirBuff, $valuePtr); if ($valuePtr > $maxOffset and not $et->Options('LargeFileSupport')) { $et->Warn("Can't handle $dirName entry $index (LargeFileSupport not set)"); next; } unless ($raf->Seek($valuePtr, 0) and $raf->Read($valBuff, $size) == $size) { $et->Warn("Error reading $dirName entry $index"); next; } $valBase = 0; } else { $valBuff = substr($dirBuff, $valuePtr, $size); $valBase = $bufPos; } if (defined $tagInfo and not $tagInfo) { # GetTagInfo() required the value for a Condition $tagInfo = $et->GetTagInfo($tagTablePtr, $tagID, \$valBuff); } my $val = ReadValue(\$valBuff, 0, $formatStr, $count, $size, \$rational); if ($htmlDump) { my $tval = $val; # show numerator/denominator separately for rational numbers $tval .= " ($rational)" if defined $rational; my ($tagName, $colName); if ($tagID == 0x927c and $dirName eq 'ExifIFD') { $tagName = 'MakerNotes'; } elsif ($tagInfo) { $tagName = $$tagInfo{Name}; } else { $tagName = sprintf("Tag 0x%.4x",$tagID); } my $dname = sprintf("$dirName-%.2d", $index); # build our tool tip my $tip = sprintf("Tag ID: 0x%.4x\n", $tagID) . "Format: $formatStr\[$count]\nSize: $size bytes\n"; if ($size > 8) { $tip .= sprintf("Value offset: 0x%.8x\n", $valuePtr); $colName = "<span class=H>$tagName</span>"; } else { $colName = $tagName; } $tval = substr($tval,0,28) . '[...]' if length($tval) > 32; if ($formatStr =~ /^(string|undef|binary)/) { # translate non-printable characters $tval =~ tr/\x00-\x1f\x7f-\xff/./; } elsif ($tagInfo and Image::ExifTool::IsInt($tval)) { if ($$tagInfo{IsOffset}) { $tval = sprintf('0x%.4x', $tval); } elsif ($$tagInfo{PrintHex}) { $tval = sprintf('0x%x', $tval); } } $tip .= "Value: $tval"; $et->HDump($entry+$bufPos, 20, "$dname $colName", $tip, 1); if ($size > 8) { # add value data block my $flg = ($tagInfo and $$tagInfo{SubDirectory} and $$tagInfo{MakerNotes}) ? 4 : 0; $et->HDump($valuePtr,$size,"$tagName value",'SAME', $flg); } } if ($tagInfo and $$tagInfo{SubIFD}) { # process all SubIFD's as BigTIFF $verbose > 0 and $et->VerboseInfo($tagID, $tagInfo, Table => $tagTablePtr, Index => $index, Value => $val, DataPt => \$valBuff, DataPos => $valBase + $valuePtr, Start => 0, Size => $size, Format => $formatStr, Count => $count, ); my @offsets = split ' ', $val; my $i; for ($i=0; $i<scalar(@offsets); ++$i) { my $subdirName = $$tagInfo{Name}; $subdirName .= $i if $i; my %subdirInfo = ( RAF => $raf, DataPos => 0, DirStart => $offsets[$i], DirName => $subdirName, Parent => $dirInfo, ); $et->ProcessDirectory(\%subdirInfo, $tagTablePtr, \&ProcessBigIFD); } } else { my $tagKey = $et->HandleTag($tagTablePtr, $tagID, $val, Index => $index, DataPt => \$valBuff, DataPos => $valBase + $valuePtr, Start => 0, Size => $size, Format => $formatStr, TagInfo => $tagInfo, RAF => $raf, ); $tagKey and $et->SetGroup($tagKey, $dirName); } } last unless $dirName =~ /^(IFD|SubIFD)(\d*)$/; $dirName = $1 . (($2 || 0) + 1); defined $nextIFD or $et->Warn("Bad $dirName pointer"), return 0; $dirStart = Image::ExifTool::Get64u(\$nextIFD, 0); $dirStart or last; } return 1; } #------------------------------------------------------------------------------ # Extract meta information from a BigTIFF image # Inputs: 0) ExifTool object reference, 1) dirInfo reference # Returns: 1 on success, 0 if this wasn't a valid BigTIFF image sub ProcessBTF($$) { my ($et, $dirInfo) = @_; my $raf = $$dirInfo{RAF}; my $buff; return 0 unless $raf->Read($buff, 16) == 16; return 0 unless $buff =~ /^(MM\0\x2b\0\x08\0\0|II\x2b\0\x08\0\0\0)/; if ($$dirInfo{OutFile}) { $et->Error('ExifTool does not support writing of BigTIFF images'); return 1; } $et->SetFileType('BTF'); # set the FileType tag SetByteOrder(substr($buff, 0, 2)); my $offset = Image::ExifTool::Get64u(\$buff, 8); if ($$et{HTML_DUMP}) { my $o = (GetByteOrder() eq 'II') ? 'Little' : 'Big'; $et->HDump(0, 8, "BigTIFF header", "Byte order: $o endian", 0); $et->HDump(8, 8, "IFD0 pointer", sprintf("Offset: 0x%.8x",$offset), 0); } my %dirInfo = ( RAF => $raf, DataPos => 0, DirStart => $offset, DirName => 'IFD0', Parent => 'BigTIFF', ); my $tagTablePtr = GetTagTable('Image::ExifTool::Exif::Main'); $et->ProcessDirectory(\%dirInfo, $tagTablePtr, \&ProcessBigIFD); return 1; } 1; # end __END__ =head1 NAME Image::ExifTool::BigTIFF - Read Big TIFF meta information =head1 SYNOPSIS This module is used by Image::ExifTool =head1 DESCRIPTION This module contains routines required by Image::ExifTool to read meta information in BigTIFF images. =head1 AUTHOR Copyright 2003-2015, 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<http://www.awaresystems.be/imaging/tiff/bigtiff.html> =back =head1 SEE ALSO L<Image::ExifTool::TagNames/EXIF Tags>, L<Image::ExifTool(3pm)|Image::ExifTool> =cut
mudasobwa/exifice
vendor/Image-ExifTool-10.02/lib/Image/ExifTool/BigTIFF.pm
Perl
mit
10,870
use strict; use warnings; # this is for people who don't want Test::Builder to be loaded but want to # use eq_deeply. It's a bit hacky... package Test::Deep::NoTest; our $NoTest; { local $NoTest = 1; require Test::Deep; } sub import { my $import = Test::Deep->can("import"); # make the stack look like it should for use Test::Deep my $pkg = shift; unshift(@_, "Test::Deep"); goto &$import; } 1; =head1 NAME Test::Deep::NoTest - Use Test::Deep outside of the testing framework =head1 SYNOPSIS use Test::Deep::NoTest; if eq_deeply($a, $b) { print "they were deeply equal\n"; }; =head1 DESCRIPTION This exports all the same things as Test::Deep but it does not load Test::Builder so it can be used in ordinary non-test situations.
Dokaponteam/ITF_Project
xampp/perl/vendor/lib/Test/Deep/NoTest.pm
Perl
mit
765
package MT::Plugin::SingleLogin; use strict; use warnings; use base qw( MT::Plugin ); my $plugin = __PACKAGE__->new( { name => 'SingleLogin', version => '0.01', author_name => 'masiuchi', author_link => 'https://github.com/masiuchi', plugin_link => 'https://github.com/masiuchi/mt-plugin-single-login', description => '<__trans phrase="Login singly.">', registry => { l10n_lexicon => { ja => { 'Login singly.' => '多重ログインできないようにします。', }, }, }, } ); MT->add_plugin($plugin); { use MT::App; my $make_session = \&MT::App::make_session; no warnings 'redefine'; *MT::App::make_session = sub { my ( $auth, $remember ) = @_; $auth->remove_sessions; $make_session->( $auth, $remember ); }; } 1;
masiuchi/mt-plugin-single-login
plugins/SingleLogin/SingleLogin.pl
Perl
mit
947
package MIP::Recipes::Analysis::Preseq; 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{ allow check last_error }; use utf8; use warnings; use warnings qw{ FATAL utf8 }; ## CPANM use autodie qw{ :all }; use Readonly; ## MIPs lib/ use MIP::Constants qw{ $DOT $LOG_NAME $NEWLINE $UNDERSCORE }; BEGIN { require Exporter; use base qw{ Exporter }; # Functions and variables which can be optionally exported our @EXPORT_OK = qw{ analysis_preseq }; } sub analysis_preseq { ## Function : Recipe for running Preseq ## Returns : ## Arguments: $active_parameter_href => Active parameters for this analysis hash {REF} ## : $case_id => Family id ## : $file_info_href => File_info hash {REF} ## : $job_id_href => Job id hash {REF} ## : $parameter_href => Parameter hash {REF} ## : $profile_base_command => Submission profile base command ## : $recipe_name => Recipe name ## : $sample_id => Sample id ## : $sample_info_href => Info on samples and case hash {REF} my ($arg_href) = @_; ## Flatten argument(s) my $active_parameter_href; my $file_info_href; my $job_id_href; my $parameter_href; my $recipe_name; my $sample_id; my $sample_info_href; ## Default(s) my $case_id; my $profile_base_command; 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, }, job_id_href => { default => {}, defined => 1, required => 1, store => \$job_id_href, strict_type => 1, }, parameter_href => { default => {}, defined => 1, required => 1, store => \$parameter_href, strict_type => 1, }, profile_base_command => { default => q{sbatch}, store => \$profile_base_command, strict_type => 1, }, recipe_name => { defined => 1, required => 1, store => \$recipe_name, strict_type => 1, }, sample_id => { defined => 1, required => 1, store => \$sample_id, strict_type => 1, }, sample_info_href => { default => {}, defined => 1, required => 1, store => \$sample_info_href, strict_type => 1, }, }; check( $tmpl, $arg_href, 1 ) or croak q{Could not parse arguments!}; use MIP::File_info qw{ get_io_files parse_io_outfiles }; use MIP::Program::Preseq qw{ preseq_lc_extrap }; use MIP::Processmanagement::Processes qw{ submit_recipe }; use MIP::Recipe qw{ parse_recipe_prerequisites }; use MIP::Sample_info qw{ set_recipe_outfile_in_sample_info }; use MIP::Script::Setup_script qw{ setup_script }; ### PREPROCESSING: ## Retrieve logger object my $log = Log::Log4perl->get_logger($LOG_NAME); ## Unpack parameters ## Get the io infiles per chain and id my %io = get_io_files( { id => $sample_id, file_info_href => $file_info_href, parameter_href => $parameter_href, recipe_name => $recipe_name, stream => q{in}, } ); my $infile_name_prefix = $io{in}{file_name_prefix}; my $infile_path_prefix = $io{in}{file_path_prefix}; my $infile_suffix = $io{in}{file_suffix}; my $infile_path = $infile_path_prefix . $infile_suffix; my %recipe = parse_recipe_prerequisites( { active_parameter_href => $active_parameter_href, parameter_href => $parameter_href, recipe_name => $recipe_name, } ); %io = ( %io, parse_io_outfiles( { chain_id => $recipe{job_id_chain}, id => $sample_id, file_info_href => $file_info_href, file_name_prefixes_ref => [$infile_name_prefix], outdata_dir => $active_parameter_href->{outdata_dir}, parameter_href => $parameter_href, recipe_name => $recipe_name, } ) ); my $outfile_path = $io{out}{file_paths}->[0]; my $outfile_name = $io{out}{file_names}->[0]; ## Filehandles # Create anonymous filehandle my $filehandle = IO::Handle->new(); ## Creates recipe directories (info & data & script), recipe script filenames and writes sbatch header my ( $recipe_file_path, $recipe_info_path ) = setup_script( { active_parameter_href => $active_parameter_href, core_number => $recipe{core_number}, directory_id => $sample_id, filehandle => $filehandle, job_id_href => $job_id_href, memory_allocation => $recipe{memory}, process_time => $recipe{time}, recipe_directory => $recipe_name, recipe_name => $recipe_name, } ); ### SHELL: say {$filehandle} q{## } . $recipe_name; ## Run Preseq lc_extrap say {$filehandle} q{## Run lc_extrap}; preseq_lc_extrap( { bam_infile_path => $infile_path, filehandle => $filehandle, outfile_path => $outfile_path, verbose => 1, } ); say {$filehandle} $NEWLINE; ## Close filehandle close $filehandle or $log->logcroak(q{Could not close filehandle}); if ( $recipe{mode} == 1 ) { ## Collect QC metadata info for later use set_recipe_outfile_in_sample_info( { infile => $outfile_name, path => $outfile_path, recipe_name => $recipe_name, sample_id => $sample_id, sample_info_href => $sample_info_href, } ); submit_recipe( { base_command => $profile_base_command, case_id => $case_id, dependency_method => q{sample_to_island}, job_id_chain => $recipe{job_id_chain}, job_id_href => $job_id_href, job_reservation_name => $active_parameter_href->{job_reservation_name}, log => $log, max_parallel_processes_count_href => $file_info_href->{max_parallel_processes_count}, recipe_file_path => $recipe_file_path, sample_id => $sample_id, submission_profile => $active_parameter_href->{submission_profile}, } ); } return 1; } 1;
henrikstranneheim/MIP
lib/MIP/Recipes/Analysis/Preseq.pm
Perl
mit
7,863
#!/usr/bin/env perl use strict; use warnings; use Getopt::Long; use Data::Dumper; use File::Basename qw/basename/; exit(main()); sub main{ my $settings={}; GetOptions($settings,qw(help)); die usage() if($$settings{help}); # read the file my $header = <STDIN>; if(!$header){ print STDERR "$0: ERROR: not stdin was given\n"; return 1; } chomp($header); my @header = split(/\t/, $header); my $numFields = @header; my %matrix; while(<STDIN>){ s/^\s+|\s+$//g; # trim whitespace next if(/^$/); # skip empty lines my @F=split /\t/; die "ERROR: this line does not have $numFields fields\n".usage() if(@F<$numFields); my $ref = $F[0]; for(my $i=1;$i<$numFields; $i++){ my $value = $F[$i]; my $query = $header[$i]; my($g1, $g2) = sort($ref, $query); $value = 0 if($value eq '-'); $matrix{$g1}{$g2} = $value; } } close STDIN; while(my($g1, $distances) = each(%matrix)){ while(my($g2, $dist) = each(%$distances)){ print join("\t", $g1, $g2, $matrix{$g1}{$g2})."\n"; } } return 0; } sub usage{ $0=basename $0; "Turns a 2d matrix/spreadsheet into a 3-column format Usage: $0 < table.tsv > pairwise.tsv " }
lskatz/lyve-SET
scripts/2dToPairwise.pl
Perl
mit
1,225
#! /usr/bin/perl #program converts vcf file to fastPHASE input format #September 13th, 2012 $vcf = $ARGV[0]; $output = $ARGV[1]; $output2 = $ARGV[2]; $sample_size = $ARGV[3]; unless ($#ARGV==3) { print STDERR "Please provide the name of your input vcf file. Additionally, provide a filename for the two outputs - the fastPHASE formatted genotype output and a positions file. Finally, please include the sample size on command line\n\n"; die; } #end unless open(VCF, $vcf); @positions = (); @names = (); $loop_size = $sample_size + 8; %genotypes = (); print STDERR "Reading in VCF file..."; while(<VCF>) { chomp; if ($_=~/\#\#/) { next; } elsif ($_=~/\#/) { @input_line = split(/\s+/, $_); for ($a=9; $a<=$loop_size; $a++) { push(@names, $input_line[$a]); } #end for next; } #end elsif @input_line = split(/\s+/, $_); push(@positions, $input_line[1]); $ref = $input_line[3]; $alt = $input_line[4]; for ($i=9; $i<=$loop_size; $i++) { $o = $i - 9; $hap1 = $names[$o] . "_1"; $hap2 = $names[$o] . "_2"; @genotype = split(":", $input_line[$i]); # print STDERR "Hap1: $hap1; Hap2: $hap2; $Before: $genotype[0]\t"; $genotype[0] =~ s/0/$ref/g; $genotype[0] =~ s/1/$alt/g; $genotype[0] =~ s/\./\?/g; # print STDERR "After: $genotype[0]\n"; @haplotypes = split(/[\|\/]/, $genotype[0]); push @{$genotypes{$hap1}}, $haplotypes[0]; push @{$genotypes{$hap2}}, $haplotypes[1]; } #end for } #end while print STDERR "done.\nNow printing output..."; open(OUTPUT, ">$output"); open(OUTPUT2, ">$output2"); $number_loci = $#positions + 1; print OUTPUT "$sample_size\n$number_loci\nP "; print OUTPUT2 "CHR\tPOS\n"; $positions_line = "P "; for ($b=0; $b<=$#positions; $b++) { $positions_line .= "$positions[$b] "; $cnt = length($positions_line); if ($cnt<500000) { print OUTPUT "$positions[$b] "; } elsif ($cnt>=500000) { print OUTPUT "\n$positions[$b] "; $positions_line = "$positions[$b] "; } #end elsif print OUTPUT2 "$positions[$b]\n"; } #end for for ($c=0; $c<=$#names; $c++) { print OUTPUT "\n\# $names[$c]\n"; $hap1 = $names[$c] . "_1"; @hap1_geno = @{$genotypes{$hap1}}; $hap1_line = ""; for ($d=0; $d<=$#hap1_geno; $d++) { $hap1_line .= $hap1_geno[$d]; $cnt2 = length($hap1_line); if ($cnt2<500000) { print OUTPUT "$hap1_geno[$d]"; } elsif ($cnt2>=500000) { print OUTPUT "\n$hap1_geno[$d]"; $hap1_line = ""; } #end elsif } #end for print OUTPUT "\n"; $hap2 = $names[$c] . "_2"; @hap2_geno = @{$genotypes{$hap2}}; $hap2_line = ""; for ($e=0; $e<=$#hap2_geno; $e++) { $hap2_line .= $hap2_geno[$e]; $cnt3 = length($hap2_line); if ($cnt3<500000) { print OUTPUT "$hap2_geno[$e]"; } elsif ($cnt3>=500000) { print OUTPUT "\n$hap2_geno[$e]"; $hap2_line = ""; } #end elsif } #end for } #end for print OUTPUT "\n"; print STDERR "done.\n";
lstevison/vcf-conversion-tools
vcf2fastPHASE.pl
Perl
mit
2,925
:- dynamic shots/4. shots(JOUEURTEST, 0,0,0). shots(1, 1,1,0). shots(1, 4,1,0). shots(1, 7,1,0). shots(1, 8,2,0). shots(1, 5,2,0). shots(1, 2,2,0). shots(1, 10,1,0). % X _ _ X _ _ X _ _ X % _ X _ _ X _ _ X _ _ % _ _ X _ _ X _ _ X _ % X _ _ X _ _ X _ _ X % _ X _ _ X _ _ X _ _ % _ _ X _ _ X _ _ X _ % X _ _ X _ _ X _ _ X % _ X _ _ X _ _ X _ _ % _ _ X _ _ X _ _ X _ /*34 Length of the list */ :- dynamic gridLines/2. gridLines(first, [coord(1, 1), coord(4, 1), coord(7, 1), coord(10, 1), coord(2, 2), coord(5, 2), coord(8, 2), coord(3, 3), coord(3, 7)]). /*, coord(6, 3), coord(9, 3), coord(1, 4), coord(4, 4), coord(7, 4), coord(10, 4), coord(2, 5), coord(5, 5), coord(8, 5), coord(3, 6), coord(6, 6), coord(9, 6), coord(1, 7), coord(4, 7), coord(7, 7), coord(10, 7), coord(2, 8), coord(5, 8), coord(8, 8), coord(3, 9), coord(6, 9), coord(9, 9), coord(1, 10), coord(4, 10), coord(7, 10), coord(10, 10)]).*/ playGrid(Joueur, X, Y) :- not(gridLines(Joueur, _)), gridLines(first, InitList), assertz(gridLines(Joueur, InitList)). playGrid(Joueur, XX, YY) :- getCoordinate(Joueur, X, Y), shots(Joueur, X, Y, _), write('Already Shot, get Another'), playGrid(Joueur, A, B). playGrid(Joueur, X, Y) :- getCoordinate(Joueur, X, Y), not(shots(Joueur, X, Y, _)), !. getCoordinate(Joueur, X, Y) :- gridLines(Joueur, ListOfPossibleShot), length(ListOfPossibleShot, Length), Length > 0, random(1, Length, Random), nth1(Random, ListOfPossibleShot, coord(X, Y)), delete(ListOfPossibleShot, coord(X,Y), NewList), retract(gridLines(Joueur,_)), assertz(gridLines(Joueur,NewList)). /*If the list is empty, call IA1 for a random number .. ? because there are still available cases */
H4305/battleship
IA/ia_antho3.pl
Perl
mit
1,717
package Syntax::Highlight::HTML; use strict; use HTML::Parser; { no strict; $VERSION = '0.04'; @ISA = qw(HTML::Parser); } =head1 NAME Syntax::Highlight::HTML - Highlight HTML syntax =head1 VERSION Version 0.04 =cut my %classes = ( declaration => 'h-decl', # declaration <!DOCTYPE ...> process => 'h-pi', # process instruction <?xml ...?> comment => 'h-com', # comment <!-- ... --> angle_bracket => 'h-ab', # the characters '<' and '>' as tag delimiters tag_name => 'h-tag', # the tag name of an element attr_name => 'h-attr', # the attribute name attr_value => 'h-attv', # the attribute value entity => 'h-ent', # any entities: &eacute; &#171; line_number => 'h-lno', # line number ); my %defaults = ( pre => 1, # add <pre>...</pre> around the result? (default: yes) nnn => 0, # add line numbers (default: no) ); =head1 SYNOPSIS use Syntax::Highlight::HTML; my $highlighter = new Syntax::Highlight::HTML; $output = $highlighter->parse($html); If C<$html> contains the following HTML fragment: <!-- a description list --> <dl compact="compact"> <dt>some word</dt> <dd>the description of the word. Plus some <a href="/definitions/other_word" >reference</a> towards another definition. </dd> </dl> then the resulting HTML contained in C<$output> will render like this: =begin html <style type="text/css"> <!-- .h-decl { color: #336699; font-style: italic; } /* doctype declaration */ .h-pi { color: #336699; } /* process instruction */ .h-com { color: #338833; font-style: italic; } /* comment */ .h-ab { color: #000000; font-weight: bold; } /* angles as tag delim. */ .h-tag { color: #993399; font-weight: bold; } /* tag name */ .h-attr { color: #000000; font-weight: bold; } /* attribute name */ .h-attv { color: #333399; } /* attribute value */ .h-ent { color: #cc3333; } /* entity */ .h-lno { color: #aaaaaa; background: #f7f7f7;} /* line numbers */ --> </style> <pre> <span class="h-com">&lt;!-- a description list --&gt;</span> <span class="h-ab">&lt;</span><span class="h-tag">dl</span> <span class="h-attr">compact</span>=<span class="h-attv">"compact</span>"<span class="h-ab">&gt;</span> <span class="h-ab">&lt;</span><span class="h-tag">dt</span><span class="h-ab">&gt;</span>some word<span class="h-ab">&lt;/</span><span class="h-tag">dt</span><span class="h-ab">&gt;</span> <span class="h-ab">&lt;</span><span class="h-tag">dd</span><span class="h-ab">&gt;</span>the description of the word. Plus some <span class="h-ab">&lt;</span><span class="h-tag">a</span> <span class="h-attr">href</span>=<span class="h-attv">"/definitions/other_word</span>" <span class="h-ab">&gt;</span>reference<span class="h-ab">&lt;/</span><span class="h-tag">a</span><span class="h-ab">&gt;</span> towards another definition. <span class="h-ab">&lt;/</span><span class="h-tag">dd</span><span class="h-ab">&gt;</span> <span class="h-ab">&lt;/</span><span class="h-tag">dl</span><span class="h-ab">&gt;</span> </pre> =end html =head1 DESCRIPTION This module is designed to take raw HTML input and highlight it (using a CSS stylesheet, see L<"Notes"> for the classes). The returned HTML code is ready for inclusion in a web page. It is intented to be used as an highlighting filter, and as such does not reformat or reindent the original HTML code. =head1 METHODS =over 4 =item new() The constructor. Returns a C<Syntax::Highlight::HTML> object, which derives from C<HTML::Parser>. As such, any C<HTML::parser> method can be called on this object (that is, expect for C<parse()> which is overloaded here). B<Options> =over 4 =item * C<nnn> - Activate line numbering. Default value: 0 (disabled). =item * C<pre> - Surround result by C<< <pre>...</pre> >> tags. Default value: 1 (enabled). =back B<Example> To avoid surrounding the result by the C<< <pre>...</pre> >> tags: my $highlighter = Syntax::Highlight::HTML->new(pre => 0); =cut sub new { my $self = __PACKAGE__->SUPER::new( # API version api_version => 3, # Options case_sensitive => 1, attr_encoded => 1, # Handlers declaration_h => [ \&_highlight_tag, 'self, event, tagname, attr, text' ], process_h => [ \&_highlight_tag, 'self, event, tagname, attr, text' ], comment_h => [ \&_highlight_tag, 'self, event, tagname, attr, text' ], start_h => [ \&_highlight_tag, 'self, event, tagname, attr, text' ], end_h => [ \&_highlight_tag, 'self, event, tagname, attr, text' ], text_h => [ \&_highlight_text, 'self, text' ], default_h => [ \&_highlight_text, 'self, text' ], ); my $class = ref $_[0] || $_[0]; shift; bless $self, $class; $self->{options} = { %defaults }; my %args = @_; for my $arg (keys %defaults) { $self->{options}{$arg} = $args{$arg} if defined $args{$arg} } $self->{output} = ''; return $self } =item parse() Parse the HTML code given in argument and returns the highlighted HTML code, ready for inclusion in a web page. B<Example> $highlighter->parse("<p>Hello, world.</p>"); =cut sub parse { my $self = shift; ## parse the HTML fragment $self->{output} = ''; $self->SUPER::parse($_[0]); $self->eof; ## add line numbering? if($self->{options}{nnn}) { my $i = 1; $self->{output} =~ s|^|<span class="$classes{line_number}">@{[sprintf '%3d', $i++]}</span> |gm; } ## add <pre>...</pre>? $self->{output} = "<pre>\n" . $self->{output} . "</pre>\n" if $self->{options}{pre}; return $self->{output} } =back =head2 Internals Methods The following methods are for internal use only. =over 4 =item _highlight_tag() C<HTML::Parser> tags handler: highlights a tag. =cut sub _highlight_tag { my $self = shift; my $event = shift; my $tagname = shift; my $attr = shift; $_[0] =~ s|&([^;]+;)|<span class="$classes{entity}">&amp;$1</span>|g; if($event eq 'declaration' or $event eq 'process' or $event eq 'comment') { $_[0] =~ s/</&lt;/g; $_[0] =~ s/>/&gt;/g; $self->{output} .= qq|<span class="$classes{$event}">| . $_[0] . '</span>' } else { $_[0] =~ s|^<$tagname|<<span class="$classes{tag_name}">$tagname</span>|; $_[0] =~ s|^</$tagname|</<span class="$classes{tag_name}">$tagname</span>|; $_[0] =~ s|^<(/?)|<span class="$classes{angle_bracket}">&lt;$1</span>|; $_[0] =~ s|(/?)>$|<span class="$classes{angle_bracket}">$1&gt;</span>|; for my $attr_name (keys %$attr) { next if $attr_name eq '/'; $attr_name =~ s{ \+ }{\\+}xms; # haakonsk, 20060711 $attr_name =~ s{ \( }{\\(}xms; # haakonsk, 20060711 $attr_name =~ s{ \) }{\\)}xms; # haakonsk, 20060711 $attr_name =~ s{ \* }{\\*}xms; # haakonsk, 20130603 no warnings; # haakonsk, 20130603 $_[0] =~ s{$attr_name=(["'])\Q$$attr{$attr_name}\E\1} {<span class="$classes{attr_name}">$attr_name</span>=<span class="$classes{attr_value}">$1$$attr{$attr_name}</span>$1} } $self->{output} .= $_[0]; } } =item _highlight_text() C<HTML::Parser> text handler: highlights text. =cut sub _highlight_text { my $self = shift; $_[0] =~ s|&([^;]+;)|<span class="$classes{entity}">&amp;$1</span>|g; $self->{output} .= $_[0]; } =back =head1 NOTES The resulting HTML uses CSS to colourize the syntax. Here are the classes that you can define in your stylesheet. =over 4 =item * C<.h-decl> - for a markup declaration; in a HTML document, the only markup declaration is the C<DOCTYPE>, like: C<< <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> >> =item * C<.h-pi> - for a process instruction like C<< <?html ...> >> or C<< <?xml ...?> >> =item * C<.h-com> - for a comment, C<< <!-- ... --> >> =item * C<.h-ab> - for the characters C<< '<' >> and C<< '>' >> as tag delimiters =item * C<.h-tag> - for the tag name of an element =item * C<.h-attr> - for the attribute name =item * C<.h-attv> - for the attribute value =item * C<.h-ent> - for any entities: C<&eacute;> C<&#171;> =item * C<.h-lno> - for the line numbers =back An example stylesheet can be found in F<eg/html-syntax.css>. =head1 EXAMPLE Here is an example of generated HTML output. It was generated with the script F<eg/highlight.pl>. The following HTML fragment (which is the beginning of L<http://search.cpan.org/~saper/>) <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet" href="/s/style.css" type="text/css"> <title>search.cpan.org: S&#233;bastien Aperghis-Tramoni</title> </head> <body id="cpansearch"> <center><div class="logo"><a href="/"><img src="/s/img/cpan_banner.png" alt="CPAN"></a></div></center> <div class="menubar"> <a href="/">Home</a> &middot; <a href="/author/">Authors</a> &middot; <a href="/recent">Recent</a> &middot; <a href="/news">News</a> &middot; <a href="/mirror">Mirrors</a> &middot; <a href="/faq.html">FAQ</a> &middot; <a href="/feedback">Feedback</a> </div> <form method="get" action="/search" name="f" class="searchbox"> <input type="text" name="query" value="" size="35"> <br>in <select name="mode"> <option value="all">All</option> <option value="module" >Modules</option> <option value="dist" >Distributions</option> <option value="author" >Authors</option> </select>&nbsp;<input type="submit" value="CPAN Search"> </form> will be rendered like this (using the CSS stylesheet F<eg/html-syntax.css>): =begin html <pre> <span class="h-lno"> 1</span> <span class="h-decl">&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt;</span> <span class="h-lno"> 2</span> <span class="h-ab">&lt;</span><span class="h-tag">html</span><span class="h-ab">&gt;</span> <span class="h-lno"> 3</span> <span class="h-ab">&lt;</span><span class="h-tag">head</span><span class="h-ab">&gt;</span> <span class="h-lno"> 4</span> <span class="h-ab">&lt;</span><span class="h-tag">meta</span> <span class="h-attr">http-equiv</span>=<span class="h-attv">"Content-Type</span>" <span class="h-attr">content</span>=<span class="h-attv">"text/html; charset=iso-8859-1</span>"<span class="h-ab">&gt;</span> <span class="h-lno"> 5</span> <span class="h-ab">&lt;</span><span class="h-tag">link</span> <span class="h-attr">rel</span>=<span class="h-attv">"stylesheet</span>" <span class="h-attr">href</span>=<span class="h-attv">"/s/style.css</span>" <span class="h-attr">type</span>=<span class="h-attv">"text/css</span>"<span class="h-ab">&gt;</span> <span class="h-lno"> 6</span> <span class="h-ab">&lt;</span><span class="h-tag">title</span><span class="h-ab">&gt;</span>search.cpan.org: S<span class="h-ent">&amp;#233;</span>bastien Aperghis-Tramoni<span class="h-ab">&lt;/</span><span class="h-tag">title</span><span class="h-ab">&gt;</span> <span class="h-lno"> 7</span> <span class="h-ab">&lt;/</span><span class="h-tag">head</span><span class="h-ab">&gt;</span> <span class="h-lno"> 8</span> <span class="h-ab">&lt;</span><span class="h-tag">body</span> <span class="h-attr">id</span>=<span class="h-attv">"cpansearch</span>"<span class="h-ab">&gt;</span> <span class="h-lno"> 9</span> <span class="h-ab">&lt;</span><span class="h-tag">center</span><span class="h-ab">&gt;</span><span class="h-ab">&lt;</span><span class="h-tag">div</span> <span class="h-attr">class</span>=<span class="h-attv">"logo</span>"<span class="h-ab">&gt;</span><span class="h-ab">&lt;</span><span class="h-tag">a</span> <span class="h-attr">href</span>=<span class="h-attv">"/</span>"<span class="h-ab">&gt;</span><span class="h-ab">&lt;</span><span class="h-tag">img</span> <span class="h-attr">src</span>=<span class="h-attv">"/s/img/cpan_banner.png</span>" <span class="h-attr">alt</span>=<span class="h-attv">"CPAN</span>"<span class="h-ab">&gt;</span><span class="h-ab">&lt;/</span><span class="h-tag">a</span><span class="h-ab">&gt;</span><span class="h-ab">&lt;/</span><span class="h-tag">div</span><span class="h-ab">&gt;</span><span class="h-ab">&lt;/</span><span class="h-tag">center</span><span class="h-ab">&gt;</span> <span class="h-lno"> 10</span> <span class="h-ab">&lt;</span><span class="h-tag">div</span> <span class="h-attr">class</span>=<span class="h-attv">"menubar</span>"<span class="h-ab">&gt;</span> <span class="h-lno"> 11</span> <span class="h-ab">&lt;</span><span class="h-tag">a</span> <span class="h-attr">href</span>=<span class="h-attv">"/</span>"<span class="h-ab">&gt;</span>Home<span class="h-ab">&lt;/</span><span class="h-tag">a</span><span class="h-ab">&gt;</span> <span class="h-lno"> 12</span> <span class="h-ent">&amp;middot;</span> <span class="h-ab">&lt;</span><span class="h-tag">a</span> <span class="h-attr">href</span>=<span class="h-attv">"/author/</span>"<span class="h-ab">&gt;</span>Authors<span class="h-ab">&lt;/</span><span class="h-tag">a</span><span class="h-ab">&gt;</span> <span class="h-lno"> 13</span> <span class="h-ent">&amp;middot;</span> <span class="h-ab">&lt;</span><span class="h-tag">a</span> <span class="h-attr">href</span>=<span class="h-attv">"/recent</span>"<span class="h-ab">&gt;</span>Recent<span class="h-ab">&lt;/</span><span class="h-tag">a</span><span class="h-ab">&gt;</span> <span class="h-lno"> 14</span> <span class="h-ent">&amp;middot;</span> <span class="h-ab">&lt;</span><span class="h-tag">a</span> <span class="h-attr">href</span>=<span class="h-attv">"/news</span>"<span class="h-ab">&gt;</span>News<span class="h-ab">&lt;/</span><span class="h-tag">a</span><span class="h-ab">&gt;</span> <span class="h-lno"> 15</span> <span class="h-ent">&amp;middot;</span> <span class="h-ab">&lt;</span><span class="h-tag">a</span> <span class="h-attr">href</span>=<span class="h-attv">"/mirror</span>"<span class="h-ab">&gt;</span>Mirrors<span class="h-ab">&lt;/</span><span class="h-tag">a</span><span class="h-ab">&gt;</span> <span class="h-lno"> 16</span> <span class="h-ent">&amp;middot;</span> <span class="h-ab">&lt;</span><span class="h-tag">a</span> <span class="h-attr">href</span>=<span class="h-attv">"/faq.html</span>"<span class="h-ab">&gt;</span>FAQ<span class="h-ab">&lt;/</span><span class="h-tag">a</span><span class="h-ab">&gt;</span> <span class="h-lno"> 17</span> <span class="h-ent">&amp;middot;</span> <span class="h-ab">&lt;</span><span class="h-tag">a</span> <span class="h-attr">href</span>=<span class="h-attv">"/feedback</span>"<span class="h-ab">&gt;</span>Feedback<span class="h-ab">&lt;/</span><span class="h-tag">a</span><span class="h-ab">&gt;</span> <span class="h-lno"> 18</span> <span class="h-ab">&lt;/</span><span class="h-tag">div</span><span class="h-ab">&gt;</span> <span class="h-lno"> 19</span> <span class="h-ab">&lt;</span><span class="h-tag">form</span> <span class="h-attr">method</span>=<span class="h-attv">"get</span>" <span class="h-attr">action</span>=<span class="h-attv">"/search</span>" <span class="h-attr">name</span>=<span class="h-attv">"f</span>" <span class="h-attr">class</span>=<span class="h-attv">"searchbox</span>"<span class="h-ab">&gt;</span> <span class="h-lno"> 20</span> <span class="h-ab">&lt;</span><span class="h-tag">input</span> <span class="h-attr">type</span>=<span class="h-attv">"text</span>" <span class="h-attr">name</span>=<span class="h-attv">"query</span>" <span class="h-attr">value</span>=<span class="h-attv">"</span>" <span class="h-attr">size</span>=<span class="h-attv">"35</span>"<span class="h-ab">&gt;</span> <span class="h-lno"> 21</span> <span class="h-ab">&lt;</span><span class="h-tag">br</span><span class="h-ab">&gt;</span>in <span class="h-ab">&lt;</span><span class="h-tag">select</span> <span class="h-attr">name</span>=<span class="h-attv">"mode</span>"<span class="h-ab">&gt;</span> <span class="h-lno"> 22</span> <span class="h-ab">&lt;</span><span class="h-tag">option</span> <span class="h-attr">value</span>=<span class="h-attv">"all</span>"<span class="h-ab">&gt;</span>All<span class="h-ab">&lt;/</span><span class="h-tag">option</span><span class="h-ab">&gt;</span> <span class="h-lno"> 23</span> <span class="h-ab">&lt;</span><span class="h-tag">option</span> <span class="h-attr">value</span>=<span class="h-attv">"module</span>" <span class="h-ab">&gt;</span>Modules<span class="h-ab">&lt;/</span><span class="h-tag">option</span><span class="h-ab">&gt;</span> <span class="h-lno"> 24</span> <span class="h-ab">&lt;</span><span class="h-tag">option</span> <span class="h-attr">value</span>=<span class="h-attv">"dist</span>" <span class="h-ab">&gt;</span>Distributions<span class="h-ab">&lt;/</span><span class="h-tag">option</span><span class="h-ab">&gt;</span> <span class="h-lno"> 25</span> <span class="h-ab">&lt;</span><span class="h-tag">option</span> <span class="h-attr">value</span>=<span class="h-attv">"author</span>" <span class="h-ab">&gt;</span>Authors<span class="h-ab">&lt;/</span><span class="h-tag">option</span><span class="h-ab">&gt;</span> <span class="h-lno"> 26</span> <span class="h-ab">&lt;/</span><span class="h-tag">select</span><span class="h-ab">&gt;</span><span class="h-ent">&amp;nbsp;</span><span class="h-ab">&lt;</span><span class="h-tag">input</span> <span class="h-attr">type</span>=<span class="h-attv">"submit</span>" <span class="h-attr">value</span>=<span class="h-attv">"CPAN Search</span>"<span class="h-ab">&gt;</span> <span class="h-lno"> 27</span> <span class="h-ab">&lt;/</span><span class="h-tag">form</span><span class="h-ab">&gt;</span> </pre> =end html =head1 CAVEATS C<Syntax::Highlight::HTML> relies on C<HTML::Parser> for parsing the HTML and therefore suffers from the same limitations. =head1 SEE ALSO L<HTML::Parser> =head1 AUTHORS SE<eacute>bastien Aperghis-Tramoni, E<lt>sebastien@aperghis.netE<gt> =head1 BUGS Please report any bugs or feature requests to C<bug-syntax-highlight-html@rt.cpan.org>, or through the web interface at L<https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Syntax-Highlight-HTML>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. =head1 COPYRIGHT & LICENSE Copyright (C)2004 SE<eacute>bastien Aperghis-Tramoni, All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut 1; # End of Syntax::Highlight::HTML
haakonsk/O2-Framework
lib/O2/Util/ExternalModule/lib/Syntax/Highlight/HTML.pm
Perl
mit
19,002
#!/usr/bin/perl use warnings; use strict; use feature 'say'; my $fname = shift; open my $fh, "<", $fname or die "Can't open $fname: $!"; my $line = <$fh>; chomp $line; my @arr = split //, $line; my @new; my $before = @arr; while (1) { my ($cur, $next) = (0, 1); while (1) { if ($next > $#arr) { push @new, $arr[$cur]; last; } if ($arr[$cur] =~ /[[:lower:]]/ and $arr[$next] =~ /[[:upper:]]/ or $arr[$cur] =~ /[[:upper:]]/ and $arr[$next] =~ /[[:lower:]]/) { if (lc $arr[$cur] eq lc $arr[$next]) { $cur = $next + 1; $next = $cur + 1; next; } } push @new, $arr[$cur]; $cur++; $next++; } last if @new == $before; @arr = (); @arr = @new; @new = (); $before = @arr; } say scalar @new;
bewuethr/advent_of_code
2018/day05/day05a.pl
Perl
mit
742
server('epictetus', 'irc.codetalk.io':6667, ['#lobby']).
ljos/epictetus
src/epictetus/config.pl
Perl
mit
57
use strict; use Irssi; use vars qw($VERSION %IRSSI); # $Id$ use MIME::Base64; $VERSION = "1.1"; %IRSSI = ( authors => 'Michael Tharp and Jilles Tjoelker', contact => 'gxti@partiallystapled.com', name => 'cap_sasl.pl', description => 'Implements PLAIN SASL authentication mechanism for use with charybdis ircds, and enables CAP MULTI-PREFIX', license => 'GNU General Public License', url => 'http://sasl.charybdis.be/', ); my %sasl_auth = (); my %mech = (); sub timeout; sub server_connected { my $server = shift; $server->send_raw_now("CAP LS"); } sub event_cap { my ($server, $args, $nick, $address) = @_; my ($subcmd, $caps, $tosend); $tosend = ''; if ($args =~ /^\S+ (\S+) :(.*)$/) { $subcmd = uc $1; $caps = ' '.$2.' '; if ($subcmd eq 'LS') { $tosend .= ' multi-prefix' if $caps =~ / multi-prefix /i; $tosend .= ' sasl' if $caps =~ / sasl /i && defined($sasl_auth{$server->{tag}}); $tosend =~ s/^ //; $server->print('', "CLICAP: supported by server:$caps"); if (!$server->{connected}) { if ($tosend eq '') { $server->send_raw_now("CAP END"); } else { $server->print('', "CLICAP: requesting: $tosend"); $server->send_raw_now("CAP REQ :$tosend"); } } Irssi::signal_stop(); } elsif ($subcmd eq 'ACK') { $server->print('', "CLICAP: now enabled:$caps"); if ($caps =~ / sasl /i) { $sasl_auth{$server->{tag}}{buffer} = ''; if($mech{$sasl_auth{$server->{tag}}{mech}}) { $server->send_raw_now("AUTHENTICATE " . $sasl_auth{$server->{tag}}{mech}); Irssi::timeout_add_once(30000, \&timeout, $server->{tag}); }else{ $server->print('', 'SASL: attempted to start unknown mechanism "' . $sasl_auth{$server->{tag}}{mech} . '"'); } } elsif (!$server->{connected}) { $server->send_raw_now("CAP END"); } Irssi::signal_stop(); } elsif ($subcmd eq 'NAK') { $server->print('', "CLICAP: refused:$caps"); if (!$server->{connected}) { $server->send_raw_now("CAP END"); } Irssi::signal_stop(); } elsif ($subcmd eq 'LIST') { $server->print('', "CLICAP: currently enabled:$caps"); Irssi::signal_stop(); } } } sub event_authenticate { my ($server, $args, $nick, $address) = @_; my $sasl = $sasl_auth{$server->{tag}}; return unless $sasl && $mech{$sasl->{mech}}; $sasl->{buffer} .= $args; return if length($args) == 400; my $data = $sasl->{buffer} eq '+' ? '' : decode_base64($sasl->{buffer}); my $out = $mech{$sasl->{mech}}($sasl, $data); $out = '' unless defined $out; $out = $out eq '' ? '+' : encode_base64($out, ''); while(length $out >= 400) { my $subout = substr($out, 0, 400, ''); $server->send_raw_now("AUTHENTICATE $subout"); } if(length $out) { $server->send_raw_now("AUTHENTICATE $out"); }else{ # Last piece was exactly 400 bytes, we have to send some padding to indicate we're done $server->send_raw_now("AUTHENTICATE +"); } $sasl->{buffer} = ''; Irssi::signal_stop(); } sub event_saslend { my ($server, $args, $nick, $address) = @_; my $data = $args; $data =~ s/^\S+ :?//; # need this to see it, ?? -- jilles $server->print('', $data); if (!$server->{connected}) { $server->send_raw_now("CAP END"); } } sub timeout { my $tag = shift; my $server = Irssi::server_find_tag($tag); if(!$server->{connected}) { $server->print('', "SASL: authentication timed out"); $server->send_raw_now("CAP END"); } } sub cmd_sasl { my ($data, $server, $item) = @_; if ($data ne '') { Irssi::command_runsub ('sasl', $data, $server, $item); } else { cmd_sasl_show(@_); } } sub cmd_sasl_set { my ($data, $server, $item) = @_; if (my($net, $u, $p, $m) = $data =~ /^(\S+) (\S+) (\S+) (\S+)$/) { if($mech{uc $m}) { $sasl_auth{$net}{user} = $u; $sasl_auth{$net}{password} = $p; $sasl_auth{$net}{mech} = uc $m; Irssi::print("SASL: added $net: [$m] $sasl_auth{$net}{user} *"); }else{ Irssi::print("SASL: unknown mechanism $m"); } } elsif ($data =~ /^(\S+)$/) { $net = $1; if (defined($sasl_auth{$net})) { delete $sasl_auth{$net}; Irssi::print("SASL: deleted $net"); } else { Irssi::print("SASL: no entry for $net"); } } else { Irssi::print("SASL: usage: /sasl set <net> <user> <password or keyfile> <mechanism>"); } } sub cmd_sasl_show { #my ($data, $server, $item) = @_; my $net; my $count = 0; foreach $net (keys %sasl_auth) { Irssi::print("SASL: $net: [$sasl_auth{$net}{mech}] $sasl_auth{$net}{user} *"); $count++; } Irssi::print("SASL: no networks defined") if !$count; } sub cmd_sasl_save { #my ($data, $server, $item) = @_; my $file = Irssi::get_irssi_dir()."/sasl.auth"; open FILE, "> $file" or return; foreach my $net (keys %sasl_auth) { printf FILE ("%s\t%s\t%s\t%s\n", $net, $sasl_auth{$net}{user}, $sasl_auth{$net}{password}, $sasl_auth{$net}{mech}); } close FILE; Irssi::print("SASL: auth saved to $file"); } sub cmd_sasl_load { #my ($data, $server, $item) = @_; my $file = Irssi::get_irssi_dir()."/sasl.auth"; open FILE, "< $file" or return; %sasl_auth = (); while (<FILE>) { chomp; my ($net, $u, $p, $m) = split (/\t/, $_, 4); $m ||= "PLAIN"; if($mech{uc $m}) { $sasl_auth{$net}{user} = $u; $sasl_auth{$net}{password} = $p; $sasl_auth{$net}{mech} = uc $m; }else{ Irssi::print("SASL: unknown mechanism $m"); } } close FILE; Irssi::print("SASL: auth loaded from $file"); } sub cmd_sasl_mechanisms { Irssi::print("SASL: mechanisms supported: " . join(" ", keys %mech)); } Irssi::signal_add_first('server connected', \&server_connected); Irssi::signal_add('event cap', \&event_cap); Irssi::signal_add('event authenticate', \&event_authenticate); Irssi::signal_add('event 903', 'event_saslend'); Irssi::signal_add('event 904', 'event_saslend'); Irssi::signal_add('event 905', 'event_saslend'); Irssi::signal_add('event 906', 'event_saslend'); Irssi::signal_add('event 907', 'event_saslend'); Irssi::command_bind('sasl', \&cmd_sasl); Irssi::command_bind('sasl load', \&cmd_sasl_load); Irssi::command_bind('sasl save', \&cmd_sasl_save); Irssi::command_bind('sasl set', \&cmd_sasl_set); Irssi::command_bind('sasl show', \&cmd_sasl_show); Irssi::command_bind('sasl mechanisms', \&cmd_sasl_mechanisms); $mech{PLAIN} = sub { my($sasl, $data) = @_; my $u = $sasl->{user}; my $p = $sasl->{password}; join("\0", $u, $u, $p); }; eval { use Crypt::OpenSSL::Bignum; use Crypt::DH; use Crypt::Blowfish; use Math::BigInt; sub bin2bi { return Crypt::OpenSSL::Bignum->new_from_bin(shift)->to_decimal } # binary to BigInt sub bi2bin { return Crypt::OpenSSL::Bignum->new_from_decimal((shift)->bstr)->to_bin } # BigInt to binary $mech{'DH-BLOWFISH'} = sub { my($sasl, $data) = @_; my $u = $sasl->{user}; my $pass = $sasl->{password}; # Generate private key and compute secret key my($p, $g, $y) = unpack("(n/a*)3", $data); my $dh = Crypt::DH->new(p => bin2bi($p), g => bin2bi($g)); $dh->generate_keys; my $secret = bi2bin($dh->compute_secret(bin2bi($y))); my $pubkey = bi2bin($dh->pub_key); # Pad the password to the nearest multiple of blocksize and encrypt $pass .= "\0"; $pass .= chr(rand(256)) while length($pass) % 8; my $cipher = Crypt::Blowfish->new($secret); my $crypted = ''; while(length $pass) { my $clear = substr($pass, 0, 8, ''); $crypted .= $cipher->encrypt($clear); } pack("n/a*Z*a*", $pubkey, $u, $crypted); }; }; cmd_sasl_load(); # vim: ts=4
allanclloyds/.dotfiles
.irssi/scripts/cap_sasl.pl
Perl
mit
7,439
#!/usr/bin/perl -w # This file was preprocessed, do not edit! package Debconf::FrontEnd::Kde::Wizard; use strict; use utf8; use Debconf::Log ':all'; use Qt; use Qt::isa qw(Debconf::FrontEnd::Kde::WizardUi); use Qt::slots 'goNext' => [], 'goBack' => [], 'goBye' => []; use Qt::attributes qw(frontend); use Debconf::FrontEnd::Kde::WizardUi; sub NEW { shift->SUPER::NEW(@_[0..2]); frontend = $_[2]; this->connect(bNext, SIGNAL 'clicked ()', SLOT 'goNext ()'); this->connect(bBack, SIGNAL 'clicked ()', SLOT 'goBack ()'); this->connect(bCancel, SIGNAL 'clicked ()', SLOT 'goBye ()'); this->title->show; } sub setTitle { this->title->setText($_[0]); } sub setNextEnabled { bNext->setEnabled(shift); } sub setBackEnabled { bBack->setEnabled(shift); } sub goNext { debug frontend => "QTF: -- LEAVE EVENTLOOP --------"; frontend->goback(0); Qt::app->exit(0); } sub goBack { debug frontend => "QTF: -- LEAVE EVENTLOOP --------"; frontend->goback(1); Qt::app->exit(0); } sub goBye { debug developer => "QTF: -- LEAVE EVENTLOOP --------"; frontend->cancelled(1); Qt::app->exit (0); } 1;
carlgao/lenga
images/lenny64-peon/usr/share/perl5/Debconf/FrontEnd/Kde/Wizard.pm
Perl
mit
1,112
# Copyright (c) 2008 ToI-Planning, All rights reserved. # # 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. # # $Id$ package TabbedEditPage; my $instance = undef; sub instance { my $class = shift if ! ref $_[0]; $instance = shift if $_[0]; $instance; } 1;
usualoma/mt-plugin-TabbedEditPage
plugins/TabbedEditPage/lib/TabbedEditPage.pm
Perl
mit
1,279
eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' && eval 'exec perl -S $0 $argv:q' if 0; use strict; $^W=1; # turn warning on # # thumbpdf.pl # # Copyright (C) 1999-2005 Heiko Oberdiek. # # This work may be distributed and/or modified under the # conditions of the LaTeX Project Public License, either version 1.3 # of this license or (at your option) any later version. # The latest version of this license is in # http://www.latex-project.org/lppl.txt # and version 1.3 or later is part of all distributions of LaTeX # version 2003/12/01 or later. # # This work has the LPPL maintenance status "maintained". # # This Current Maintainer of this work is Heiko Oberdiek. # # See file "readme.txt" for a list of files that belong to this project. # # This file "thumbpdf.pl" may be renamed to "thumbpdf" # for installation purposes. # my $file = "thumbpdf.pl"; my $program = uc($&) if $file =~ /^\w+/; my $version = "3.8"; my $date = "2005/07/06"; my $author = "Heiko Oberdiek"; my $copyright = "Copyright (c) 1999-2005 by $author."; # # Reqirements: Perl5, Ghostscript # History: # 1999/02/14 v1.0: First release. # 1999/02/23 v1.1: # * Looking for the media box to calculate the resolution # for Ghostscript # * new option --resolution # 1999/03/01 v1.2: # * optimization: indirect objects for length values removed. # * "first line" from epstopdf # 1999/03/12 v1.3: # * Copyright: LPPL # 1999/05/05 v1.4: # * Detecting of cygwin32 environment. # * Minor corrections of output of error messages. # * Sharing RGB objects. # 1999/06/13 v1.5: # * gs detection extended. # 1999/07/27 v1.6 # 1999/08/08 v1.7: # * \immediate before \pdfobj (pdfTeX 0.14a) # 1999/09/09 v1.8 # 1999/09/06 v1.9: # * Check for direct /Length values (for jpg images) # 2000/01/11 v1.10: # * Bug fix: /Length (direct) as last entry. # * Direct /Length in RGB objects supported. # 2000/01/19 v1.11: # * "for (my $j=0;...;...)" replaced by "my $j; for($j=0;...;...)", # because there exist perl versions that have problems with. # 2000/02/11 v1.12: # * Option `clean' added. # * The name of thumbnail data file: jobname.tnd, # if thumbpdf is called: thumbpdf jobname[.pdf] [options] # 2000/02/22 v2.0: # * pdfmark support for dvips/ps2pdf route added. # * <jobname>.tpt replaces thumbdta.tex (for pdfTeX) # <jobname>.tpm (for pdfmark) # <jobname>.top replaces thumbopt.tex # * Options `useps', `modes' added, # `makedef' renamed to `makedata'. # 2000/02/28 v2.1: # * Environment variable `THUMBPDF' supported. # 2000/03/07 v2.2: # * Support for Distiller 3 and 4, the streams are uncompressed. # * Call of gs is changed in order to show the currently processed # page number of the pdf file. # * Option --printgscmd creates the command line file `thumbpdf.gs' # for the Ghostscript call. # 2000/03/22 v2.3: # * Bug fix: --useps now works. # 2000/04/10 v2.4: # * Fix for ActiveState Perl 5.6.0: uc line changed, fork removed. # (Thanks to Andreas Buehmann <andreas.buehmann@gmx.de>.) # * Version test for thumbpdf.tex added for users that # mix versions, sigh. # 2000/07/29 v2.5: # * `save' trick in call of ghostscript. # * Undocumented option --gspages added. # 2000/09/27 v2.6 # 2000/10/27 v2.7: # * -dFIXEDMEDIA=0 added in gs call # 2001/01/12 v2.8: # * Bug fix in dvips mode and active option `level2': # pack parameter corrected for little-endian machines. # * /Rotate in pdf pages: # ghostscript versions around 6.01 have added a hack # in /pdfshowpage_setpage, that ignores the /Rotate entry. # A patch is added to disable the hack. # * Ghostscript uses the MediaBox for calculating the # page size. For version 6.50 a patch is added to use # the /CropBox instead. # 2001/03/29 v2.9: # * Option --password added. # 2001/04/02 v2.10 # 2001/04/26 v2.11 # * Option --antialias added (suggestion of Juergen Bausa). # 2002/01/11 v3.0 # * Syntax of option --antialias changed (see readme.txt). # * Support for VTeX's PS mode added. # * Greek mode added (see readme.txt). # * Signal handlers added for cleanup. # 2002/05/26 v3.1 # * SIG_HUP unkown in Windows. # * Bug fix: The signal function for __DIE__ "cleanup" aborts # before the error message of "die" is printed. # Replaced by "clean" that does not contain "exit 1". # * Small bug fix in mode detection and mode "vtex" # removed from list. "vtexpdfmark" was detected, # "vtex" did not work and perhaps it will be used # later for VTeX in PDF mode. # 2002/05/26 v3.2 # * Fix: "MacOS/X: darwin" is now not interpreted as # Windows. # 2003/03/19 v3.3 # * Fix for gs 8.00 in mode dvips: # THB_DistillerPatch also applied to ghostscript >= 8.00. # 2003/06/06 v3.4 # * Bug fix, two forgotten "pop"s added for Distiller case. # 2004/10/24 v3.5 # * Revert Cygwin detection: is unix (request by Jan Nieuwenhuizen). # * LPPL 1.3. # 2004/11/19 v3.6 # * Bug fix for dvips mode and gs < 8.00 (/stackunderflow in pop). # 2004/11/19 v3.7: # * For easier debugging, the special thumbpdf objects of # thumbpdf.pdf are now valid PDF objects (dictionaries). # * Remove of extra '\n' before "endstream" that is added # by pdfTeX 1.20a. # 2005/07/06 v3.8: # * Fix because of pdfTeX 1.30. # ### program identification my $title = "$program $version, $date - $copyright\n"; ### error strings my $Error = "!!! Error:"; # error prefix ### string constants for Ghostscript run # get Ghostscript command name my $GS = "gs"; $GS = "gs386" if $^O =~ /dos/i; $GS = "gsos2" if $^O =~ /os2/i; $GS = "gswin32c" if $^O =~ /mswin32/i; # Windows detection (no SIGHUP) my $Win = 0; $Win = 1 if $^O =~ /mswin32/i; my $gspages = 1; $gspages = 0 if $^O =~ /dos/i; ### variables my $jobname = ""; my $jobfile = ""; my $pdftexfile = ""; my $pdfmarkfile = ""; my $psext = ".ps"; my $pdfext = ".pdf"; my $pdftexext = ".tpt"; my $pdfmarkext = ".tpm"; my $thumbprefix = "thb"; my $envvar = "THUMBPDF"; my $pdffile = "thumbpdf.pdf"; my $logfile = "thumbpdf.log"; my $texfile = "thumbpdf"; my $package = "thumbpdf.sty"; my $readme = "readme.txt"; my $gscnffile = "thumbpdf.gs"; my $gssection = "section I. `Known Problems'"; my @cleanlist = (); my $resolution = 9; my $mode_pdftex = 0; my $mode_pdfmark = 0; my $antialias_default = "4"; my @arglist = @ARGV; my $gskidrunning = 0; ### option variables my @bool = ("false", "true"); $::opt_device = "png16m"; $::opt_compress = "10"; $::opt_resolution = ""; $::opt_modes = "pdftex"; $::opt_gscmd = ""; $::opt_level2 = 0; $::opt_help = 0; $::opt_quiet = 0; $::opt_debug = 0; $::opt_verbose = 0; $::opt_useps = 0; $::opt_printgscmd = 0; $::opt_gspages = $gspages; # undocumented $::opt_makepng = 1; $::opt_makepdf = 1; $::opt_makedata = 1; $::opt_clean = 1; $::opt_password = ""; $::opt_antialias = $antialias_default; $::opt_greek = 0; my $usage = <<"END_OF_USAGE"; ${title}Syntax: \L$program\E [options] <jobname[.pdf|.ps]> Function: Support of thumbnails for pdfTeX or dvips/ps2pdf (pdfmark). Thumbnails are generated by Ghostscript and the result is written to data files for package `$package': `<jobname>$pdftexext' (pdfTeX), `<jobname>$pdfmarkext' (pdfmark) Options: (defaults:) --help print usage --(no)quiet suppress messages ($bool[$::opt_quiet]) --(no)verbose verbose printing ($bool[$::opt_verbose]) --(no)debug debug informations ($bool[$::opt_debug]) --(no)makepng make thumbnails `$thumbprefix*.png' ($bool[$::opt_makepng]) --(no)makepdf make `$pdffile' with thumbnails as images ($bool[$::opt_makepdf]) --(no)makedata make data file(s) for package `$package' ($bool[$::opt_makedata]) --(no)clean clear temp files ($bool[$::opt_clean]) --(no)useps `makepng' uses `.ps' instead of `.pdf' file ($bool[$::opt_useps]) --(no)level2 `<jobname>.tpm' with ps level 2 features ($bool[$::opt_level2]) --(no)greek text in greek style (experimental) ($bool[$::opt_greek]) --antialias <num1>[num2] anti-aliasing, 0 = disable, 4 = max ($::opt_antialias) --device|png [png]<dev> Ghostscript device for thumbnails, dev = mono, gray, 16, 256, 16m ($::opt_device) --resolution <res> thumbnail resolution for makepng ($resolution) --compress <n> thumbnail compress level, n = 0..10 ($::opt_compress) --modes <mode>[,mode] mode=pdftex|pdfmark|dvips|ps2pdf| vtexpdfmark|all ($::opt_modes) --password apassword for an encrypted pdf file ($::opt_password) END_OF_USAGE ### environment variable THUMBPDF if ($ENV{$envvar}) { unshift(@ARGV, split(/\s+/, $ENV{$envvar})); } ### process options my @OrgArgv = @ARGV; use Getopt::Long; GetOptions( "help!", "quiet!", "debug!", "verbose!", "device|png=s", "gscmd=s", "level2!", "compress=i", "resolution=f", "modes=s", "useps!", "printgscmd!", "gspages!", "makepng!", "makepdf!", "makedata!", "clean!", "password=s", "antialias=s", "greek!" ) or die $usage; !$::opt_help or die $usage; @ARGV < 2 or die "$usage$Error Too many files!\n"; @ARGV == 1 or die "$usage$Error Missing jobname!\n"; $::opt_device = "png$::opt_device" unless $::opt_device =~ /^png/; $::opt_quiet = 0 if $::opt_verbose; $::opt_clean = 0 if $::opt_debug or !$::opt_makepdf or !$::opt_makedata; $::opt_compress = 0 if $::opt_compress < 0; $::opt_compress = 10 if $::opt_compress > 10; my $J = "^^J"; $J = "" if $::opt_compress == 10; $::opt_antialias = $antialias_default if $::opt_antialias eq ""; $::opt_antialias =~ /^[0124][0124]?$/ or die "$usage$Error Wrong value for option --antialias!\n"; $::opt_antialias .= $::opt_antialias if length($::opt_antialias) < 2; my $AntiAliasText = substr($::opt_antialias, 0, 1); my $AntiAliasGraphics = substr($::opt_antialias, 1, 1); $AntiAliasText = "1" if $AntiAliasText eq "0"; $AntiAliasGraphics = "1" if $AntiAliasGraphics eq "0"; $GS = $::opt_gscmd if $::opt_gscmd; $gspages = $::opt_gspages; ### get modes $::opt_modes = "\L$::opt_modes\E"; $::opt_modes =~ s/dvips/pdfmark/g; $::opt_modes =~ s/ps2pdf/pdfmark/g; $::opt_modes =~ s/vtexpdfmark/pdfmark/g; $::opt_modes =~ s/vtexpdfmark/pdfmark/g; if ($::opt_modes =~ /pdftex/) { $mode_pdftex = 1; $::opt_modes =~ s/pdftex//g; } if ($::opt_modes =~ /pdfmark/) { $mode_pdfmark = 1; $::opt_modes =~ s/pdfmark//g; } if ($::opt_modes =~ /all/) { $mode_pdftex = 1; $mode_pdfmark = 1; $::opt_modes =~ s/all//g; } $::opt_modes =~ s/\s+//g; $::opt_modes =~ s/,+/,/g; $::opt_modes =~ s/^,//; $::opt_modes =~ s/,$//; if ($::opt_modes ne "") { die "$usage$Error Unknown mode(s): `$::opt_modes'\n"; } if ($::opt_makedata) { $mode_pdftex or $mode_pdfmark or die "$usage$Error Missing mode!\n"; } ### get jobname $jobname = $ARGV[0]; if ($::opt_useps) { $jobname =~ s/\.ps$//i; $jobname =~ s/\\/\//g; $jobfile = $jobname . $psext; } else { $jobname =~ s/\.pdf$//i; $jobname =~ s/\\/\//g; $jobfile = $jobname . $pdfext; } $pdftexfile = $jobname . $pdftexext; $pdfmarkfile = $jobname . $pdfmarkext; print $title unless $::opt_quiet; print "* jobname: `$jobname'\n" if $::opt_verbose; if ($::opt_debug) { print <<"END_DEB"; * OSNAME: $^O * PERL_VERSION: $] * ARGV: @OrgArgv END_DEB } ### set signals $SIG{__DIE__} = \&clean; setsignals(\&cleanup); my $MaxThumb = 0; ### ### make thumbnails ### if ($::opt_makepng) { print "*** make png files / run Ghostscript ***\n" unless $::opt_quiet or $::opt_printgscmd; if ($::opt_useps) { print "* ps file: $jobfile\n" if $::opt_verbose; } else { print "* pdf file: $jobfile\n" if $::opt_verbose; } print "* Ghostscript command: `$GS'\n" . "* Ghostscript png device: `$::opt_device'\n" if $::opt_verbose; if ($::opt_resolution) { $resolution = $::opt_resolution } else { # looking for MediaBox my $max_x = 0; my $max_y = 0; { my $MB = $jobfile; open(MB, $MB) or die "$Error Cannot open `$MB'!\n"; binmode(MB); my $xy_patt = '[\-\.\d]'; while (<MB>) { if (/\/MediaBox\s*\[\s*($xy_patt+)\s+($xy_patt+)\s+($xy_patt+)\s+($xy_patt+)\s*\]/) { my $x = $3 - $1; my $y = $4 - $2; $max_x = $x if $x > $max_x; $max_y = $y if $y > $max_y; } } close(MB); } if ($max_x <= 0 || $max_y <= 0) { print "!!! Warning: MediaBox not found, " . "using default resolution: $resolution DPI\n"; } else { print "* Max. Size of MediaBox: $max_x x $max_y\n" if $::opt_verbose; my $rx = 106 * 72 / $max_x; my $ry = 106 * 72 / $max_y; $resolution = $rx; $resolution = $ry if $ry < $rx; print "* Resolution: $resolution DPI\n" if $::opt_verbose; } } # Ghostscript's pdfshowpage_setpage is patched for solving # some problems: # * gs6.0* includes a hack that ignores the /Rotate entry # in the PDF page, if OutputFile is set. # gs6.50 does not need a fix and it is not applied, # because pdfshowpage_setpage does not contain /OutputFile. # * If /CropBox is set, then it should be used instead # of the /MediaBox entry. Because the CropBox area should # be part of the MediaBox, the MediaBox is overwritten # with the CropBox values for generating the thumbnails. # The fixes are only applied for versions >= 6.0, because # gs5.50 gets a /PageSize problem with this fix. # my $SetPageHack = <<'SET_PAGE_HACK'; currentglobal true setglobal false /product where { pop product (Ghostscript) search { pop pop pop revision 600 ge { pop true } if }{pop} ifelse } if { /pdfdict where { pop pdfdict begin /pdfshowpage_setpage [ pdfdict /pdfshowpage_setpage get { dup type /nametype eq { dup /OutputFile eq { pop /AntiRotationHack }{ dup /MediaBox eq revision 650 ge and { /THB.CropHack { 1 index /CropBox pget { 2 index exch /MediaBox exch put } if } def /THB.CropHack cvx } if } ifelse } if } forall ] cvx def end } if } if setglobal SET_PAGE_HACK my $Greek = ""; $Greek = <<'END_GREEK' if $::opt_greek; currentglobal true setglobal userdict begin % * Patch for `show' /THB_ORG_show {show} bind def /THB_greekstring /.charboxpath where { pop { currentpoint newpath moveto true .charboxpath closepath fill } bind def }{ { { 1 string dup 0 4 -1 roll put dup stringwidth pop exch true charpath flattenpath pathbbox 2 index sub exch 3 index sub exch rectfill 0 rmoveto } forall } bind def } ifelse /show { currentfont /FontType get 1 eq { dup gsave % assuming white background [ currentrgbcolor ] { 1 add 2 div } forall setrgbcolor THB_greekstring grestore stringwidth pop 0 rmoveto }{ THB_ORG_show } ifelse } bind def % * Patch for the PDF case userdict /GS_PDF_ProcSet known { % GS_PDF_ProcSet is readonly, so it will be copied first GS_PDF_ProcSet length 10 add dict dup GS_PDF_ProcSet { put dup } forall /GS_PDF_ProcSet exch def dup begin % `setshowstate' contains the use of `show', so it has to % be overwritten, because it was defined with `bind'. % The definition is taken from `pdf_ops.ps'. revision 710 lt { % 5.50, 6.51, 7.00, 7.02 /setshowstate { WordSpacing 0 eq TextSpacing 0 eq and { TextRenderingMode 0 eq { { setfillstate show } } { { false charpath textrenderingprocs TextRenderingMode get exec } } ifelse } { TextRenderingMode 0 eq { WordSpacing 0 eq { { setfillstate TextSpacing exch 0 exch ashow } } { TextSpacing 0 eq { { setfillstate WordSpacing exch 0 exch 32 exch widthshow } } { { setfillstate WordSpacing exch TextSpacing exch 0 32 4 2 roll 0 exch awidthshow } } ifelse } ifelse } { { WordSpacing TextSpacing % Implement the combination of t3 and false charpath. % Note that we must use cshow for this, because we % can't parse multi-byte strings any other way. % Stack: string xword xchar { pop pop (x) dup 0 3 index put false charpath % Stack: xword xchar ccode 3 copy 32 eq { add } { exch pop } ifelse 0 rmoveto pop } 4 -1 roll cshow pop pop textrenderingprocs TextRenderingMode get exec } } ifelse } ifelse /Show gput } bdef }{ % 7.10 /setshowstate { WordSpacing 0 eq TextSpacing 0 eq and { TextRenderingMode 0 eq { { setfillstate show } } { { false charpath textrenderingprocs TextRenderingMode get exec } } ifelse } { TextRenderingMode 0 eq { WordSpacing 0 eq { { setfillstate TextSpacing 0 Vexch 3 -1 roll ashow } } { TextSpacing 0 eq { { setfillstate WordSpacing 0 Vexch 32 4 -1 roll widthshow } } { { setfillstate WordSpacing 0 Vexch 32 TextSpacing 0 Vexch 6 -1 roll awidthshow } } ifelse } ifelse } { { WordSpacing TextSpacing % Implement the combination of t3 and false charpath. % Note that we must use cshow for this, because we % can't parse multi-byte strings any other way. % Stack: string xword xchar { pop pop (x) dup 0 3 index put false charpath % Stack: xword xchar ccode 3 copy 32 eq { add } { exch pop } ifelse 0 Vexch rmoveto pop } 4 -1 roll cshow pop pop textrenderingprocs TextRenderingMode get exec } } ifelse } ifelse /Show gput } bdef } ifelse end readonly pop } if end setglobal END_GREEK my $SetPassword = ""; $SetPassword = "/PDFPassword($::opt_password)def" if $::opt_password; my $PSHeader = "save pop $SetPassword $SetPageHack $Greek"; $PSHeader =~ s/%\s.*\n/ /g; $PSHeader =~ s/\s+/ /g; $PSHeader =~ s/\s+([\(\/\[\]\{\}])/$1/g; $PSHeader =~ s/([\)\[\]\{\}])\s+/$1/g; $PSHeader =~ s/\s+$//; my $AntiAlias = ""; $AntiAlias = "\n-dTextAlphaBits=$AntiAliasText\n" . "-dGraphicsAlphaBits=$AntiAliasGraphics" if $::opt_antialias; my $gs_cmd = <<"GS_CMD_END"; $GS$AntiAlias -dNOPAUSE -dBATCH -sDEVICE=$::opt_device -r$resolution -sOutputFile=$thumbprefix%d.png -c "$PSHeader" -f $jobfile GS_CMD_END # The trick with `save' comes from `ps2pdf': # Doing an initial `save' helps keep fonts from being flushed # between pages. if ($::opt_printgscmd) { open(GSCNF, ">$gscnffile") or die "$Error Cannot open `$gscnffile'!\n"; $gs_cmd =~ s/^[^\r\n]+[\r\n]+//; print GSCNF $gs_cmd; close(GSCNF); my $options = "@arglist"; $options =~ s/\s*--?pr[intgscmd]*\s*/ /i; $options =~ s/^\s+//; $options =~ s/\s+$//; print <<"END_PERL" if $::opt_verbose; * Perl interpreter: $^X * Perl script: $0 END_PERL print <<"END_GS"; 1. Run `Ghostscript' manually: ==> $GS \@$gscnffile 2. Call `thumbpdf' again with the additional option `--nomakepng': ==> thumbpdf --nomakepng $options END_GS exit(0); } chomp($gs_cmd); $gs_cmd =~ s/\n/ /mg; print "> $gs_cmd\n" if $::opt_verbose; if ($::opt_debug) { if ($gspages) { print "* Ghostscript with page numbers\n"; } else { print "* Ghostscript without page numbers\n"; } } setsignals(\&gscleanup); my $capture = ""; if ($gspages) { my $newline = 0; open(KID, "$gs_cmd|") or die "$Error Cannot open Ghostscript ($!)!\n"; *::GSKID = *KID; $gskidrunning = 1; my $orgbar = $|; $|=1; while (<KID>) { $capture .= $_; if ($::opt_verbose) { print; } else { if (!$::opt_quiet) { print if /^Processing pages/; if (/^Page\s+(\d+)/) { print " " if $newline; $newline = 1; print "[$1]"; } } } } $gskidrunning =0; if (!close(KID)) { if ($!) { die "$Error Closing Ghostscript ($!)!\n"; } else { my $exitvalue = $? >> 8; die "$Error Closing Ghostscript (exit status: $exitvalue)!\n"; } } print "\n" if $newline; $| = $orgbar; } else # without pages { $capture = `$gs_cmd`; if (!defined($capture)) { die "$Error Cannot execute Ghostscript!\n"; } print $capture if $::opt_verbose; } if ($capture =~ /Error:\s*(.*)\n/) { die <<"END_DIE"; $Error `$1' (Ghostscript)! See `$readme', $gssection, for further information. END_DIE } if ($capture =~ /Unknown device:\s*(.*)\n/) { die "$Error Unknown device `$1' (Ghostscript)!\n"; } if ($?) { my $exitvalue = $?; if ($exitvalue > 255) { $exitvalue >>= 8; die "$Error Closing Ghostscript (exit status: $exitvalue)!\n"; } die "$Error Closing Ghostscript ($exitvalue)!\n"; } if ($capture =~ /Processing pages \d+ through (\d+)./) { $MaxThumb = $1; } print "* max. page: $MaxThumb\n" if $::opt_debug; setsignals(\&cleanup); } ### ### make thumbpdf.pdf file ### if ($::opt_makepdf) { print "*** make `$pdffile' / run pdfTeX ***\n" unless $::opt_quiet; if ($MaxThumb > 0) { my $i; for ($i=1; $i<=$MaxThumb; $i++) { push(@cleanlist, "$thumbprefix$i.png"); } } else { # get max thumb number to speed up the pdfTeX run $MaxThumb = 0; foreach (glob("$thumbprefix*.png")) { next unless /$thumbprefix(\d+).png/; $MaxThumb = $1 if $1 > $MaxThumb; push(@cleanlist, $_); } } push(@cleanlist, $logfile); push(@cleanlist, $pdffile); my $compress = $::opt_compress; $compress = 9 if $::opt_compress == 10; my $cmd = "pdftex \"" . "\\nonstopmode" . "\\pdfcompresslevel$compress" . "\\def\\thumbjob{$jobname}" . "\\def\\thumbmax{$MaxThumb}" . "\\input $texfile" . "\""; print "> $cmd\n" if $::opt_verbose; my @capture = `$cmd`; if (!defined(@capture)) { die "$Error Cannot execute pdfTeX!\n"; } if ($::opt_verbose) { print @capture; } else { foreach (@capture) { print if /^!\s/; } } if ($?) { my $exitvalue = $?; if ($exitvalue > 255) { $exitvalue >>= 8; die "$Error Closing pdfTeX (exit status: $exitvalue)!\n"; } die "$Error Closing pdfTeX ($exitvalue)!\n"; } # test version my $versionfound = 0; foreach (@capture) { if (/File:.*thumbpdf.*(\d\d\d\d\/\d\d\/\d\d)\s+v(\d+\.\d+)/) { $versionfound = 1; if ($1 ne $date or $2 ne $version) { print <<"END_WARN"; !!! Warning: Version of `thumbpdf.tex' does not match with perl script! Current `thumbpdf.tex': $1 v$2 Please install version: $date v$version END_WARN } } } print "!!! Warning: Version of `thumbpdf.tex' not found!\n" if !$versionfound; $_ = pop(@cleanlist); } ### ### parse thumbpdf.pdf ### if ($::opt_makedata) { push(@cleanlist, $pdffile); print "*** parse `$pdffile' ***\n" unless $::opt_quiet; ### reading file and parse obj structure my @objno = (); # obj number my @objdict = (); # boolean, object is dict my @objtext = (); # text of object my @objstream = (); # stream of object if any my $maxobj = 0; my @getobjindex = (); # $getobj[obj number] ==> index for $obj...[index] # open file my $PDF = $pdffile; open(PDF, $PDF) or die "$Error Cannot open `$PDF'!\n"; binmode(PDF); my $lineno = 0; # read header $_ = <PDF>; $lineno++; $_ or die "$Error Cannot read header of `$PDF' or file is empty!\n"; /^%PDF/ or die "$Error No PDF specification found!\n"; print "* pdf header: $_" if ($::opt_debug); # read body objects my $count = 0; while (<PDF>) { $lineno++; # continue, if comment line (2nd line of PDF output by pdfTeX 1.30) next if /^%/; # stop at xref last if /^xref$/; # scan first obj line /^(\d+)\s+0\s+obj\s*(<<)?$/ or die "$Error `obj' expected on line $lineno!\n"; $objno[$count] = $1; $getobjindex[$1] = $count; $objdict[$count] = ($2); # boolean (if $2 exists) my $stream = 0; print "* obj $objno[$count]" . (($objdict[$count]) ? " (dict)" : "") . "\n" if $::opt_debug; # get obj $objtext[$count] = ""; while (<PDF>) { $lineno++; if ($objdict[$count]) { if (/^>>/) { last if /^>>\s+endobj$/; # obj without stream # get stream $_ = <PDF>; $lineno++; /^stream$/ or die "$Error `stream' expected on line $lineno!\n"; print "* stream\n" if $::opt_debug; $objstream[$count] = ""; while (<PDF>) { $lineno++; if (/(.*)endstream$/) { $objstream[$count] .= $1; last; } $objstream[$count] .= $_; } $_ = <PDF>; $lineno++; /^endobj$/ or die "$Error `endobj' expected on line $lineno!\n"; last; } } else # no dict { last if /^endobj$/; } $objtext[$count] .= $_; } $count++; } close(PDF); $maxobj = $count; print "* $maxobj objects found.\n" if $::opt_debug; ### get thumbnail page numbers my @thumbpageno = (); my $found = 0; foreach (@objtext) { if (/^<<\/ListThumbs\s+(.+)>>$/) { $_ = $1; chomp; @thumbpageno = split / /; # split(/ /, $_); print "* ListThumbs: @thumbpageno\n" if $::opt_debug; $found = 1; last; } } $found or die "$Error `/ListThumbs' not found!\n"; { my $j; for ($j=0; $j<@thumbpageno; $j++) { $thumbpageno[$j] = $1 if $thumbpageno[$j] =~ /^{(.+)}$/; } } ### identify thumb objects my @thumbobj = (); # index for @obj... with image stream my @thumblength = (); # stream length values my @thumbrgbobj = (); # index for @obj... with rgb stream my @thumbrgblength = (); # rgb stream length values my $maxthumb = 0; $count = 0; my $i; for ($i=0; $i<$maxobj; $i++) { if ($objtext[$i] =~ /^\/Type\s+\/XObject\n\/Subtype\s+\/Image\n/m) { $thumbobj[$count] = $i; $_ = $'; $objtext[$i] = $_; # check width and height /\/Width\s+(\d+)\n\/Height\s+(\d+)/m or die "$Error width/height of thumbnail not found!\n"; print "* Size: $1x$2\n" if $::opt_debug; print "==> Width ($1) " . "of thumbnail `$thumbpageno[$count]' " . "is larger than recommended (106).\n" if $1 > 106; print "==> Height ($2) " . "of thumbnail `$thumbpageno[$count]' " . "is larger than recommended (106).\n" if $2 > 106; # get stream length if (/\/Length\s+(\d+)\s+([\/\>]|$)/m) { $thumblength[$count] = $1; print "* Length (direct): $1\n" if $::opt_debug; # remove whitespace after length obj $objtext[$i] =~ s/(\/Length\s+\d+)\s+\n/$1\n/; } else # looking for indirect reference { /\/Length\s+(\d+)\s+0\s+R/m or die "$Error `/Length' entry not found!\n"; # save obj text for later correction my $objpre = $`; my $objpost = $'; # look for length obj $getobjindex[$1] or die "$Error Length obj not found!\n"; $objtext[$getobjindex[$1]] =~ /^(\d+)$/m or die "$Error length value not found!\n"; $thumblength[$count] = $1; print "* Length (indirect): $1\n" if $::opt_debug; # insert obj length directly: $objtext[$i] = $objpre . "/Length $1" . $objpost; } # remove \n from end of stream if ($thumblength[$count] < length($objstream[$i])) { chop($objstream[$i]); } # check /Indexed /DeviceRGB if ($objtext[$i] =~ /\/ColorSpace\s+\[\/Indexed\s+\/DeviceRGB\s+(\d+)\s+(\d+)\s+0\s+R\]/m) { # correct thumb object text $objtext[$i] = "$`/ColorSpace [/Indexed /DeviceRGB $1 \\the\\pdflastobj\\ 0 R]$'"; # get RGB obj number $getobjindex[$2] or die "$Error RGB object not found!\n"; $_ = $getobjindex[$2]; $thumbrgbobj[$count] = $_; # get stream length if ($objtext[$_] =~ /\/Length\s+(\d+)\s+([\/\>]|$)/m) { $thumbrgblength[$count] = $1; print "* RGB length (direct): $1\n" if $::opt_debug; $objtext[$_] =~ s/(\/Length\s+\d+)\s+\n/$1\n/; } else # looking for indirect reference { $objtext[$_] =~ /\/Length\s+(\d+)\s+0\s+R/m or die "$Error Length entry of rgb object not found\n"; # save obj text for later correction my $objrgbpre = $`; my $objrgbpost = $'; # get rgb stream length $getobjindex[$1] or die "$Error RGB length object not found!\n"; $objtext[$getobjindex[$1]] =~ /^(\d+)$/m or die "$Error length value not found!\n"; $thumbrgblength[$count] = $1; print "* RGB length (indirect): $1\n" if $::opt_debug; # insert RGB object length directly: $objtext[$_] = $objrgbpre . "/Length $1" . $objrgbpost; } } $count++; } } $maxthumb = $count; if ($maxthumb != @thumbpageno) { my $pagecount = @thumbpageno; die "$Error $maxthumb thumbnails found, but there should be $pagecount!\n"; } print "* $maxthumb thumbnails found.\n" if $::opt_verbose; ### ### write data files ### my $timestamp; { my ($sec, $min, $hour, $mday, $mon, $year) = localtime(); $mon++; $year += 1900; $timestamp = sprintf("%04d/%02d/%02d %02d:%02d:%02d", $year, $mon, $mday, $hour, $min, $sec); } if ($mode_pdftex) { print "*** write `$pdftexfile' (pdfTeX thumbnail data) ***\n" unless $::opt_quiet; my $DTA_PT = $pdftexfile; open(DTA_PT, ">$DTA_PT") or die "$Error Cannot open `$DTA_PT'!\n"; binmode(DTA_PT); print DTA_PT <<"END_DTA"; % File: $DTA_PT % Producer: $program $version % Mode: pdftex % Date: $timestamp END_DTA } my $maxpagethumb; my $dictbegin; if ($mode_pdfmark) { print "*** write `$pdfmarkfile' (pdfmark thumbnail data) ***\n" unless $::opt_quiet; my $DTA_PM = $pdfmarkfile; open(DTA_PM, ">$DTA_PM") or die "$Error Cannot open `$DTA_PM'!\n"; binmode(DTA_PM); # write tex part print DTA_PM <<"END_DTA"; % \\iffalse % File: $DTA_PM % Producer: $program $version % Mode: pdfmark % Date: $timestamp % \\fi END_DTA # looking for max. number of regular thumbnails $maxpagethumb = $maxthumb; for ($i=0; $i<$maxobj; $i++) { if ($objtext[$i] =~ /<<\/MaxThumbNumber\s+(\d+)>>/) { $maxpagethumb = $1; last; } } # write TeX part for ($i=$maxpagethumb; $i<$maxthumb; $i++) { print DTA_PM "% \\DefThisThumb{$thumbpageno[$i]}\n"; } # write PostScript header my $dictstart = <<'END_DICT'; 4 dict begin /enddict { counttomark 2 idiv dup dict begin {def} repeat pop currentdict end } bind def END_DICT chomp($dictstart); $dictbegin = "["; my $dictend = "enddict"; my $filter = ""; my $read = "readhexstring"; if ($::opt_level2) { $dictstart = " 3 dict begin"; $dictbegin = "<<"; $dictend = ">>"; $filter = " /ASCII85Decode filter"; $read = "readstring"; } print DTA_PM <<"END_DTA"; % \\endinput % TeX part ends here % PostScript definitions END_DTA my $PS_Header = <<"END_HEAD"; % % Default definition of pdfmark /pdfmark where {pop} {userdict /pdfmark /cleartomark load put} ifelse % % Check the version of Ghostscript. If it is below 6.0, % the commands, that produce the thumbnails, are defined % to be dummies. % true /product where { pop product (Ghostscript) search { pop pop pop revision 600 lt { (!!! Warning (thumbpdf): Ghostscript 6.0 required for thumbnails!\\n) print pop false } if }{pop} ifelse } if { % Syntax: <thumb object> thisTHB - % thisTHB is used globally, so it is defined in the current % dictionary (perhaps userdict should explicitly be set). /thisTHB {[ exch /Thumb exch /PAGE pdfmark} bind def $dictstart % Syntax: <page object> <thumb object> pagethumb - /pagethumb { [ 3 1 roll $dictbegin exch /Thumb exch $dictend /PUT pdfmark } bind def % Syntax: <thumb object> <stream length> % <mark> <key value pairs> streamobj - % % Distiller ignores the compression of previously compressed % streams and uses its own settings. Therefore for Distiller % the streams are uncompressed. % Now ghostscript versions greater than 8 behave in the same way % as Distiller. Therefore detection for this versions is added. % The detection and patch for distiller require features of level 2 % and the filter /FlateDecode (level 3), that is used by pdfTeX's % compression. /THB_DistillerPatch false def /languagelevel where { pop languagelevel 2 ge { product (Distiller) search {pop pop pop true}{pop false} ifelse product (Ghostscript) search { pop pop pop revision 800 ge }{pop false} ifelse or { (FlateDecode) { pop % Syntax: <dict> THB_DistillerPatch <dict> false % <dict> THB_DistillerPatch <dict> <filter> /THB_DistillerPatch { dup /Filter known { dup dup /Filter get exch /Filter undef }{false} ifelse } bind def } (FlateDecode) /Filter resourceforall } if } if } if /streamobj { $dictend exch % Stack: <thumb> <dict> <length> 3 -1 roll dup % Stack: <dict> <length> <thumb> <thumb> [ /_objdef 3 -1 roll /type /stream /OBJ pdfmark % Stack: <dict> <length> <thumb> dup dup 5 -1 roll % Stack: <length> <thumb> <thumb> <thumb> <dict> THB_DistillerPatch % Stack: <length> <thumb> <thumb> <thumb> <dict> <filter/false> [ 4 -2 roll /PUT pdfmark % Stack: <length> <thumb> <thumb> <filter/false> [ 3 1 roll currentfile${filter} % Stack: <length> <thumb> [ <thumb> <filter/false> <file> 6 -1 roll string $read pop % Stack: <thumb> [ <thumb> <filter/false> <string> exch dup type /booleantype ne {true} if {filter} if % Stack: <thumb> [ <thumb> <file> /PUT pdfmark % Stack: <thumb> [ exch /CLOSE pdfmark } bind def }{ % Syntax: <thumb object> thisTHB - /thisTHB {pop} bind def 2 dict begin % Syntax: <page object> <thumb object> pagethumb - /pagethumb {pop pop} bind def % Syntax: <thumb object> <stream length> % <mark> <key value pairs> streamobj - /streamobj { cleartomark exch pop string currentfile${filter} exch $read pop pop } bind def } ifelse END_HEAD $PS_Header =~ s/%[^\r\n]*[\r\n]+//gm; print DTA_PM $PS_Header; print DTA_PM <<"END_DTA"; % adding thumbnails to pages END_DTA for ($i=0; $i<$maxpagethumb; $i++) { print DTA_PM <<"END_DTA"; {Page$thumbpageno[$i]} {THB$thumbpageno[$i]} pagethumb END_DTA } print DTA_PM "\n% thumbnail data\n"; } for ($i=0; $i<$maxthumb; $i++) { # rgb object if ($thumbrgbobj[$i]) { # find the same rgb object my $j; for ($j=0; $j<$i; $j++) { next unless $thumbrgbobj[$j]; next unless $objtext[$thumbrgbobj[$j]] eq $objtext[$thumbrgbobj[$i]]; next unless $objstream[$thumbrgbobj[$j]] eq $objstream[$thumbrgbobj[$i]]; last; } if ($j==$i) # not found { if ($mode_pdftex) { { my $rgbstream = pdftexstream($objstream[$thumbrgbobj[$i]]); my $dict = $objtext[$thumbrgbobj[$i]]; if ($::opt_compress == 10) { chomp($dict); $dict =~ s/\n([^\/])/^^J\n$1/mg; $dict =~ s/[ ]+\//\//mg; } else { $dict =~ s/\n/^^J\n/mg; } print DTA_PT <<"END_DTA"; \\immediate\\pdfobj{<<$J $dict>>$J stream^^J $rgbstream endstream} \\DefRGB{$i} END_DTA } } if ($mode_pdfmark) { { my $rgbstream = pdfmarkstream($objstream[$thumbrgbobj[$i]]); my $rgblength = $thumbrgblength[$i]; my $dict = $objtext[$thumbrgbobj[$i]]; $dict =~ s/\/Length\s+\d+\s*//; $dict =~ s/^\s+//; $dict =~ s/\s+$//; print DTA_PM <<"END_DTA"; {RGB_$i} $rgblength $dictbegin $dict streamobj $rgbstream END_DTA } } } else # $j with same rgb obj { $objtext[$thumbobj[$i]] =~ s/\\the\\pdflastobj/\\UseRGB{$j}/; print "* Reuses RGB object $j for $i\n" if $::opt_debug; } } # thumb object if ($mode_pdftex) { { my $dict = $objtext[$thumbobj[$i]]; if ($::opt_compress == 10) { chomp($dict); $dict =~ s/\n([^\/])/^^J\n$1/mg; $dict =~ s/[ ]+\//\//mg; $dict =~ s/[ ]+\[/\[/mg; } else { $dict =~ s/\n/^^J\n/mg; } my $stream = pdftexstream($objstream[$thumbobj[$i]]); print DTA_PT <<"END_DTA"; \\immediate\\pdfobj{<<$J $dict>>$J stream^^J $stream endstream} \\DefThumb{$thumbpageno[$i]} END_DTA } } if ($mode_pdfmark) { { my $stream = pdfmarkstream($objstream[$thumbobj[$i]]); my $length = $thumblength[$i]; my $dict = $objtext[$thumbobj[$i]]; $dict =~ s/\\the\\pdflastobj\\\s*\d+\s*R/{RGB_$i}/; $dict =~ s/\\UseRGB{(\d+)}\\\s*\d+\s*R/{RGB_$1}/; $dict =~ s/\/Length\s+\d+\s*//; $dict =~ s/^\s+//; $dict =~ s/\s+$//; my $thismarker = ""; $thismarker = "_", if $i >= $maxpagethumb; print DTA_PM <<"END_DTA"; {THB$thismarker$thumbpageno[$i]} $length $dictbegin $dict streamobj $stream END_DTA } } } if ($mode_pdftex) { print DTA_PT "\\endinput\n"; close(DTA_PT); } if ($mode_pdfmark) { print DTA_PM <<"END_DTA"; end % end of thumbnail data file END_DTA close(DTA_PM); } } sub pdftexstream { my $str = ""; my $mod = 0; foreach (split(//, $_[0])) { my $num = ord($_); if ($num == 13) { $str .= '\\/'; } elsif ($num < 32) { $str .= '^^' . chr($num + 64); } elsif ($num == 32) { $str .= '\\~'; } # space elsif ($num == 37) { $str .= '\\%'; } # percent elsif ($num == 92) { $str .= '\\\\'; } # backslash elsif ($num == 94) { $str .= '\\+'; } # caret elsif ($num == 123) { $str .= '\\{'; } # curly brace left elsif ($num == 125) { $str .= '\\}'; } # curly brace right else { $str .= $_; } $mod++; if ($mod == 26) { $mod = 0; $str .= "\n"; } } chomp $str; return $str; } sub pdfmarkstream { my $str; if ($::opt_level2) { my $s = $_[0]; my $len = length($s); $str = ""; my $i; for ($i=0; $i<$len-4; $i+=4) { $_ = ASCII85Encode(substr($s, $i, 4)); s/!!!!!/z/; $str .= $_; } my $r = $len % 4; if ($r) { $_ = substr($s, $i, $r) . "\000\000\000"; $_ = ASCII85Encode(substr($_, 0, 4)); $str .= substr($_, 0, $r+1); } $str =~ s/(.{60})/$1\n/g; chomp($str); $str .= "~>"; } else { $str = uc(unpack('H*', $_[0])); $str =~ s/(.{60})/$1\n/g; chomp($str); } return $str; } sub ASCII85Encode { my $val = unpack("N", $_[0]); my @c; $c[4] = $val % 85 + 33; $val = int($val/85); $c[3] = $val % 85 + 33; $val = int($val/85); $c[2] = $val % 85 + 33; $val = int($val/85); $c[1] = $val % 85 + 33; $c[0] = int($val/85) + 33; return pack("C*", @c); } sub setsignals { my $func = $_[0]; $SIG{'HUP'} = $func unless $Win; $SIG{'INT'} = $func; $SIG{'QUIT'} = $func; $SIG{'TERM'} = $func; } sub clean { if ($::opt_clean) { print "*** clear temp files ***\n" unless $::opt_quiet; foreach (@cleanlist) { unlink; } } } sub cleanup { print "\n" unless $::opt_quiet; clean(); exit 1; } sub gscleanup { print "\n" unless $::opt_quiet; clean(); close(::GSKID) if $gskidrunning; foreach (glob("$thumbprefix*.png")) { unlink; } exit 1; } clean(); print "*** ready. ***\n" unless $::opt_quiet; __END__
carlgao/lenga
images/lenny64-peon/usr/share/texmf-texlive/scripts/thumbpdf/thumbpdf.pl
Perl
mit
41,678
#!/usr/bin/env perl use local::lib; use Catalyst::ScriptRunner; Catalyst::ScriptRunner->run('Maximus', 'Task'); =head1 NAME maximus_task.pl - Execute a Maximus task =head1 SYNOPSIS maximus_task.pl [options] -t --task Task to execute, e.g. Modules::Update -q --queue Send task (and sub-tasks) to the queue server --dump_response Dump response to STDOUT =head1 DESCRIPTION Run a Maximus task from the command line. =head1 SEE ALSO L<maximus_worker> =head1 AUTHORS Christiaan Kras =head1 LICENSE Copyright (c) 2010-2013 Christiaan Kras 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 1;
maximos/maximus-web
script/maximus_task.pl
Perl
mit
1,613
use c_rt_lib; use ptd; use nlasm; use boolean_t; use array; sub register_cleaner::clean_registers; sub register_cleaner_priv::clean; sub register_cleaner_priv::clean_f; sub register_cleaner_priv::recalculate_registers; sub register_cleaner_priv::recalculate_annotation; sub register_cleaner_priv::find_unused_regs; return 1; sub register_cleaner::clean_registers($) { my $memory_0;my $memory_1;my $memory_2;my $memory_3;my $memory_4;my $memory_5;my $memory_6;$memory_0 = $_[0];Scalar::Util::weaken($_[0]) if ref($_[0]); #line 13 $memory_1 = {}; #line 14 $memory_4 = c_rt_lib::init_iter($memory_0); #line 14 label_2: #line 14 $memory_2 = c_rt_lib::is_end_hash($memory_4); #line 14 if (c_rt_lib::check_true($memory_2)) {goto label_14;} #line 14 $memory_2 = c_rt_lib::get_key_iter($memory_4); #line 14 $memory_3 = c_rt_lib::hash_get_value($memory_0, $memory_2); #line 15 $memory_5 = register_cleaner_priv::clean($memory_3); #line 15 $memory_6 = $memory_5; #line 15 c_rt_lib::hash_set_value($memory_1, $memory_2, $memory_6); #line 15 undef($memory_5); #line 15 undef($memory_6); #line 16 $memory_4 = c_rt_lib::next_iter($memory_4); #line 16 goto label_2; #line 16 label_14: #line 16 undef($memory_2); #line 16 undef($memory_3); #line 16 undef($memory_4); #line 17 $memory_0 = $memory_1; #line 17 undef($memory_1); #line 17 $_[0] = $memory_0;return; $_[0] = $memory_0;} sub register_cleaner_priv::clean($) { my $memory_0;my $memory_1;my $memory_2;my $memory_3;my $memory_4;my $memory_5;my $memory_6;my $memory_7;my $memory_8;$memory_0 = $_[0]; #line 22 $memory_1 = []; #line 23 $memory_2 = $memory_0->{'functions'}; #line 23 $memory_4 = 0; #line 23 $memory_5 = 1; #line 23 $memory_6 = c_rt_lib::array_len($memory_2); #line 23 label_5: #line 23 $memory_7 = c_rt_lib::to_nl($memory_4 >= $memory_6); #line 23 if (c_rt_lib::check_true($memory_7)) {goto label_14;} #line 23 $memory_3 = $memory_2->[$memory_4]; #line 24 $memory_8 = register_cleaner_priv::clean_f($memory_3); #line 24 c_rt_lib::array_push($memory_1, $memory_8); #line 24 undef($memory_8); #line 25 $memory_4 = $memory_4 + $memory_5; #line 25 goto label_5; #line 25 label_14: #line 25 undef($memory_2); #line 25 undef($memory_3); #line 25 undef($memory_4); #line 25 undef($memory_5); #line 25 undef($memory_6); #line 25 undef($memory_7); #line 26 $memory_2 = $memory_1; #line 26 if (c_rt_lib::get_hashcount($memory_0) > 1) {$memory_0 = {%{$memory_0}};}$memory_0->{'functions'} = $memory_2; #line 26 undef($memory_2); #line 27 undef($memory_1); #line 27 return $memory_0; #line 27 undef($memory_1); #line 27 undef($memory_0); #line 27 return; } sub register_cleaner_priv::clean_f($) { my $memory_0;my $memory_1;my $memory_2;my $memory_3;my $memory_4;my $memory_5;my $memory_6;my $memory_7;my $memory_8;my $memory_9;$memory_0 = $_[0]; #line 32 $memory_1 = register_cleaner_priv::find_unused_regs($memory_0); #line 34 $memory_2 = 0; #line 35 $memory_3 = {}; #line 36 $memory_4 = $memory_0->{'reg_size'}; #line 36 $memory_5 = 0; #line 36 $memory_6 = 1; #line 36 label_6: #line 36 $memory_7 = c_rt_lib::to_nl($memory_5 >= $memory_4); #line 36 if (c_rt_lib::check_true($memory_7)) {goto label_23;} #line 37 $memory_8 = c_rt_lib::hash_get_value($memory_1, $memory_5); #line 37 $memory_8 = c_rt_lib::to_nl(!c_rt_lib::check_true($memory_8)); #line 37 if (c_rt_lib::check_true($memory_8)) {goto label_19;} #line 38 $memory_9 = $memory_2; #line 38 c_rt_lib::hash_set_value($memory_3, $memory_5, $memory_9); #line 38 undef($memory_9); #line 39 $memory_9 = 1; #line 39 $memory_2 = $memory_2 + $memory_9; #line 39 undef($memory_9); #line 40 goto label_19; #line 40 label_19: #line 40 undef($memory_8); #line 41 $memory_5 = $memory_5 + $memory_6; #line 41 goto label_6; #line 41 label_23: #line 41 undef($memory_4); #line 41 undef($memory_5); #line 41 undef($memory_6); #line 41 undef($memory_7); #line 42 $memory_4 = ""; #line 42 $memory_6 = ""; #line 42 $memory_5 = $memory_4; #line 42 c_rt_lib::hash_set_value($memory_3, $memory_6, $memory_5); #line 42 undef($memory_4); #line 42 undef($memory_5); #line 42 undef($memory_6); #line 43 $memory_4 = $memory_0; #line 44 $memory_5 = $memory_2; #line 44 if (c_rt_lib::get_hashcount($memory_4) > 1) {$memory_4 = {%{$memory_4}};}$memory_4->{'reg_size'} = $memory_5; #line 44 undef($memory_5); #line 45 $memory_6 = $memory_0->{'commands'}; #line 45 $memory_5 = register_cleaner_priv::recalculate_registers($memory_6, $memory_3); #line 45 undef($memory_6); #line 45 $memory_6 = $memory_5; #line 45 if (c_rt_lib::get_hashcount($memory_4) > 1) {$memory_4 = {%{$memory_4}};}$memory_4->{'commands'} = $memory_6; #line 45 undef($memory_5); #line 45 undef($memory_6); #line 46 undef($memory_0); #line 46 undef($memory_1); #line 46 undef($memory_2); #line 46 undef($memory_3); #line 46 return $memory_4; #line 46 undef($memory_1); #line 46 undef($memory_2); #line 46 undef($memory_3); #line 46 undef($memory_4); #line 46 undef($memory_0); #line 46 return; } sub register_cleaner_priv::recalculate_registers($$) { my $memory_0;my $memory_1;my $memory_2;my $memory_3;my $memory_4;my $memory_5;my $memory_6;my $memory_7;my $memory_8;my $memory_9;my $memory_10;my $memory_11;my $memory_12;my $memory_13;my $memory_14;my $memory_15;my $memory_16;my $memory_17;my $memory_18;my $memory_19;my $memory_20;my $memory_21;my $memory_22;$memory_0 = $_[0];$memory_1 = $_[1]; #line 51 $memory_2 = []; #line 52 $memory_4 = 0; #line 52 $memory_5 = 1; #line 52 $memory_6 = c_rt_lib::array_len($memory_0); #line 52 label_4: #line 52 $memory_7 = c_rt_lib::to_nl($memory_4 >= $memory_6); #line 52 if (c_rt_lib::check_true($memory_7)) {goto label_514;} #line 52 $memory_3 = $memory_0->[$memory_4]; #line 54 $memory_9 = $memory_3->{'cmd'}; #line 54 $memory_10 = c_rt_lib::ov_is($memory_9, 'arr_decl'); #line 54 if (c_rt_lib::check_true($memory_10)) {goto label_54;} #line 63 $memory_10 = c_rt_lib::ov_is($memory_9, 'hash_decl'); #line 63 if (c_rt_lib::check_true($memory_10)) {goto label_88;} #line 74 $memory_10 = c_rt_lib::ov_is($memory_9, 'func'); #line 74 if (c_rt_lib::check_true($memory_10)) {goto label_128;} #line 80 $memory_10 = c_rt_lib::ov_is($memory_9, 'call'); #line 80 if (c_rt_lib::check_true($memory_10)) {goto label_144;} #line 97 $memory_10 = c_rt_lib::ov_is($memory_9, 'una_op'); #line 97 if (c_rt_lib::check_true($memory_10)) {goto label_206;} #line 103 $memory_10 = c_rt_lib::ov_is($memory_9, 'bin_op'); #line 103 if (c_rt_lib::check_true($memory_10)) {goto label_224;} #line 110 $memory_10 = c_rt_lib::ov_is($memory_9, 'ov_is'); #line 110 if (c_rt_lib::check_true($memory_10)) {goto label_246;} #line 116 $memory_10 = c_rt_lib::ov_is($memory_9, 'ov_as'); #line 116 if (c_rt_lib::check_true($memory_10)) {goto label_264;} #line 122 $memory_10 = c_rt_lib::ov_is($memory_9, 'return'); #line 122 if (c_rt_lib::check_true($memory_10)) {goto label_282;} #line 128 $memory_10 = c_rt_lib::ov_is($memory_9, 'die'); #line 128 if (c_rt_lib::check_true($memory_10)) {goto label_310;} #line 130 $memory_10 = c_rt_lib::ov_is($memory_9, 'move'); #line 130 if (c_rt_lib::check_true($memory_10)) {goto label_318;} #line 135 $memory_10 = c_rt_lib::ov_is($memory_9, 'load_const'); #line 135 if (c_rt_lib::check_true($memory_10)) {goto label_334;} #line 140 $memory_10 = c_rt_lib::ov_is($memory_9, 'get_frm_idx'); #line 140 if (c_rt_lib::check_true($memory_10)) {goto label_348;} #line 146 $memory_10 = c_rt_lib::ov_is($memory_9, 'set_at_idx'); #line 146 if (c_rt_lib::check_true($memory_10)) {goto label_368;} #line 152 $memory_10 = c_rt_lib::ov_is($memory_9, 'get_val'); #line 152 if (c_rt_lib::check_true($memory_10)) {goto label_388;} #line 158 $memory_10 = c_rt_lib::ov_is($memory_9, 'set_val'); #line 158 if (c_rt_lib::check_true($memory_10)) {goto label_406;} #line 164 $memory_10 = c_rt_lib::ov_is($memory_9, 'ov_mk'); #line 164 if (c_rt_lib::check_true($memory_10)) {goto label_424;} #line 176 $memory_10 = c_rt_lib::ov_is($memory_9, 'prt_lbl'); #line 176 if (c_rt_lib::check_true($memory_10)) {goto label_463;} #line 178 $memory_10 = c_rt_lib::ov_is($memory_9, 'if_goto'); #line 178 if (c_rt_lib::check_true($memory_10)) {goto label_470;} #line 183 $memory_10 = c_rt_lib::ov_is($memory_9, 'goto'); #line 183 if (c_rt_lib::check_true($memory_10)) {goto label_484;} #line 185 $memory_10 = c_rt_lib::ov_is($memory_9, 'clear'); #line 185 if (c_rt_lib::check_true($memory_10)) {goto label_491;} #line 185 $memory_10 = "NOMATCHALERT"; #line 185 $memory_10 = [$memory_10,$memory_9]; #line 185 die(dfile::ssave($memory_10)); #line 54 label_54: #line 54 $memory_11 = c_rt_lib::ov_as($memory_9, 'arr_decl'); #line 55 $memory_12 = []; #line 56 $memory_13 = $memory_11->{'src'}; #line 56 $memory_15 = 0; #line 56 $memory_16 = 1; #line 56 $memory_17 = c_rt_lib::array_len($memory_13); #line 56 label_61: #line 56 $memory_18 = c_rt_lib::to_nl($memory_15 >= $memory_17); #line 56 if (c_rt_lib::check_true($memory_18)) {goto label_70;} #line 56 $memory_14 = $memory_13->[$memory_15]; #line 57 $memory_19 = c_rt_lib::hash_get_value($memory_1, $memory_14); #line 57 c_rt_lib::array_push($memory_12, $memory_19); #line 57 undef($memory_19); #line 58 $memory_15 = $memory_15 + $memory_16; #line 58 goto label_61; #line 58 label_70: #line 58 undef($memory_13); #line 58 undef($memory_14); #line 58 undef($memory_15); #line 58 undef($memory_16); #line 58 undef($memory_17); #line 58 undef($memory_18); #line 60 $memory_15 = $memory_11->{'dest'}; #line 60 $memory_14 = c_rt_lib::hash_get_value($memory_1, $memory_15); #line 60 undef($memory_15); #line 60 $memory_13 = {dest => $memory_14,src => $memory_12,}; #line 60 undef($memory_14); #line 60 $memory_13 = c_rt_lib::ov_mk_arg('arr_decl', $memory_13); #line 60 $memory_8 = $memory_13; #line 60 undef($memory_13); #line 60 undef($memory_12); #line 60 undef($memory_11); #line 63 goto label_499; #line 63 label_88: #line 63 $memory_11 = c_rt_lib::ov_as($memory_9, 'hash_decl'); #line 64 $memory_12 = []; #line 65 $memory_13 = $memory_11->{'src'}; #line 65 $memory_15 = 0; #line 65 $memory_16 = 1; #line 65 $memory_17 = c_rt_lib::array_len($memory_13); #line 65 label_95: #line 65 $memory_18 = c_rt_lib::to_nl($memory_15 >= $memory_17); #line 65 if (c_rt_lib::check_true($memory_18)) {goto label_110;} #line 65 $memory_14 = $memory_13->[$memory_15]; #line 67 $memory_20 = $memory_14->{'key'}; #line 67 $memory_22 = $memory_14->{'val'}; #line 67 $memory_21 = c_rt_lib::hash_get_value($memory_1, $memory_22); #line 67 undef($memory_22); #line 67 $memory_19 = {key => $memory_20,val => $memory_21,}; #line 67 undef($memory_20); #line 67 undef($memory_21); #line 67 c_rt_lib::array_push($memory_12, $memory_19); #line 67 undef($memory_19); #line 69 $memory_15 = $memory_15 + $memory_16; #line 69 goto label_95; #line 69 label_110: #line 69 undef($memory_13); #line 69 undef($memory_14); #line 69 undef($memory_15); #line 69 undef($memory_16); #line 69 undef($memory_17); #line 69 undef($memory_18); #line 71 $memory_15 = $memory_11->{'dest'}; #line 71 $memory_14 = c_rt_lib::hash_get_value($memory_1, $memory_15); #line 71 undef($memory_15); #line 71 $memory_13 = {dest => $memory_14,src => $memory_12,}; #line 71 undef($memory_14); #line 71 $memory_13 = c_rt_lib::ov_mk_arg('hash_decl', $memory_13); #line 71 $memory_8 = $memory_13; #line 71 undef($memory_13); #line 71 undef($memory_12); #line 71 undef($memory_11); #line 74 goto label_499; #line 74 label_128: #line 74 $memory_11 = c_rt_lib::ov_as($memory_9, 'func'); #line 76 $memory_14 = $memory_11->{'dest'}; #line 76 $memory_13 = c_rt_lib::hash_get_value($memory_1, $memory_14); #line 76 undef($memory_14); #line 77 $memory_14 = $memory_11->{'module'}; #line 78 $memory_15 = $memory_11->{'name'}; #line 78 $memory_12 = {dest => $memory_13,module => $memory_14,name => $memory_15,}; #line 78 undef($memory_13); #line 78 undef($memory_14); #line 78 undef($memory_15); #line 78 $memory_12 = c_rt_lib::ov_mk_arg('func', $memory_12); #line 78 $memory_8 = $memory_12; #line 78 undef($memory_12); #line 78 undef($memory_11); #line 80 goto label_499; #line 80 label_144: #line 80 $memory_11 = c_rt_lib::ov_as($memory_9, 'call'); #line 81 $memory_12 = []; #line 82 $memory_13 = $memory_11->{'args'}; #line 82 $memory_15 = 0; #line 82 $memory_16 = 1; #line 82 $memory_17 = c_rt_lib::array_len($memory_13); #line 82 label_151: #line 82 $memory_18 = c_rt_lib::to_nl($memory_15 >= $memory_17); #line 82 if (c_rt_lib::check_true($memory_18)) {goto label_184;} #line 82 $memory_14 = $memory_13->[$memory_15]; #line 84 $memory_20 = c_rt_lib::ov_is($memory_14, 'val'); #line 84 if (c_rt_lib::check_true($memory_20)) {goto label_162;} #line 86 $memory_20 = c_rt_lib::ov_is($memory_14, 'ref'); #line 86 if (c_rt_lib::check_true($memory_20)) {goto label_170;} #line 86 $memory_20 = "NOMATCHALERT"; #line 86 $memory_20 = [$memory_20,$memory_14]; #line 86 die(dfile::ssave($memory_20)); #line 84 label_162: #line 84 $memory_21 = c_rt_lib::ov_as($memory_14, 'val'); #line 85 $memory_22 = c_rt_lib::hash_get_value($memory_1, $memory_21); #line 85 $memory_22 = c_rt_lib::ov_mk_arg('val', $memory_22); #line 85 $memory_19 = $memory_22; #line 85 undef($memory_22); #line 85 undef($memory_21); #line 86 goto label_178; #line 86 label_170: #line 86 $memory_21 = c_rt_lib::ov_as($memory_14, 'ref'); #line 87 $memory_22 = c_rt_lib::hash_get_value($memory_1, $memory_21); #line 87 $memory_22 = c_rt_lib::ov_mk_arg('ref', $memory_22); #line 87 $memory_19 = $memory_22; #line 87 undef($memory_22); #line 87 undef($memory_21); #line 88 goto label_178; #line 88 label_178: #line 88 undef($memory_20); #line 89 c_rt_lib::array_push($memory_12, $memory_19); #line 89 undef($memory_19); #line 90 $memory_15 = $memory_15 + $memory_16; #line 90 goto label_151; #line 90 label_184: #line 90 undef($memory_13); #line 90 undef($memory_14); #line 90 undef($memory_15); #line 90 undef($memory_16); #line 90 undef($memory_17); #line 90 undef($memory_18); #line 92 $memory_15 = $memory_11->{'dest'}; #line 92 $memory_14 = c_rt_lib::hash_get_value($memory_1, $memory_15); #line 92 undef($memory_15); #line 93 $memory_15 = $memory_11->{'mod'}; #line 94 $memory_16 = $memory_11->{'fun_name'}; #line 94 $memory_13 = {dest => $memory_14,mod => $memory_15,fun_name => $memory_16,args => $memory_12,}; #line 94 undef($memory_14); #line 94 undef($memory_15); #line 94 undef($memory_16); #line 94 $memory_13 = c_rt_lib::ov_mk_arg('call', $memory_13); #line 94 $memory_8 = $memory_13; #line 94 undef($memory_13); #line 94 undef($memory_12); #line 94 undef($memory_11); #line 97 goto label_499; #line 97 label_206: #line 97 $memory_11 = c_rt_lib::ov_as($memory_9, 'una_op'); #line 99 $memory_14 = $memory_11->{'dest'}; #line 99 $memory_13 = c_rt_lib::hash_get_value($memory_1, $memory_14); #line 99 undef($memory_14); #line 100 $memory_15 = $memory_11->{'src'}; #line 100 $memory_14 = c_rt_lib::hash_get_value($memory_1, $memory_15); #line 100 undef($memory_15); #line 101 $memory_15 = $memory_11->{'op'}; #line 101 $memory_12 = {dest => $memory_13,src => $memory_14,op => $memory_15,}; #line 101 undef($memory_13); #line 101 undef($memory_14); #line 101 undef($memory_15); #line 101 $memory_12 = c_rt_lib::ov_mk_arg('una_op', $memory_12); #line 101 $memory_8 = $memory_12; #line 101 undef($memory_12); #line 101 undef($memory_11); #line 103 goto label_499; #line 103 label_224: #line 103 $memory_11 = c_rt_lib::ov_as($memory_9, 'bin_op'); #line 105 $memory_14 = $memory_11->{'dest'}; #line 105 $memory_13 = c_rt_lib::hash_get_value($memory_1, $memory_14); #line 105 undef($memory_14); #line 106 $memory_15 = $memory_11->{'left'}; #line 106 $memory_14 = c_rt_lib::hash_get_value($memory_1, $memory_15); #line 106 undef($memory_15); #line 107 $memory_16 = $memory_11->{'right'}; #line 107 $memory_15 = c_rt_lib::hash_get_value($memory_1, $memory_16); #line 107 undef($memory_16); #line 108 $memory_16 = $memory_11->{'op'}; #line 108 $memory_12 = {dest => $memory_13,left => $memory_14,right => $memory_15,op => $memory_16,}; #line 108 undef($memory_13); #line 108 undef($memory_14); #line 108 undef($memory_15); #line 108 undef($memory_16); #line 108 $memory_12 = c_rt_lib::ov_mk_arg('bin_op', $memory_12); #line 108 $memory_8 = $memory_12; #line 108 undef($memory_12); #line 108 undef($memory_11); #line 110 goto label_499; #line 110 label_246: #line 110 $memory_11 = c_rt_lib::ov_as($memory_9, 'ov_is'); #line 112 $memory_14 = $memory_11->{'dest'}; #line 112 $memory_13 = c_rt_lib::hash_get_value($memory_1, $memory_14); #line 112 undef($memory_14); #line 113 $memory_15 = $memory_11->{'src'}; #line 113 $memory_14 = c_rt_lib::hash_get_value($memory_1, $memory_15); #line 113 undef($memory_15); #line 114 $memory_15 = $memory_11->{'type'}; #line 114 $memory_12 = {dest => $memory_13,src => $memory_14,type => $memory_15,}; #line 114 undef($memory_13); #line 114 undef($memory_14); #line 114 undef($memory_15); #line 114 $memory_12 = c_rt_lib::ov_mk_arg('ov_is', $memory_12); #line 114 $memory_8 = $memory_12; #line 114 undef($memory_12); #line 114 undef($memory_11); #line 116 goto label_499; #line 116 label_264: #line 116 $memory_11 = c_rt_lib::ov_as($memory_9, 'ov_as'); #line 118 $memory_14 = $memory_11->{'dest'}; #line 118 $memory_13 = c_rt_lib::hash_get_value($memory_1, $memory_14); #line 118 undef($memory_14); #line 119 $memory_15 = $memory_11->{'src'}; #line 119 $memory_14 = c_rt_lib::hash_get_value($memory_1, $memory_15); #line 119 undef($memory_15); #line 120 $memory_15 = $memory_11->{'type'}; #line 120 $memory_12 = {dest => $memory_13,src => $memory_14,type => $memory_15,}; #line 120 undef($memory_13); #line 120 undef($memory_14); #line 120 undef($memory_15); #line 120 $memory_12 = c_rt_lib::ov_mk_arg('ov_as', $memory_12); #line 120 $memory_8 = $memory_12; #line 120 undef($memory_12); #line 120 undef($memory_11); #line 122 goto label_499; #line 122 label_282: #line 122 $memory_11 = c_rt_lib::ov_as($memory_9, 'return'); #line 123 $memory_12 = c_rt_lib::ov_is($memory_11, 'val'); #line 123 if (c_rt_lib::check_true($memory_12)) {goto label_291;} #line 125 $memory_12 = c_rt_lib::ov_is($memory_11, 'emp'); #line 125 if (c_rt_lib::check_true($memory_12)) {goto label_300;} #line 125 $memory_12 = "NOMATCHALERT"; #line 125 $memory_12 = [$memory_12,$memory_11]; #line 125 die(dfile::ssave($memory_12)); #line 123 label_291: #line 123 $memory_13 = c_rt_lib::ov_as($memory_11, 'val'); #line 124 $memory_14 = c_rt_lib::hash_get_value($memory_1, $memory_13); #line 124 $memory_14 = c_rt_lib::ov_mk_arg('val', $memory_14); #line 124 $memory_14 = c_rt_lib::ov_mk_arg('return', $memory_14); #line 124 $memory_8 = $memory_14; #line 124 undef($memory_14); #line 124 undef($memory_13); #line 125 goto label_306; #line 125 label_300: #line 126 $memory_13 = c_rt_lib::ov_mk_none('emp'); #line 126 $memory_13 = c_rt_lib::ov_mk_arg('return', $memory_13); #line 126 $memory_8 = $memory_13; #line 126 undef($memory_13); #line 127 goto label_306; #line 127 label_306: #line 127 undef($memory_12); #line 127 undef($memory_11); #line 128 goto label_499; #line 128 label_310: #line 128 $memory_11 = c_rt_lib::ov_as($memory_9, 'die'); #line 129 $memory_12 = c_rt_lib::hash_get_value($memory_1, $memory_11); #line 129 $memory_12 = c_rt_lib::ov_mk_arg('die', $memory_12); #line 129 $memory_8 = $memory_12; #line 129 undef($memory_12); #line 129 undef($memory_11); #line 130 goto label_499; #line 130 label_318: #line 130 $memory_11 = c_rt_lib::ov_as($memory_9, 'move'); #line 132 $memory_14 = $memory_11->{'dest'}; #line 132 $memory_13 = c_rt_lib::hash_get_value($memory_1, $memory_14); #line 132 undef($memory_14); #line 133 $memory_15 = $memory_11->{'src'}; #line 133 $memory_14 = c_rt_lib::hash_get_value($memory_1, $memory_15); #line 133 undef($memory_15); #line 133 $memory_12 = {dest => $memory_13,src => $memory_14,}; #line 133 undef($memory_13); #line 133 undef($memory_14); #line 133 $memory_12 = c_rt_lib::ov_mk_arg('move', $memory_12); #line 133 $memory_8 = $memory_12; #line 133 undef($memory_12); #line 133 undef($memory_11); #line 135 goto label_499; #line 135 label_334: #line 135 $memory_11 = c_rt_lib::ov_as($memory_9, 'load_const'); #line 137 $memory_14 = $memory_11->{'dest'}; #line 137 $memory_13 = c_rt_lib::hash_get_value($memory_1, $memory_14); #line 137 undef($memory_14); #line 138 $memory_14 = $memory_11->{'val'}; #line 138 $memory_12 = {dest => $memory_13,val => $memory_14,}; #line 138 undef($memory_13); #line 138 undef($memory_14); #line 138 $memory_12 = c_rt_lib::ov_mk_arg('load_const', $memory_12); #line 138 $memory_8 = $memory_12; #line 138 undef($memory_12); #line 138 undef($memory_11); #line 140 goto label_499; #line 140 label_348: #line 140 $memory_11 = c_rt_lib::ov_as($memory_9, 'get_frm_idx'); #line 142 $memory_14 = $memory_11->{'dest'}; #line 142 $memory_13 = c_rt_lib::hash_get_value($memory_1, $memory_14); #line 142 undef($memory_14); #line 143 $memory_15 = $memory_11->{'src'}; #line 143 $memory_14 = c_rt_lib::hash_get_value($memory_1, $memory_15); #line 143 undef($memory_15); #line 144 $memory_16 = $memory_11->{'idx'}; #line 144 $memory_15 = c_rt_lib::hash_get_value($memory_1, $memory_16); #line 144 undef($memory_16); #line 144 $memory_12 = {dest => $memory_13,src => $memory_14,idx => $memory_15,}; #line 144 undef($memory_13); #line 144 undef($memory_14); #line 144 undef($memory_15); #line 144 $memory_12 = c_rt_lib::ov_mk_arg('get_frm_idx', $memory_12); #line 144 $memory_8 = $memory_12; #line 144 undef($memory_12); #line 144 undef($memory_11); #line 146 goto label_499; #line 146 label_368: #line 146 $memory_11 = c_rt_lib::ov_as($memory_9, 'set_at_idx'); #line 148 $memory_14 = $memory_11->{'src'}; #line 148 $memory_13 = c_rt_lib::hash_get_value($memory_1, $memory_14); #line 148 undef($memory_14); #line 149 $memory_15 = $memory_11->{'idx'}; #line 149 $memory_14 = c_rt_lib::hash_get_value($memory_1, $memory_15); #line 149 undef($memory_15); #line 150 $memory_16 = $memory_11->{'val'}; #line 150 $memory_15 = c_rt_lib::hash_get_value($memory_1, $memory_16); #line 150 undef($memory_16); #line 150 $memory_12 = {src => $memory_13,idx => $memory_14,val => $memory_15,}; #line 150 undef($memory_13); #line 150 undef($memory_14); #line 150 undef($memory_15); #line 150 $memory_12 = c_rt_lib::ov_mk_arg('set_at_idx', $memory_12); #line 150 $memory_8 = $memory_12; #line 150 undef($memory_12); #line 150 undef($memory_11); #line 152 goto label_499; #line 152 label_388: #line 152 $memory_11 = c_rt_lib::ov_as($memory_9, 'get_val'); #line 154 $memory_13 = $memory_11->{'key'}; #line 155 $memory_15 = $memory_11->{'dest'}; #line 155 $memory_14 = c_rt_lib::hash_get_value($memory_1, $memory_15); #line 155 undef($memory_15); #line 156 $memory_16 = $memory_11->{'src'}; #line 156 $memory_15 = c_rt_lib::hash_get_value($memory_1, $memory_16); #line 156 undef($memory_16); #line 156 $memory_12 = {key => $memory_13,dest => $memory_14,src => $memory_15,}; #line 156 undef($memory_13); #line 156 undef($memory_14); #line 156 undef($memory_15); #line 156 $memory_12 = c_rt_lib::ov_mk_arg('get_val', $memory_12); #line 156 $memory_8 = $memory_12; #line 156 undef($memory_12); #line 156 undef($memory_11); #line 158 goto label_499; #line 158 label_406: #line 158 $memory_11 = c_rt_lib::ov_as($memory_9, 'set_val'); #line 160 $memory_14 = $memory_11->{'src'}; #line 160 $memory_13 = c_rt_lib::hash_get_value($memory_1, $memory_14); #line 160 undef($memory_14); #line 161 $memory_15 = $memory_11->{'val'}; #line 161 $memory_14 = c_rt_lib::hash_get_value($memory_1, $memory_15); #line 161 undef($memory_15); #line 162 $memory_15 = $memory_11->{'key'}; #line 162 $memory_12 = {src => $memory_13,val => $memory_14,key => $memory_15,}; #line 162 undef($memory_13); #line 162 undef($memory_14); #line 162 undef($memory_15); #line 162 $memory_12 = c_rt_lib::ov_mk_arg('set_val', $memory_12); #line 162 $memory_8 = $memory_12; #line 162 undef($memory_12); #line 162 undef($memory_11); #line 164 goto label_499; #line 164 label_424: #line 164 $memory_11 = c_rt_lib::ov_as($memory_9, 'ov_mk'); #line 166 $memory_13 = $memory_11->{'src'}; #line 166 $memory_14 = c_rt_lib::ov_is($memory_13, 'arg'); #line 166 if (c_rt_lib::check_true($memory_14)) {goto label_434;} #line 168 $memory_14 = c_rt_lib::ov_is($memory_13, 'emp'); #line 168 if (c_rt_lib::check_true($memory_14)) {goto label_442;} #line 168 $memory_14 = "NOMATCHALERT"; #line 168 $memory_14 = [$memory_14,$memory_13]; #line 168 die(dfile::ssave($memory_14)); #line 166 label_434: #line 166 $memory_15 = c_rt_lib::ov_as($memory_13, 'arg'); #line 167 $memory_16 = c_rt_lib::hash_get_value($memory_1, $memory_15); #line 167 $memory_16 = c_rt_lib::ov_mk_arg('arg', $memory_16); #line 167 $memory_12 = $memory_16; #line 167 undef($memory_16); #line 167 undef($memory_15); #line 168 goto label_447; #line 168 label_442: #line 169 $memory_15 = c_rt_lib::ov_mk_none('emp'); #line 169 $memory_12 = $memory_15; #line 169 undef($memory_15); #line 170 goto label_447; #line 170 label_447: #line 170 undef($memory_13); #line 170 undef($memory_14); #line 172 $memory_15 = $memory_11->{'dest'}; #line 172 $memory_14 = c_rt_lib::hash_get_value($memory_1, $memory_15); #line 172 undef($memory_15); #line 174 $memory_15 = $memory_11->{'name'}; #line 174 $memory_13 = {dest => $memory_14,src => $memory_12,name => $memory_15,}; #line 174 undef($memory_14); #line 174 undef($memory_15); #line 174 $memory_13 = c_rt_lib::ov_mk_arg('ov_mk', $memory_13); #line 174 $memory_8 = $memory_13; #line 174 undef($memory_13); #line 174 undef($memory_12); #line 174 undef($memory_11); #line 176 goto label_499; #line 176 label_463: #line 176 $memory_11 = c_rt_lib::ov_as($memory_9, 'prt_lbl'); #line 177 $memory_12 = c_rt_lib::ov_mk_arg('prt_lbl', $memory_11); #line 177 $memory_8 = $memory_12; #line 177 undef($memory_12); #line 177 undef($memory_11); #line 178 goto label_499; #line 178 label_470: #line 178 $memory_11 = c_rt_lib::ov_as($memory_9, 'if_goto'); #line 180 $memory_13 = $memory_11->{'dest'}; #line 181 $memory_15 = $memory_11->{'src'}; #line 181 $memory_14 = c_rt_lib::hash_get_value($memory_1, $memory_15); #line 181 undef($memory_15); #line 181 $memory_12 = {dest => $memory_13,src => $memory_14,}; #line 181 undef($memory_13); #line 181 undef($memory_14); #line 181 $memory_12 = c_rt_lib::ov_mk_arg('if_goto', $memory_12); #line 181 $memory_8 = $memory_12; #line 181 undef($memory_12); #line 181 undef($memory_11); #line 183 goto label_499; #line 183 label_484: #line 183 $memory_11 = c_rt_lib::ov_as($memory_9, 'goto'); #line 184 $memory_12 = c_rt_lib::ov_mk_arg('goto', $memory_11); #line 184 $memory_8 = $memory_12; #line 184 undef($memory_12); #line 184 undef($memory_11); #line 185 goto label_499; #line 185 label_491: #line 185 $memory_11 = c_rt_lib::ov_as($memory_9, 'clear'); #line 186 $memory_12 = c_rt_lib::hash_get_value($memory_1, $memory_11); #line 186 $memory_12 = c_rt_lib::ov_mk_arg('clear', $memory_12); #line 186 $memory_8 = $memory_12; #line 186 undef($memory_12); #line 186 undef($memory_11); #line 187 goto label_499; #line 187 label_499: #line 187 undef($memory_9); #line 187 undef($memory_10); #line 189 $memory_11 = $memory_3->{'annotation'}; #line 189 $memory_10 = register_cleaner_priv::recalculate_annotation($memory_11, $memory_1); #line 189 undef($memory_11); #line 190 $memory_11 = $memory_3->{'debug'}; #line 190 $memory_9 = {annotation => $memory_10,debug => $memory_11,cmd => $memory_8,}; #line 190 undef($memory_10); #line 190 undef($memory_11); #line 190 c_rt_lib::array_push($memory_2, $memory_9); #line 190 undef($memory_9); #line 190 undef($memory_8); #line 193 $memory_4 = $memory_4 + $memory_5; #line 193 goto label_4; #line 193 label_514: #line 193 undef($memory_3); #line 193 undef($memory_4); #line 193 undef($memory_5); #line 193 undef($memory_6); #line 193 undef($memory_7); #line 194 undef($memory_0); #line 194 undef($memory_1); #line 194 return $memory_2; #line 194 undef($memory_2); #line 194 undef($memory_0); #line 194 undef($memory_1); #line 194 return; } sub register_cleaner_priv::recalculate_annotation($$) { my $memory_0;my $memory_1;my $memory_2;my $memory_3;my $memory_4;my $memory_5;my $memory_6;my $memory_7;my $memory_8;my $memory_9;my $memory_10;$memory_0 = $_[0];$memory_1 = $_[1]; #line 198 $memory_2 = c_rt_lib::ov_is($memory_0, 'none'); #line 198 if (c_rt_lib::check_true($memory_2)) {goto label_7;} #line 200 $memory_2 = c_rt_lib::ov_is($memory_0, 'const'); #line 200 if (c_rt_lib::check_true($memory_2)) {goto label_15;} #line 200 $memory_2 = "NOMATCHALERT"; #line 200 $memory_2 = [$memory_2,$memory_0]; #line 200 die(dfile::ssave($memory_2)); #line 198 label_7: #line 199 $memory_3 = c_rt_lib::ov_mk_none('none'); #line 199 undef($memory_0); #line 199 undef($memory_1); #line 199 undef($memory_2); #line 199 return $memory_3; #line 199 undef($memory_3); #line 200 goto label_47; #line 200 label_15: #line 200 $memory_3 = c_rt_lib::ov_as($memory_0, 'const'); #line 201 $memory_4 = []; #line 202 $memory_6 = 0; #line 202 $memory_7 = 1; #line 202 $memory_8 = c_rt_lib::array_len($memory_3); #line 202 label_21: #line 202 $memory_9 = c_rt_lib::to_nl($memory_6 >= $memory_8); #line 202 if (c_rt_lib::check_true($memory_9)) {goto label_30;} #line 202 $memory_5 = $memory_3->[$memory_6]; #line 203 $memory_10 = c_rt_lib::hash_get_value($memory_1, $memory_5); #line 203 c_rt_lib::array_push($memory_4, $memory_10); #line 203 undef($memory_10); #line 204 $memory_6 = $memory_6 + $memory_7; #line 204 goto label_21; #line 204 label_30: #line 204 undef($memory_5); #line 204 undef($memory_6); #line 204 undef($memory_7); #line 204 undef($memory_8); #line 204 undef($memory_9); #line 205 $memory_5 = c_rt_lib::ov_mk_arg('const', $memory_4); #line 205 undef($memory_0); #line 205 undef($memory_1); #line 205 undef($memory_2); #line 205 undef($memory_3); #line 205 undef($memory_4); #line 205 return $memory_5; #line 205 undef($memory_5); #line 205 undef($memory_4); #line 205 undef($memory_3); #line 206 goto label_47; #line 206 label_47: #line 206 undef($memory_2); #line 206 undef($memory_0); #line 206 undef($memory_1); #line 206 return; } sub register_cleaner_priv::find_unused_regs($) { my $memory_0;my $memory_1;my $memory_2;my $memory_3;my $memory_4;my $memory_5;my $memory_6;my $memory_7;my $memory_8;my $memory_9;my $memory_10;my $memory_11;my $memory_12;my $memory_13;my $memory_14;my $memory_15;my $memory_16;my $memory_17;my $memory_18;my $memory_19;my $memory_20;$memory_0 = $_[0]; #line 210 $memory_1 = {}; #line 211 $memory_2 = $memory_0->{'reg_size'}; #line 211 $memory_3 = 0; #line 211 $memory_4 = 1; #line 211 label_4: #line 211 $memory_5 = c_rt_lib::to_nl($memory_3 >= $memory_2); #line 211 if (c_rt_lib::check_true($memory_5)) {goto label_14;} #line 212 $memory_6 = c_rt_lib::to_nl(0); #line 212 $memory_7 = $memory_6; #line 212 c_rt_lib::hash_set_value($memory_1, $memory_3, $memory_7); #line 212 undef($memory_6); #line 212 undef($memory_7); #line 213 $memory_3 = $memory_3 + $memory_4; #line 213 goto label_4; #line 213 label_14: #line 213 undef($memory_2); #line 213 undef($memory_3); #line 213 undef($memory_4); #line 213 undef($memory_5); #line 215 $memory_3 = $memory_0->{'args_type'}; #line 215 $memory_2 = array::len($memory_3); #line 215 undef($memory_3); #line 215 $memory_3 = 0; #line 215 $memory_4 = 1; #line 215 label_24: #line 215 $memory_5 = c_rt_lib::to_nl($memory_3 >= $memory_2); #line 215 if (c_rt_lib::check_true($memory_5)) {goto label_34;} #line 216 $memory_6 = c_rt_lib::to_nl(1); #line 216 $memory_7 = $memory_6; #line 216 c_rt_lib::hash_set_value($memory_1, $memory_3, $memory_7); #line 216 undef($memory_6); #line 216 undef($memory_7); #line 217 $memory_3 = $memory_3 + $memory_4; #line 217 goto label_24; #line 217 label_34: #line 217 undef($memory_2); #line 217 undef($memory_3); #line 217 undef($memory_4); #line 217 undef($memory_5); #line 219 $memory_2 = $memory_0->{'commands'}; #line 219 $memory_4 = 0; #line 219 $memory_5 = 1; #line 219 $memory_6 = c_rt_lib::array_len($memory_2); #line 219 label_43: #line 219 $memory_7 = c_rt_lib::to_nl($memory_4 >= $memory_6); #line 219 if (c_rt_lib::check_true($memory_7)) {goto label_520;} #line 219 $memory_3 = $memory_2->[$memory_4]; #line 220 $memory_8 = $memory_3->{'cmd'}; #line 220 $memory_9 = c_rt_lib::ov_is($memory_8, 'arr_decl'); #line 220 if (c_rt_lib::check_true($memory_9)) {goto label_93;} #line 225 $memory_9 = c_rt_lib::ov_is($memory_8, 'hash_decl'); #line 225 if (c_rt_lib::check_true($memory_9)) {goto label_126;} #line 230 $memory_9 = c_rt_lib::ov_is($memory_8, 'func'); #line 230 if (c_rt_lib::check_true($memory_9)) {goto label_161;} #line 232 $memory_9 = c_rt_lib::ov_is($memory_8, 'call'); #line 232 if (c_rt_lib::check_true($memory_9)) {goto label_172;} #line 241 $memory_9 = c_rt_lib::ov_is($memory_8, 'una_op'); #line 241 if (c_rt_lib::check_true($memory_9)) {goto label_227;} #line 244 $memory_9 = c_rt_lib::ov_is($memory_8, 'bin_op'); #line 244 if (c_rt_lib::check_true($memory_9)) {goto label_245;} #line 248 $memory_9 = c_rt_lib::ov_is($memory_8, 'ov_is'); #line 248 if (c_rt_lib::check_true($memory_9)) {goto label_270;} #line 251 $memory_9 = c_rt_lib::ov_is($memory_8, 'ov_as'); #line 251 if (c_rt_lib::check_true($memory_9)) {goto label_288;} #line 254 $memory_9 = c_rt_lib::ov_is($memory_8, 'return'); #line 254 if (c_rt_lib::check_true($memory_9)) {goto label_306;} #line 259 $memory_9 = c_rt_lib::ov_is($memory_8, 'die'); #line 259 if (c_rt_lib::check_true($memory_9)) {goto label_330;} #line 261 $memory_9 = c_rt_lib::ov_is($memory_8, 'move'); #line 261 if (c_rt_lib::check_true($memory_9)) {goto label_339;} #line 264 $memory_9 = c_rt_lib::ov_is($memory_8, 'load_const'); #line 264 if (c_rt_lib::check_true($memory_9)) {goto label_357;} #line 266 $memory_9 = c_rt_lib::ov_is($memory_8, 'get_frm_idx'); #line 266 if (c_rt_lib::check_true($memory_9)) {goto label_368;} #line 270 $memory_9 = c_rt_lib::ov_is($memory_8, 'set_at_idx'); #line 270 if (c_rt_lib::check_true($memory_9)) {goto label_393;} #line 274 $memory_9 = c_rt_lib::ov_is($memory_8, 'get_val'); #line 274 if (c_rt_lib::check_true($memory_9)) {goto label_418;} #line 277 $memory_9 = c_rt_lib::ov_is($memory_8, 'set_val'); #line 277 if (c_rt_lib::check_true($memory_9)) {goto label_436;} #line 280 $memory_9 = c_rt_lib::ov_is($memory_8, 'ov_mk'); #line 280 if (c_rt_lib::check_true($memory_9)) {goto label_454;} #line 286 $memory_9 = c_rt_lib::ov_is($memory_8, 'prt_lbl'); #line 286 if (c_rt_lib::check_true($memory_9)) {goto label_487;} #line 287 $memory_9 = c_rt_lib::ov_is($memory_8, 'if_goto'); #line 287 if (c_rt_lib::check_true($memory_9)) {goto label_491;} #line 289 $memory_9 = c_rt_lib::ov_is($memory_8, 'goto'); #line 289 if (c_rt_lib::check_true($memory_9)) {goto label_502;} #line 290 $memory_9 = c_rt_lib::ov_is($memory_8, 'clear'); #line 290 if (c_rt_lib::check_true($memory_9)) {goto label_506;} #line 290 $memory_9 = "NOMATCHALERT"; #line 290 $memory_9 = [$memory_9,$memory_8]; #line 290 die(dfile::ssave($memory_9)); #line 220 label_93: #line 220 $memory_10 = c_rt_lib::ov_as($memory_8, 'arr_decl'); #line 221 $memory_11 = c_rt_lib::to_nl(1); #line 221 $memory_13 = $memory_10->{'dest'}; #line 221 $memory_12 = $memory_11; #line 221 c_rt_lib::hash_set_value($memory_1, $memory_13, $memory_12); #line 221 undef($memory_11); #line 221 undef($memory_12); #line 221 undef($memory_13); #line 222 $memory_11 = $memory_10->{'src'}; #line 222 $memory_13 = 0; #line 222 $memory_14 = 1; #line 222 $memory_15 = c_rt_lib::array_len($memory_11); #line 222 label_106: #line 222 $memory_16 = c_rt_lib::to_nl($memory_13 >= $memory_15); #line 222 if (c_rt_lib::check_true($memory_16)) {goto label_117;} #line 222 $memory_12 = $memory_11->[$memory_13]; #line 223 $memory_17 = c_rt_lib::to_nl(1); #line 223 $memory_18 = $memory_17; #line 223 c_rt_lib::hash_set_value($memory_1, $memory_12, $memory_18); #line 223 undef($memory_17); #line 223 undef($memory_18); #line 224 $memory_13 = $memory_13 + $memory_14; #line 224 goto label_106; #line 224 label_117: #line 224 undef($memory_11); #line 224 undef($memory_12); #line 224 undef($memory_13); #line 224 undef($memory_14); #line 224 undef($memory_15); #line 224 undef($memory_16); #line 224 undef($memory_10); #line 225 goto label_515; #line 225 label_126: #line 225 $memory_10 = c_rt_lib::ov_as($memory_8, 'hash_decl'); #line 226 $memory_11 = c_rt_lib::to_nl(1); #line 226 $memory_13 = $memory_10->{'dest'}; #line 226 $memory_12 = $memory_11; #line 226 c_rt_lib::hash_set_value($memory_1, $memory_13, $memory_12); #line 226 undef($memory_11); #line 226 undef($memory_12); #line 226 undef($memory_13); #line 227 $memory_11 = $memory_10->{'src'}; #line 227 $memory_13 = 0; #line 227 $memory_14 = 1; #line 227 $memory_15 = c_rt_lib::array_len($memory_11); #line 227 label_139: #line 227 $memory_16 = c_rt_lib::to_nl($memory_13 >= $memory_15); #line 227 if (c_rt_lib::check_true($memory_16)) {goto label_152;} #line 227 $memory_12 = $memory_11->[$memory_13]; #line 228 $memory_17 = c_rt_lib::to_nl(1); #line 228 $memory_19 = $memory_12->{'val'}; #line 228 $memory_18 = $memory_17; #line 228 c_rt_lib::hash_set_value($memory_1, $memory_19, $memory_18); #line 228 undef($memory_17); #line 228 undef($memory_18); #line 228 undef($memory_19); #line 229 $memory_13 = $memory_13 + $memory_14; #line 229 goto label_139; #line 229 label_152: #line 229 undef($memory_11); #line 229 undef($memory_12); #line 229 undef($memory_13); #line 229 undef($memory_14); #line 229 undef($memory_15); #line 229 undef($memory_16); #line 229 undef($memory_10); #line 230 goto label_515; #line 230 label_161: #line 230 $memory_10 = c_rt_lib::ov_as($memory_8, 'func'); #line 231 $memory_11 = c_rt_lib::to_nl(1); #line 231 $memory_13 = $memory_10->{'dest'}; #line 231 $memory_12 = $memory_11; #line 231 c_rt_lib::hash_set_value($memory_1, $memory_13, $memory_12); #line 231 undef($memory_11); #line 231 undef($memory_12); #line 231 undef($memory_13); #line 231 undef($memory_10); #line 232 goto label_515; #line 232 label_172: #line 232 $memory_10 = c_rt_lib::ov_as($memory_8, 'call'); #line 233 $memory_11 = c_rt_lib::to_nl(1); #line 233 $memory_13 = $memory_10->{'dest'}; #line 233 $memory_12 = $memory_11; #line 233 c_rt_lib::hash_set_value($memory_1, $memory_13, $memory_12); #line 233 undef($memory_11); #line 233 undef($memory_12); #line 233 undef($memory_13); #line 234 $memory_11 = $memory_10->{'args'}; #line 234 $memory_13 = 0; #line 234 $memory_14 = 1; #line 234 $memory_15 = c_rt_lib::array_len($memory_11); #line 234 label_185: #line 234 $memory_16 = c_rt_lib::to_nl($memory_13 >= $memory_15); #line 234 if (c_rt_lib::check_true($memory_16)) {goto label_218;} #line 234 $memory_12 = $memory_11->[$memory_13]; #line 235 $memory_17 = c_rt_lib::ov_is($memory_12, 'val'); #line 235 if (c_rt_lib::check_true($memory_17)) {goto label_196;} #line 237 $memory_17 = c_rt_lib::ov_is($memory_12, 'ref'); #line 237 if (c_rt_lib::check_true($memory_17)) {goto label_205;} #line 237 $memory_17 = "NOMATCHALERT"; #line 237 $memory_17 = [$memory_17,$memory_12]; #line 237 die(dfile::ssave($memory_17)); #line 235 label_196: #line 235 $memory_18 = c_rt_lib::ov_as($memory_12, 'val'); #line 236 $memory_19 = c_rt_lib::to_nl(1); #line 236 $memory_20 = $memory_19; #line 236 c_rt_lib::hash_set_value($memory_1, $memory_18, $memory_20); #line 236 undef($memory_19); #line 236 undef($memory_20); #line 236 undef($memory_18); #line 237 goto label_214; #line 237 label_205: #line 237 $memory_18 = c_rt_lib::ov_as($memory_12, 'ref'); #line 238 $memory_19 = c_rt_lib::to_nl(1); #line 238 $memory_20 = $memory_19; #line 238 c_rt_lib::hash_set_value($memory_1, $memory_18, $memory_20); #line 238 undef($memory_19); #line 238 undef($memory_20); #line 238 undef($memory_18); #line 239 goto label_214; #line 239 label_214: #line 239 undef($memory_17); #line 240 $memory_13 = $memory_13 + $memory_14; #line 240 goto label_185; #line 240 label_218: #line 240 undef($memory_11); #line 240 undef($memory_12); #line 240 undef($memory_13); #line 240 undef($memory_14); #line 240 undef($memory_15); #line 240 undef($memory_16); #line 240 undef($memory_10); #line 241 goto label_515; #line 241 label_227: #line 241 $memory_10 = c_rt_lib::ov_as($memory_8, 'una_op'); #line 242 $memory_11 = c_rt_lib::to_nl(1); #line 242 $memory_13 = $memory_10->{'dest'}; #line 242 $memory_12 = $memory_11; #line 242 c_rt_lib::hash_set_value($memory_1, $memory_13, $memory_12); #line 242 undef($memory_11); #line 242 undef($memory_12); #line 242 undef($memory_13); #line 243 $memory_11 = c_rt_lib::to_nl(1); #line 243 $memory_13 = $memory_10->{'src'}; #line 243 $memory_12 = $memory_11; #line 243 c_rt_lib::hash_set_value($memory_1, $memory_13, $memory_12); #line 243 undef($memory_11); #line 243 undef($memory_12); #line 243 undef($memory_13); #line 243 undef($memory_10); #line 244 goto label_515; #line 244 label_245: #line 244 $memory_10 = c_rt_lib::ov_as($memory_8, 'bin_op'); #line 245 $memory_11 = c_rt_lib::to_nl(1); #line 245 $memory_13 = $memory_10->{'dest'}; #line 245 $memory_12 = $memory_11; #line 245 c_rt_lib::hash_set_value($memory_1, $memory_13, $memory_12); #line 245 undef($memory_11); #line 245 undef($memory_12); #line 245 undef($memory_13); #line 246 $memory_11 = c_rt_lib::to_nl(1); #line 246 $memory_13 = $memory_10->{'left'}; #line 246 $memory_12 = $memory_11; #line 246 c_rt_lib::hash_set_value($memory_1, $memory_13, $memory_12); #line 246 undef($memory_11); #line 246 undef($memory_12); #line 246 undef($memory_13); #line 247 $memory_11 = c_rt_lib::to_nl(1); #line 247 $memory_13 = $memory_10->{'right'}; #line 247 $memory_12 = $memory_11; #line 247 c_rt_lib::hash_set_value($memory_1, $memory_13, $memory_12); #line 247 undef($memory_11); #line 247 undef($memory_12); #line 247 undef($memory_13); #line 247 undef($memory_10); #line 248 goto label_515; #line 248 label_270: #line 248 $memory_10 = c_rt_lib::ov_as($memory_8, 'ov_is'); #line 249 $memory_11 = c_rt_lib::to_nl(1); #line 249 $memory_13 = $memory_10->{'dest'}; #line 249 $memory_12 = $memory_11; #line 249 c_rt_lib::hash_set_value($memory_1, $memory_13, $memory_12); #line 249 undef($memory_11); #line 249 undef($memory_12); #line 249 undef($memory_13); #line 250 $memory_11 = c_rt_lib::to_nl(1); #line 250 $memory_13 = $memory_10->{'src'}; #line 250 $memory_12 = $memory_11; #line 250 c_rt_lib::hash_set_value($memory_1, $memory_13, $memory_12); #line 250 undef($memory_11); #line 250 undef($memory_12); #line 250 undef($memory_13); #line 250 undef($memory_10); #line 251 goto label_515; #line 251 label_288: #line 251 $memory_10 = c_rt_lib::ov_as($memory_8, 'ov_as'); #line 252 $memory_11 = c_rt_lib::to_nl(1); #line 252 $memory_13 = $memory_10->{'dest'}; #line 252 $memory_12 = $memory_11; #line 252 c_rt_lib::hash_set_value($memory_1, $memory_13, $memory_12); #line 252 undef($memory_11); #line 252 undef($memory_12); #line 252 undef($memory_13); #line 253 $memory_11 = c_rt_lib::to_nl(1); #line 253 $memory_13 = $memory_10->{'src'}; #line 253 $memory_12 = $memory_11; #line 253 c_rt_lib::hash_set_value($memory_1, $memory_13, $memory_12); #line 253 undef($memory_11); #line 253 undef($memory_12); #line 253 undef($memory_13); #line 253 undef($memory_10); #line 254 goto label_515; #line 254 label_306: #line 254 $memory_10 = c_rt_lib::ov_as($memory_8, 'return'); #line 255 $memory_11 = c_rt_lib::ov_is($memory_10, 'val'); #line 255 if (c_rt_lib::check_true($memory_11)) {goto label_315;} #line 257 $memory_11 = c_rt_lib::ov_is($memory_10, 'emp'); #line 257 if (c_rt_lib::check_true($memory_11)) {goto label_324;} #line 257 $memory_11 = "NOMATCHALERT"; #line 257 $memory_11 = [$memory_11,$memory_10]; #line 257 die(dfile::ssave($memory_11)); #line 255 label_315: #line 255 $memory_12 = c_rt_lib::ov_as($memory_10, 'val'); #line 256 $memory_13 = c_rt_lib::to_nl(1); #line 256 $memory_14 = $memory_13; #line 256 c_rt_lib::hash_set_value($memory_1, $memory_12, $memory_14); #line 256 undef($memory_13); #line 256 undef($memory_14); #line 256 undef($memory_12); #line 257 goto label_326; #line 257 label_324: #line 258 goto label_326; #line 258 label_326: #line 258 undef($memory_11); #line 258 undef($memory_10); #line 259 goto label_515; #line 259 label_330: #line 259 $memory_10 = c_rt_lib::ov_as($memory_8, 'die'); #line 260 $memory_11 = c_rt_lib::to_nl(1); #line 260 $memory_12 = $memory_11; #line 260 c_rt_lib::hash_set_value($memory_1, $memory_10, $memory_12); #line 260 undef($memory_11); #line 260 undef($memory_12); #line 260 undef($memory_10); #line 261 goto label_515; #line 261 label_339: #line 261 $memory_10 = c_rt_lib::ov_as($memory_8, 'move'); #line 262 $memory_11 = c_rt_lib::to_nl(1); #line 262 $memory_13 = $memory_10->{'dest'}; #line 262 $memory_12 = $memory_11; #line 262 c_rt_lib::hash_set_value($memory_1, $memory_13, $memory_12); #line 262 undef($memory_11); #line 262 undef($memory_12); #line 262 undef($memory_13); #line 263 $memory_11 = c_rt_lib::to_nl(1); #line 263 $memory_13 = $memory_10->{'src'}; #line 263 $memory_12 = $memory_11; #line 263 c_rt_lib::hash_set_value($memory_1, $memory_13, $memory_12); #line 263 undef($memory_11); #line 263 undef($memory_12); #line 263 undef($memory_13); #line 263 undef($memory_10); #line 264 goto label_515; #line 264 label_357: #line 264 $memory_10 = c_rt_lib::ov_as($memory_8, 'load_const'); #line 265 $memory_11 = c_rt_lib::to_nl(1); #line 265 $memory_13 = $memory_10->{'dest'}; #line 265 $memory_12 = $memory_11; #line 265 c_rt_lib::hash_set_value($memory_1, $memory_13, $memory_12); #line 265 undef($memory_11); #line 265 undef($memory_12); #line 265 undef($memory_13); #line 265 undef($memory_10); #line 266 goto label_515; #line 266 label_368: #line 266 $memory_10 = c_rt_lib::ov_as($memory_8, 'get_frm_idx'); #line 267 $memory_11 = c_rt_lib::to_nl(1); #line 267 $memory_13 = $memory_10->{'dest'}; #line 267 $memory_12 = $memory_11; #line 267 c_rt_lib::hash_set_value($memory_1, $memory_13, $memory_12); #line 267 undef($memory_11); #line 267 undef($memory_12); #line 267 undef($memory_13); #line 268 $memory_11 = c_rt_lib::to_nl(1); #line 268 $memory_13 = $memory_10->{'src'}; #line 268 $memory_12 = $memory_11; #line 268 c_rt_lib::hash_set_value($memory_1, $memory_13, $memory_12); #line 268 undef($memory_11); #line 268 undef($memory_12); #line 268 undef($memory_13); #line 269 $memory_11 = c_rt_lib::to_nl(1); #line 269 $memory_13 = $memory_10->{'idx'}; #line 269 $memory_12 = $memory_11; #line 269 c_rt_lib::hash_set_value($memory_1, $memory_13, $memory_12); #line 269 undef($memory_11); #line 269 undef($memory_12); #line 269 undef($memory_13); #line 269 undef($memory_10); #line 270 goto label_515; #line 270 label_393: #line 270 $memory_10 = c_rt_lib::ov_as($memory_8, 'set_at_idx'); #line 271 $memory_11 = c_rt_lib::to_nl(1); #line 271 $memory_13 = $memory_10->{'val'}; #line 271 $memory_12 = $memory_11; #line 271 c_rt_lib::hash_set_value($memory_1, $memory_13, $memory_12); #line 271 undef($memory_11); #line 271 undef($memory_12); #line 271 undef($memory_13); #line 272 $memory_11 = c_rt_lib::to_nl(1); #line 272 $memory_13 = $memory_10->{'src'}; #line 272 $memory_12 = $memory_11; #line 272 c_rt_lib::hash_set_value($memory_1, $memory_13, $memory_12); #line 272 undef($memory_11); #line 272 undef($memory_12); #line 272 undef($memory_13); #line 273 $memory_11 = c_rt_lib::to_nl(1); #line 273 $memory_13 = $memory_10->{'idx'}; #line 273 $memory_12 = $memory_11; #line 273 c_rt_lib::hash_set_value($memory_1, $memory_13, $memory_12); #line 273 undef($memory_11); #line 273 undef($memory_12); #line 273 undef($memory_13); #line 273 undef($memory_10); #line 274 goto label_515; #line 274 label_418: #line 274 $memory_10 = c_rt_lib::ov_as($memory_8, 'get_val'); #line 275 $memory_11 = c_rt_lib::to_nl(1); #line 275 $memory_13 = $memory_10->{'dest'}; #line 275 $memory_12 = $memory_11; #line 275 c_rt_lib::hash_set_value($memory_1, $memory_13, $memory_12); #line 275 undef($memory_11); #line 275 undef($memory_12); #line 275 undef($memory_13); #line 276 $memory_11 = c_rt_lib::to_nl(1); #line 276 $memory_13 = $memory_10->{'src'}; #line 276 $memory_12 = $memory_11; #line 276 c_rt_lib::hash_set_value($memory_1, $memory_13, $memory_12); #line 276 undef($memory_11); #line 276 undef($memory_12); #line 276 undef($memory_13); #line 276 undef($memory_10); #line 277 goto label_515; #line 277 label_436: #line 277 $memory_10 = c_rt_lib::ov_as($memory_8, 'set_val'); #line 278 $memory_11 = c_rt_lib::to_nl(1); #line 278 $memory_13 = $memory_10->{'src'}; #line 278 $memory_12 = $memory_11; #line 278 c_rt_lib::hash_set_value($memory_1, $memory_13, $memory_12); #line 278 undef($memory_11); #line 278 undef($memory_12); #line 278 undef($memory_13); #line 279 $memory_11 = c_rt_lib::to_nl(1); #line 279 $memory_13 = $memory_10->{'val'}; #line 279 $memory_12 = $memory_11; #line 279 c_rt_lib::hash_set_value($memory_1, $memory_13, $memory_12); #line 279 undef($memory_11); #line 279 undef($memory_12); #line 279 undef($memory_13); #line 279 undef($memory_10); #line 280 goto label_515; #line 280 label_454: #line 280 $memory_10 = c_rt_lib::ov_as($memory_8, 'ov_mk'); #line 281 $memory_11 = c_rt_lib::to_nl(1); #line 281 $memory_13 = $memory_10->{'dest'}; #line 281 $memory_12 = $memory_11; #line 281 c_rt_lib::hash_set_value($memory_1, $memory_13, $memory_12); #line 281 undef($memory_11); #line 281 undef($memory_12); #line 281 undef($memory_13); #line 282 $memory_11 = $memory_10->{'src'}; #line 282 $memory_12 = c_rt_lib::ov_is($memory_11, 'arg'); #line 282 if (c_rt_lib::check_true($memory_12)) {goto label_471;} #line 284 $memory_12 = c_rt_lib::ov_is($memory_11, 'emp'); #line 284 if (c_rt_lib::check_true($memory_12)) {goto label_480;} #line 284 $memory_12 = "NOMATCHALERT"; #line 284 $memory_12 = [$memory_12,$memory_11]; #line 284 die(dfile::ssave($memory_12)); #line 282 label_471: #line 282 $memory_13 = c_rt_lib::ov_as($memory_11, 'arg'); #line 283 $memory_14 = c_rt_lib::to_nl(1); #line 283 $memory_15 = $memory_14; #line 283 c_rt_lib::hash_set_value($memory_1, $memory_13, $memory_15); #line 283 undef($memory_14); #line 283 undef($memory_15); #line 283 undef($memory_13); #line 284 goto label_482; #line 284 label_480: #line 285 goto label_482; #line 285 label_482: #line 285 undef($memory_11); #line 285 undef($memory_12); #line 285 undef($memory_10); #line 286 goto label_515; #line 286 label_487: #line 286 $memory_10 = c_rt_lib::ov_as($memory_8, 'prt_lbl'); #line 286 undef($memory_10); #line 287 goto label_515; #line 287 label_491: #line 287 $memory_10 = c_rt_lib::ov_as($memory_8, 'if_goto'); #line 288 $memory_11 = c_rt_lib::to_nl(1); #line 288 $memory_13 = $memory_10->{'src'}; #line 288 $memory_12 = $memory_11; #line 288 c_rt_lib::hash_set_value($memory_1, $memory_13, $memory_12); #line 288 undef($memory_11); #line 288 undef($memory_12); #line 288 undef($memory_13); #line 288 undef($memory_10); #line 289 goto label_515; #line 289 label_502: #line 289 $memory_10 = c_rt_lib::ov_as($memory_8, 'goto'); #line 289 undef($memory_10); #line 290 goto label_515; #line 290 label_506: #line 290 $memory_10 = c_rt_lib::ov_as($memory_8, 'clear'); #line 291 $memory_11 = c_rt_lib::to_nl(1); #line 291 $memory_12 = $memory_11; #line 291 c_rt_lib::hash_set_value($memory_1, $memory_10, $memory_12); #line 291 undef($memory_11); #line 291 undef($memory_12); #line 291 undef($memory_10); #line 292 goto label_515; #line 292 label_515: #line 292 undef($memory_8); #line 292 undef($memory_9); #line 293 $memory_4 = $memory_4 + $memory_5; #line 293 goto label_43; #line 293 label_520: #line 293 undef($memory_2); #line 293 undef($memory_3); #line 293 undef($memory_4); #line 293 undef($memory_5); #line 293 undef($memory_6); #line 293 undef($memory_7); #line 294 undef($memory_0); #line 294 return $memory_1; #line 294 undef($memory_1); #line 294 undef($memory_0); #line 294 return; }
nianiolang/nl
bin/nianio_lang_pm/register_cleaner.pm
Perl
mit
51,653
# LaTeX2HTML 99.2beta6 (1.42) # Associate images original text with physical files. $key = q/^{eme};MSF=1.6;AAT/; $cached_env_img{$key} = q|<IMG WIDTH="28" HEIGHT="15" ALIGN="BOTTOM" BORDER="0" SRC="|."$dir".q|img2.gif" ALT="$^{eme}$">|; $key = q/nomath_inline}oenomath_inline};MSF=1.6;AAT/; $cached_env_img{$key} = q|<IMG WIDTH="13" HEIGHT="9" ALIGN="BOTTOM" BORDER="0" SRC="|."$dir".q|img1.gif" ALT="\oe">|; 1;
mmusicante/PlacidoConfArtigos
CAISE2011/submitted/Bib/WF/images.pl
Perl
mit
426
# # 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 hardware::server::sun::mgmt_cards::mode::environmentv4xx; use base qw(centreon::plugins::mode); use strict; use warnings; use centreon::plugins::misc; use hardware::server::sun::mgmt_cards::lib::telnet; sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; $options{options}->add_options(arguments => { "hostname:s" => { name => 'hostname' }, "port:s" => { name => 'port', default => 23 }, "username:s" => { name => 'username' }, "password:s" => { name => 'password' }, "timeout:s" => { name => 'timeout', default => 30 }, }); return $self; } sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); if (!defined($self->{option_results}->{hostname})) { $self->{output}->add_option_msg(short_msg => "Need to specify a hostname."); $self->{output}->option_exit(); } if (!defined($self->{option_results}->{username})) { $self->{output}->add_option_msg(short_msg => "Need to specify a username."); $self->{output}->option_exit(); } if (!defined($self->{option_results}->{password})) { $self->{output}->add_option_msg(short_msg => "Need to specify a password."); $self->{output}->option_exit(); } } sub run { my ($self, %options) = @_; my $telnet_handle = hardware::server::sun::mgmt_cards::lib::telnet::connect( username => $self->{option_results}->{username}, password => $self->{option_results}->{password}, hostname => $self->{option_results}->{hostname}, port => $self->{option_results}->{port}, timeout => $self->{option_results}->{timeout}, output => $self->{output}); my @lines = $telnet_handle->cmd("showenvironment"); $self->{output}->output_add(severity => 'OK', short_msg => "No problems detected."); my ($output) = join("", @lines); $output =~ s/\r//g; my $long_msg = $output; $long_msg =~ s/\|/~/mg; $self->{output}->output_add(long_msg => $long_msg); if ($output =~ /^System LED Status:[^\[]+?\[([^\]]+?)][^\[]+?\[([^\]]+?)]/ims && defined($1)) { #System LED Status: LOCATOR FAULT POWER # [OFF] [OFF] [ ON] my $genfault_status = $2; $genfault_status = centreon::plugins::misc::trim($genfault_status); if (defined($genfault_status) && $genfault_status !~ /^(OFF)$/i) { $self->{output}->output_add(severity => 'CRITICAL', short_msg => "Gen Fault status is '" . $genfault_status . "'"); } } if ($output =~ /^Disk LED Status:(.*?)=======/ims) { #Disk LED Status: OK = GREEN ERROR = YELLOW # DISK 1: [EMPTY] # DISK 0: [OK] my $content = $1; while (($content =~ /DISK\s+([0-9]+)\s*:\s+\[([^\]]+?)\]/imsg)) { my $disknum = $1; my $disk_status = $2; $disk_status = centreon::plugins::misc::trim($disk_status); if (defined($disk_status) && $disk_status !~ /^(OK|EMPTY)$/i) { $self->{output}->output_add(severity => 'CRITICAL', short_msg => "Disk $disknum status is '" . $disk_status . "'"); } } } if ($output =~ /^Fan Tray :(.*?)=======/ims) { #Fan Tray : #---------- # #Tray Speed Status #---- ----- ------ #FAN TRAY0 CPU FAN0 5555 [OK] #FAN TRAY0 CPU FAN1 4000 [OK] #FAN TRAY0 CPU FAN2 3846 [OK] #FAN TRAY1 IO FAN0 4000 [OK] #FAN TRAY1 IO FAN1 4166 [OK] #FAN TRAY1 IO FAN2 0 [UNKNOWN] # # Can be [FAILED], [OK], [UNKNOWN] # If system is poweroff, nothing displayed. my $content = $1; while (($content =~ /\n([^\n]*?)(\s+[0-9]+\s+|\s+)\[(.*?)\]$/imsg)) { my $fan_name = $1; my $fan_status = $3; $fan_name = centreon::plugins::misc::trim($fan_name); $fan_status = centreon::plugins::misc::trim($fan_status); if (defined($fan_status) && $fan_status !~ /^(OK)$/i) { $self->{output}->output_add(severity => 'CRITICAL', short_msg => "Fan '" . $fan_name . "' status is '" . $fan_status . "'"); } } } if ($output =~ /^Power Supplies(.*?)=======/ims) { # Power Supplies: #--------------- # #Supply Status PS Fault Fan Fault Temp Fault #------ ------------ -------- --------- ---------- # 0 OK OFF OFF OFF # 1 OK OFF OFF OFF my $content = $1; while (($content =~ /^\s*?([0-9]+)\s+(.*?)(\n|\s{2})/imsg)) { my $supplynum = $1; my $supply_status = $2; $supply_status = centreon::plugins::misc::trim($supply_status); if (defined($supply_status) && $supply_status !~ /^(OK)$/i) { $self->{output}->output_add(severity => 'CRITICAL', short_msg => "Supply '" . $supplynum . "' status is '" . $supply_status . "'"); } } } $self->{output}->display(); $self->{output}->exit(); } 1; __END__ =head1 MODE Check Sun 'v480' and 'v490' Hardware (through RSC card). =over 8 =item B<--hostname> Hostname to query. =item B<--port> telnet port (Default: 23). =item B<--username> telnet username. =item B<--password> telnet password. =item B<--timeout> Timeout in seconds for the command (Default: 30). =back =cut
Tpo76/centreon-plugins
hardware/server/sun/mgmt_cards/mode/environmentv4xx.pm
Perl
apache-2.0
7,086
##************************************************************** ## ## Copyright (C) 1990-2011, 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. ## ##************************************************************** # CondorPersonal.pm - a Perl API to Condor for Personal Condors # # Designed to allow a flexible way to have tests and other jobs # run in conjunction with other Condor perl modules and control # the environment in which they run # # 1-6-05 Bill Taylor - vastly updated Bill Taylor 10-2-14 # ################################################################# # # A Personal Condor will be constructed in a subdirectory # based on current PID and the version string passed in # such that bin, sbin, log, condor_config and the rest # live in: # # PID/PIDversion/sbin # PID/PIDversion/bin # PID/PIDversion/log # PID/PIDversion/execute # PID/PIDversion/condor_config # ... package CondorPersonal; use strict; use warnings; use Carp; use Cwd; use POSIX qw/sys_wait_h strftime/; use Socket; use Sys::Hostname; use CondorUtils; use CondorTest; my $iswindows = CondorUtils::is_windows(); my $iscygwin = CondorUtils::is_cygwin_perl(); my $iswindowsnativeperl = CondorUtils::is_windows_native_perl(); my $wininstalldir = ""; my $installdir = ""; my $masterconfig = ""; #one built by batch_test and moving to test glue my $currentlocation; sub Initialize { # we want to initialize by whatever we have in $ENNV(CONDOR_CONFIG} # not something created in the test glue. my %control = @_; my $intheglue = 0; if( exists $control{test_glue}) { $intheglue = 1; } my $newconfig = deriveMasterConfig(); debug("Effective config now $newconfig\n", 2); $currentlocation = getcwd(); if(CondorUtils::is_windows() == 1) { if(is_windows_native_perl()) { $currentlocation =~ s/\//\\/g; $masterconfig = "$currentlocation" . "\\$newconfig"; } else { # never have cygwin till test runs, so glue would not be set #print "RAW curentlocation:-$currentlocation-\n"; my $tmp = `cygpath -m $currentlocation`; fullchomp($tmp); #print "tmp after cygpath:$tmp\n"; $tmp =~ s/\//\\/g; $currentlocation = $tmp; $masterconfig = "$currentlocation" . "\\$newconfig"; } } else { $masterconfig = "$currentlocation" . "/$newconfig"; } } sub deriveMasterConfig { # since we still are in the impact of the initial condor # get all of the actual settings my @outres = (); my $derivedconfig = "derived_condor_config"; if(-f "$derivedconfig") { return($derivedconfig); } else { # we need gererate the effective current config and # start from there. There are all the possible config files # plus changed vs default values. my $res = CondorTest::runCondorTool("condor_config_val -writeconfig:file $derivedconfig",\@outres,2,{emit_output=>0,expect_result=>\&ANY}); if($res != 1) { die "Error while getting the effective current configuration\n"; } open(DR,"<derived_condor_config") or die "Failed to create derived_condor_config: $!\n"; my $line = ""; while(<DR>) { $line = $_; fullchomp($line); print "$line\n"; } } return($derivedconfig); } BEGIN { } my %windows_semaphores = (); my %framework_timers = (); ################################################################# # # Parameters used within parameter config file...... # # Parameter Use Default Variable stored in # ---------------------------------------------------------------------------------------------- # condortemplate Core config file condor_config_template $personal_template # condorlocalsrc Name for condor local config src $personal_local_src # daemonwait Wait for startd/schedd to be seen true $personal_startup_wait # localpostsrc New end of local config file $personal_local_post_src # append_condor_config Text to append to end of local config file # secprepostsrc New security settings $personal_sec_prepost_src # condordaemon daemon list to start contents of config template $personal_daemons # condorconfig Name for condor config file condor_config $personal_config # condordomain Name for domain local $condordomain # condorlocal Name for condor local config condor_config.local $personal_local # condor "install" or path to tarball nightlies $condordistribution # collector Used to define COLLECTOR_HOST $collectorhost # nameschedd Used to define SCHEDD_NAME cat(name and collector) $scheddname # condorhost Used to define CONDOR_HOST $condorhost # ports Select dynamic or normal ports dynamic $portchanges # slots sets NUM_CPUS NUM_SLOTS none # universe parallel configuration of schedd none $personal_universe # # Notes added 10/3/14 bt # # The use of param files and tests calling other scripts is over. What we have now # are test additional knobs which are added to the end of a very basic local file. # All platforms go with the initial CONDOR_CONFIG in the environment which simply # put has a valid RELEASE_DIR. # # Notes from January 2014 bill taylor # Clumsy and unreliable IsRunningYet causes test to fail and failures to be long in time # for a series of tests as platforms etc vary. We are moving away from IsRunningYet # address file based to daemon information available with condor_who -daemon -log xxxxxxxx # # So we can collect whodata within our presonal condor instance # # Se we first want a test setable trigger to start using new start up evaluation # and get one test working this way. # # The new way will still block. It will have a time tolerance not a try tolerance. # There must be functions to determine our current direction based state and a way # to call this state evaluation repeatably. # # There is a large comment relative to our data storage class in CondorTest.pm above this # pacakge: package WhoDataInstance # # We actually do not have test framework call backs. But we added a basic state change loop # which will check for and call callbacks while we are looping to change state. NewIsRunningYet # replaces IsRunningYet and KillDaemons replaces KillDaemonPids and uses NewIsDownYet(new). # Both NewIs functions call the same state transition code which collects and examines condor_who # data stored in the instance of the personal condor my %daemon_logs = ( "COLLECTOR" => "CollectorLog", "NEGOTIATOR" => "NegotiatorLog", "MASTER" => "MasterLog", "STARTD" => "StartLog", "SCHEDD" => "SchedLog", "collector" => "CollectorLog", "negotiator" => "NegotiatorLog", "master" => "MasterLog", "startd" => "StartLog", "schedd" => "SchedLog", ); ######################################## ## ## 7/28/14 bt ## ## Our normal test pass has the LOCKDIR to deep ## to use a folder for shared ports handles ## So the flag below relocates it to /tmp ## Other switch turns on shared port for ## every personal condor spun up ## my $MOVESOCKETDIR = 0; my $USESHARERPORT = 0; ## ## ######################################## my $RunningTimeStamp = 0; my $topleveldir = getcwd(); my $home = $topleveldir; my $localdir; my $condorlocaldir; my $pid = $$; my $version = ""; # remote, middle, ....... for naming schedd "schedd . pid . version" my $mastername = ""; # master_$verison my $DEBUGLEVEL = 1; # nothing higher shows up my $debuglevel = 4; # take all the ones we don't want to see # and allowed easy changing and remove hard # coded value my @debugcollection = (); my $isnightly = IsThisNightly($topleveldir); my $wrap_test; ################################################################# # # Debug messages get time stamped. These will start showing up # at DEBUGLEVEL = 3 with some rather verbous at 4. # # For a single test which uses this module simply # CondorPersonal::DebugOn(); # CondorPersonal::DebugLevel(3); # .... some time later ..... # CondorPersonal::DebugLevel(2); # # There is no reason not to have debug always on the the level # pretty completely controls it. All DebugOff calls # have been removed. # # This is a similar debug setup as the rest of the test # suite but I did not want to require the other condor # modules for this one. # ################################################################# my %personal_condor_params; my %personal_config_changes; my $personal_config = "condor_config"; my $personal_template = "condor_config_template"; my $personal_daemons = ""; my $personal_local = "condor_config.local"; my $personal_local_src = ""; my $personal_local_post_src = ""; my $personal_sec_prepost_src = ""; my $personal_universe = ""; my $personal_startup_wait = "true"; my $personalmaster; my $portchanges = "dynamic"; my $collector_port = "0"; my $personal_config_file = ""; my $condordomain = ""; my $procdaddress = ""; ################################################################# # # Main interface StartCondor #condor # Calls functions to parse parameters, install binaries, tune the config file # and start the personal condor. Passes back config file location and port # number<config_file_location:collector_port>. # sub StartCondor { my $mpid = ""; my $arraysz = scalar(@_); my $testname = shift || die "Missing test name\n"; my $paramfile = shift || die "Missing parameter file!\n"; $version = shift || die "Missing parameter version!\n"; my $nowait = shift; my $config_and_port = ""; my $winpath = ""; if(!(-f $paramfile)) { die "StartCondor: param file $paramfile does not exist!!\n"; } CondorPersonal::ParsePersonalCondorParams($paramfile); if(defined $nowait) { #print "StartCondor: no wait option\n"; $personal_condor_params{"no_wait"} = "TRUE"; } # Insert the positional arguments into the new-style named-argument # hash and call the version of this function which handles it. $personal_condor_params{"test_name"} = $testname; $personal_condor_params{"condor_name"} = $version; $personal_condor_params{"fresh_local"} = "TRUE"; return StartCondorWithParams(%personal_condor_params); } ############################################ ## StartCondorWithParams ## ## Starts up a personal condor that is configured as specified in ## the named arguments to this function. If you are using the ## CondorTest framework, do not call this function directly. ## Call CondorTest::StartCondorWithParams(). ## ## Required Arguments: ## condor_name - a descriptive name, used when generating directory names ## ## Optional Arguments: ## test_name - name of the test that is using this personal condor ## append_condor_config - lines to be added to the (local) configuration file ## daemon_list - list of condor daemons to run ## ## ############################################ sub StartCondorWithParams { %personal_condor_params = @_; if(is_windows()) { $ENV{LOCAL_DIR} = undef; } Initialize(%personal_condor_params); # Make sure at the least we have an initial Config folder to seed future # personal condors. Test via environment variable CONDOR_CONFIG. # my $configvalid = DoInitialConfigCheck(); if($configvalid == 1) { die "We expected a configured HTCondor in our environment\n"; } my $condor_name = $personal_condor_params{"condor_name"}; my $testname = $personal_condor_params{"test_name"} || die "Missing test_name\n"; $version = $personal_condor_params{"condor_name"} || die "Missing condor_name!\n"; my $mpid = $personal_condor_params{"owner_pid"} || $pid; $mpid = "pdir$mpid"; my $config_and_port = ""; my $winpath = ""; if(exists $personal_condor_params{"test_glue"}) { system("mkdir -p $topleveldir/condor_tests/$testname.saveme/$mpid/$mpid$version"); $topleveldir = "$topleveldir/condor_tests/$testname.saveme/$mpid/$mpid$version"; } else { if(is_windows() && is_windows_native_perl()) { CreateDir("-p $topleveldir\\$testname.saveme\\$mpid\\$mpid$version"); $topleveldir = "$topleveldir\\$testname.saveme\\$mpid\\$mpid$version"; } elsif(is_windows() && is_cygwin_perl()) { CreateDir("-p $topleveldir/$testname.saveme/$mpid/$mpid$version"); my $tmp1 = "$topleveldir/$testname.saveme/$mpid/$mpid$version"; $topleveldir = `cygpath -m $tmp1`; CondorUtils::fullchomp($topleveldir); } else { CreateDir("-p $topleveldir/$testname.saveme/$mpid/$mpid$version"); $topleveldir = "$topleveldir/$testname.saveme/$mpid/$mpid$version"; } } $procdaddress = $mpid . $version; if(exists $personal_condor_params{"personaldir"}) { $topleveldir = $personal_condor_params{"personaldir"}; debug( "SETTING $topleveldir as topleveldir\n",$debuglevel); system("mkdir -p $topleveldir"); } # if we are wrapping tests, publish log location $wrap_test = $ENV{WRAP_TESTS}; if(defined $wrap_test) { my $logdir = $topleveldir . "/log"; #CondorPubLogdirs::PublishLogDir($testname,$logdir); } if(is_windows() && is_windows_native_perl()){ $personal_config_file = $topleveldir ."\\condor_config"; } elsif(is_windows() && is_cygwin_perl()){ $personal_config_file = $topleveldir ."/condor_config"; } else { $personal_config_file = $topleveldir ."/condor_config"; } $ENV{CONDOR_CONFIG} = $masterconfig; # we need the condor instance early for state determination #print "Personal: StartCondorWithParams: Creating condor instance for: $personal_config_file\n"; my $new_condor = CondorTest::CreateAndStoreCondorInstance( $version, $personal_config_file, 0, 0 ); $localdir = CondorPersonal::InstallPersonalCondor(); # if($localdir eq "") { return("Failed to do needed Condor Install\n"); } if( CondorUtils::is_windows() == 1 ){ if(is_windows_native_perl()) { $localdir =~ s/\//\\/g; $condorlocaldir = $localdir; } else { $winpath = `cygpath -m $localdir`; CondorUtils::fullchomp($winpath); $condorlocaldir = $winpath; } if( exists $personal_condor_params{catch_startup_tune}) { CondorPersonal::TunePersonalCondor($condorlocaldir, $mpid, $personal_condor_params{catch_startup_tune}); } else { CondorPersonal::TunePersonalCondor($condorlocaldir, $mpid); } } else { if( exists $personal_condor_params{catch_startup_tune}) { CondorPersonal::TunePersonalCondor($localdir, $mpid,$personal_condor_params{catch_startup_tune}); } else { CondorPersonal::TunePersonalCondor($localdir, $mpid); } } $ENV{CONDOR_CONFIG} = $personal_config_file; if(exists $personal_condor_params{"do_not_start"}) { $topleveldir = $home; return("do_not_start"); } $collector_port = CondorPersonal::StartPersonalCondor(); # reset topleveldir to $home so all configs go at same level $topleveldir = $home; debug( "collector port is $collector_port\n",$debuglevel); if( CondorUtils::is_windows() == 1 ){ if(is_windows_native_perl()) { $personal_config_file =~ s/\//\\/g; $config_and_port = $personal_config_file . "+" . $collector_port ; } else { $winpath = `cygpath -m $personal_config_file`; CondorUtils::fullchomp($winpath); $config_and_port = $winpath . "+" . $collector_port ; } } else { $config_and_port = $personal_config_file . "+" . $collector_port ; } #CondorPersonal::Reset(); debug( "StartCondor config_and_port is --$config_and_port--\n",$debuglevel); debug( "Personal Condor Started\n",$debuglevel); return( $config_and_port ); } sub StartCondorWithParamsStart { my $winpath = ""; my $config_and_port = ""; if(is_windows()) { $ENV{LOCAL_DIR} = undef; } $collector_port = CondorPersonal::StartPersonalCondor(); debug( "collector port is $collector_port\n",$debuglevel); if( CondorUtils::is_windows() == 1 ){ if(is_windows_native_perl()) { $_ = $personal_config_file; s/\//\\/g; $winpath = $_; } else { $winpath = `cygpath -m $personal_config_file`; CondorUtils::fullchomp($winpath); } $config_and_port = $winpath . "+" . $collector_port ; } else { $config_and_port = $personal_config_file . "+" . $collector_port ; } CondorPersonal::Reset(); debug( "StartCondor config_and_port is --$config_and_port--\n",$debuglevel); debug( "Personal Condor Started\n",$debuglevel); return( $config_and_port ); } sub debug { my $string = shift; my $level = shift; my $time = timestamp(); if(!(defined $level)) { $level = 0; } if ($level <= $DEBUGLEVEL) { my $msg = "$time $string"; print $msg; push @debugcollection, $msg; } else { my $msg = "$time (CP$level) $string"; push @debugcollection, $msg; } } sub debug_flush { print "\nDEBUG_FLUSH:\n"; my $logdir = `condor_config_val log`; fullchomp($logdir); print "\nLOG=$logdir and contains:\n"; List("ls -lh $logdir"); # what daemons does condor_who see running/exited? print "\ncondor_who -verb says:\n"; system("condor_who -verb"); # what is in our config files? print "\ncondor_config_val -writeconfig:file says:\n"; system("condor_config_val -writeconfig:file -"); print "\n------------Saved debug output is----------------\n"; foreach my $line (@debugcollection) { print "$line"; } } sub DebugLevel { my $newlevel = shift; my $oldlevel = $DEBUGLEVEL; $DEBUGLEVEL = $newlevel; return($oldlevel); } sub timestamp { return strftime("%H:%M:%S", localtime); } sub Reset { debug( "CondorPersonal RESET\n",$debuglevel); %personal_condor_params = (); %personal_config_changes = (); $personal_config = "condor_config"; $personal_template = "condor_config_template"; $personal_daemons = ""; $personal_local = "condor_config.local"; $personal_local_src = ""; $personal_local_post_src = ""; $personal_sec_prepost_src = ""; $personal_universe = ""; $personal_startup_wait = "true"; $RunningTimeStamp = 0; $topleveldir = getcwd(); $home = $topleveldir; $portchanges = "dynamic"; $collector_port = "0"; $personal_config_file = ""; $condordomain = ""; $procdaddress = ""; } ################################################################# # # ParsePersonalCondorParams # # Parses parameter file in typical condor form of NAME = VALUE # and stores results into a hash for lookup later. # sub ParsePersonalCondorParams { my $submit_file = shift || die "missing submit file argument"; my $line = 0; if( ! open( SUBMIT_FILE, $submit_file ) ) { die "error opening \"$submit_file\": $!\n"; return 0; } debug( "reading submit file...\n" ,4); my $variable; my $value; while( <SUBMIT_FILE> ) { CondorUtils::fullchomp($_); $line++; # skip comments & blank lines next if /^#/ || /^\s*$/; # if this line is a variable assignment... if( /^(\w+)\s*\=\s*(.*)$/ ) { $variable = lc $1; $value = $2; # if line ends with a continuation ('\')... while( $value =~ /\\\s*$/ ) { # remove the continuation $value =~ s/\\\s*$//; # read the next line and append it <SUBMIT_FILE> || last; $value .= $_; } # compress whitespace and remove trailing newline for readability $value =~ s/\s+/ /g; CondorUtils::fullchomp($value); # Do proper environment substitution if( $value =~ /(.*)\$ENV\((.*)\)(.*)/ ) { my $envlookup = $ENV{$2}; debug( "Found $envlookup in environment \n",4); $value = $1.$envlookup.$3; } debug( "(CondorPersonal.pm) $variable = $value\n" ,$debuglevel); #print "(CondorPersonal.pm) $variable = $value\n"; # save the variable/value pair $personal_condor_params{$variable} = $value; } else { # debug( "line $line of $submit_file not a variable assignment... " . # "skipping\n" ); } } close(SUBMIT_FILE); return 1; } ################################################################## # # Run condor_config_val using the specified configuration file. # sub CondorConfigVal { my $config_file = shift; my $param_name = shift; my $returnarrayref = shift; my @otherarray = (); my $result = ""; my $oldconfig = $ENV{CONDOR_CONFIG}; $ENV{CONDOR_CONFIG} = $config_file; #print "CondorConfigVal called with this fig:$config_file;\n"; #my $result = `condor_config_val $param_name`; if (defined $returnarrayref) { my $res = CondorTest::runCondorTool("condor_config_val $param_name",$returnarrayref,2,{emit_output=>0,expect_result=>\&ANY}); } else { my $res = CondorTest::runCondorTool("condor_config_val $param_name",\@otherarray,2,{emit_output=>0}); my $firstline = $otherarray[0]; fullchomp $firstline; $result = $firstline; } $ENV{CONDOR_CONFIG} = $oldconfig; return $result; } ################################################################# # # InstallPersonalCondor # # We either find binaries in the environment or we install # a particular tar ball. # sub InstallPersonalCondor { # this used to be used globally but now passwed # in from StartCondorWithParams #%personal_condor_params = @_; my %control = %personal_condor_params; my $master; my $collector; my $submit; my $iswindows = CondorUtils::is_windows() ; my $condorq = ""; my $sbinloc = ""; my $configline = ""; my @configfiles; my $condordistribution; my $tmpconfig = $ENV{CONDOR_CONFIG}; my $configdir = ""; if($iswindows) { $condorq = Which("condor_q.exe"); } else { $condorq = Which("condor_q"); } if($tmpconfig =~ /^(.*\/)\w+$/) { $configdir = $1; #print "InstallPersonalCondor: CONFIG DIR:$configdir\n"; } my $binloc = ""; $condordistribution = $control{"condor"} || "nightlies"; debug( "Install this condor --$condordistribution--\n",$debuglevel); if( $condordistribution eq "nightlies" ) { # test if this is really the environment we are in or # switch it to install mode. if(! -f "../../condor/sbin/condor_master") { $condordistribution = "install"; } } if( $condordistribution eq "install" ) { if($iswindows == 1) { #print "condor distribution = install\n"; } # where is the hosting condor_config file? The one assumed to be based # on a setup with condor_configure. my @config = (); debug("InstallPersonalCondor getting ccv -config\n",$debuglevel); CondorTest::runCondorTool("condor_config_val -config",\@config,2,{emit_output=>0}); debug("InstallPersonalCondor BACK FROM ccv -config\n",$debuglevel); open(CONFIG,"condor_config_val -config 2>&1 | ") || die "Can not find config file: $!\n"; while(<CONFIG>) { next if ($_ =~ /figuration source/); CondorUtils::fullchomp($_); $configline = $_; push @configfiles, $configline; } close(CONFIG); $personal_condor_params{"condortemplate"} = shift @config; fullchomp($personal_condor_params{"condortemplate"}); #print " ****** Condortemplate set to <$personal_condor_params{condortemplate}>\n"; if(exists $personal_condor_params{fresh_local}) { } else { # Always start with a freshly constructed local config file # so we know what we get bt 5/13 #$personal_condor_params{"condorlocalsrc"} = shift @configfiles; } debug("condor_q: $condorq\n",$debuglevel); debug("topleveldir: $topleveldir\n",$debuglevel); if($iswindows == 1) { # maybe we have a dos path if(is_windows_native_perl()) { if($condorq =~ /[A-Za-z]:/) { $_ = $condorq; s/\//\\/g; $condorq = $_; #print "condor_q now:$condorq\n"; if($condorq =~ /^([A-Za-z]:\\.*?)\\bin\\(.*)$/) { #print "setting binloc:$1 \n"; $binloc = $1; $sbinloc = $1; } } } else { my $tmp = `cygpath -m $condorq`; fullchomp($tmp); #print "InstallPersonalCondor:condorq:$tmp\n"; $condorq = $tmp; if($condorq =~ /[A-Za-z]:/) { if($condorq =~ /^([A-Za-z]:\/.*?)\/bin\/(.*)$/) { #print "setting binloc:$1 \n"; $binloc = $1; $sbinloc = $1; } } } } if($binloc eq "") { if( $condorq =~ /^(\/.*\/)(\w+)\s*$/ ) { debug( "Root path $1 and base $2\n",$debuglevel); $binloc = $1; # we'll get our binaries here. } elsif(-f "../release_dir/bin/condor_status") { #print "Bummer which condor_q failed\n"; #print "Using ../release_dir/bin(s)\n"; $binloc = "../release_dir/bin"; # we'll get our binaries here. } else { #print "which condor_q responded: $condorq! CondorPersonal Failing now\n"; debug_flush(); die "Can not seem to find a Condor install!\n"; } } if($sbinloc eq "") { if( $binloc =~ /^(\/.*\/)s*bin\/\s*$/ ) { debug( "Root path to sbin is $1\n",$debuglevel); $sbinloc = $1; # we'll get our binaries here. # local_dir is here } else { debug_flush(); die "Can not seem to locate Condor release binaries\n"; } } debug( "Sandbox started rooted here: $topleveldir\n",$debuglevel); #print "Sandbox started rooted here: $topleveldir\n"; if(is_windows_native_perl()) { #print "before making local dirs\n"; #CondorUtils::dir_listing("$topleveldir"); my $cwd = getcwd(); chdir ("$topleveldir"); CreateDir("execute spool log log\\tmp"); chdir ("$cwd"); #print "after making local dirs\n"; #CondorUtils::dir_listing("$topleveldir"); } else { system("cd $topleveldir && mkdir -p execute spool log log/tmp"); } } elsif( $condordistribution eq "nightlies" ) { if($iswindows == 1) { } # we want a mechanism by which to find the condor binaries # we are testing. But we know where they are relative to us # ../../condor/bin etc # That is simply the nightly test setup.... for now at least # where is the hosting condor_config file? The one assumed to be based # on a setup with condor_configure. debug(" Nightlies - find environment config files\n",$debuglevel); my @config = (); CondorTest::runCondorTool("condor_config_val -config",\@config,2,{emit_output=>0}); $personal_condor_params{"condortemplate"} = shift @config; $personal_condor_params{"condorlocalsrc"} = shift @config; fullchomp($personal_condor_params{"condortemplate"}); fullchomp($personal_condor_params{"condorlocalsrc"}); #print " ****** Case nightlies leading to <$personal_condor_params{condortemplate}> and $personal_condor_params{condorlocalsrc}\n"; debug( "My path to condor_q is $condorq and topleveldir is $topleveldir\n",$debuglevel); if( $condorq =~ /^(\/.*\/)(\w+)\s*$/ ) { debug( "Root path $1 and base $2\n",$debuglevel); $binloc = $1; # we'll get our binaries here. } else { #print "which condor_q responded: $condorq! CondorPersonal Failing now\n"; debug_flush(); die "Can not seem to find a Condor install!\n"; } if( $binloc =~ /^(\/.*)\/bin\/\s*$/ ) { debug( "Root path to sbin is $1\n",$debuglevel); $sbinloc = $1; # we'll get our binaries here. # local_dir is here } else { debug_flush(); die "Can not seem to locate Condor release binaries\n"; } debug( "My path to condor_q is $binloc and topleveldir is $topleveldir\n",$debuglevel); debug( "Sandbox started rooted here: $topleveldir\n",$debuglevel); if(is_windows_native_perl()) { my $cwd = getcwd(); system("chdir $topleveldir"); CreateDir("execute spool log log/tmp"); system("chdir $cwd"); } else { system("cd $topleveldir && mkdir -p execute spool log log/tmp"); } } elsif( -e $condordistribution ) { if($iswindows == 1) { } # in this option we ought to run condor_configure # to get a current config files but we'll do this # after getting the current condor_config from # the environment we are in as it is supposed to # have been generated this way in the nightly tests # run in the NWO. my $res = chdir "$topleveldir"; if(!$res) { die "chdir $topleveldir failed: $!\n"; exit(1); } system("cd $topleveldir && mkdir -p execute spool log"); system("tar -xf $home/$condordistribution"); $sbinloc = $topleveldir; # local_dir is here chdir "$home"; } else { debug_flush(); die "Undiscernable install directive! (condor = $condordistribution)\n"; } debug( "InstallPersonalCondor returning $sbinloc for LOCAL_DIR setting\n",$debuglevel); return($sbinloc); } sub FetchParams { return(%personal_condor_params); } ################################################################# # # TunePersonalCondor # # Most changes go into the condor_config.local file but # some changes are done to the condor_config template. # # RELEASE_DIR, LOCAL_DIR and LOCAL_CONFIG_FILE are # adjusted from the main template file and other # changes are in the condor_config.local file. # sub TunePersonalCondor { my %control = %personal_condor_params; my $myhost = CondorTest::getFqdnHost(); my @domainparts = split /\./, $myhost; my $condorhost = ""; my $collectorhost = ""; my $localdir = shift; my $mpid = shift; my $scheddname; my $startdname; my $minimalconfig = 0; my $returnarrayref = shift; my $iswindows = CondorUtils::is_windows(); if(!(defined $mpid)) { $mpid = $$; $mpid = "pdir$mpid"; } my $socketdir = ""; if($MOVESOCKETDIR == 1) { # The tests get pretty long paths to LOCK_DIR making unix sockets exceed # the max character length. So in remote_pre we create a folder to hold # the test run's socket folder. /tmp/tds$pid. We place this name we will # need to configure each personal with in condor_tests/SOCKETDIR and we will # configure with our own pid. Remote_post removes this top level directory. if( CondorUtils::is_windows() == 0 ){ # windows does not have a path length limit if(!(-f "SOCKETDIR")) { print "Creating SOCKETDIR?\n"; my $privatetmploc = "/tmp/tds$$"; print "tmp loc:$privatetmploc\n"; $socketdir = "SOCKETDIR"; system("mkdir $privatetmploc;ls /tmp"); open(SD,">$socketdir") or print "Failed to create:$socketdir:$!\n"; print SD "$privatetmploc\n"; close(SD); } else { open(SD,"<SOCKETDIR") or print "Failed to open:SOCKETDIR:$!\n"; $socketdir = (<SD>); chomp($socketdir); print "Fetch master SOCKETDIR:$socketdir\n"; $socketdir = "$socketdir" . "/$$"; print "This tests socketdir:$socketdir\n"; } } } #print " ****** TunePersonalCondor with localdir set to <$localdir>\n"; debug( "TunePersonalCondor setting LOCAL_DIR to $localdir\n",$debuglevel); debug( "My basic name is $myhost\n",$debuglevel); # was a special condor host called out? if( exists $control{"condorhost"} ) { $condorhost = $control{"condorhost"}; } # was a special condor collector called out? if( exists $control{"collector"} ) { $collectorhost = $control{"collector"}; } # was a special domain called out? if( exists $control{"condordomain"} ) { $condordomain = $control{"condordomain"}; } if( $condordomain ne "" ) { $condorhost = $myhost . "." . $condordomain; } else { $condorhost = $myhost; } debug( "Fully qualified domain name is ************************ $condorhost ********************\n",$debuglevel); # was a special template called out? if( exists $control{"condortemplate"} ) { $personal_template = $control{"condortemplate"}; } # was a special config file called out? if( exists $control{"condorconfig"} ) { $personal_config = $control{"condorconfig"}; } else { $personal_config = "condor_config"; # store this default in the personal condor params so # other parts of the code can rely on it. $personal_condor_params{"condorconfig"} = $personal_config; } # was a special daemon list called out? if( exists $control{"daemon_list"} ) { #print "New daemon list called out <$control{daemon_list}>\n"; $personal_daemons = $control{"daemon_list"}; } # was a special local config file name called out? if( exists $control{"condorlocal"} ) { $personal_local = $control{"condorlocal"}; } else { $personal_local = "condor_config.local"; } # was a special local config file src called out? if( exists $control{"condorlocalsrc"} ) { $personal_local_src = $control{"condorlocalsrc"}; } # was a special local config file post src called out? if( exists $control{"secprepostsrc"} ) { $personal_sec_prepost_src = $control{"secprepostsrc"}; } # was a special local config file post src called out? if( exists $control{"localpostsrc"} ) { $personal_local_post_src = $control{"localpostsrc"}; } # is this for a specific universe like parallel? if( exists $control{"universe"} ) { $personal_universe = $control{"universe"}; debug( "HMMMMMMMMMMM universe request is $personal_universe\n",$debuglevel); } debug( "Proto file is --$personal_template--\n",3); $personalmaster = "$topleveldir/sbin/condor_master"; #filter fig file storing entries we set so we can test #for completeness when we are done my $mytoppath = ""; if( CondorUtils::is_windows() == 1 ){ if(is_windows_native_perl()) { $_ = $topleveldir; s/\//\\/g; # convert to reverse slants #s/\\/\\\\/g; $mytoppath = $_; } else { $mytoppath = `cygpath -m $topleveldir`; } CondorUtils::fullchomp($mytoppath); } else { $mytoppath = $topleveldir; } debug( "HMMMMMMMMMMM personal local is $personal_local , mytoppath is $mytoppath",$debuglevel); my $line; open(TEMPLATE,"<$personal_template") || die "Can not open template: $personal_template: $!\n"; debug( "want to open new config file as $topleveldir/$personal_config\n",$debuglevel); open(NEW,">$topleveldir/$personal_config") || die "Can not open new config file: $topleveldir/$personal_config: $!\n"; # There is an interesting side effect of reading and changing the condor_config # template and then at the end, add the new LOCAL_DIR entree. That is when the constructed # file is inspected it looks like the LOCAL_DIR came from the environment. # So we are going to parse for a comment only line and only drop it out if it is NOT # the one followed by "# from <Environment>". When that is the line that follows, we will drop # out the new LOCAL_DIR, then a blank line and THEN those two saved lines. my $lastline = ""; my $thisline = ""; while(<TEMPLATE>) { CondorUtils::fullchomp($_); $line = $_; if( $line =~ /^LOCAL_DIR\s*=.*/ ) # this is now beeing added to Config/condor_config so should propograte { debug( "-----------$line-----------\n",4); $personal_config_changes{"LOCAL_DIR"} = "LOCAL_DIR = $mytoppath\n"; print NEW "LOCAL_DIR = $mytoppath\n"; } elsif( $line =~ /^LOCAL_CONFIG_FILE\s*=.*/ ) { debug( "-----------$line-----------\n",4); if($iswindows) { if(is_windows_native_perl()) { #print "My toppath:$mytoppath\n"; $personal_config_changes{"LOCAL_CONFIG_FILE"} = "LOCAL_CONFIG_FILE = $mytoppath\\$personal_local\n"; print NEW "LOCAL_CONFIG_FILE = $mytoppath\\$personal_local\n"; } else { $personal_config_changes{"LOCAL_CONFIG_FILE"} = "LOCAL_CONFIG_FILE = $mytoppath/$personal_local\n"; print NEW "LOCAL_CONFIG_FILE = $mytoppath/$personal_local\n"; } } else { $personal_config_changes{"LOCAL_CONFIG_FILE"} = "LOCAL_CONFIG_FILE = $mytoppath/$personal_local\n"; print NEW "LOCAL_CONFIG_FILE = $mytoppath/$personal_local\n"; } } elsif( $line =~ /^#\s*$/ ) { #print "save $line could be comment before environment label\n"; $lastline = $line; } elsif( $line =~ /^#.*?Environment.*$/ ) { $thisline = $line; #print "TunePersonalCondor: setting LOCAL_DIR=$mytoppath\n"; print NEW "LOCAL_DIR = $mytoppath\n"; print NEW "\n"; print NEW "$lastline\n"; print NEW "$thisline\n"; } elsif( $line =~ /^#.*$/ ) { #print "Not environment label, drop both lines\n"; print NEW "$lastline\n"; print NEW "$thisline\n"; } elsif( $line =~ /^LOCAL_CONFIG_DIR\s*=.*/ ) { # eat this entry } else { print NEW "$line\n"; } } close(TEMPLATE); close(NEW); open(NEW,">$topleveldir/$personal_local") || die "Can not open template: $!\n"; if($minimalconfig == 0) { if( ! exists $personal_config_changes{"CONDOR_HOST"} ) { $personal_config_changes{"CONDOR_HOST"} = "CONDOR_HOST = $condorhost\n"; } if( exists $control{"ports"} ) { debug( "Port Changes being Processed!!!!!!!!!!!!!!!!!!!!\n",$debuglevel); $portchanges = $control{"ports"}; debug( "portchanges set to $portchanges\n",$debuglevel); } debug( "opening to write: $topleveldir/$personal_local\n",$debuglevel); if($personal_daemons ne "") { # Allow the collector to run on the default and expected port as the main # condor install on this system. print NEW "# Adding requested daemons\n"; print NEW "DAEMON_LIST = $personal_daemons\n"; } else { print NEW "DAEMON_LIST = MASTER STARTD SCHEDD COLLECTOR NEGOTIATOR\n"; } if(is_windows_native_perl()) { print NEW "NEGOTIATOR_ADDRESS_FILE = \$(LOG)\\.negotiator_address\n"; print NEW "SCHEDD_ADDRESS_FILE = \$(LOG)\\.schedd_address\n"; } else { print NEW "NEGOTIATOR_ADDRESS_FILE = \$(LOG)/.negotiator_address\n"; print NEW "SCHEDD_ADDRESS_FILE = \$(LOG)/.schedd_address\n"; } print NEW "SCHEDD_INTERVAL = 5\n"; print NEW "UPDATE_INTERVAL = 5\n"; print NEW "NEGOTIATOR_INTERVAL = 5\n"; print NEW "CONDOR_ADMIN = \n"; print NEW "CONDOR_JOB_POLL_INTERVAL = 5\n"; print NEW "PERIODIC_EXPR_TIMESLICE = .99\n"; print NEW "JOB_START_DELAY = 0\n"; print NEW "LOCK = \$(LOG)\n"; if($iswindows == 1) { #print NEW "PROCD_LOG = \$(LOG)/ProcLog\n"; print NEW "# Adding procd pipe for windows\n"; print NEW "PROCD_ADDRESS = \\\\.\\pipe\\$procdaddress\n"; } my $jvm = ""; my $java_libdir = ""; my $exec_result; my $javabinary = ""; # now we consider configuration requests if( exists $control{"slots"} ) { my $myslots = $control{"slots"}; debug( "Slots wanted! Number = $myslots\n",$debuglevel); print NEW "# Adding slot request from param file\n"; print NEW "NUM_CPUS = $myslots\n"; print NEW "SLOTS = $myslots\n"; print NEW "# Done Adding slot request from param file\n"; } if($personal_local_src ne "") { print NEW "# Requested local config: $personal_local_src\n"; #print "******************** Must seed condor_config.local <<$personal_local_src>> ************************\n"; debug( "opening to read: $personal_local_src\n",$debuglevel); open(LOCSRC,"<$personal_local_src") || die "Can not open local config template: $!\n"; while(<LOCSRC>) { CondorUtils::fullchomp($_); $line = $_; print NEW "$line\n"; } # now make sure we have the local dir we want after the generic .local file is seeded in # $line = $personal_config_changes{"LOCAL_DIR"}; # print NEW "$line\n"; # # and a lock directory we like close(LOCSRC); } if($personal_sec_prepost_src ne "") { debug( "Adding to local config file from $personal_sec_prepost_src\n",$debuglevel); open(SECURITY,"<$personal_sec_prepost_src") || die "Can not do local config additions: $personal_sec_prepost_src: $!\n"; print NEW "# Adding changes requested from $personal_sec_prepost_src\n"; while(<SECURITY>) { print NEW "$_"; } close(SECURITY); print NEW "# Done Adding changes requested from $personal_sec_prepost_src\n"; } if($personal_local_post_src ne "") { debug("Adding to local config file from $personal_local_post_src\n",$debuglevel); open(POST,"<$personal_local_post_src") || die "Can not do local config additions: $personal_local_post_src:$!\n"; print NEW "# Adding changes requested from $personal_local_post_src\n"; while(<POST>) { print NEW "$_"; } close(POST); print NEW "# Done Adding changes requested from $personal_local_post_src\n"; } if( exists $control{append_condor_config} ) { print NEW "# Appending from 'append_condor_config'\n"; print NEW "$control{append_condor_config}\n"; print NEW "# Done appending from 'append_condor_config'\n"; } # assume an array reference if( exists $control{append_condor_config_plus} ) { print NEW "# Appending from 'append_condor_config_plus'\n"; my $arrayref = $control{append_condor_config_plus}; foreach my $line (@{$arrayref}) { print NEW "$line\n"; } print NEW "# Done appending from 'append_condor_config_plus'\n"; } } #lets always overrule existing A__DEBUG with one that adds to it D_CMD print NEW "ALL_DEBUG = \$(ALL_DEBUG) D_CMD:1\n"; # we are testing. dramatically reduce MaxVacateTime print NEW "JOB_MAX_VACATE_TIME = 15\n"; close(NEW); if (defined $returnarrayref) { PostTunePersonalCondor($personal_config_file,$returnarrayref); } else { PostTunePersonalCondor($personal_config_file); } } ################################################################# # # PostTunePersonalCondor() is called after TunePersonalCondor. # It assumes that the configuration file is all set up and # ready to use. sub PostTunePersonalCondor { my $config_file = shift; my $outputarrayref = shift; debug("PostTunePersonalCondor: getting DAEMON_LIST from $config_file\n",2); my $configured_daemon_list; if (defined $outputarrayref) { $configured_daemon_list = CondorConfigVal($config_file,"daemon_list", $outputarrayref); } else { $configured_daemon_list = CondorConfigVal($config_file,"daemon_list"); } } ################################################################# # # StartPersonalCondor will start a personal condor which has # been set up. If the ports are dynamic, it will look up the # address and return the port number. # sub StartPersonalCondor { my %control = %personal_condor_params; my $personalmaster = ""; # If we start a personal Condor as root (for testing the VM universe), # we need to change the permissions/ownership on the directories we # made so that the master (which runs as condor) can use them. if( ! CondorUtils::is_windows() && ( $> == 0 )) { my $testName = $control{ 'test_name' }; system( "chown condor.condor $home/${testName}.saveme >& /dev/null" ); system( "chown -R condor.condor $home/${testName}.saveme/pdir$pid >& /dev/null" ); } my $configfile = $control{"condorconfig"}; #my $fullconfig = "$topleveldir/$configfile"; my $fullconfig = "$ENV{CONDOR_CONFIG}"; #print "StartPersonalCondor CONDOR_CONFIG=$fullconfig\n"; debug( "Want $configfile for config file\n",$debuglevel); my $figpath = ""; if( CondorUtils::is_windows() == 1 ){ if(is_windows_native_perl()) { $personalmaster = "start $localdir" . "\\bin\\condor_master.exe -f"; } else { $figpath = `cygpath -m $fullconfig`; CondorUtils::fullchomp($figpath); $fullconfig = $figpath; # note: on windows all binaaries in bin! my $tmp = `cygpath -m $localdir`; CondorUtils::fullchomp($tmp); $personalmaster = $tmp . "/bin/condor_master.exe -f &"; } } else { $personalmaster = $localdir . "sbin/condor_master -f &"; } # We may not want to wait for certain daemons to talk # to each other on startup. if( exists $control{"daemonwait"} ) { my $waitparam = $control{"daemonwait"}; if($waitparam eq "false") { $personal_startup_wait = "false"; } } # set up to use the existing generated configfile my $condorstate = 0; $ENV{CONDOR_CONFIG} = $fullconfig; my $condor_instance = CondorTest::GetPersonalCondorWithConfig($fullconfig); if($condor_instance != 0) { $condorstate = $condor_instance->GetCondorAlive(); } else { $condorstate = 0; } my $fig = $ENV{CONDOR_CONFIG}; debug( "Condor_config from environment is --$fig--\n",$debuglevel); # At the momment we only restart/start a personal we just configured # or reconfigured if( $condorstate == 0 ) { # not running with this config so treat it like a start case debug("Condor state is off\n",$debuglevel); debug( "start up the personal condor!--$personalmaster--\n",$debuglevel); # when open3 is used it sits and waits forever if( exists $control{catch_startup_start}) { print "catch_startup_start seen. Calling runCondorTool\n"; runCondorTool("$personalmaster",$control{catch_startup_start},2,{emit_output=>1}); } else { my $res = system("$personalmaster"); if($res != 0) { print "Failed system call starting master\n"; } } sleep(2); } else { debug_flush(); die "Bad state for a new personal condor configuration! running :-(\n"; } # is test opting into new condor personal status yet? my $res = 1; sleep(5); if(exists $control{"no_wait"}) { #print "use no methods here to be sure daemons are up.\n"; } else { #print "NO_WAIT not set???????\n"; my $condor_name = $personal_condor_params{"condor_name"}; $res = NewIsRunningYet($fullconfig, $condor_name); } if($res == 0) { debug_flush(); die "Can not continue because condor is not running!!!!\n"; } # if this was a dynamic port startup, return the port which # the collector is listening on... if( $portchanges eq "dynamic" ) { debug("Looking for collector port!\n",$debuglevel); return( FindCollectorPort() ); } else { debug("NOT Looking for collector port!\n",$debuglevel); return("0"); } } sub ProcessStateWanted { my $condor_config = shift; #print "ProcessStateWanted: $condor_config\n"; my $condor_instance = CondorTest::GetPersonalCondorWithConfig($condor_config); my $direction = $condor_instance->GetCondorDirection(); # up or down #print "in ProcessStateWanted going:$direction\n"; if($condor_instance == 0) { return("?"); } # lets look for best case first my $scheddseen = ""; if($direction eq "up") { my $alldaemons = $condor_instance->HasAllLiveDaemons(); if($alldaemons eq "yes") { $scheddseen = $condor_instance->CollectorSeesSchedd(); if($scheddseen eq "yes") { return("up"); } return("alldaemonsup"); } } else { my $nodaemons = $condor_instance->HasNoLiveDaemons(); if($nodaemons eq "yes") { return("down"); } } my $master = $condor_instance->HasLiveMaster(); if($master == 0) { return("down"); } return("hasmaster"); } sub StateChange { my $desiredstate = shift || croak "No desired state passed in\n"; my $config = shift; my $timelimit = shift; my $masterlimit = shift; my $RunningTimeStamp = time; my $finaltime = 0; my $state = ""; my $now = 0; # we'll use this to set alive field in instance correctly # or upon error to drop out condor_who data my $condor_config = $ENV{CONDOR_CONFIG}; my $condor_instance = CondorTest::GetPersonalCondorWithConfig($condor_config); my $node_name = $condor_instance->GetCondorName() || "Condor"; my $daemonlist = $condor_instance->GetDaemonList(); debug("CondorPersonal Waiting $timelimit sec for <$node_name> to be $desiredstate. MasterTime:$masterlimit\n\tDAEMON_LIST = $daemonlist\n", 1); #print "\tCONDOR_CONFIG=$config\n"; while($state ne $desiredstate) { #print "Waiting for state: $desiredstate current $state\n"; my $amialive = $condor_instance->HasLiveMaster(); $now = time; if(($amialive == 0) &&($desiredstate eq "up")) { if(($now - $RunningTimeStamp) >= $masterlimit) { print "StateChange: <$node_name> Master did not start in $masterlimit seconds, giving up.\n"; $condor_instance->DisplayWhoDataInstances(); return(0); } } if(($amialive == 1) &&($desiredstate eq "down")) { if(($now - $RunningTimeStamp) >= $masterlimit) { print "StateChange: <$node_name> Master did not exit in $masterlimit seconds. giving up.\n"; $condor_instance->DisplayWhoDataInstances(); return(0); } } if((($now - $RunningTimeStamp) >= $timelimit) && ($timelimit >= $masterlimit)) { print "StateChange: <$node_name>:$desiredstate not seen after $timelimit seconds. giving up\n"; $condor_instance->DisplayWhoDataInstances(); return(0); } #print "StateChange: again\n"; #CollectWhoData($desiredstate); CollectWhoData(); $state = ProcessStateWanted($config); #print "StateChange: now:$state\n"; CheckNamedFWTimed(); sleep 1; } if($desiredstate eq "up") { $condor_instance->SetCondorAlive(1); } elsif($desiredstate eq "down") { $condor_instance->SetCondorAlive(0); } else { die "Only up/down transitions expected to be requested\n"; } #$condor_instance->DisplayWhoDataInstances(); $now = time; $finaltime = ($now - $RunningTimeStamp); if($desiredstate eq "up") { debug("Condor <$node_name> is running. ($finaltime of $timelimit seconds)\n", 1); } elsif($desiredstate eq "down") { debug("Condor <$node_name> is off. ($finaltime of $timelimit seconds)\n", 1); } return(1); } sub NewIsRunningYet { my $config = shift; my $name = shift; #print "Checking running of: $name config:$config \n"; # ON going up or down, first number total time to allow a full up state, but # master has to be alive by second number or bail my $res = StateChange("up", $config, 120, 30); return $res; } sub NewIsDownYet { my $config = shift; my $name = shift; if(defined $name) { #print "Checking running of: $name config:$config \n"; } else { #print "This config does not have a condor instance condor_name:$config\n"; } my $res = StateChange("down", $config, 120, 160); return $res; } ################################################################# # # dual State thoughts which condor_who may detect # # turning on, Unknown # turning on, Not Run Yet # turning on, Coming up # turning on, mater alive # turning on, collector alive # turning on, collector knows xxxxx # turning on, all daemons # going down, all daemons # going down, collector knows XXXXX # going down, collector alive # going down, master alive # down # $self = { # textfile => shift, # placeholders => { } # { }, not ( ) # }; # ... # $self->{placeholders}->{$key} = $value; # delete $self->{placeholders}->{$key}; # @keys = keys %{$self->{placeholders}}; # foreach my ($k,$v) each %{$self->{placeholders}} { ... } # # sub CollectWhoData { my $desiredstate = shift; # experient to vary by going up vs down OFF now # and nothing is passed in my @whoarray; #print "CollectWhoData for this Condor:<$ENV{CONDOR_CONFIG}>\n"; # Get condor instance for this config #print CondorUtils::TimeStr() . " CollectWhoData start\n"; my $usequick = 1; my $condor = CondorTest::GetPersonalCondorWithConfig($ENV{CONDOR_CONFIG}); #$condor->DisplayWhoDataInstances(); # condor_who -quick is best before master is alive if($condor != 0) { if(defined $desiredstate) { if($desiredstate eq "down"){ print "going down and using quick mode\n"; } else { if($condor->HasLiveMaster() == 1) { $usequick = 0; } } } else { my $hasLive = $condor->HasLiveMaster(); #print "HasLiveMaster says:$hasLive\n"; if($condor->HasLiveMaster() == 1) { $usequick = 0; } } } else { die "CollectWhoData with no condor instance yet\n"; } my $logdir = `condor_config_val log`; $_ = $logdir; s/\\/\//g; $logdir = $_; CondorUtils::fullchomp($logdir); if($usequick == 1) { #print "Using -quick\n"; CondorTest::runCondorTool("condor_who -quick -daemon -log \"$logdir\"",\@whoarray,2,{emit_output=>0}); foreach my $wholine (@whoarray) { CondorUtils::fullchomp($wholine); # print timestamp() . ": raw whodataline: $wholine\n"; if($wholine =~ /(\w*)\s+(.*?)\s+(.*?)\s+(.*?)/) { # print timestamp() . ": Who data with 4 fields:$1,$2,$3,$4\n"; #print "condor_who -quick fields. $1 daemon name $2 pid\n"; #id this is the master is pid real? my $savepid = $2; my $processstring = ""; if($1 eq "Master") { #print "Master found\n"; if(CondorUtils::is_windows() == 1) { my @grift = `tasklist | grep $savepid`; foreach my $process (@grift) { #print "consider:$process saved pid: $savepid\n"; if($process =~ /(.*?)\s+(\d+)\s+(\w+).*/) { $processstring = $1; if($2 eq $savepid) { #print "Pids equal:$processstring\n"; # does this process have master in binary if($processstring =~ /condor_master/) { #print "Is master, thus master alive\n"; CondorTest::LoadWhoData("Master","yes",$savepid,"","","",""); } } } } } else { #print "Master record\n"; if($savepid ne "no") { my @psdata = `ps $savepid`; my $pssize = @psdata; #print "ps data on $savepid: $psdata[1]\n"; if($pssize >= 2) { if($psdata[1] =~ /condor_master/) { #Mark master alive #print "Marking Master Alive*************************************************************\n"; #print "Before LoadWhoData:\n"; CondorTest::LoadWhoData("Master","yes",$savepid,"","","",""); } } } } } #else { #print "Not Master but $1\n"; #next if $wholine =~ /^Daemon.*$/; # skip column headings #next if $wholine =~ /^\-\-\-\-\-\-.*$/; # skip dashes #CondorTest::LoadWhoData($1,$2,"","","","",""); #} } } } else { CondorTest::runCondorTool("condor_who -daemon -log \"$logdir\"",\@whoarray,2,{emit_output=>0}); foreach my $wholine (@whoarray) { CondorUtils::fullchomp($wholine); next if $wholine =~ /^Daemon.*$/; # skip column headings next if $wholine =~ /^\-\-\-\-\-\-.*$/; # skip dashes # print timestamp() . ": rawhodataline: $wholine\n"; if($wholine =~ /(.*?)\s+(.*?)\s+(.*?)\s+(.*?)\s+(.*?)\s+<(.*)>\s+(.*)/) { # print timestamp() . ": Who data with 7 fields:$1,$2,$3,$4,$5,$6,$7\n"; # print "Parse:$wholine\n"; # print "Before LoadWhoData: $1,$2,$3,$4,$5,$6,$7\n"; # this next call assumes we are interested in currently configed personal condor # which means a lookup for condor instance for each daemon CondorTest::LoadWhoData($1,$2,$3,$4,$5,$6,$7); } elsif($wholine =~ /(.*?)\s+(.*?)\s+(.*?)\s+(.*?)\s+(.*?).*/) { # print timestamp() . ": Who data with 5 fields:$1,$2,$3,$4,$5\n"; # print "Before LoadWhoData: $1,$2,$3,$4,$5\n"; CondorTest::LoadWhoData($1,$2,$3,$4,$5,"",""); } else { #print "CollectWhoData: Parse Error: $wholine\n"; } } } #print CondorUtils::TimeStr() . " CollectWhoData done\n"; } sub KillDaemons { my $desiredconfig = shift; my $oldconfig = $ENV{CONDOR_CONFIG}; $ENV{CONDOR_CONFIG} = $desiredconfig; my $condor_name = $personal_condor_params{"condor_name"}; my $condor_instance = CondorTest::GetPersonalCondorWithConfig($desiredconfig); my $alive = $condor_instance->GetCondorAlive(); if($alive == 0) { # nothing to do since it is not marked as ever coming up return(1); } CondorTest::runToolNTimes("condor_off -master -fast",1,0,{expect_result=>\&ANY,emit_output=>0}); my $res = NewIsDownYet($desiredconfig, $condor_name); # reset config to whatever it was. $ENV{CONDOR_CONFIG} = $oldconfig; return($res); } ################################################################# # # KillDaemonPids # # Find the log directory via the config file passed in. Then # open the PIDS fill and kill every pid in it for a sure kill. # ################################################################# sub KillDaemonPids { my $desiredconfig = shift; my $oldconfig = $ENV{CONDOR_CONFIG}; #print "Using new kill method\n"; KillDaemons($desiredconfig); #print "Exit KillDaemonPids after calling KillDaemons\n"; return(0); } ################################################################# # # FindCollectorPort # # Looks for collector_address_file via condor_config_val and tries # to parse port number out of the file. # sub FindCollectorAddress { my $collector_address_file = `condor_config_val collector_address_file`; my $line; CondorUtils::fullchomp($collector_address_file); debug( "Looking for collector port in file ---$collector_address_file---\n",$debuglevel); if($collector_address_file eq "") { debug( "No collector address file defined! Can not find port\n",$debuglevel); return("0"); } if( ! -e "$collector_address_file") { debug( "No collector address file exists! Can not find port\n",$debuglevel); return("0"); } open(COLLECTORADDR,"<$collector_address_file") || die "Can not open collector address file: $!\n"; while(<COLLECTORADDR>) { CondorUtils::fullchomp($_); $line = $_; if( $line =~ /^\s*(<[^>]+>)\s*$/ ) { debug( "Collector address is $1\n",$debuglevel); return($1); } else { debug( "$line\n",$debuglevel); } } close(COLLECTORADDR); debug( "No collector address found in collector address file!\n",$debuglevel); return(""); } sub FindCollectorPort { my $addr = FindCollectorAddress(); if( $addr =~ /^(\d+\.\d+\.\d+\.\d+):(\d+)$/ ) { debug( "Collector ip $1 and port $2\n",$debuglevel); return($2); } else { debug( "Failed to extract port from collector address: $addr\n",$debuglevel); } return("0"); } ################################################################# # # SaveMeSetup # # Make the saveme directory for a test, Create the pid based # location for the current test within this saveme directory # and then create a symbolic link to this pid directory. By doing this # when the personal condor setup go to make a pid directory to # run in, it ends up running within the saveme directory. # This saveme directory allows more data to be returned during the # nightly testing. # # If all is good the current pid is returned but if there # is an error 0 is returned. # ################################################################# sub SaveMeSetup { my $testname = shift; print "Into SaveMeSetup for:$testname\n"; my $mypid = $$; my $res = 1; my $mysaveme = $testname . ".saveme"; $res = CreateDir("-p $mysaveme"); if($res != 0) { print "SaveMeSetup: Could not create \"saveme\" directory for test\n"; return(0); } my $mypiddir = $mysaveme . "/pdir" . $mypid; # there should be no matching directory here # unless we are getting pid recycling. Start fresh. $res = system("rm -rf $mypiddir"); if($res != 0) { print "SaveMeSetup: Could not remove prior pid directory in savemedir \n"; return(0); } $res = system("mkdir $mypiddir"); if($res != 0) { print "SaveMeSetup: Could not create pid directory in \"saveme\" directory\n"; return(0); } # make a symbolic link for personal condor module to use # if we get pid recycling, blow the symbolic link # This might not be a symbolic link, so use -r to be sure #$res = verbose_system("rm -fr $mypid"); #if($res != 0) { #print "SaveMeSetup: Could not remove prior pid directory\n"; #return(0); #} #$res = verbose_system("ln -s $mypiddir $mypid"); #if($res != 0) { #print "SaveMeSetup: Could not link to pid dir in \"saveme\" directory\n"; #return(0); #} return($mypid); } sub PersonalSystem { my $args = shift @_; my $dumpLogs = $ENV{DUMP_CONDOR_LOGS}; my $mypid = $$; $mypid = "pdir$mypid"; if(defined $dumpLogs) { print "Dump Condor Logs if things go south\n"; print "Pid dir is $mypid\n"; system("pwd"); } my $hashref = system($args); my $rc = ${$hashref}{exitcode}; if(defined $dumpLogs) { print "Dumping Condor Logs\n"; my $savedir = getcwd(); chdir("$mypid"); system("ls"); PersonalDumpLogs($mypid); chdir("$savedir"); system("pwd"); } return $rc; } sub PersonalDumpLogs { my $piddir = shift; local *PD; #print "PersonalDumpLogs for $piddir\n"; #system("pwd"); #system("ls -la"); opendir PD, "." || die "failed to open . : $!\n"; #print "Open worked.... listing follows.....\n"; foreach my $file (readdir PD) { #print "Consider: $file\n"; next if $file =~ /^\.\.?$/; # skip . and .. if(-f $file ) { #print "F:$file\n"; } elsif( -d $file ) { #print "D:$file\n"; my $logdir = $file . "/log"; PersonalDumpCondorLogs($logdir); } } close(PD); } sub PersonalDumpCondorLogs { my $logdir = shift; local *LD; #print "PersonalDumpLogs for $logdir\n"; my $now = getcwd(); chdir("$logdir"); #system("pwd"); #system("ls -la"); print "\n\n******************* DUMP $logdir ******************\n\n"; opendir LD, "." || die "failed to open . : $!\n"; #print "Open worked.... listing follows.....\n"; foreach my $file (readdir LD) { #print "Consider: $file\n"; next if $file =~ /^\.\.?$/; # skip . and .. if(-f $file ) { print "\n\n******************* DUMP $file ******************\n\n"; open(FF,"<$file") || die "Can not open logfile: $file: $!\n"; while(<FF>){ print "$_"; } close(FF); } elsif( -d $file ) { #print "D:$file\n"; } } close(LD); chdir("$now"); } sub DisplayPartialLocalConfig { my $configloc = shift; my $logdir = `condor_config_val log`; $_ = $logdir; s/\\/\//g; $logdir = $_; my $fullpathtolocalconfig = ""; my $line = ""; fullchomp($logdir); if($logdir =~ /(.*\/)log/) { #print "Config File Location <$1>\n"; $fullpathtolocalconfig = $1 . $personal_local; print "\nlocal config file: $fullpathtolocalconfig\n"; if( -f $fullpathtolocalconfig) { print "\nDumping Adjustments to: $personal_local\n\n"; my $startdumping = 0; open(LC,"<$fullpathtolocalconfig") or die "Can not open $fullpathtolocalconfig: $!\n"; while(<LC>) { fullchomp($_); $line = $_; if($line =~ /# Requested.*/) { print "$line\n"; } elsif($line =~ /# Adding.*/) { if($startdumping == 0) { $startdumping = 1; } print "$line\n"; } else { if($startdumping == 1) { print "$line\n"; } } } close(LC); print "\nDONE Dumping Adjustments to: $personal_local\n\n"; } } } sub IsThisNightly { my $mylocation = shift; debug("IsThisNightly passed: $mylocation\n",$debuglevel); if($mylocation =~ /^.*(\/execute\/).*$/) { return(1); } else { return(0); } } sub CheckNamedFWTimed { foreach my $key (sort keys %framework_timers) { } } sub RegisterFWTimed { my $name = shift || croak "Missing fw callback name\n"; my $timedcallback = shift || croak "missing callback argument\n"; my $timeddelta = shift || croak "missing delta argument\n"; $framework_timers{$name}{name} = $name; $framework_timers{$name}{timer_time} = time; $framework_timers{$name}{timedcallback} = $timedcallback; $framework_timers{$name}{timeddelta} = $timeddelta; } sub RemoveFWTimed { my $namedcallback = shift || croak "Missing name of named callback to delete\n"; delete $framework_timers{$namedcallback}; } my $minimalistConfig = " "; my $WinminimalistConfigextra = " "; sub DoInitialConfigCheck { if(exists $ENV{CONDOR_CONFIG}) { my $config = $ENV{CONDOR_CONFIG}; if( -f "$config") { #print "Our initial main config file:$config\n"; return(0); } else { print "CONDOR_CONFIG defined but missing:$config\n"; return(1); } } else { print "CONDOR_CONFIG not set\n"; return(1); } } 1;
bbockelm/htcondor
src/condor_scripts/CondorPersonal.pm
Perl
apache-2.0
62,667
=head1 LICENSE Copyright [1999-2015] 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. =cut package XrefParser::ReactomeParser; use strict; use warnings; use Carp; use DBI; use base qw( XrefParser::BaseParser ); use XrefParser::Database; # Parse file of Reactome records and assign direct xrefs # -------------------------------------------------------------------------------- sub run { my ($self, $ref_arg) = @_; my $source_id = $ref_arg->{source_id}; my $species_id = $ref_arg->{species_id}; my $files = $ref_arg->{files}; my $release_file = $ref_arg->{rel_file}; my $verbose = $ref_arg->{verbose}; if((!defined $source_id) or (!defined $species_id) or (!defined $files) ){ croak "Needs to pass source_id, species_id and files as pairs"; } $verbose |=0; my $file_desc = @{$files}[1]; if ( defined $release_file ) { my $release; # Parse and set release information from $release_file. my $release_io = $self->get_filehandle($release_file); while ( defined( my $line = $release_io->getline() ) ) { if ( $line =~ /([0-9]*)/ ) { $release = $1; print "Reactome release is '$release'\n" if($verbose); last; } } if (!$release) { croak "Could not find release using $release_file\n"; } $self->set_release( $source_id, $release ); } # Create a hash of all valid names for this species my %species2alias = $self->species_id2name(); my @aliases = @{$species2alias{$species_id}}; my %alias2species_id = map {$_, 1} @aliases; my $parsed_count = 0; my $err_count = 0; my %reactome2ensembl; my $dbi = $self->dbi(); my $reactome_source_id = $self->get_source_id_for_source_name("reactome", "direct"); my $reactome_uniprot_source_id = $self->get_source_id_for_source_name("reactome", "uniprot"); if($reactome_source_id < 1){ die "Could not find source id for reactome direct???\n"; } else{ print "Source_id = $reactome_source_id\n"; } if($reactome_uniprot_source_id < 1){ die "Could not find source id for reactome uniprot???\n"; } else{ print "Source_id = $reactome_uniprot_source_id\n"; } my (%uniprot) = %{$self->get_valid_codes("uniprot/",$species_id)}; foreach my $file (@$files) { my $reactome_io = $self->get_filehandle($file); # Example line: # ENSG00000138685 REACT_111045 http://www.reactome.org/PathwayBrowser/#REACT_111045 Developmental Biology TAS Homo sapiens while (my $line = $reactome_io->getline() ) { chomp $line; my ($ensembl_stable_id, $reactome_id, $url, $description, $evidence, $species) = split /\t+/,$line; $species =~ s/\s//; $species = lc($species); if ( $alias2species_id{$species} ){ $parsed_count++; # Attempt to guess the object_type based on the stable id # Some entries just don't match on stable id, so warn but do not die # For example: # 00000074047 REACT_268323 http://www.reactome.org/PathwayBrowser/#REACT_268323 Hedgehog 'off' state TAS Homo sapiens my $type; my $info_type = 'DIRECT'; print "Now checking $ensembl_stable_id with $reactome_id and $species_id\n"; if (defined($uniprot{$ensembl_stable_id})) { # First check if it is a uniprot id foreach my $xref_id (@{$uniprot{$ensembl_stable_id}}){ $self->add_dependent_xref({ master_xref_id => $xref_id, acc => $reactome_id, label => $reactome_id, desc => $description, source_id => $reactome_uniprot_source_id, species_id => $species_id} ); } $info_type = 'DEPENDENT'; } elsif ($ensembl_stable_id =~ /G[0-9]*$/) { $type = 'gene'; } elsif ($ensembl_stable_id =~ /T[0-9]*$/) { $type = 'transcript'; } elsif ($ensembl_stable_id =~ /P[0-9]*$/) { $type = 'translation'; } else { # Is not in Uniprot and does not match Ensembl stable id format print STDERR "Could not find type for $ensembl_stable_id\n"; $err_count++; next; } # Add new entry for reactome xref # as well as direct xref to ensembl stable id my $xref_id = $self->add_xref({ acc => $reactome_id, label => $reactome_id, desc => $description, info_type => $info_type, source_id => $reactome_source_id, species_id => $species_id} ); $self->add_direct_xref($xref_id, $ensembl_stable_id, $type) if $type; } } } print "$parsed_count entries processed\n$err_count not found\n"; return 0; } 1;
at7/ensembl
misc-scripts/xref_mapping/XrefParser/ReactomeParser.pm
Perl
apache-2.0
5,418
# 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::V9::Services::KeywordPlanService::KeywordPlanCampaignForecast; use strict; use warnings; use base qw(Google::Ads::GoogleAds::BaseEntity); use Google::Ads::GoogleAds::Utils::GoogleAdsHelper; sub new { my ($class, $args) = @_; my $self = { campaignForecast => $args->{campaignForecast}, keywordPlanCampaign => $args->{keywordPlanCampaign}}; # 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/V9/Services/KeywordPlanService/KeywordPlanCampaignForecast.pm
Perl
apache-2.0
1,134
use File::Basename; use lib dirname (__FILE__); use IOFake; my $app = sub { my ($environ) = @_; my $io = IOFake->new($environ->{'psgi.errors'}); return ['200', [ 'Content-Length' => '2' ], $io]; };
nginx/unit
test/perl/body_io_fake/psgi.pl
Perl
apache-2.0
213
package Google::Ads::AdWords::v201402::CampaignFeedService::mutate; use strict; use warnings; { # BLOCK to scope variables sub get_xmlns { 'https://adwords.google.com/api/adwords/cm/v201402' } __PACKAGE__->__set_name('mutate'); __PACKAGE__->__set_nillable(); __PACKAGE__->__set_minOccurs(); __PACKAGE__->__set_maxOccurs(); __PACKAGE__->__set_ref(); use base qw( SOAP::WSDL::XSD::Typelib::Element Google::Ads::SOAP::Typelib::ComplexType ); our $XML_ATTRIBUTE_CLASS; undef $XML_ATTRIBUTE_CLASS; sub __get_attr_class { return $XML_ATTRIBUTE_CLASS; } use Class::Std::Fast::Storable constructor => 'none'; use base qw(Google::Ads::SOAP::Typelib::ComplexType); { # BLOCK to scope variables my %operations_of :ATTR(:get<operations>); __PACKAGE__->_factory( [ qw( operations ) ], { 'operations' => \%operations_of, }, { 'operations' => 'Google::Ads::AdWords::v201402::CampaignFeedOperation', }, { 'operations' => 'operations', } ); } # end BLOCK } # end of BLOCK 1; =pod =head1 NAME Google::Ads::AdWords::v201402::CampaignFeedService::mutate =head1 DESCRIPTION Perl data type class for the XML Schema defined element mutate from the namespace https://adwords.google.com/api/adwords/cm/v201402. Adds, sets or removes CampaignFeeds. @param operations The operations to apply. @return The resulting Feeds. @throws ApiException Indicates a problem with the request. =head1 PROPERTIES The following properties may be accessed using get_PROPERTY / set_PROPERTY methods: =over =item * operations $element->set_operations($data); $element->get_operations(); =back =head1 METHODS =head2 new my $element = Google::Ads::AdWords::v201402::CampaignFeedService::mutate->new($data); Constructor. The following data structure may be passed to new(): { operations => $a_reference_to, # see Google::Ads::AdWords::v201402::CampaignFeedOperation }, =head1 AUTHOR Generated by SOAP::WSDL =cut
gitpan/GOOGLE-ADWORDS-PERL-CLIENT
lib/Google/Ads/AdWords/v201402/CampaignFeedService/mutate.pm
Perl
apache-2.0
2,003
# # 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 cloud::azure::integration::eventgrid::mode::discovery; use base qw(centreon::plugins::mode); use strict; use warnings; use JSON::XS; sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; $options{options}->add_options(arguments => { 'namespace:s' => { name => 'namespace' }, 'type:s' => { name => 'type' }, 'resource-group:s' => { name => 'resource_group' }, 'location:s' => { name => 'location' }, 'prettify' => { name => 'prettify' }, }); return $self; } sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); $self->{namespace} = $self->{option_results}->{namespace}; $self->{type} = $self->{option_results}->{type}; $self->{location} = $self->{option_results}->{location}; $self->{resource_group} = $self->{option_results}->{resource_group}; } sub run { my ($self, %options) = @_; my @disco_data; my $disco_stats; $disco_stats->{start_time} = time(); my $resources = $options{custom}->azure_list_resources( namespace => $self->{namespace}, resource_type => $self->{type}, location => $self->{location}, resource_group => $self->{resource_group} ); $disco_stats->{end_time} = time(); $disco_stats->{duration} = $disco_stats->{end_time} - $disco_stats->{start_time}; foreach my $resource (@{$resources}) { next if ($resource->{type} !~ /Microsoft\.EventGrid/); $resource->{type} =~ s/Microsoft\.EventGrid\///; my $resource_group = ''; $resource_group = $resource->{resourceGroup} if (defined($resource->{resourceGroup})); $resource_group = $1 if ($resource_group eq '' && defined($resource->{id}) && $resource->{id} =~ /resourceGroups\/(.*)\/providers/); $resource->{resourceGroup} = $resource_group; foreach my $entry (keys %{$resource}) { next if (ref($resource->{$entry}) ne "HASH"); my @array; foreach my $key (keys %{$resource->{$entry}}) { push @array, { key => $key, value => $resource->{$entry}->{$key} }; } $resource->{$entry} = \@array; } push @disco_data, $resource; } $disco_stats->{discovered_items} = @disco_data; $disco_stats->{results} = \@disco_data; my $encoded_data; eval { if (defined($self->{option_results}->{prettify})) { $encoded_data = JSON::XS->new->utf8->pretty->encode($disco_stats); } else { $encoded_data = JSON::XS->new->utf8->encode($disco_stats); } }; if ($@) { $encoded_data = '{"code":"encode_error","message":"Cannot encode discovered data into JSON format"}'; } $self->{output}->output_add(short_msg => $encoded_data); $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1); $self->{output}->exit(); } 1; __END__ =head1 MODE Resources discovery. =over 8 =item B<--namespace> Specify resources namespace. =item B<--type> Specify resources type. =item B<--resource-group> Specify resources resource group. =item B<--location> Specify resources location. =item B<--prettify> Prettify JSON output. =back =cut
centreon/centreon-plugins
cloud/azure/integration/eventgrid/mode/discovery.pm
Perl
apache-2.0
4,091
=head1 LICENSE Copyright [1999-2014] 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. =cut package EnsEMBL::Web::ViewConfig::Healthcheck::Details; use strict; sub init { my $self = shift; $self->set_defaults({ result_INFO => 'on', result_WARNING => 'on', result_PROBLEM => 'on', unannotated => 'yes', tc_note => 'on', tc_under_review => 'on', tc_healthcheck_bug => 'off', tc_manual_ok => 'off', tc_manual_ok_this_assembly => 'off', tc_manual_ok_all_releases => 'off', }); } sub form { my $self = shift; $self->add_form_element({ type => 'SubHeader', value => 'Show results of type', }); $self->add_form_element({ name => 'result_INFO', type => 'AltCheckBox', notes => 'INFO', value => 'on', }); $self->add_form_element({ name => 'result_WARNING', type => 'AltCheckBox', notes => 'WARNING', value => 'on', }); $self->add_form_element({ name => 'result_PROBLEM', type => 'AltCheckBox', notes => 'PROBLEM', value => 'on', }); $self->add_form_element({ name => 'unannotated', label => 'Show unannotated testcases', type => 'DropDown', values => [ { name => 'Yes', value => 'yes' }, { name => 'No', value => 'no' }, ], }); $self->add_form_element({ type => 'SubHeader', value => "Show testcases with 'Action' of", }); $self->add_form_element({ name => 'tc_note', type => 'AltCheckBox', notes => 'Note', value => 'on', }); $self->add_form_element({ name => 'tc_under_review', type => 'AltCheckBox', notes => 'Under review', value => 'on', }); $self->add_form_element({ name => 'tc_healthcheck_bug', type => 'AltCheckBox', notes => 'Healthcheck bug', value => 'on', }); $self->add_form_element({ name => 'tc_manual_ok', type => 'AltCheckBox', notes => 'Manual - OK', value => 'on', }); $self->add_form_element({ name => 'tc_manual_ok_this_assembly', type => 'AltCheckBox', notes => 'Manual - OK this assembly', value => 'on', }); $self->add_form_element({ name => 'tc_manual_ok_all_releases', type => 'AltCheckBox', notes => 'Manual - OK all releases', value => 'on', }); } 1;
andrewyatz/public-plugins
admin/modules/EnsEMBL/Web/ViewConfig/Healthcheck/Details.pm
Perl
apache-2.0
2,986
package TargetAdapter::LocalMapping::SimpleTargetAdapter::MixtureSlot; # TODO : MixtureSlot => mixture of AbstractiveSlot and WordEmbeddingSlot # => simply create slot that has both slots undernead and combine options use strict; use warnings; use Moose; use namespace::autoclean; extends( 'TargetAdapter::LocalMapping::SimpleTargetAdapter::Slot' ); has '_abstractive_slot' => ( is => 'ro' , isa => 'TargetAdapter::LocalMapping::SimpleTargetAdapter::AbstractiveSlot' , init_arg => undef , lazy => 1 , builder => '_abstractive_slot_builder' ); sub _abstractive_slot_builder { my $this = shift; return $this->_slot_builder( 'TargetAdapter::LocalMapping::SimpleTargetAdapter::AbstractiveSlot' ); } has '_extractive_slot' => ( is => 'ro' , isa => 'TargetAdapter::LocalMapping::SimpleTargetAdapter::WordEmbeddingSlot' , init_arg => undef , lazy => 1 , builder => '_extractive_slot_builder' ); sub _extractive_slot_builder { my $this = shift; return $this->_slot_builder( 'TargetAdapter::LocalMapping::SimpleTargetAdapter::WordEmbeddingSlot' ); } sub _slot_builder { my $this = shift; my $slot_class = shift; # TODO : ideally I should avoid code redundancy with AdaptableSequence => create a new method ? my $slot_object = ( Web::Summarizer::Utils::load_class( $slot_class ) )->new( parent => $this->parent, id => $this->id, key => $this->key, # TODO : can we avoid having to explicitly pass the neighborhood ? neighborhood => $this->neighborhood, from => $this->from, to => $this->to, # TODO : provide callback to compute probability ? replacement_probability_only => 1 ); return $slot_object; } has 'mixture_ratio' => ( is => 'ro' , isa => 'Num' , init_arg => undef , lazy => 1 , builder => '_mixture_ratio_builder' ); sub _mixture_ratio_builder { my $this = shift; my $current_filler = $this->key; # TODO : the appearance prior (mixture ratio) probably shouldn't be target-dependent (?) my $mixture_ratio = $this->neighborhood->neighborhood_density->{ $current_filler } || 0; return $mixture_ratio; } sub mix { my $this = shift; my $component_1 = shift; my $component_2 = shift; my $mixture_ratio = $this->mixture_ratio; return $mixture_ratio * $component_1 + ( 1 - $mixture_ratio ) * $component_2; } sub appearance_prior { my $this = shift; my $candidate = shift; $this->mix( map { $_->appearance_prior( $candidate ) } ( $this->_abstractive_slot , $this->_extractive_slot ) ); } sub process { my $this = shift; my %_options; my %_id_2_object; my $mixture_ratio = $this->mixture_ratio; foreach my $entry ( [ 1 - $mixture_ratio , $this->_extractive_slot ] , [ $mixture_ratio , $this->_abstractive_slot ] ) { my $basic_slot_option_weight = $entry->[ 0 ]; if ( $basic_slot_option_weight ) { my $basic_slot_options = $entry->[ 1 ]->process; map { my $basic_slot_option = $_; my $basic_slot_option_token = $basic_slot_option->[ 0 ]; my $basic_slot_option_token_id = $basic_slot_option_token->id; my $basic_slot_option_probability = $basic_slot_option->[ 1 ]; $_options{ $basic_slot_option_token_id } += $basic_slot_option_weight * $basic_slot_option_probability; $_id_2_object{ $basic_slot_option_token_id } = $basic_slot_option_token; } @{ $basic_slot_options }; } } my @options = map { [ $_id_2_object{ $_ } , $_options{ $_ } ] } keys( %_options ); return \@options; } __PACKAGE__->meta->make_immutable; 1;
ypetinot/web-summarization
summarizers/graph-summarizer-4/src/TargetAdapter/LocalMapping/SimpleTargetAdapter/MixtureSlot.pm
Perl
apache-2.0
3,517
#!/usr/bin/env perl # Copyright [1999-2015] 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 <helpdesk.org>. =cut use strict; use warnings; use Bio::EnsEMBL::Registry; use Bio::EnsEMBL::Utils::Sequence qw( reverse_comp ); use Getopt::Long; use DBI qw(:sql_types); our $DEFAULT_FLANKING_SIZE = 400; my $submission_report; my $registry_file; my $verbose; my $help; my $source; my $species; usage() if (!scalar(@ARGV)); GetOptions( 'submission_report=s' => \$submission_report, 'registry_file=s' => \$registry_file, 'source=s' => \$source, 'species=s' => \$species, 'verbose!' => \$verbose, 'help!' => \$help ); # Use human by default $species ||= 'Human'; usage() if ($help); die ("The source name of the submission is required") unless (defined($source)); die ("A submission report file is required") unless (defined($submission_report)); die ("A registry configuration file is required") unless (defined($registry_file)); # Load the registry and get a variation feature adaptor Bio::EnsEMBL::Registry->load_all($registry_file); my $vf_adaptor = Bio::EnsEMBL::Registry->get_adaptor($species,'Variation','VariationFeature'); # Get a db_handle to the variation database my $dbh = Bio::EnsEMBL::Registry->get_DBAdaptor($species,'Variation')->dbc->db_handle(); # Check that the source exists in the source table, otherwise add it import_source($source,$dbh); # Open the submission report for parsing open(FH,'<',$submission_report) or die ("Could not open $submission_report for reading"); while (<FH>) { chomp; # Skip comments next if (m/^#/); # Split the line my ($local_id,$hgvs,$ssid,$rsid,$condition,$omim) = split(/\t/); # Skip if local id or hgvs notation could not be found next unless (defined($local_id) && defined($hgvs)); # Set the ssID to be undefined if it's just an empty string $ssid = undef unless (defined($ssid) && length($ssid)); # If the rsId is not all digits (after stripping an initial rs), warn and skip to the next record $rsid =~ s/^rs//; warn ("Can not import variant with rsId '$rsid', skipping row beginning with '" . substr($_,0,35) . "...'") unless ($rsid =~ m/^\d+$/); # Get a VariationFeature from the HGVS notation my $vf = $vf_adaptor->fetch_by_hgvs_notation($hgvs); # Warn if we didn't get a variation feature back if (!defined($vf)) { warn ("Could not parse $hgvs into a variation feature"); next; } # Set the name, source and synonym of the variation $vf->variation->source($source); # In case an rsId was supplied, use that if (defined($rsid)) { $vf->variation->name("rs$rsid"); $vf->variation->source("dbSNP"); $vf->variation->add_synonym($source,$local_id); } # Else, use the ssID if necessary elsif (defined($ssid)) { $vf->variation->name("ss$ssid"); $vf->variation->add_synonym($source,$local_id); } # Else, use the local id else { $vf->variation->name($local_id); } $vf->source($vf->variation->source); # If defined, add the subsnp_id to the alleles if (defined($ssid)) { map {$_->subsnp($ssid)} @{$vf->variation->get_all_Alleles()}; } # Set the validation_status of the variation_feature and variation to 'precious' $vf->add_validation_state('precious'); $vf->variation->add_validation_state('precious'); # Transform the variation feature to the chromosome coordinate system my $chr_vf = $vf->transform('chromosome'); # Warn if the transform was unsuccessful but store the variation feature using LRG coordinates warn ("Could not transform $hgvs to the chromosome coordinate system") unless (defined($chr_vf)); $chr_vf ||= $vf; # Check if there already exists a variation feature in the same location, in which case we should only add synonyms to this one my $slice = $chr_vf->feature_Slice(); my $existing_vfs = $vf_adaptor->fetch_all_by_Slice($slice); # If we already have a variation here and it has the same rsID as the one we are importing, add synonyms to the submitter and add the alleles if necessary if (scalar(@{$existing_vfs}) && grep {$_->variation_name() eq $chr_vf->variation->name()} @{$existing_vfs}) { my ($ext_vf) = grep {$_->variation_name() eq $chr_vf->variation->name()} @{$existing_vfs}; # Set the variation_id of our vf to match the one in the database $chr_vf->dbID($ext_vf->dbID()); $chr_vf->variation->dbID($ext_vf->variation->dbID()); # Flip our vf if it's on a different strand than the existing vf if ($chr_vf->strand() != $ext_vf->strand()) { flip_variation_feature(\$chr_vf); } # Add the alleles of our variation import_alleles($chr_vf->variation,$dbh); # Add the synonyms import_variation_synonyms($chr_vf->variation,$dbh); # Add 'precious' to the validation_state of the existing variation if it's not set unless (grep {$_ =~ m/precious/} @{$ext_vf->get_all_validation_states()}) { my $vid = $ext_vf->variation->dbID(); my $stmt = qq{ UPDATE variation_feature SET validation_status = CONCAT(validation_status,',precious') WHERE variation_id = $vid }; $dbh->do($stmt); } unless (grep {$_ =~ m/precious/} @{$ext_vf->variation->get_all_validation_states()}) { my $vid = $ext_vf->variation->dbID(); my $stmt = qq{ UPDATE variation SET validation_status = CONCAT(validation_status,',precious') WHERE variation_id = $vid }; $dbh->do($stmt); } } # Else, add everything to the database else { # If the variation feature is on the negative strand on the chromsome, flip everything around to be on the positive strand if ($chr_vf->strand() < 0) { flip_variation_feature(\$chr_vf); } # 1) import the variation object import_variation($chr_vf->variation,$dbh); # 2) import the alleles import_alleles($chr_vf->variation,$dbh); # 3) import the flanking sequence import_flanking_sequence($chr_vf,$dbh); # 4) import the variation_synonyms import_variation_synonyms($chr_vf->variation,$dbh); # 5) import the variation_feature import_variation_feature($chr_vf,$dbh); } # Verify that the vf does not fail # check_failed($chr_vf,$dbh); =head # If the input data contains phenotypes, attach a variation annotation object to the variation if (defined($condition) && $condition ne 'NULL' && defined($omim) && $omim ne 'NULL') { my $study = Bio::EnsEMBL::Variation::Study-new( -name => ); my $v_annotation = Bio::EnsEMBL::Variation::VariationAnnotation->new( '-source_name' => $source, '-variation' => $chr_vf->variation(), '-phenotype_description' => $condition, '-study' => 'MIM:' . $omim, '-adaptor' => $vf_adaptor->db->get_VariationAnnotationAdaptor() ); import_variation_annotation($v_annotation,$dbh); } =cut } close(FH); sub flip_variation_feature { my $vf = shift; # Flip the allele string my @alleles = split(/\//,${$vf}->allele_string()); map {reverse_comp(\$_)} @alleles; ${$vf}->allele_string(join("/",@alleles)); # Flip the alleles foreach my $allele (@{${$vf}->variation()->get_all_Alleles()}) { my $seq = $allele->allele(); reverse_comp(\$seq); $allele->allele($seq); } # Change the strand ${$vf}->strand(-1 * ${$vf}->strand()); } sub import_variation_annotation { my $va = shift; my $dbh = shift; my $stmt = qq{ SELECT va.variation_annotation_id FROM variation_annotation va JOIN phenotype p ON ( p.phenotype_id = va.phenotype_id ) JOIN source s ON ( s.source_id = va.source_id ) WHERE va.variation_id = ? AND p.description = ? AND s.name = ? LIMIT 1 }; my $check_sth = $dbh->prepare($stmt); $stmt = qq{ INSERT IGNORE INTO variation_annotation ( variation_id, phenotype_id, source_id, study ) VALUES ( ?, ?, ( SELECT source_id FROM source WHERE name = ? LIMIT 1 ), ? ) }; my $sth = $dbh->prepare($stmt); $check_sth->execute( $va->variation->dbID(), $va->phenotype_description(), $va->source_name() ); my $row = $check_sth->fetchrow_arrayref(); my $dbid; $dbid = $row->[0] if (defined($row)); $va->dbID($dbid); unless (defined($va->dbID())) { my $phenotype_id = import_phenotype($va->phenotype_description(),$dbh); $sth->execute( $va->variation->dbID(), $phenotype_id, $va->source_name(), $va->study() ); $va->dbID($dbh->last_insert_id(undef,undef,undef,undef)); } return $va->dbID(); } sub import_variation_synonyms { my $variation = shift; my $dbh = shift; my @dbIDs; my $check_stmt = qq{ SELECT vs.variation_synonym_id FROM variation_synonym vs JOIN source s ON ( s.source_id = vs.source_id ) WHERE vs.variation_id = %d AND vs.subsnp_id %s AND s.name = '%s' AND vs.name = '%s' LIMIT 1 }; my $stmt = qq{ INSERT IGNORE INTO variation_synonym ( variation_id, subsnp_id, source_id, name ) VALUES ( ?,?, ( SELECT source_id FROM source WHERE name = ? LIMIT 1 ),? ) }; my $sth = $dbh->prepare($stmt); # If there is a subsnp_id attached to an allele object on the variation, get it my $subsnp_id = $variation->get_all_Alleles->[0]->subsnp() if (scalar(@{$variation->get_all_Alleles()})); # Loop over all synonym sources foreach my $source (@{$variation->get_all_synonym_sources()}) { # Loop over all synonyms from this source foreach my $synonym (@{$variation->get_all_synonyms($source)}) { # Check if the synonym exists $stmt = sprintf($check_stmt,$variation->dbID(),(defined($subsnp_id) ? "= $subsnp_id" : "IS NULL"),$source,$synonym); my $dbid = $dbh->selectall_arrayref($stmt)->[0][0]; unless (defined($dbid)) { $sth->execute( $variation->dbID(), $subsnp_id, $source, $synonym ); $dbid = $dbh->last_insert_id(undef,undef,undef,undef); } push(@dbIDs,$dbid); } } return \@dbIDs; } sub import_variation_feature { my $vf = shift; my $dbh = shift; # Check if we already have a variation feature with this variation and position and in that case, return that dbId and do nothing my $stmt = qq{ SELECT vf.variation_feature_id FROM variation_feature vf JOIN seq_region sr ON ( vf.seq_region_id = sr.seq_region_id ) WHERE vf.variation_id = ? AND sr.name = ? AND vf.seq_region_start = ? AND vf.seq_region_end = ? AND vf.seq_region_strand = ? LIMIT 1 }; my $sth = $dbh->prepare($stmt); $stmt = qq{ INSERT IGNORE INTO variation_feature ( seq_region_id, seq_region_start, seq_region_end, seq_region_strand, variation_id, allele_string, variation_name, map_weight, source_id, validation_status ) VALUES ( ( SELECT seq_region_id FROM seq_region WHERE name = ? LIMIT 1 ), ?,?,?,?,?,?,?, ( SELECT source_id FROM source WHERE name = ? LIMIT 1 ), ? ) }; $sth->execute( $vf->variation->dbID(), $vf->seq_region_name(), $vf->seq_region_start(), $vf->seq_region_end(), $vf->seq_region_strand() ); my $row = $sth->fetchrow_arrayref; my $dbid; $dbid = $row->[0] if (defined($row)); $vf->dbID($dbid); unless (defined($vf->dbID())) { $sth = $dbh->prepare($stmt); $sth->execute( $vf->seq_region_name(), $vf->seq_region_start(), $vf->seq_region_end(), $vf->seq_region_strand(), $vf->variation->dbID(), $vf->allele_string(), $vf->variation->name(), $vf->map_weight(), $vf->source(), (defined($vf->get_all_validation_states()) ? join(",",@{$vf->get_all_validation_states()}) : undef) ); $vf->dbID($dbh->last_insert_id(undef,undef,undef,undef)); } return $vf->dbID(); } sub import_alleles { my $variation = shift; my $dbh = shift; # For each allele, check whether we already have that allele for the variation, subsnp and sample, in which case we do nothing my $check_stmt = qq{ SELECT allele_id FROM allele WHERE variation_id = %d AND allele = '%s' # Skip subsnp_id for now AND subsnp_id %s LIMIT 1 }; my @dbIDs; my $stmt = qq{ INSERT IGNORE INTO allele ( variation_id, subsnp_id, sample_id, allele, frequency, count ) VALUES ( ?,?,?,?,?,? ) }; my $sth = $dbh->prepare($stmt); # Loop over all alleles for this variation object foreach my $allele (@{$variation->get_all_Alleles()}) { # Check if the allele already exists $stmt = sprintf($check_stmt,$variation->dbID(),$allele->allele(),(defined($allele->subsnp()) ? "= " . $allele->subsnp() : "IS NULL ")); my $dbid = $dbh->selectall_arrayref($stmt)->[0][0]; $allele->dbID($dbid); # Insert the allele if it wasn't already in the db unless (defined($allele->dbID())) { $sth->execute( $variation->dbID(), $allele->subsnp(), (defined($allele->population()) ? $allele->population->dbID() : undef), $allele->allele(), $allele->frequency(), $allele->count() ); $allele->dbID($dbh->last_insert_id(undef,undef,undef,undef)); } push(@dbIDs,$allele->dbID()); } return \@dbIDs; } sub import_variation { my $variation = shift; my $dbh = shift; # First, check if the variation name already exists. In that case, just set the dbID of our object and return my $stmt = qq{ SELECT variation_id FROM variation WHERE name = ? LIMIT 1 }; my $sth = $dbh->prepare($stmt); $stmt = qq{ INSERT IGNORE INTO variation ( source_id, name, validation_status, ancestral_allele, flipped ) VALUES ( ( SELECT source_id FROM source WHERE name = ? LIMIT 1 ),?,?,?,? ) }; $sth->execute($variation->name()); my $row = $sth->fetchrow_arrayref; my $dbid; $dbid = $row->[0] if (defined($row)); $variation->dbID($dbid); unless (defined($variation->dbID())) { $sth = $dbh->prepare($stmt); $sth->execute( $variation->source(), $variation->name(), (defined($variation->get_all_validation_states()) ? join(",",@{$variation->get_all_validation_states()}) : undef), $variation->ancestral_allele(), undef ); $variation->dbID($dbh->last_insert_id(undef,undef,undef,undef)); } return $variation->dbID(); } sub import_flanking_sequence { my $vf = shift; my $dbh = shift; my $stmt = qq{ INSERT IGNORE INTO flanking_sequence ( variation_id, up_seq_region_start, up_seq_region_end, down_seq_region_start, down_seq_region_end, seq_region_id, seq_region_strand ) VALUES ( ?,?,?,?,?, ( SELECT seq_region_id FROM seq_region WHERE name = ? LIMIT 1 ),? ) }; my $sth = $dbh->prepare($stmt); $sth->execute( $vf->variation->dbID(), ($vf->seq_region_start - $DEFAULT_FLANKING_SIZE), ($vf->seq_region_start - 1), ($vf->seq_region_end + 1), ($vf->seq_region_end + $DEFAULT_FLANKING_SIZE), $vf->seq_region_name, $vf->seq_region_strand ); return $vf->variation->dbID(); } sub import_phenotype { my $description = shift; my $dbh = shift; my $stmt = qq{ SELECT phenotype_id FROM phenotype WHERE description LIKE ? LIMIT 1 }; my $check_sth = $dbh->prepare($stmt); $stmt = qq{ INSERT IGNORE INTO phenotype ( description ) VALUES ( ? ) }; my $sth = $dbh->prepare($stmt); $check_sth->execute( $description ); my $row = $check_sth->fetchrow_arrayref(); my $dbid; $dbid = $row->[0] if (defined($row)); unless (defined($dbid)) { $sth->execute( $description ); $dbid = $dbh->last_insert_id(undef,undef,undef,undef); } return $dbid; } sub check_failed { my $vf = shift; my $dbh = shift; my $stmt = qq{ INSERT IGNORE INTO failed_variation ( variation_id, subsnp_id, failed_description_id ) VALUES ( ?,?,? ) }; my $sth = $dbh->prepare($stmt); $stmt = qq{ UPDATE variation SET validation_status = CONCAT(validation_status,',failed'); WHERE variation_id = ? }; my $fail_sth = $dbh->prepare($stmt); # Get the subsnp id if available my $subsnp_id; $subsnp_id = $vf->variation->get_all_Alleles->[0]->subsnp() if (defined($vf->variation->get_all_Alleles)); # Check if the reference allele matches the reference sequence unless (grep {$_->allele() eq $vf->feature_Slice->seq()} @{$vf->variation->get_all_Alleles()}) { warn ("None of the variant alleles for variation_feature_id " . $vf->dbID() . " (" . $vf->variation->name() . ", " . $vf->allele_string . ") match the reference sequence (" . $vf->seq_region_name . ":" . $vf->seq_region_start . "-" . $vf->seq_region_end . ":" . $vf->seq_region_strand . ")"); $sth->execute($vf->variation->dbID(),$subsnp_id,2); # $fail_sth->execute($vf->variation->dbID()); } } sub import_source { my $source = shift; my $dbh = shift; my $stmt = qq{ SELECT source_id FROM source WHERE name = '$source' LIMIT 1 }; my $dbid = $dbh->selectall_arrayref($stmt)->[0][0]; unless (defined($dbid)) { $stmt = qq{ INSERT INTO source ( name, type ) VALUES ( '$source', 'lsdb' ) }; $dbh->do($stmt); $dbid = $dbh->last_insert_id(undef,undef,undef,undef); } return $dbid; } sub usage { print STDOUT qq{ }; exit(0); }
dbolser/ensembl-variation
scripts/import/import_variant_submissions.pl
Perl
apache-2.0
22,585
package VMOMI::ClusterVmToolsMonitoringSettings; use parent 'VMOMI::DynamicData'; use strict; use warnings; our @class_ancestors = ( 'DynamicData', ); our @class_members = ( ['enabled', 'boolean', 0, 1], ['vmMonitoring', undef, 0, 1], ['clusterSettings', 'boolean', 0, 1], ['failureInterval', undef, 0, 1], ['minUpTime', undef, 0, 1], ['maxFailures', undef, 0, 1], ['maxFailureWindow', undef, 0, 1], ); 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/ClusterVmToolsMonitoringSettings.pm
Perl
apache-2.0
657
package VMOMI::ArrayOfProfileMetadataProfileSortSpec; use parent 'VMOMI::ComplexType'; use strict; use warnings; our @class_ancestors = ( ); our @class_members = ( ['ProfileMetadataProfileSortSpec', 'ProfileMetadataProfileSortSpec', 1, 1], ); 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/ArrayOfProfileMetadataProfileSortSpec.pm
Perl
apache-2.0
468
package VMOMI::ProfileParameterMetadata; use parent 'VMOMI::DynamicData'; use strict; use warnings; our @class_ancestors = ( 'DynamicData', ); our @class_members = ( ['id', 'ExtendedElementDescription', 0, ], ['type', undef, 0, ], ['optional', 'boolean', 0, ], ['defaultValue', 'anyType', 0, 1], ['hidden', 'boolean', 0, 1], ['securitySensitive', 'boolean', 0, 1], ['readOnly', 'boolean', 0, 1], ); 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/ProfileParameterMetadata.pm
Perl
apache-2.0
653
use Spreadsheet::Read; my $file = 'test.xls'; my $spreadsheet = ReadData( $file ) or die "Cannot read $file\n"; my $sheet_count = $spreadsheet->[0]{sheets} or die "No sheets in $file\n"; for my $sheet_index (1 .. $sheet_count) { # Skip empty worksheets my $sheet = $spreadsheet->[$sheet_index] or next; printf( "%s - %02d: [ %-12s ] %3d Cols, %5d Rows\n", $file, $sheet_index, $sheet->{label}, $sheet->{maxcol}, $sheet->{maxrow} ); for my $row ( 1 .. $sheet->{maxrow} ) { print join "\t" => map { $sheet->{cell}[$_][$row] // "-" } 1 .. $sheet->{maxcol}; print "\n"; } }
jmcveigh/komodo-tools
scripts/perl/use_any_spreadsheet_as_a_data_source/read_xls.pl
Perl
bsd-2-clause
678
########################################################################### # # This file is partially auto-generated by the DateTime::Locale generator # tools (v0.10). This code generator comes with the DateTime::Locale # distribution in the tools/ directory, and is called generate-modules. # # This file was generated from the CLDR JSON locale data. See the LICENSE.cldr # file included in this distribution for license details. # # Do not edit this file directly unless you are sure the part you are editing # is not created by the generator. # ########################################################################### =pod =encoding UTF-8 =head1 NAME DateTime::Locale::am_ET - Locale data examples for the am-ET locale. =head1 DESCRIPTION This pod file contains examples of the locale data available for the Amharic Ethiopia locale. =head2 Days =head3 Wide (format) ሰኞ ማክሰኞ ረቡዕ ሐሙስ ዓርብ ቅዳሜ እሑድ =head3 Abbreviated (format) ሰኞ ማክሰ ረቡዕ ሐሙስ ዓርብ ቅዳሜ እሑድ =head3 Narrow (format) ሰ ማ ረ ሐ ዓ ቅ እ =head3 Wide (stand-alone) ሰኞ ማክሰኞ ረቡዕ ሐሙስ ዓርብ ቅዳሜ እሑድ =head3 Abbreviated (stand-alone) ሰኞ ማክሰ ረቡዕ ሐሙስ ዓርብ ቅዳሜ እሑድ =head3 Narrow (stand-alone) ሰ ማ ረ ሐ ዓ ቅ እ =head2 Months =head3 Wide (format) ጃንዩወሪ ፌብሩወሪ ማርች ኤፕሪል ሜይ ጁን ጁላይ ኦገስት ሴፕቴምበር ኦክቶበር ኖቬምበር ዲሴምበር =head3 Abbreviated (format) ጃንዩ ፌብሩ ማርች ኤፕሪ ሜይ ጁን ጁላይ ኦገስ ሴፕቴ ኦክቶ ኖቬም ዲሴም =head3 Narrow (format) ጃ ፌ ማ ኤ ሜ ጁ ጁ ኦ ሴ ኦ ኖ ዲ =head3 Wide (stand-alone) ጃንዩወሪ ፌብሩወሪ ማርች ኤፕሪል ሜይ ጁን ጁላይ ኦገስት ሴፕቴምበር ኦክቶበር ኖቬምበር ዲሴምበር =head3 Abbreviated (stand-alone) ጃንዩ ፌብሩ ማርች ኤፕሪ ሜይ ጁን ጁላይ ኦገስ ሴፕቴ ኦክቶ ኖቬም ዲሴም =head3 Narrow (stand-alone) ጃ ፌ ማ ኤ ሜ ጁ ጁ ኦ ሴ ኦ ኖ ዲ =head2 Quarters =head3 Wide (format) 1ኛው ሩብ 2ኛው ሩብ 3ኛው ሩብ 4ኛው ሩብ =head3 Abbreviated (format) ሩብ1 ሩብ2 ሩብ3 ሩብ4 =head3 Narrow (format) 1 2 3 4 =head3 Wide (stand-alone) 1ኛው ሩብ 2ኛው ሩብ 3ኛው ሩብ 4ኛው ሩብ =head3 Abbreviated (stand-alone) ሩብ1 ሩብ2 ሩብ3 ሩብ4 =head3 Narrow (stand-alone) 1 2 3 4 =head2 Eras =head3 Wide (format) ዓመተ ዓለም ዓመተ ምሕረት =head3 Abbreviated (format) ዓ/ዓ ዓ/ም =head3 Narrow (format) ዓ/ዓ ዓ/ም =head2 Date Formats =head3 Full 2008-02-05T18:30:30 = ማክሰኞ ፣5 ፌብሩወሪ 2008 1995-12-22T09:05:02 = ዓርብ ፣22 ዲሴምበር 1995 -0010-09-15T04:44:23 = ቅዳሜ ፣15 ሴፕቴምበር -10 =head3 Long 2008-02-05T18:30:30 = 5 ፌብሩወሪ 2008 1995-12-22T09:05:02 = 22 ዲሴምበር 1995 -0010-09-15T04:44:23 = 15 ሴፕቴምበር -10 =head3 Medium 2008-02-05T18:30:30 = 5 ፌብሩ 2008 1995-12-22T09:05:02 = 22 ዲሴም 1995 -0010-09-15T04:44:23 = 15 ሴፕቴ -10 =head3 Short 2008-02-05T18:30:30 = 05/02/2008 1995-12-22T09:05:02 = 22/12/1995 -0010-09-15T04:44:23 = 15/09/-10 =head2 Time Formats =head3 Full 2008-02-05T18:30:30 = 6:30:30 ከሰዓት UTC 1995-12-22T09:05:02 = 9:05:02 ጥዋት UTC -0010-09-15T04:44:23 = 4:44:23 ጥዋት UTC =head3 Long 2008-02-05T18:30:30 = 6:30:30 ከሰዓት UTC 1995-12-22T09:05:02 = 9:05:02 ጥዋት UTC -0010-09-15T04:44:23 = 4:44:23 ጥዋት UTC =head3 Medium 2008-02-05T18:30:30 = 6:30:30 ከሰዓት 1995-12-22T09:05:02 = 9:05:02 ጥዋት -0010-09-15T04:44:23 = 4:44:23 ጥዋት =head3 Short 2008-02-05T18:30:30 = 6:30 ከሰዓት 1995-12-22T09:05:02 = 9:05 ጥዋት -0010-09-15T04:44:23 = 4:44 ጥዋት =head2 Datetime Formats =head3 Full 2008-02-05T18:30:30 = ማክሰኞ ፣5 ፌብሩወሪ 2008 6:30:30 ከሰዓት UTC 1995-12-22T09:05:02 = ዓርብ ፣22 ዲሴምበር 1995 9:05:02 ጥዋት UTC -0010-09-15T04:44:23 = ቅዳሜ ፣15 ሴፕቴምበር -10 4:44:23 ጥዋት UTC =head3 Long 2008-02-05T18:30:30 = 5 ፌብሩወሪ 2008 6:30:30 ከሰዓት UTC 1995-12-22T09:05:02 = 22 ዲሴምበር 1995 9:05:02 ጥዋት UTC -0010-09-15T04:44:23 = 15 ሴፕቴምበር -10 4:44:23 ጥዋት UTC =head3 Medium 2008-02-05T18:30:30 = 5 ፌብሩ 2008 6:30:30 ከሰዓት 1995-12-22T09:05:02 = 22 ዲሴም 1995 9:05:02 ጥዋት -0010-09-15T04:44:23 = 15 ሴፕቴ -10 4:44:23 ጥዋት =head3 Short 2008-02-05T18:30:30 = 05/02/2008 6:30 ከሰዓት 1995-12-22T09:05:02 = 22/12/1995 9:05 ጥዋት -0010-09-15T04:44:23 = 15/09/-10 4:44 ጥዋት =head2 Available Formats =head3 E (ccc) 2008-02-05T18:30:30 = ማክሰ 1995-12-22T09:05:02 = ዓርብ -0010-09-15T04:44:23 = ቅዳሜ =head3 EHm (E HH:mm) 2008-02-05T18:30:30 = ማክሰ 18:30 1995-12-22T09:05:02 = ዓርብ 09:05 -0010-09-15T04:44:23 = ቅዳሜ 04:44 =head3 EHms (E HH:mm:ss) 2008-02-05T18:30:30 = ማክሰ 18:30:30 1995-12-22T09:05:02 = ዓርብ 09:05:02 -0010-09-15T04:44:23 = ቅዳሜ 04:44:23 =head3 Ed (E d) 2008-02-05T18:30:30 = ማክሰ 5 1995-12-22T09:05:02 = ዓርብ 22 -0010-09-15T04:44:23 = ቅዳሜ 15 =head3 Ehm (E h:mm a) 2008-02-05T18:30:30 = ማክሰ 6:30 ከሰዓት 1995-12-22T09:05:02 = ዓርብ 9:05 ጥዋት -0010-09-15T04:44:23 = ቅዳሜ 4:44 ጥዋት =head3 Ehms (E h:mm:ss a) 2008-02-05T18:30:30 = ማክሰ 6:30:30 ከሰዓት 1995-12-22T09:05:02 = ዓርብ 9:05:02 ጥዋት -0010-09-15T04:44:23 = ቅዳሜ 4:44:23 ጥዋት =head3 Gy (y G) 2008-02-05T18:30:30 = 2008 ዓ/ም 1995-12-22T09:05:02 = 1995 ዓ/ም -0010-09-15T04:44:23 = -10 ዓ/ዓ =head3 GyMMM (MMM y G) 2008-02-05T18:30:30 = ፌብሩ 2008 ዓ/ም 1995-12-22T09:05:02 = ዲሴም 1995 ዓ/ም -0010-09-15T04:44:23 = ሴፕቴ -10 ዓ/ዓ =head3 GyMMMEd (E፣ MMM d፣ y G) 2008-02-05T18:30:30 = ማክሰ፣ ፌብሩ 5፣ 2008 ዓ/ም 1995-12-22T09:05:02 = ዓርብ፣ ዲሴም 22፣ 1995 ዓ/ም -0010-09-15T04:44:23 = ቅዳሜ፣ ሴፕቴ 15፣ -10 ዓ/ዓ =head3 GyMMMd (MMM d፣ y G) 2008-02-05T18:30:30 = ፌብሩ 5፣ 2008 ዓ/ም 1995-12-22T09:05:02 = ዲሴም 22፣ 1995 ዓ/ም -0010-09-15T04:44:23 = ሴፕቴ 15፣ -10 ዓ/ዓ =head3 H (H) 2008-02-05T18:30:30 = 18 1995-12-22T09:05:02 = 9 -0010-09-15T04:44:23 = 4 =head3 Hm (HH:mm) 2008-02-05T18:30:30 = 18:30 1995-12-22T09:05:02 = 09:05 -0010-09-15T04:44:23 = 04:44 =head3 Hms (HH:mm:ss) 2008-02-05T18:30:30 = 18:30:30 1995-12-22T09:05:02 = 09:05:02 -0010-09-15T04:44:23 = 04:44:23 =head3 Hmsv (HH:mm:ss v) 2008-02-05T18:30:30 = 18:30:30 UTC 1995-12-22T09:05:02 = 09:05:02 UTC -0010-09-15T04:44:23 = 04:44:23 UTC =head3 Hmv (HH:mm v) 2008-02-05T18:30:30 = 18:30 UTC 1995-12-22T09:05:02 = 09:05 UTC -0010-09-15T04:44:23 = 04:44 UTC =head3 M (L) 2008-02-05T18:30:30 = 2 1995-12-22T09:05:02 = 12 -0010-09-15T04:44:23 = 9 =head3 MEd (E፣ M/d) 2008-02-05T18:30:30 = ማክሰ፣ 2/5 1995-12-22T09:05:02 = ዓርብ፣ 12/22 -0010-09-15T04:44:23 = ቅዳሜ፣ 9/15 =head3 MMM (LLL) 2008-02-05T18:30:30 = ፌብሩ 1995-12-22T09:05:02 = ዲሴም -0010-09-15T04:44:23 = ሴፕቴ =head3 MMMEd (E፣ MMM d) 2008-02-05T18:30:30 = ማክሰ፣ ፌብሩ 5 1995-12-22T09:05:02 = ዓርብ፣ ዲሴም 22 -0010-09-15T04:44:23 = ቅዳሜ፣ ሴፕቴ 15 =head3 MMMMEd (E፣ MMMM d) 2008-02-05T18:30:30 = ማክሰ፣ ፌብሩወሪ 5 1995-12-22T09:05:02 = ዓርብ፣ ዲሴምበር 22 -0010-09-15T04:44:23 = ቅዳሜ፣ ሴፕቴምበር 15 =head3 MMMMd (MMMM d) 2008-02-05T18:30:30 = ፌብሩወሪ 5 1995-12-22T09:05:02 = ዲሴምበር 22 -0010-09-15T04:44:23 = ሴፕቴምበር 15 =head3 MMMd (MMM d) 2008-02-05T18:30:30 = ፌብሩ 5 1995-12-22T09:05:02 = ዲሴም 22 -0010-09-15T04:44:23 = ሴፕቴ 15 =head3 Md (M/d) 2008-02-05T18:30:30 = 2/5 1995-12-22T09:05:02 = 12/22 -0010-09-15T04:44:23 = 9/15 =head3 d (d) 2008-02-05T18:30:30 = 5 1995-12-22T09:05:02 = 22 -0010-09-15T04:44:23 = 15 =head3 h (h a) 2008-02-05T18:30:30 = 6 ከሰዓት 1995-12-22T09:05:02 = 9 ጥዋት -0010-09-15T04:44:23 = 4 ጥዋት =head3 hm (h:mm a) 2008-02-05T18:30:30 = 6:30 ከሰዓት 1995-12-22T09:05:02 = 9:05 ጥዋት -0010-09-15T04:44:23 = 4:44 ጥዋት =head3 hms (h:mm:ss a) 2008-02-05T18:30:30 = 6:30:30 ከሰዓት 1995-12-22T09:05:02 = 9:05:02 ጥዋት -0010-09-15T04:44:23 = 4:44:23 ጥዋት =head3 hmsv (h:mm:ss a v) 2008-02-05T18:30:30 = 6:30:30 ከሰዓት UTC 1995-12-22T09:05:02 = 9:05:02 ጥዋት UTC -0010-09-15T04:44:23 = 4:44:23 ጥዋት UTC =head3 hmv (h:mm a v) 2008-02-05T18:30:30 = 6:30 ከሰዓት UTC 1995-12-22T09:05:02 = 9:05 ጥዋት UTC -0010-09-15T04:44:23 = 4:44 ጥዋት UTC =head3 ms (mm:ss) 2008-02-05T18:30:30 = 30:30 1995-12-22T09:05:02 = 05:02 -0010-09-15T04:44:23 = 44:23 =head3 y (y) 2008-02-05T18:30:30 = 2008 1995-12-22T09:05:02 = 1995 -0010-09-15T04:44:23 = -10 =head3 yM (M/y) 2008-02-05T18:30:30 = 2/2008 1995-12-22T09:05:02 = 12/1995 -0010-09-15T04:44:23 = 9/-10 =head3 yMEd (E፣ d/M/y) 2008-02-05T18:30:30 = ማክሰ፣ 5/2/2008 1995-12-22T09:05:02 = ዓርብ፣ 22/12/1995 -0010-09-15T04:44:23 = ቅዳሜ፣ 15/9/-10 =head3 yMMM (MMM y) 2008-02-05T18:30:30 = ፌብሩ 2008 1995-12-22T09:05:02 = ዲሴም 1995 -0010-09-15T04:44:23 = ሴፕቴ -10 =head3 yMMMEd (E፣ MMM d y) 2008-02-05T18:30:30 = ማክሰ፣ ፌብሩ 5 2008 1995-12-22T09:05:02 = ዓርብ፣ ዲሴም 22 1995 -0010-09-15T04:44:23 = ቅዳሜ፣ ሴፕቴ 15 -10 =head3 yMMMM (MMMM y) 2008-02-05T18:30:30 = ፌብሩወሪ 2008 1995-12-22T09:05:02 = ዲሴምበር 1995 -0010-09-15T04:44:23 = ሴፕቴምበር -10 =head3 yMMMd (d MMM y) 2008-02-05T18:30:30 = 5 ፌብሩ 2008 1995-12-22T09:05:02 = 22 ዲሴም 1995 -0010-09-15T04:44:23 = 15 ሴፕቴ -10 =head3 yMd (d/M/y) 2008-02-05T18:30:30 = 5/2/2008 1995-12-22T09:05:02 = 22/12/1995 -0010-09-15T04:44:23 = 15/9/-10 =head3 yQQQ (QQQ y) 2008-02-05T18:30:30 = ሩብ1 2008 1995-12-22T09:05:02 = ሩብ4 1995 -0010-09-15T04:44:23 = ሩብ3 -10 =head3 yQQQQ (QQQQ y) 2008-02-05T18:30:30 = 1ኛው ሩብ 2008 1995-12-22T09:05:02 = 4ኛው ሩብ 1995 -0010-09-15T04:44:23 = 3ኛው ሩብ -10 =head2 Miscellaneous =head3 Prefers 24 hour time? No =head3 Local first day of the week 1 (ሰኞ) =head1 SUPPORT See L<DateTime::Locale>. =cut
jkb78/extrajnm
local/lib/perl5/DateTime/Locale/am_ET.pod
Perl
mit
11,238
package Paws::DeviceFarm::DeleteNetworkProfileResult; use Moose; has _request_id => (is => 'ro', isa => 'Str'); ### main pod documentation begin ### =head1 NAME Paws::DeviceFarm::DeleteNetworkProfileResult =head1 ATTRIBUTES =head2 _request_id => Str =cut 1;
ioanrogers/aws-sdk-perl
auto-lib/Paws/DeviceFarm/DeleteNetworkProfileResult.pm
Perl
apache-2.0
272
package Google::Ads::AdWords::v201409::LocationCriterionService::ResponseHeader; use strict; use warnings; { # BLOCK to scope variables sub get_xmlns { 'https://adwords.google.com/api/adwords/cm/v201409' } __PACKAGE__->__set_name('ResponseHeader'); __PACKAGE__->__set_nillable(); __PACKAGE__->__set_minOccurs(); __PACKAGE__->__set_maxOccurs(); __PACKAGE__->__set_ref(); use base qw( SOAP::WSDL::XSD::Typelib::Element Google::Ads::AdWords::v201409::SoapResponseHeader ); } 1; =pod =head1 NAME Google::Ads::AdWords::v201409::LocationCriterionService::ResponseHeader =head1 DESCRIPTION Perl data type class for the XML Schema defined element ResponseHeader from the namespace https://adwords.google.com/api/adwords/cm/v201409. =head1 METHODS =head2 new my $element = Google::Ads::AdWords::v201409::LocationCriterionService::ResponseHeader->new($data); Constructor. The following data structure may be passed to new(): $a_reference_to, # see Google::Ads::AdWords::v201409::SoapResponseHeader =head1 AUTHOR Generated by SOAP::WSDL =cut
gitpan/GOOGLE-ADWORDS-PERL-CLIENT
lib/Google/Ads/AdWords/v201409/LocationCriterionService/ResponseHeader.pm
Perl
apache-2.0
1,068
# !!!!!!! DO NOT EDIT THIS FILE !!!!!!! # This file is machine-generated by lib/unicore/mktables from the Unicode # database, Version 6.2.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'; FB1E END
Bjay1435/capstone
rootfs/usr/share/perl/5.18.2/unicore/lib/Ccc/CCC26.pl
Perl
mit
430
# # 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 apps::exchange::2010::local::mode::mapimailbox; use base qw(centreon::plugins::mode); use strict; use warnings; use centreon::plugins::misc; use centreon::common::powershell::exchange::2010::mapimailbox; 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 => { "remote-host:s" => { name => 'remote_host', }, "remote-user:s" => { name => 'remote_user', }, "remote-password:s" => { name => 'remote_password', }, "no-ps" => { name => 'no_ps', }, "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' }, "ps-exec-only" => { name => 'ps_exec_only', }, "warning:s" => { name => 'warning', }, "critical:s" => { name => 'critical', default => '%{result} !~ /Success/i' }, "mailbox:s" => { name => 'mailbox', }, }); return $self; } sub change_macros { my ($self, %options) = @_; foreach (('warning', 'critical')) { if (defined($self->{option_results}->{$_})) { $self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{data}->{$1}/g; } } } sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); if (!defined($self->{option_results}->{mailbox}) || $self->{option_results}->{mailbox} eq '') { $self->{output}->add_option_msg(short_msg => "Need to specify '--mailbox' option."); $self->{output}->option_exit(); } $self->change_macros(); } sub run { my ($self, %options) = @_; my $ps = centreon::common::powershell::exchange::2010::mapimailbox::get_powershell( remote_host => $self->{option_results}->{remote_host}, remote_user => $self->{option_results}->{remote_user}, remote_password => $self->{option_results}->{remote_password}, mailbox => $self->{option_results}->{mailbox}, no_ps => $self->{option_results}->{no_ps}, ); $self->{option_results}->{command_options} .= " " . $ps; my ($stdout) = centreon::plugins::misc::windows_execute(output => $self->{output}, timeout => $self->{option_results}->{timeout}, 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(); } centreon::common::powershell::exchange::2010::mapimailbox::check($self, stdout => $stdout, mailbox => $self->{option_results}->{mailbox}); $self->{output}->display(); $self->{output}->exit(); } 1; __END__ =head1 MODE Check mapi connection to a mailbox. =over 8 =item B<--remote-host> Open a session to the remote-host (fully qualified host name). --remote-user and --remote-password are optional =item B<--remote-user> Open a session to the remote-host with authentication. This also needs --remote-host and --remote-password. =item B<--remote-password> Open a session to the remote-host with authentication. This also needs --remote-user and --remote-host. =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<--warning> Set warning threshold. Can used special variables like: %{result}, %{scenario} =item B<--critical> Set critical threshold (Default: '%{result} !~ /Success/i'). Can used special variables like: %{result}, %{scenario} =item B<--mailbox> Set the mailbox to check (Required). =back =cut
maksimatveev/centreon-plugins
apps/exchange/2010/local/mode/mapimailbox.pm
Perl
apache-2.0
6,418
package Gherkin::ParserContext; use strict; use warnings; use Class::XSAccessor accessors => [ qw/token_scanner token_matcher token_queue _errors/, ]; sub new { my ( $class, $options ) = @_; $options->{'token_queue'} ||= []; $options->{'_errors'} ||= []; bless $options, $class; } sub add_tokens { my $self = shift; push( @{ $self->token_queue }, @_ ); } sub errors { my $self = shift; return @{ $self->_errors } } sub add_errors { my $self = shift; push( @{ $self->_errors }, @_ ); } sub read_token { my ($self) = shift(); return shift( @{ $self->token_queue } ) || $self->token_scanner->read; } 1;
Zearin/gherkin3
perl/lib/Gherkin/ParserContext.pm
Perl
mit
644
#!/usr/local/bin/perl # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # # Copyright 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # require 5.8.4; $PNAME = $0; $PNAME =~ s:.*/::; $USAGE = "Usage: $PNAME [file ...]\n"; $errs = 0; sub err { my($msg) = @_; print "$file: $lineno: $msg\n"; $errs++; } sub dstyle { open(FILE, "$file"); $lineno = 0; $inclause = 0; $skipnext = 0; while (<FILE>) { $lineno++; chop; if ($skipnext) { $skipnext = 0; next; } # # Amazingly, some ident strings are longer than 80 characters! # if (/^#pragma ident/) { next; } # # The algorithm to calculate line length from cstyle. # $line = $_; if ($line =~ tr/\t/\t/ * 7 + length($line) > 80) { # yes, there is a chance. # replace tabs with spaces and check again. $eline = $line; 1 while $eline =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e; if (length($eline) > 80) { err "line > 80 characters"; } } if (/\/\*DSTYLED\*\//) { $skipnext = 1; next; } if (/^#pragma/) { next; } if (/^#include/) { next; } # # Before we do any more analysis, we want to prune out any # quoted strings. This is a bit tricky because we need # to be careful of backslashed quotes within quoted strings. # I'm sure there is a very crafty way to do this with a # single regular expression, but that will have to wait for # somone with better regex juju that I; we do this by first # eliminating the backslashed quotes, and then eliminating # whatever quoted strings are left. Note that we eliminate # the string by replacing it with "quotedstr"; this is to # allow lines to end with a quoted string. (If we simply # eliminated the quoted string, dstyle might complain about # the line ending in a space or tab.) # s/\\\"//g; s/\"[^\"]*\"/quotedstr/g; if (/[ \t]$/) { err "space or tab at end of line"; } if (/^[\t]+[ ]+[\t]+/) { err "spaces between tabs"; } if (/^[\t]* \*/) { next; } if (/^ /) { err "indented by spaces not tabs"; } if (/^{}$/) { next; } if (!/^enum/ && !/^\t*struct/ && !/^\t*union/ && !/^typedef/ && !/^translator/ && !/^provider/) { if (/[\w\s]+{/) { err "left brace not on its own line"; } if (/{[\w\s]+/) { err "left brace not on its own line"; } } if (!/;$/) { if (/[\w\s]+}/) { err "right brace not on its own line"; } if (/}[\w\s]+/) { err "right brace not on its own line"; } } if (/^}/) { $inclause = 0; } if (!$inclause && /^[\w ]+\//) { err "predicate not at beginning of line"; } if (!$inclause && /^\/[ \t]+\w/) { err "space between '/' and expression in predicate"; } if (!$inclause && /\w[ \t]+\/$/) { err "space between expression and '/' in predicate"; } if (!$inclause && /\s,/) { err "space before comma in probe description"; } if (!$inclause && /\w,[\w\s]/ && !/;$/) { if (!/extern/ && !/\(/ && !/inline/) { err "multiple probe descriptions on same line"; } } if ($inclause && /sizeof\(/) { err "missing space after sizeof"; } if ($inclause && /^[\w ]/) { err "line doesn't begin with a tab"; } if ($inclause && /,[\w]/) { err "comma without trailing space"; } if (/\w&&/ || /&&\w/ || /\w\|\|/ || /\|\|\w/) { err "logical operator not set off with spaces"; } # # We want to catch "i<0" variants, but we don't want to # erroneously flag translators. # if (!/\w<\w+>\(/) { if (/\w>/ || / >\w/ || /\w</ || /<\w/) { err "comparison operator not set " . "off with spaces"; } } if (/\w==/ || /==\w/ || /\w<=/ || />=\w/ || /\w!=/ || /!=\w/) { err "comparison operator not set off with spaces"; } if (/\w=/ || /=\w/) { err "assignment operator not set off with spaces"; } if (/^{/) { $inclause = 1; } } } foreach $arg (@ARGV) { if (-f $arg) { push(@files, $arg); } else { die "$PNAME: $arg is not a valid file\n"; } } die $USAGE if (scalar(@files) == 0); foreach $file (@files) { dstyle($file); } exit($errs != 0);
dplbsd/soc2013
head/cddl/contrib/opensolaris/cmd/dtrace/test/cmd/scripts/dstyle.pl
Perl
bsd-2-clause
4,910
#! /usr/bin/env perl # Copyright 2006-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 # https://www.openssl.org/source/license.html # # ==================================================================== # Written by Andy Polyakov <appro@fy.chalmers.se> for the OpenSSL # project. The module is, however, dual licensed under OpenSSL and # CRYPTOGAMS licenses depending on where you obtain it. For further # details see http://www.openssl.org/~appro/cryptogams/. # ==================================================================== # # On 21264 RSA sign performance improves by 70/35/20/15 percent for # 512/1024/2048/4096 bit key lengths. This is against vendor compiler # instructed to '-tune host' code with in-line assembler. Other # benchmarks improve by 15-20%. To anchor it to something else, the # code provides approximately the same performance per GHz as AMD64. # I.e. if you compare 1GHz 21264 and 2GHz Opteron, you'll observe ~2x # difference. $output=pop; open STDOUT,">$output"; # int bn_mul_mont( $rp="a0"; # BN_ULONG *rp, $ap="a1"; # const BN_ULONG *ap, $bp="a2"; # const BN_ULONG *bp, $np="a3"; # const BN_ULONG *np, $n0="a4"; # const BN_ULONG *n0, $num="a5"; # int num); $lo0="t0"; $hi0="t1"; $lo1="t2"; $hi1="t3"; $aj="t4"; $bi="t5"; $nj="t6"; $tp="t7"; $alo="t8"; $ahi="t9"; $nlo="t10"; $nhi="t11"; $tj="t12"; $i="s3"; $j="s4"; $m1="s5"; $code=<<___; #ifdef __linux__ #include <asm/regdef.h> #else #include <asm.h> #include <regdef.h> #endif .text .set noat .set noreorder .globl bn_mul_mont .align 5 .ent bn_mul_mont bn_mul_mont: lda sp,-48(sp) stq ra,0(sp) stq s3,8(sp) stq s4,16(sp) stq s5,24(sp) stq fp,32(sp) mov sp,fp .mask 0x0400f000,-48 .frame fp,48,ra .prologue 0 .align 4 .set reorder sextl $num,$num mov 0,v0 cmplt $num,4,AT bne AT,.Lexit ldq $hi0,0($ap) # ap[0] s8addq $num,16,AT ldq $aj,8($ap) subq sp,AT,sp ldq $bi,0($bp) # bp[0] lda AT,-4096(zero) # mov -4096,AT ldq $n0,0($n0) and sp,AT,sp mulq $hi0,$bi,$lo0 ldq $hi1,0($np) # np[0] umulh $hi0,$bi,$hi0 ldq $nj,8($np) mulq $lo0,$n0,$m1 mulq $hi1,$m1,$lo1 umulh $hi1,$m1,$hi1 addq $lo1,$lo0,$lo1 cmpult $lo1,$lo0,AT addq $hi1,AT,$hi1 mulq $aj,$bi,$alo mov 2,$j umulh $aj,$bi,$ahi mov sp,$tp mulq $nj,$m1,$nlo s8addq $j,$ap,$aj umulh $nj,$m1,$nhi s8addq $j,$np,$nj .align 4 .L1st: .set noreorder ldq $aj,0($aj) addl $j,1,$j ldq $nj,0($nj) lda $tp,8($tp) addq $alo,$hi0,$lo0 mulq $aj,$bi,$alo cmpult $lo0,$hi0,AT addq $nlo,$hi1,$lo1 mulq $nj,$m1,$nlo addq $ahi,AT,$hi0 cmpult $lo1,$hi1,v0 cmplt $j,$num,$tj umulh $aj,$bi,$ahi addq $nhi,v0,$hi1 addq $lo1,$lo0,$lo1 s8addq $j,$ap,$aj umulh $nj,$m1,$nhi cmpult $lo1,$lo0,v0 addq $hi1,v0,$hi1 s8addq $j,$np,$nj stq $lo1,-8($tp) nop unop bne $tj,.L1st .set reorder addq $alo,$hi0,$lo0 addq $nlo,$hi1,$lo1 cmpult $lo0,$hi0,AT cmpult $lo1,$hi1,v0 addq $ahi,AT,$hi0 addq $nhi,v0,$hi1 addq $lo1,$lo0,$lo1 cmpult $lo1,$lo0,v0 addq $hi1,v0,$hi1 stq $lo1,0($tp) addq $hi1,$hi0,$hi1 cmpult $hi1,$hi0,AT stq $hi1,8($tp) stq AT,16($tp) mov 1,$i .align 4 .Louter: s8addq $i,$bp,$bi ldq $hi0,0($ap) ldq $aj,8($ap) ldq $bi,0($bi) ldq $hi1,0($np) ldq $nj,8($np) ldq $tj,0(sp) mulq $hi0,$bi,$lo0 umulh $hi0,$bi,$hi0 addq $lo0,$tj,$lo0 cmpult $lo0,$tj,AT addq $hi0,AT,$hi0 mulq $lo0,$n0,$m1 mulq $hi1,$m1,$lo1 umulh $hi1,$m1,$hi1 addq $lo1,$lo0,$lo1 cmpult $lo1,$lo0,AT mov 2,$j addq $hi1,AT,$hi1 mulq $aj,$bi,$alo mov sp,$tp umulh $aj,$bi,$ahi mulq $nj,$m1,$nlo s8addq $j,$ap,$aj umulh $nj,$m1,$nhi .align 4 .Linner: .set noreorder ldq $tj,8($tp) #L0 nop #U1 ldq $aj,0($aj) #L1 s8addq $j,$np,$nj #U0 ldq $nj,0($nj) #L0 nop #U1 addq $alo,$hi0,$lo0 #L1 lda $tp,8($tp) mulq $aj,$bi,$alo #U1 cmpult $lo0,$hi0,AT #L0 addq $nlo,$hi1,$lo1 #L1 addl $j,1,$j mulq $nj,$m1,$nlo #U1 addq $ahi,AT,$hi0 #L0 addq $lo0,$tj,$lo0 #L1 cmpult $lo1,$hi1,v0 #U0 umulh $aj,$bi,$ahi #U1 cmpult $lo0,$tj,AT #L0 addq $lo1,$lo0,$lo1 #L1 addq $nhi,v0,$hi1 #U0 umulh $nj,$m1,$nhi #U1 s8addq $j,$ap,$aj #L0 cmpult $lo1,$lo0,v0 #L1 cmplt $j,$num,$tj #U0 # borrow $tj addq $hi0,AT,$hi0 #L0 addq $hi1,v0,$hi1 #U1 stq $lo1,-8($tp) #L1 bne $tj,.Linner #U0 .set reorder ldq $tj,8($tp) addq $alo,$hi0,$lo0 addq $nlo,$hi1,$lo1 cmpult $lo0,$hi0,AT cmpult $lo1,$hi1,v0 addq $ahi,AT,$hi0 addq $nhi,v0,$hi1 addq $lo0,$tj,$lo0 cmpult $lo0,$tj,AT addq $hi0,AT,$hi0 ldq $tj,16($tp) addq $lo1,$lo0,$j cmpult $j,$lo0,v0 addq $hi1,v0,$hi1 addq $hi1,$hi0,$lo1 stq $j,0($tp) cmpult $lo1,$hi0,$hi1 addq $lo1,$tj,$lo1 cmpult $lo1,$tj,AT addl $i,1,$i addq $hi1,AT,$hi1 stq $lo1,8($tp) cmplt $i,$num,$tj # borrow $tj stq $hi1,16($tp) bne $tj,.Louter s8addq $num,sp,$tj # &tp[num] mov $rp,$bp # put rp aside mov sp,$tp mov sp,$ap mov 0,$hi0 # clear borrow bit .align 4 .Lsub: ldq $lo0,0($tp) ldq $lo1,0($np) lda $tp,8($tp) lda $np,8($np) subq $lo0,$lo1,$lo1 # tp[i]-np[i] cmpult $lo0,$lo1,AT subq $lo1,$hi0,$lo0 cmpult $lo1,$lo0,$hi0 or $hi0,AT,$hi0 stq $lo0,0($rp) cmpult $tp,$tj,v0 lda $rp,8($rp) bne v0,.Lsub subq $hi1,$hi0,$hi0 # handle upmost overflow bit mov sp,$tp mov $bp,$rp # restore rp and sp,$hi0,$ap bic $bp,$hi0,$bp bis $bp,$ap,$ap # ap=borrow?tp:rp .align 4 .Lcopy: ldq $aj,0($ap) # copy or in-place refresh lda $tp,8($tp) lda $rp,8($rp) lda $ap,8($ap) stq zero,-8($tp) # zap tp cmpult $tp,$tj,AT stq $aj,-8($rp) bne AT,.Lcopy mov 1,v0 .Lexit: .set noreorder mov fp,sp /*ldq ra,0(sp)*/ ldq s3,8(sp) ldq s4,16(sp) ldq s5,24(sp) ldq fp,32(sp) lda sp,48(sp) ret (ra) .end bn_mul_mont .ascii "Montgomery Multiplication for Alpha, CRYPTOGAMS by <appro\@openssl.org>" .align 2 ___ print $code; close STDOUT;
openweave/openweave-core
third_party/openssl/openssl/crypto/bn/asm/alpha-mont.pl
Perl
apache-2.0
5,948
#!/usr/bin/env 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. use strict; use warnings; use AI::MXNet qw(mx); ### model my $data = mx->symbol->Variable('data'); my $conv1= mx->symbol->Convolution(data => $data, name => 'conv1', num_filter => 32, kernel => [3,3], stride => [2,2]); my $bn1 = mx->symbol->BatchNorm(data => $conv1, name => "bn1"); my $act1 = mx->symbol->Activation(data => $bn1, name => 'relu1', act_type => "relu"); my $mp1 = mx->symbol->Pooling(data => $act1, name => 'mp1', kernel => [2,2], stride =>[2,2], pool_type=>'max'); my $conv2= mx->symbol->Convolution(data => $mp1, name => 'conv2', num_filter => 32, kernel=>[3,3], stride=>[2,2]); my $bn2 = mx->symbol->BatchNorm(data => $conv2, name=>"bn2"); my $act2 = mx->symbol->Activation(data => $bn2, name=>'relu2', act_type=>"relu"); my $mp2 = mx->symbol->Pooling(data => $act2, name => 'mp2', kernel=>[2,2], stride=>[2,2], pool_type=>'max'); my $fl = mx->symbol->Flatten(data => $mp2, name=>"flatten"); my $fc1 = mx->symbol->FullyConnected(data => $fl, name=>"fc1", num_hidden=>30); my $act3 = mx->symbol->Activation(data => $fc1, name=>'relu3', act_type=>"relu"); my $fc2 = mx->symbol->FullyConnected(data => $act3, name=>'fc2', num_hidden=>10); my $softmax = mx->symbol->SoftmaxOutput(data => $fc2, name => 'softmax'); ## creates the image file in working directory, you need GraphViz installed for this to work mx->viz->plot_network($softmax, save_format => 'png')->render("network.png");
larroy/mxnet
perl-package/AI-MXNet/examples/plot_network.pl
Perl
apache-2.0
2,220
# mod_ls.pl sub mod_ls_directives { local $rv = [ [ 'DirFakeUser', 0, 2, 'virtual anon global', 1.15 ], [ 'DirFakeGroup', 0, 2, 'virtual anon global', 1.15 ], [ 'DirFakeMode', 0, 2, 'virtual anon global', 1.16 ], [ 'LsDefaultOptions', 0, 2, 'virtual anon global', 1.16 ], [ 'ListOptions', 0, 2, 'virtual anon global directory ftpaccess', 1.208 ], [ 'ShowDotFiles', 0, 2, 'virtual anon global', '0.99-1.206' ], ]; return &make_directives($rv, $_[0], "mod_ls"); } sub edit_DirFakeGroup { local $rv; local $w = $_[0]->{'words'}->[0]; $rv .= sprintf "<input type=radio name=DirFakeGroup value=off %s> %s\n", lc($w) eq 'off' ? "checked" : "", $text{'no'}; $rv .= sprintf "<input type=radio name=DirFakeGroup value='' %s> %s\n", lc($w) ? "" : "checked", $text{'default'}; $rv .= sprintf "<input type=radio name=DirFakeGroup value=on %s> %s\n", lc($w) eq 'on' ? "checked" : "", $text{'mod_ls_fakeasgroup'}; $rv .= "<table border cellpadding=0 cellspacing=0><tr><td>"; local $a = $_[0]->{'words'}->[1]; $rv .= sprintf "<input type=radio name=DirFakeGroup_m value=0 %s> %s\n", $a ? "" : "checked", "<tt>ftp</tt>"; $rv .= sprintf "<input type=radio name=DirFakeGroup_m value=1 %s> %s\n", $a eq "~" ? "checked" : "", $text{'mod_ls_fakesamegroup'}; $rv .= sprintf "<input type=radio name=DirFakeGroup_m value=2 %s>\n", $a eq "~" || !$a ? "" : "checked"; $rv .= sprintf "<input name=DirFakeGroup_a size=12 value='%s'>\n", $a eq "~" ? "" : $a; $rv .= "</td></tr></table>\n"; return (2, $text{'mod_ls_fakegroup'}, $rv); } sub save_DirFakeGroup { if (!$in{'DirFakeGroup'}) { return ( [ ] ); } else { local $s = $in{'DirFakeGroup'}; if ($in{'DirFakeGroup_m'} == 1) { $s .= " ~"; } elsif ($in{'DirFakeGroup_m'} == 2) { $in{'DirFakeGroup_a'} =~ /^\S+$/ || &error($text{'mod_ls_efakegroup'}); $s .= " ".$in{'DirFakeGroup_a'}; } return ( [ $s ] ); } } sub edit_DirFakeUser { local $rv; local $w = $_[0]->{'words'}->[0]; $rv .= sprintf "<input type=radio name=DirFakeUser value=off %s> %s\n", lc($w) eq 'off' ? "checked" : "", $text{'no'}; $rv .= sprintf "<input type=radio name=DirFakeUser value='' %s> %s\n", lc($w) ? "" : "checked", $text{'default'}; $rv .= sprintf "<input type=radio name=DirFakeUser value=on %s> %s\n", lc($w) eq 'on' ? "checked" : "", $text{'mod_ls_fakeasuser'}; $rv .= "<table border cellpadding=0 cellspacing=0><tr><td>"; local $a = $_[0]->{'words'}->[1]; $rv .= sprintf "<input type=radio name=DirFakeUser_m value=0 %s> %s\n", $a ? "" : "checked", "<tt>ftp</tt>"; $rv .= sprintf "<input type=radio name=DirFakeUser_m value=1 %s> %s\n", $a eq "~" ? "checked" : "", $text{'mod_ls_fakesameuser'}; $rv .= sprintf "<input type=radio name=DirFakeUser_m value=2 %s>\n", $a eq "~" || !$a ? "" : "checked"; $rv .= sprintf "<input name=DirFakeUser_a size=12 value='%s'>\n", $a eq "~" ? "" : $a; $rv .= "</td></tr></table>\n"; return (2, $text{'mod_ls_fakeuser'}, $rv); } sub save_DirFakeUser { if (!$in{'DirFakeUser'}) { return ( [ ] ); } else { local $s = $in{'DirFakeUser'}; if ($in{'DirFakeUser_m'} == 1) { $s .= " ~"; } elsif ($in{'DirFakeUser_m'} == 2) { $in{'DirFakeUser_a'} =~ /^\S+$/ || &error($text{'mod_ls_efakeuser'}); $s .= " ".$in{'DirFakeUser_a'}; } return ( [ $s ] ); } } sub edit_DirFakeMode { return (1, $text{'mod_ls_fakemode'}, &opt_input($_[0]->{'value'}, "DirFakeMode", $text{'mod_ls_nofake'}, 5)); } sub save_DirFakeMode { return &parse_opt("DirFakeMode", '0[0-7]{3}', $text{'mod_ls_efakemode'}); } sub edit_LsDefaultOptions { return (1, $text{'mod_ls_ls'}, &opt_input($_[0]->{'value'}, "LsDefaultOptions", $text{'default'}, 20)); } sub save_LsDefaultOptions { return &parse_opt("LsDefaultOptions", '\S', $text{'mod_ls_els'}); } sub edit_ShowDotFiles { return (1, $text{'mod_ls_dotfiles'}, &choice_input($_[0]->{'value'}, "ShowDotFiles", "", "$text{'yes'},on", "$text{'no'},off", "$text{'default'},")); } sub save_ShowDotFiles { return &parse_choice("ShowDotFiles", ""); } sub edit_ListOptions { local $rv = &opt_input($_[0]->{'words'}->[0], "ListOptions", $text{'default'}, 20); $rv .= sprintf "<input type=checkbox name=ListOptions_strict value=1 %s> %s\n", lc($_[0]->{'words'}->[1]) eq 'strict' ? "checked" : "", $text{'mod_ls_strict'}; return (2, $text{'mod_ls_options'}, $rv); } sub save_ListOptions { if ($in{"ListOptions_def"}) { return ( [ ] ); } else { local $rv = '"'.$in{"ListOptions"}.'"'; $rv .= " strict" if ($in{'ListOptions_strict'}); return ( [ $rv ] ); } }
rcuvgd/Webmin22.01.2016
proftpd/mod_ls.pl
Perl
bsd-3-clause
4,503
package UI::ChangeLog; # # Copyright 2015 Comcast Cable Communications Management, 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. # # # use UI::Utils; use Mojo::Base 'Mojolicious::Controller'; sub changelog { my $self = shift; my $date_string = `date "+%Y-%m-%d% %H:%M:%S"`; chomp($date_string); $self->session( last_seen_log => $date_string ); &navbarpage($self); } sub readlog { my $self = shift; my $numdays = defined( $self->param('days') ) ? $self->param('days') : 30; my $rows = defined( $self->param('days') ) ? 1000000 : 1000; # all of them gets to be too much my @data; my $interval = "> now() - interval '" . $numdays . " day'"; # postgres if ( $self->db->storage->isa("DBIx::Class::Storage::DBI::mysql") ) { $interval = "> now() - interval " . $numdays . " day"; } my $rs = $self->db->resultset('Log')->search( { 'me.last_updated' => \$interval }, { prefetch => [ { 'tm_user' => undef } ], order_by => { -desc => 'me.last_updated' }, rows => $rows } ); while ( my $row = $rs->next ) { push( @data, { "id" => $row->id, "level" => $row->level, "message" => $row->message, "user" => $row->tm_user->username, "ticketnum" => $row->ticketnum, "last_updated" => $row->last_updated, } ); } # setting cookie in the lib/Cdn/alog sub - this will be cached # my $date_string = `date "+%Y-%m-%d% %H:%M:%S"`; # chomp($date_string); # $self->session( last_seen_log => $date_string ); $self->render( json => \@data ); } sub newlogcount { my $self = shift; my $cookie = $self->cookie('last_seen_log'); my $user = $self->current_user()->{userid}; my $count = 0; if ( !defined($cookie) ) { my $date_string = `date "+%Y-%m-%d% %H:%M:%S"`; chomp($date_string); $self->cookie( last_seen_log => $date_string, { path => "/", max_age => 604800 } ); # expires in a week. } else { my $since_string = "> \'" . $cookie . "\'"; $count = $self->db->resultset('Log')->search( { -and => [ { tm_user => { '!=' => $user } }, { last_updated => \$since_string } ] }, )->count(); } my $jdata = { newlogcount => $count }; $self->render( json => $jdata ); } sub createlog { my $self = shift; &log( $self, $self->param('message'), $self->param('level') ); return $self->redirect_to('/misc'); } 1;
smalenfant/traffic_control
traffic_ops/app/lib/UI/ChangeLog.pm
Perl
apache-2.0
2,839
#!/usr/local/bin/perl use strict; use utf8; use DBI; use Data::Dumper; use Getopt::Long; # how to conut DML tables # my ($orahost,$oraport,$orasid,$orauser,$orapass,$checkuser,$in_rollback,$in_xid)=("","1521","","system","","",0,""); my ($startpos,$stoppos,$startdate,$stopdate,$select,$table,$debug); GetOptions('start-position=s'=> \$startpos,'stop-position=s'=> \$stoppos,'start-datetime=s'=> \$startdate,'stop-datetime=s'=> \$stopdate,'select'=>\$select , 'host=s'=> \$orahost,'port=s'=> \$oraport,'sid=s'=> \$orasid,'user=s'=> \$orauser,'password=s'=> \$orapass,'checkuser=s'=> \$checkuser,'table=s'=> \$table,'debug'=>\$debug,'in_rollback'=>\$in_rollback,'xid=s'=> \$in_xid); #check options if(!$orahost || ! $oraport || ! $orasid || ! $orauser || ! $orapass ) { &Help(); exit; } #checklogfiles if($#ARGV+1 == 0) { print "[ERROR]Set logfile\n"; &Help; exit; } #connect oracle my $ORADBH=Ora_connect_db($orahost,$oraport,$orasid,$orauser,$orapass); $table = uc $table if($table); $checkuser= uc $checkuser if($checkuser); Main(); sub Help { print << "EOS" Usage: perl $0 [options] log-files Options: --start-position [SCN] Start reading REDO log at SCN. (START_SCN >= #) --stop-position [SCN] Stop reading REDO log at SCN. (COMMIT_SCN <= #) --start-datetime ['YYYY/MM/DD HH24:MI:SS'] Start reading REDO log at first event having a datetime equal. (START_TIMESTAMP >= 'YYYY/MM/DD HH24:MI:SS') --stop-datetime ['YYYY/MM/DD HH24:MI:SS'] Stop reading REDO log at first event having a datetime equal. (COMMIT_TIMESTAMP <= 'YYYY/MM/DD HH24:MI:SS') --select Show EXPLAIN SELECT STATEMENTS --table [TABLENAME] To extract transactions the table has been used (ex."'USERS_TABLE','TEST_TABLE'") --xid [transaction id] only show XID --in_rollback include rollback.default is to show only commit transacitions. Connect Options: --host hostname --port port --sid sid --user user must be 'system' --pass password --checkuser FORMAT is "'username','username'...." (ex. --checkuser "'ORCL','ORCLUSER'") Detail: Set log-files(archivelog or online redolog) at Current Dir or Fullpath EOS } sub Main { #GET SCN my $SCN; #READ REDO exit if(&Check_REDO()); my $commit= $in_rollback ? "" : " + SYS.DBMS_LOGMNR.COMMITTED_DATA_ONLY" ; #Start Analyze REDO $ORADBH->do("begin SYS.DBMS_LOGMNR.START_LOGMNR( OPTIONS => SYS.DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG + SYS.DBMS_LOGMNR.NO_ROWID_IN_STMT $commit) ; end;"); print "exec SYS.DBMS_LOGMNR.START_LOGMNR( OPTIONS => SYS.DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG + SYS.DBMS_LOGMNR.NO_ROWID_IN_STMT $commit);\n" if($debug); #FORMAT SQL my $addsql; my $chackusers= $checkuser ? " AND USERNAME in ($checkuser) " : ""; $addsql=$addsql." AND START_SCN >= $startpos " if($startpos); $addsql=$addsql." AND COMMIT_SCN <= $stoppos " if($stoppos); $addsql=$addsql." AND START_TIMESTAMP >= TO_DATE('$startdate', 'yyyy/mm/dd hh24:mi:ss') " if($startdate); $addsql=$addsql." AND COMMIT_TIMESTAMP <= TO_DATE('$stopdate', 'yyyy/mm/dd hh24:mi:ss') " if($stopdate); $addsql=$addsql." AND TABLE_NAME in ($table) " if($table); $addsql=$addsql." AND xid='$in_xid' " if($in_xid); my $getsql=qq{ SELECT * FROM ( SELECT SCN, MIN(START_SCN) OVER (PARTITION BY RAWTOHEX(xid)) as START_SCN, MAX(COMMIT_SCN) OVER (PARTITION BY RAWTOHEX(xid)) as COMMIT_SCN, RAWTOHEX(xid) as xid, SEQUENCE#, MIN(START_TIMESTAMP) OVER (PARTITION BY RAWTOHEX(xid)) as START_TIMESTAMP, MAX(COMMIT_TIMESTAMP) OVER (PARTITION BY RAWTOHEX(xid)) as COMMIT_TIMESTAMP, SQL_REDO, OPERATION_CODE, MIN(OPERATION_CODE) OVER (PARTITION BY RAWTOHEX(xid) ) as OPE_CODE_MIN, TABLE_NAME, TIMESTAMP, MAX(SESSION_INFO) OVER (PARTITION BY RAWTOHEX(xid) ) as SESSION_INFO FROM V\$LOGMNR_CONTENTS WHERE (SEG_OWNER <> 'SYS' or SEG_OWNER is null) AND (INFO not like '%INTERNAL%' or INFO is null) AND OPERATION_CODE in (1,2,3,5,6,7,36) $chackusers ) WHERE OPE_CODE_MIN <> 6 AND (OPE_CODE_MIN <> 5 or OPERATION_CODE = 5) $addsql ORDER BY COMMIT_SCN,xid,SEQUENCE#}; $getsql=qq{ SELECT SCN,START_SCN,COMMIT_SCN,xid,SEQUENCE#,START_TIMESTAMP,COMMIT_TIMESTAMP,SQL_REDO,OPERATION_CODE,OPE_CODE_MIN,TABLE_NAME,TIMESTAMP,SESSION_INFO FROM ( SELECT SCN, MAX(SCN) OVER (PARTITION BY RAWTOHEX(xid)) as MAX_SCN, MIN(START_SCN) OVER (PARTITION BY RAWTOHEX(xid)) as START_SCN, MAX(COMMIT_SCN) OVER (PARTITION BY RAWTOHEX(xid)) as COMMIT_SCN, RAWTOHEX(xid) as xid, SEQUENCE#, MIN(START_TIMESTAMP) OVER (PARTITION BY RAWTOHEX(xid)) as START_TIMESTAMP, MAX(COMMIT_TIMESTAMP) OVER (PARTITION BY RAWTOHEX(xid)) as COMMIT_TIMESTAMP, SQL_REDO, OPERATION_CODE, MIN(OPERATION_CODE) OVER (PARTITION BY RAWTOHEX(xid) ) as OPE_CODE_MIN, TABLE_NAME, TIMESTAMP, MAX(SESSION_INFO) OVER (PARTITION BY RAWTOHEX(xid) ) as SESSION_INFO FROM V\$LOGMNR_CONTENTS WHERE (SEG_OWNER <> 'SYS' or SEG_OWNER is null) AND (INFO not like '%INTERNAL%' or INFO is null) AND OPERATION_CODE in (1,2,3,5,6,7,36) $chackusers ) WHERE OPE_CODE_MIN <> 6 AND (OPE_CODE_MIN <> 5 or OPERATION_CODE = 5) $addsql ORDER BY MAX_SCN,xid,SEQUENCE#} if($in_rollback); print "$getsql\n" if($debug); my ($vBaseXid,@vSelectAry); my $sth=$ORADBH->prepare($getsql) or die DBI->errstr; $sth->execute() or die DBI->errstr; while ( my ($vScn,$vStart,$vCommit,$vXid,$vSeq,$vTime,$vCtime,$vSql,$vOpeCode,$vOpemin,$vTname,$vTimestamp,$vSessInfo)= $sth->fetchrow) { #transaction changed if($vBaseXid eq $vXid) { print "$vTimestamp : $vSql\n"; } else { @vSelectAry=PrintSelect(@vSelectAry) if(@vSelectAry && $select); print MakeHeader($vTime,$vCtime,$vStart,$vCommit,$vXid,$vSql,$vTimestamp,$vSessInfo); $vBaseXid=$vXid; } #report select my $vSel=CreateSel($vOpeCode,$vSql) if($select); push(@vSelectAry,$vSel) if($vSel && $select); } @vSelectAry=PrintSelect(@vSelectAry) if(@vSelectAry && $select); } ####MakeHeader sub MakeHeader { my ($vTime,$vCtime,$vStart,$vCommit,$vXid,$vSql,$vTimestamp,$vSessInfo)=(shift,shift,shift,shift,shift,shift,shift,shift); my $header=<<"EOS"; -- START_TIME: $vTime COMMIT_TIME: $vCtime -- START_SCN: $vStart COMMIT_SCN: $vCommit -- TRANSACTION ID: $vXid -- SESSION INFO: $vSessInfo $vTimestamp : $vSql EOS return $header; } ####Print EXPLAIN SELECT sub PrintSelect { my @vArr=@_; my @eArr=(); print "\n-- EXPLAIN SELECT: \n"; foreach my $i(@vArr){print "$i\n";} return @eArr; } ####ReplaceVars sub ReplaceVars { my @vars=@_; my (@vBufs,$vBuf); foreach my $t(@vars) { if($t=~/^['|"].+['|"]$/ || $t=~/^NULL/) { if($vBuf) { push(@vBufs,$vBuf); $vBuf=""; } push(@vBufs,$t); } else { if($t=~/^\s/ || $t=~/^[0-9]/) { $vBuf=$vBuf.",".$t; } else { push(@vBufs,$vBuf) if($vBuf); $vBuf=$t; } } } push(@vBufs,$vBuf) if($vBuf); return (@vBufs); } ####CreateSel sub CreateSel{ my ($vOpe,$vSql)=(shift,shift); my $vNotCreate="-- Can't Create Select Statement"; my $vNotPrint="-- Can't show because of Too Long"; my $allWhere; my $rtn; my $len=3500; if($vOpe == 1 ) #INSERT { if($vSql=~/^insert into (\S+)\(("\S+)\) values \((.+).+;/) { my @cols=split(/,/, $2); my @vars=split(/,/, $3); #replacement @vars2 @vars @vars=ReplaceVars(@vars) if(scalar(@cols) != scalar(@vars)); my ($colsLen,$varsLen)=(scalar(@cols),scalar(@vars)); return $vNotCreate if($colsLen != $varsLen); for(my $i=0;$i < $colsLen;$i++) { my $vWhere = $vars[$i] eq "NULL" ? " $cols[$i] is null " : "$cols[$i] = $vars[$i]"; $allWhere= $i==0 ? "where $vWhere " : $allWhere." and $vWhere "; } $rtn= "-- select count(*) from $1 $allWhere;"; return length($rtn) > $len ? $vNotPrint : $rtn; } } if($vOpe == 2) #DELETE { if($vSql=~/^delete from (\S+) where (.+);/) { $rtn= "-- select count(*) from $1 where $2;"; return length($rtn) > $len ? $vNotPrint : $rtn; } } if($vOpe == 3) #UPDATE { if($vSql=~/^update (\S+) set.+ where (".+);/) { $rtn= "-- select count(*) from $1 where $2;"; return length($rtn) > $len ? $vNotPrint : $rtn; } } return ""; } ####Check_REDO sub Check_REDO{ my $pwd=`pwd`; chomp($pwd); my $new=0; foreach my $log (@ARGV) { $log="$pwd/$log" if($log !~/^\//); my $ops=$new ? "SYS.DBMS_LOGMNR.ADDFILE" : "SYS.DBMS_LOGMNR.NEW"; $ORADBH->do("begin SYS.DBMS_LOGMNR.ADD_LOGFILE( LOGFILENAME => '$log', OPTIONS => $ops); end;") or die DBI->errstr; print "exec SYS.DBMS_LOGMNR.ADD_LOGFILE( LOGFILENAME => '$log', OPTIONS => $ops);\n" if($debug); $new=1; } } ####Ora_connect_db sub Ora_connect_db { my $db = join(';',"dbi:Oracle:host=$_[0]","port=$_[1]","sid=$_[2]"); my $db_uid_passwd = "$_[3]/$_[4]"; my $dbh = DBI->connect($db, $db_uid_passwd, "") or die DBI->errstr; return $dbh; }
kenken0807/Oracle-ArchiveLog-Analyzer
Oracle-ArchiveLog-Analyzer.pl
Perl
mit
9,246
package CGI::Application::NetNewsIface::Cache::DBI; use strict; use warnings; use DBI; =head1 NAME CGI::Application::NetNewsIface::Cache::DBI - an internally used class to form a fast cache of the NNTP data. =head1 SYNOPSIS use CGI::Application::NetNewsIface::Cache::DBI; my $cache = CGI::Application::NetNewsIface::Cache::DBI->new( { 'nntp' => $nntp, 'dsn' => "dbi:SQLite:dbname=foo.sqlite", }, ); =head1 FUNCTIONS =head2 new({ %params }) Constructs a new cache object. Accepts a single argument - a hash ref with named parameters. Required parameters are: =over 4 =item 'nntp' A handle to the Net::NNTP object that will be used for querying the NNTP server. =item 'dsn' The DBI 'dsn' for the DBI initialization. =back =cut sub new { my $class = shift; my $self = {}; bless $self, $class; $self->_initialize(@_); return $self; } sub _initialize { my $self = shift; my $args = shift; $self->{'nntp'} = $args->{'nntp'}; my $dbh = $self->{'dbh'} = DBI->connect($args->{'dsn'}, "", ""); $self->{'sths'}->{'select_group'} = $dbh->prepare_cached( "SELECT idx, last_art FROM groups WHERE name = ?" ); $self->{'sths'}->{'insert_group'} = $dbh->prepare_cached( "INSERT INTO groups (name, idx, last_art) VALUES (?, null, 0)" ); $self->{'sths'}->{'insert_art'} = $dbh->prepare_cached( "INSERT INTO articles (group_idx, article_idx, msg_id, parent, subject, frm, date) VALUES (?, ?, ?, ?, ?, ?, ?)" ); $self->{'sths'}->{'update_last_art'} = $dbh->prepare_cached( "UPDATE groups SET last_art = ? WHERE idx = ?" ); $self->{'sths'}->{'get_index_of_id'} = $dbh->prepare_cached( "SELECT article_idx FROM articles WHERE (group_idx = ?) AND (msg_id = ?)" ); $self->{'sths'}->{'get_parent'} = $dbh->prepare_cached( "SELECT parent FROM articles WHERE (group_idx = ?) AND (article_idx = ?)" ); $self->{'sths'}->{'get_sub_thread'} = $dbh->prepare_cached( "SELECT article_idx, subject, date, frm" . " FROM articles" . " WHERE (group_idx = ?) AND (parent = ?)" . # We're ordering on (group_idx, article_idx) because that's what # the relevant index on the table is wired to. " ORDER BY group_idx, article_idx" ); $self->{'sths'}->{'get_art_info'} = $dbh->prepare_cached( "SELECT subject, date, frm FROM articles WHERE (group_idx = ?) AND (article_idx = ?)" ); return 0; } # This is a non-working workaround for the following DBD-SQLite bug: # http://rt.cpan.org/Public/Bug/Display.html?id=9643 # It can probably be removed afterwards. sub DESTROY { my $self = shift; my @stmts = keys(%{$self->{'sths'}}); foreach my $s (@stmts) { my $sth = delete($self->{'sths'}->{$s}); $sth->finish(); } } =head2 $cache->select( $group ) Selects the newsgroup $group. =cut sub select { my ($self, $group) = @_; $self->{'group'} = $group; return $self->_update_group(); } sub _update_group { my $self = shift; my $group = $self->{'group'}; my $nntp = $self->{'nntp'}; my @info = $nntp->group($group); if (! @info) { die "Unknown group \"$group\"."; } my ($num_articles, $first_article, $last_article) = @info; # TODO: Add a transaction here my $sth = $self->{sths}->{select_group}; $sth->execute($group); my $group_record = $sth->fetchrow_arrayref(); if (!defined($group_record)) { $self->{sths}->{insert_group}->execute($group); $sth = $self->{sths}->{select_group}; $sth->execute($group); $group_record = $sth->fetchrow_arrayref(); } my $last_updated_art; my $group_idx; my $start_art; ($group_idx, $last_updated_art) = @$group_record; $self->{group_idx} = $group_idx; if ($last_updated_art == 0) { $start_art = $first_article; } else { $start_art = $last_updated_art+1; } my $ins_sth = $self->{sths}->{insert_art}; for (my $art_idx=$start_art; $art_idx <= $last_article;$art_idx++) { my $head = $nntp->head($art_idx); if (!defined($head)) { next; } my ($msg_id,$subject, $from, $date); my $parent = 0; foreach my $header (@$head) { chomp($header); if ($header =~ m{^Subject: (.*)}) { $subject = $1; } elsif ($header =~ m{^Message-ID: <(.*?)>$}) { $msg_id = $1; } elsif ($header =~ m{In-reply-to: <(.*?)>$}i) { $parent = $self->get_index_of_id($1); } elsif ($header =~ m{^From: (.*)$}) { $from = $1; } elsif ($header =~ m{^Date: (.*)$}) { $date = $1; } } $ins_sth->execute( $group_idx, $art_idx, $msg_id, $parent, $subject, $from, $date, ); } if ($start_art <= $last_article) { $self->{sths}->{update_last_art} ->execute($last_article, $group_idx); } return 0; } =head2 $cache->get_index_of_id($id) Retrieves the index of the message with the id C<$id>. =cut sub get_index_of_id { my ($self, $msg_id) = @_; my $sth = $self->{sths}->{get_index_of_id}; $sth->execute($self->{'group_idx'}, $msg_id); my $ret = $sth->fetchrow_arrayref(); return (defined($ret) ? $ret->[0] : 0); } sub _get_parent { my ($self, $index) = @_; my $sth = $self->{sths}->{get_parent}; $sth->execute($self->{'group_idx'}, $index); my $ret = $sth->fetchrow_arrayref(); return (defined($ret) ? $ret->[0] : undef); } =head2 ($thread, $coords) = $cache->get_thread($index); Gets the thread for the message indexed C<$index>. Thread is: C<$thread> looks like this: { 'idx' => $index, 'subject' => "Problem with Test::More", 'date' => $date, 'from' => "Shlomi Fish <shlomif@iglu.org.il>", 'subs' => [ { 'idx' => $index, . 'subs' => [ . . . ], } . . . ], } C<$coords> is the coordinates leading to the current article within the thread. To access the current article from the coords use: $thread->{'subs'}->[$coords[0]]->{'subs'}->[$coords[1]]->... =cut sub get_thread { my ($self, $index) = @_; # Get the first ancestor of the thread. my $thread_head; { my ($parent, $grandparent); $parent = $index; while (($grandparent = $self->_get_parent($parent)) != 0) { $parent = $grandparent; } $thread_head = $parent; } # Make sure we retrieve information for the top-most node. my $sth = $self->{sths}->{get_art_info}; $sth->execute($self->{group_idx}, $thread_head); my $info = $sth->fetchrow_arrayref(); my $thread_struct = { 'idx' => $thread_head, 'subject' => $info->[0], 'date' => $info->[1], 'from' => $info->[2], }; my $coords; $self->_get_sub_thread($thread_struct, $index, \$coords, []); return ($thread_struct, $coords); } sub _get_sub_thread { my ($self, $struct_ptr, $requested, $coords_ptr, $coords) = @_; my $index = $struct_ptr->{idx}; if ($index == $requested) { $$coords_ptr = $coords; } my $sth = $self->{sths}->{get_sub_thread}; $sth->execute($self->{group_idx}, $index); my @subs; while (my $row = $sth->fetchrow_arrayref()) { push @subs, { 'idx' => $row->[0], 'subject' => $row->[1], 'date' => $row->[2], 'from' => $row->[3], }; } if (@subs) { $struct_ptr->{subs} = \@subs; foreach my $child_idx (0 .. $#subs) { $self->_get_sub_thread( $subs[$child_idx], $requested, $coords_ptr, [@$coords, $child_idx], ); } } } =head1 AUTHOR Shlomi Fish, C<< <shlomif@iglu.org.il> >> =head1 BUGS Please report any bugs or feature requests to C<bug-cgi-application-netnewsiface@rt.cpan.org>, or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CGI-Application-NetNewsIface>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. =head1 ACKNOWLEDGEMENTS =head1 COPYRIGHT & LICENSE Copyright 2006 Shlomi Fish, all rights reserved. This program is released under the following license: MIT X11. =cut 1;
gitpan/CGI-Application-NetNewsIface
lib/CGI/Application/NetNewsIface/Cache/DBI.pm
Perl
mit
9,073
package # Date::Manip::TZ::amsant01; # 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:33:47 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 (%Dates,%LastRule); END { undef %Dates; undef %LastRule; } our ($VERSION); $VERSION='6.52'; END { undef $VERSION; } %Dates = ( 1 => [ [ [1,1,2,0,0,0],[1,1,1,20,21,12],'-03:38:48',[-3,-38,-48], 'LMT',0,[1914,1,1,3,38,47],[1913,12,31,23,59,59], '0001010200:00:00','0001010120:21:12','1914010103:38:47','1913123123:59:59' ], ], 1914 => [ [ [1914,1,1,3,38,48],[1913,12,31,23,38,48],'-04:00:00',[-4,0,0], 'AMT',0,[1931,10,3,14,59,59],[1931,10,3,10,59,59], '1914010103:38:48','1913123123:38:48','1931100314:59:59','1931100310:59:59' ], ], 1931 => [ [ [1931,10,3,15,0,0],[1931,10,3,12,0,0],'-03:00:00',[-3,0,0], 'AMST',1,[1932,4,1,2,59,59],[1932,3,31,23,59,59], '1931100315:00:00','1931100312:00:00','1932040102:59:59','1932033123:59:59' ], ], 1932 => [ [ [1932,4,1,3,0,0],[1932,3,31,23,0,0],'-04:00:00',[-4,0,0], 'AMT',0,[1932,10,3,3,59,59],[1932,10,2,23,59,59], '1932040103:00:00','1932033123:00:00','1932100303:59:59','1932100223:59:59' ], [ [1932,10,3,4,0,0],[1932,10,3,1,0,0],'-03:00:00',[-3,0,0], 'AMST',1,[1933,4,1,2,59,59],[1933,3,31,23,59,59], '1932100304:00:00','1932100301:00:00','1933040102:59:59','1933033123:59:59' ], ], 1933 => [ [ [1933,4,1,3,0,0],[1933,3,31,23,0,0],'-04:00:00',[-4,0,0], 'AMT',0,[1949,12,1,3,59,59],[1949,11,30,23,59,59], '1933040103:00:00','1933033123:00:00','1949120103:59:59','1949113023:59:59' ], ], 1949 => [ [ [1949,12,1,4,0,0],[1949,12,1,1,0,0],'-03:00:00',[-3,0,0], 'AMST',1,[1950,4,16,3,59,59],[1950,4,16,0,59,59], '1949120104:00:00','1949120101:00:00','1950041603:59:59','1950041600:59:59' ], ], 1950 => [ [ [1950,4,16,4,0,0],[1950,4,16,0,0,0],'-04:00:00',[-4,0,0], 'AMT',0,[1950,12,1,3,59,59],[1950,11,30,23,59,59], '1950041604:00:00','1950041600:00:00','1950120103:59:59','1950113023:59:59' ], [ [1950,12,1,4,0,0],[1950,12,1,1,0,0],'-03:00:00',[-3,0,0], 'AMST',1,[1951,4,1,2,59,59],[1951,3,31,23,59,59], '1950120104:00:00','1950120101:00:00','1951040102:59:59','1951033123:59:59' ], ], 1951 => [ [ [1951,4,1,3,0,0],[1951,3,31,23,0,0],'-04:00:00',[-4,0,0], 'AMT',0,[1951,12,1,3,59,59],[1951,11,30,23,59,59], '1951040103:00:00','1951033123:00:00','1951120103:59:59','1951113023:59:59' ], [ [1951,12,1,4,0,0],[1951,12,1,1,0,0],'-03:00:00',[-3,0,0], 'AMST',1,[1952,4,1,2,59,59],[1952,3,31,23,59,59], '1951120104:00:00','1951120101:00:00','1952040102:59:59','1952033123:59:59' ], ], 1952 => [ [ [1952,4,1,3,0,0],[1952,3,31,23,0,0],'-04:00:00',[-4,0,0], 'AMT',0,[1952,12,1,3,59,59],[1952,11,30,23,59,59], '1952040103:00:00','1952033123:00:00','1952120103:59:59','1952113023:59:59' ], [ [1952,12,1,4,0,0],[1952,12,1,1,0,0],'-03:00:00',[-3,0,0], 'AMST',1,[1953,3,1,2,59,59],[1953,2,28,23,59,59], '1952120104:00:00','1952120101:00:00','1953030102:59:59','1953022823:59:59' ], ], 1953 => [ [ [1953,3,1,3,0,0],[1953,2,28,23,0,0],'-04:00:00',[-4,0,0], 'AMT',0,[1963,12,9,3,59,59],[1963,12,8,23,59,59], '1953030103:00:00','1953022823:00:00','1963120903:59:59','1963120823:59:59' ], ], 1963 => [ [ [1963,12,9,4,0,0],[1963,12,9,1,0,0],'-03:00:00',[-3,0,0], 'AMST',1,[1964,3,1,2,59,59],[1964,2,29,23,59,59], '1963120904:00:00','1963120901:00:00','1964030102:59:59','1964022923:59:59' ], ], 1964 => [ [ [1964,3,1,3,0,0],[1964,2,29,23,0,0],'-04:00:00',[-4,0,0], 'AMT',0,[1965,1,31,3,59,59],[1965,1,30,23,59,59], '1964030103:00:00','1964022923:00:00','1965013103:59:59','1965013023:59:59' ], ], 1965 => [ [ [1965,1,31,4,0,0],[1965,1,31,1,0,0],'-03:00:00',[-3,0,0], 'AMST',1,[1965,3,31,2,59,59],[1965,3,30,23,59,59], '1965013104:00:00','1965013101:00:00','1965033102:59:59','1965033023:59:59' ], [ [1965,3,31,3,0,0],[1965,3,30,23,0,0],'-04:00:00',[-4,0,0], 'AMT',0,[1965,12,1,3,59,59],[1965,11,30,23,59,59], '1965033103:00:00','1965033023:00:00','1965120103:59:59','1965113023:59:59' ], [ [1965,12,1,4,0,0],[1965,12,1,1,0,0],'-03:00:00',[-3,0,0], 'AMST',1,[1966,3,1,2,59,59],[1966,2,28,23,59,59], '1965120104:00:00','1965120101:00:00','1966030102:59:59','1966022823:59:59' ], ], 1966 => [ [ [1966,3,1,3,0,0],[1966,2,28,23,0,0],'-04:00:00',[-4,0,0], 'AMT',0,[1966,11,1,3,59,59],[1966,10,31,23,59,59], '1966030103:00:00','1966022823:00:00','1966110103:59:59','1966103123:59:59' ], [ [1966,11,1,4,0,0],[1966,11,1,1,0,0],'-03:00:00',[-3,0,0], 'AMST',1,[1967,3,1,2,59,59],[1967,2,28,23,59,59], '1966110104:00:00','1966110101:00:00','1967030102:59:59','1967022823:59:59' ], ], 1967 => [ [ [1967,3,1,3,0,0],[1967,2,28,23,0,0],'-04:00:00',[-4,0,0], 'AMT',0,[1967,11,1,3,59,59],[1967,10,31,23,59,59], '1967030103:00:00','1967022823:00:00','1967110103:59:59','1967103123:59:59' ], [ [1967,11,1,4,0,0],[1967,11,1,1,0,0],'-03:00:00',[-3,0,0], 'AMST',1,[1968,3,1,2,59,59],[1968,2,29,23,59,59], '1967110104:00:00','1967110101:00:00','1968030102:59:59','1968022923:59:59' ], ], 1968 => [ [ [1968,3,1,3,0,0],[1968,2,29,23,0,0],'-04:00:00',[-4,0,0], 'AMT',0,[1985,11,2,3,59,59],[1985,11,1,23,59,59], '1968030103:00:00','1968022923:00:00','1985110203:59:59','1985110123:59:59' ], ], 1985 => [ [ [1985,11,2,4,0,0],[1985,11,2,1,0,0],'-03:00:00',[-3,0,0], 'AMST',1,[1986,3,15,2,59,59],[1986,3,14,23,59,59], '1985110204:00:00','1985110201:00:00','1986031502:59:59','1986031423:59:59' ], ], 1986 => [ [ [1986,3,15,3,0,0],[1986,3,14,23,0,0],'-04:00:00',[-4,0,0], 'AMT',0,[1986,10,25,3,59,59],[1986,10,24,23,59,59], '1986031503:00:00','1986031423:00:00','1986102503:59:59','1986102423:59:59' ], [ [1986,10,25,4,0,0],[1986,10,25,1,0,0],'-03:00:00',[-3,0,0], 'AMST',1,[1987,2,14,2,59,59],[1987,2,13,23,59,59], '1986102504:00:00','1986102501:00:00','1987021402:59:59','1987021323:59:59' ], ], 1987 => [ [ [1987,2,14,3,0,0],[1987,2,13,23,0,0],'-04:00:00',[-4,0,0], 'AMT',0,[1987,10,25,3,59,59],[1987,10,24,23,59,59], '1987021403:00:00','1987021323:00:00','1987102503:59:59','1987102423:59:59' ], [ [1987,10,25,4,0,0],[1987,10,25,1,0,0],'-03:00:00',[-3,0,0], 'AMST',1,[1988,2,7,2,59,59],[1988,2,6,23,59,59], '1987102504:00:00','1987102501:00:00','1988020702:59:59','1988020623:59:59' ], ], 1988 => [ [ [1988,2,7,3,0,0],[1988,2,6,23,0,0],'-04:00:00',[-4,0,0], 'AMT',0,[2008,6,24,3,59,59],[2008,6,23,23,59,59], '1988020703:00:00','1988020623:00:00','2008062403:59:59','2008062323:59:59' ], ], 2008 => [ [ [2008,6,24,4,0,0],[2008,6,24,1,0,0],'-03:00:00',[-3,0,0], 'BRT',0,[9999,12,31,0,0,0],[9999,12,30,21,0,0], '2008062404:00:00','2008062401:00:00','9999123100:00:00','9999123021:00:00' ], ], ); %LastRule = ( ); 1;
jkb78/extrajnm
local/lib/perl5/Date/Manip/TZ/amsant01.pm
Perl
mit
8,099
#!/usr/local/bin/perl #------------------------------------- # Edit Scratchpad, # (C)1997-2000, 1998 Harvard University # # W. S. Lane/M. Baker # # v3.1a # # licensed to Finnigan #------------------------------------- # a simple editor for known_ions.txt that simply uses a <TEXTAREA> to hold and # edit the file ################################################ # find and read in standard include file { my $path = $0; $path =~ s!\\!/!g; $path =~ s!^(.*)/[^/]+/.*$!$1/etc!; unshift (@INC, "$path"); require "microchem_include.pl"; } ################################################ &cgi_receive; $file = "$incdir/scratchpad.txt"; $link = "$webincdir/scratchpad.txt"; $input = $FORM{"input"}; if (!defined $input) { &MS_pages_header ("Scratch Pad", "#9F9F5F"); &output_form(); exit; } # Otherwise, we are receiving the edited page # convert the ^M^J line separators to Unix style ^J $input =~ s!\015\012!\012!g; # make sure input ends with a carriage return chomp $input; $input .= "\n"; #$command = "cat $file > $file" . ".previous"; #qx{ $command }; # let's use Perl code instead: copy("$file","$file.previous"); &MS_pages_header ("Scratch Pad", "#9F9F5F"); print "<P><HR><P>\n"; open (KNOWN_IONS, ">$file") || (print ("<h3>ERROR: Unable to save.</h3>") && exit); print KNOWN_IONS $input; close KNOWN_IONS; print <<EOM; <div> <h5>File has been saved.</h5> You can <a href="$link">check the saved file</a> or <a href="$HOMEPAGE">return home</a>. <h5>Output was:</h5> </div> <pre> EOM # clean up for HTML: $input =~ s/&/&amp;/g; $input =~ s/>/&gt;/g; $input =~ s/</&lt;/g; $input =~ s/\"/&quot;/; print $input; print ("</pre>\n"); exit; # this is the first page. # we receive from FuzzyIons the info of the DTA used, # the "pretty sequence" and the sequence in fuzzy form sub output_form { my @input, $input; open (FILE, "$file") || print ("unable to open $file.\n");; @input = <FILE>; close FILE; my $dta = $FORM{"Dta"} || $FORM{"dtafile"}; my $prettyseq = $FORM{"PrettySeq"}; my $pep = $FORM{"Pep"} || $FORM{"pep"}; # separate by either backslash or forward slash my @temp = split (m![/\\]!, $dta); $dta = pop @temp; my $dir = pop @temp; my $fancyname; $fancyname = &get_fancyname ($dir); my $date = &get_regular_date(); $input = join ("", @input); # clean up for HTML: $input =~ s/&/&amp;/g; $input =~ s/>/&gt;/g; $input =~ s/</&lt;/g; $input =~ s/\"/&quot;/; print <<EOF; <div> <FORM ACTION="$ourname" METHOD=POST> <tt><TEXTAREA ROWS=28 COLS=100 WRAP=VIRTUAL NAME="input">$input</TEXTAREA></tt> EOF if ($dir ne "") { print <<EOF; <br> <tt><span style="color:red">$fancyname<br> &nbsp;$dta $pep ($date xxx )</span></tt><br> EOF } print <<EOF; <br> <b>File:</b> <a href="$link">$file</a> &nbsp;&nbsp;&nbsp;&nbsp; <INPUT TYPE=RESET CLASS=button VALUE="Revert"> &nbsp;&nbsp;&nbsp;&nbsp; <INPUT TYPE=SUBMIT CLASS=button VALUE="Save"> </FORM> </div> EOF }
wangchulab/CIMAGE
cravatt_web/cgi-bin/flicka/edit_scratchpad.pl
Perl
mit
2,961
%query: append3(o,o,o,i). % mode: append[i,i,o] append([],L,L). append([H|L1],L2,[H|L3]) :- append(L1,L2,L3). % mode: append3[i,i,i,o] append3(A,B,C,D) :- append(A,B,E), append(E,C,D).
ComputationWithBoundedResources/ara-inference
doc/tpdb_trs/Logic_Programming/talp_plumer/pl4.0.1-oooi.pl
Perl
mit
187
#!/usr/bin/perl use 5.010; use strict; use warnings; use Scalar::Util qw(looks_like_number); sub printlist { my $i = 1; print "\n( "; foreach my $element (@_) { if( $i <= scalar @_) { print "$element "; } $i++; } print ")\n"; } sub printlist2 { my $i=1; print "\n( "; foreach my $element (@_) { if( $i <= scalar @_) { print "${element}% "; } $i++; } print ")\n"; } sub result { my $sum = 0; foreach my $element (@_) { $sum += $element; } my @procent; my $pSumm = 0; foreach my $element (@_) { my $ptmp = sprintf("%.1f",($element/$sum)*100); push ( @procent, $ptmp ); $pSumm += $ptmp; } if($pSumm == "100") { printlist2(@procent); } else{ $procent[-1]+=(100-$pSumm); printlist2(@procent); } } sub main { print "Введите числа для задачи \"100%\"\n(для завершения ввода введите end): "; my $tmp; my @list; my $x = 1; while( $x ) { chomp( $tmp = <STDIN>); if( looks_like_number($tmp) ) { push ( @list, $tmp ); } elsif( $tmp eq "end" ) { $x=0; } } print "Mасcив: "; printlist(@list); result(@list); print "\n"; } main(); __END__
dimir2/hse12pi2-scripts
KolchinE/Perl/Hw3.pl
Perl
mit
1,122
############################################################################## # $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/distributions/Perl-Critic/lib/Perl/Critic/Exception/Configuration/Option/Global/ParameterValue.pm $ # $Date: 2012-07-02 22:16:39 -0700 (Mon, 02 Jul 2012) $ # $Author: thaljef $ # $Revision: 4126 $ ############################################################################## package Perl::Critic::Exception::Configuration::Option::Global::ParameterValue; use 5.006001; use strict; use warnings; use Readonly; use Perl::Critic::Utils qw{ :characters }; our $VERSION = '1.118'; #----------------------------------------------------------------------------- use Exception::Class ( 'Perl::Critic::Exception::Configuration::Option::Global::ParameterValue' => { isa => 'Perl::Critic::Exception::Configuration::Option::Global', description => 'A problem with the value of a global parameter.', alias => 'throw_global_value', }, ); #----------------------------------------------------------------------------- Readonly::Array our @EXPORT_OK => qw< throw_global_value >; #----------------------------------------------------------------------------- sub full_message { my ( $self ) = @_; my $source = $self->source(); if ($source) { $source = qq{ found in "$source"}; } else { $source = $EMPTY; } my $option_name = $self->option_name(); my $option_value = defined $self->option_value() ? $DQUOTE . $self->option_value() . $DQUOTE : '<undef>'; my $message_suffix = $self->message_suffix() || $EMPTY; return qq{The value for the global "$option_name" option } . qq{($option_value)$source $message_suffix}; } 1; __END__ #----------------------------------------------------------------------------- =pod =for stopwords =head1 NAME Perl::Critic::Exception::Configuration::Option::Global::ParameterValue - A problem with the value of a global parameter. =head1 DESCRIPTION A representation of a problem found with the value of a global parameter, whether from a F<.perlcriticrc>, another profile file, or command line. =head1 INTERFACE SUPPORT This is considered to be a public class. Any changes to its interface will go through a deprecation cycle. =head1 CLASS METHODS =over =item C<< throw( option_name => $option_name, option_value => $option_value, source => $source, message_suffix => $message_suffix ) >> See L<Exception::Class/"throw">. =item C<< new( option_name => $option_name, option_value => $option_value, source => $source, message_suffix => $message_suffix ) >> See L<Exception::Class/"new">. =back =head1 METHODS =over =item C<full_message()> Provide a standard message for global configuration problems. See L<Exception::Class/"full_message">. =back =head1 AUTHOR Elliot Shank <perl@galumph.com> =head1 COPYRIGHT Copyright (c) 2007-2011 Elliot Shank. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license can be found in the LICENSE file included with this module. =cut # Local Variables: # mode: cperl # cperl-indent-level: 4 # fill-column: 78 # indent-tabs-mode: nil # c-indentation-style: bsd # End: # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :
amidoimidazol/bio_info
Beginning Perl for Bioinformatics/lib/Perl/Critic/Exception/Configuration/Option/Global/ParameterValue.pm
Perl
mit
3,427
package Spreadsheet::Template::Writer; BEGIN { $Spreadsheet::Template::Writer::AUTHORITY = 'cpan:DOY'; } $Spreadsheet::Template::Writer::VERSION = '0.04'; use Moose::Role; # ABSTRACT: role for classes which write spreadsheet files from a template requires 'write'; no Moose::Role; 1; __END__ =pod =encoding UTF-8 =head1 NAME Spreadsheet::Template::Writer - role for classes which write spreadsheet files from a template =head1 VERSION version 0.04 =head1 SYNOPSIS package MyWriter; use Moose; with 'Spreadsheet::Template::Writer'; sub write { # ... } =head1 DESCRIPTION This role should be consumed by any class which will be used as the C<writer_class> in a L<Spreadsheet::Template> instance. =head1 METHODS =head2 write($data) This method is required to be implemented by any classes which consume this role. It should use the data in C<$data> (in the format described in L<Spreadsheet::Template>) to create a new spreadsheet file containing that data. It should return a string containing the binary contents of the spreadsheet file. =head1 AUTHOR Jesse Luehrs <doy@tozt.net> =head1 COPYRIGHT AND LICENSE This software is Copyright (c) 2014 by Jesse Luehrs. This is free software, licensed under: The MIT (X11) License =cut
gitpan/Spreadsheet-Template
lib/Spreadsheet/Template/Writer.pm
Perl
mit
1,275
use strict; use Data::Dumper; use Carp; # # This is a SAS Component # =head1 NAME all_entities_Regulog =head1 SYNOPSIS all_entities_Regulog [-a] [--fields fieldlist] > entity-data =head1 DESCRIPTION Return all instances of the Regulog entity. Example: all_entities_Regulog -a would retrieve all entities of type Regulog and include all fields in the entities in the output. =head2 Related entities The Regulog entity has the following relationship links: =over 4 =item HasRegulator Regulator =item IsInCollection RegulogCollection =item RegulogHasRegulon Regulon =back =head1 COMMAND-LINE OPTIONS Usage: all_entities_Regulog [arguments] > entity.data --fields list Choose a set of fields to return. List is a comma-separated list of strings. -a Return all available fields. --show-fields List the available fields. The following fields are available: =over 4 =item description =back =head1 AUTHORS L<The SEED Project|http://www.theseed.org> =cut use Bio::KBase::CDMI::CDMIClient; use Getopt::Long; #Default fields my @all_fields = ( 'description' ); my %all_fields = map { $_ => 1 } @all_fields; our $usage = <<'END'; Usage: all_entities_Regulog [arguments] > entity.data --fields list Choose a set of fields to return. List is a comma-separated list of strings. -a Return all available fields. --show-fields List the available fields. The following fields are available: description END my $a; my $f; my @fields; my $show_fields; my $help; my $geO = Bio::KBase::CDMI::CDMIClient->new_get_entity_for_script("a" => \$a, "show-fields" => \$show_fields, "h" => \$help, "fields=s" => \$f); if ($help) { print $usage; exit 0; } if ($show_fields) { print "Available fields:\n"; print "\t$_\n" foreach @all_fields; exit 0; } if (@ARGV != 0 || ($a && $f)) { print STDERR $usage, "\n"; exit 1; } if ($a) { @fields = @all_fields; } elsif ($f) { my @err; for my $field (split(",", $f)) { if (!$all_fields{$field}) { push(@err, $field); } else { push(@fields, $field); } } if (@err) { print STDERR "all_entities_Regulog: unknown fields @err. Valid fields are: @all_fields\n"; exit 1; } } my $start = 0; my $count = 1_000_000; my $h = $geO->all_entities_Regulog($start, $count, \@fields ); while (%$h) { while (my($k, $v) = each %$h) { print join("\t", $k, map { ref($_) eq 'ARRAY' ? join(",", @$_) : $_ } @$v{@fields}), "\n"; } $start += $count; $h = $geO->all_entities_Regulog($start, $count, \@fields); }
kbase/kb_seed
scripts/all_entities_Regulog.pl
Perl
mit
2,649
# 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/africa. Olson data version 2008c # # Do not edit this file directly. # package DateTime::TimeZone::Africa::Freetown; use strict; use Class::Singleton; use DateTime::TimeZone; use DateTime::TimeZone::OlsonDB; @DateTime::TimeZone::Africa::Freetown::ISA = ( 'Class::Singleton', 'DateTime::TimeZone' ); my $spans = [ [ DateTime::TimeZone::NEG_INFINITY, 59358703980, DateTime::TimeZone::NEG_INFINITY, 59358700800, -3180, 0, 'LMT' ], [ 59358703980, 60349971180, 59358700800, 60349968000, -3180, 0, 'FMT' ], [ 60349971180, 61044195600, 60349967580, 61044192000, -3600, 0, '' ], [ 61044195600, 61054734000, 61044194400, 61054732800, -1200, 1, 'SLST' ], [ 61054734000, 61075818000, 61054730400, 61075814400, -3600, 0, 'WAT' ], [ 61075818000, 61086356400, 61075816800, 61086355200, -1200, 1, 'SLST' ], [ 61086356400, 61107354000, 61086352800, 61107350400, -3600, 0, 'WAT' ], [ 61107354000, 61117892400, 61107352800, 61117891200, -1200, 1, 'SLST' ], [ 61117892400, 61138890000, 61117888800, 61138886400, -3600, 0, 'WAT' ], [ 61138890000, 61149428400, 61138888800, 61149427200, -1200, 1, 'SLST' ], [ 61149428400, 61170426000, 61149424800, 61170422400, -3600, 0, 'WAT' ], [ 61170426000, 61180964400, 61170424800, 61180963200, -1200, 1, 'SLST' ], [ 61180964400, 61202048400, 61180960800, 61202044800, -3600, 0, 'WAT' ], [ 61202048400, 61212586800, 61202047200, 61212585600, -1200, 1, 'SLST' ], [ 61212586800, 61233584400, 61212583200, 61233580800, -3600, 0, 'WAT' ], [ 61233584400, 61244122800, 61233583200, 61244121600, -1200, 1, 'SLST' ], [ 61244122800, 61265120400, 61244119200, 61265116800, -3600, 0, 'WAT' ], [ 61265120400, 61275658800, 61265119200, 61275657600, -1200, 1, 'SLST' ], [ 61275658800, 61725459600, 61275655200, 61725456000, -3600, 0, 'WAT' ], [ 61725459600, 61738502400, 61725459600, 61738502400, 0, 0, 'WAT' ], [ 61738502400, 61746447600, 61738506000, 61746451200, 3600, 1, 'SLST' ], [ 61746447600, 61770038400, 61746447600, 61770038400, 0, 0, 'GMT' ], [ 61770038400, 61777983600, 61770042000, 61777987200, 3600, 1, 'SLST' ], [ 61777983600, 61801574400, 61777983600, 61801574400, 0, 0, 'GMT' ], [ 61801574400, 61809519600, 61801578000, 61809523200, 3600, 1, 'SLST' ], [ 61809519600, 61833196800, 61809519600, 61833196800, 0, 0, 'GMT' ], [ 61833196800, 61841142000, 61833200400, 61841145600, 3600, 1, 'SLST' ], [ 61841142000, 61864732800, 61841142000, 61864732800, 0, 0, 'GMT' ], [ 61864732800, 61872678000, 61864736400, 61872681600, 3600, 1, 'SLST' ], [ 61872678000, 61896268800, 61872678000, 61896268800, 0, 0, 'GMT' ], [ 61896268800, 61904214000, 61896272400, 61904217600, 3600, 1, 'SLST' ], [ 61904214000, DateTime::TimeZone::INFINITY, 61904214000, DateTime::TimeZone::INFINITY, 0, 0, 'GMT' ], ]; sub olson_version { '2008c' } sub has_dst_changes { 14 } sub _max_year { 2018 } sub _new_instance { return shift->_init( @_, spans => $spans ); } 1;
carlgao/lenga
images/lenny64-peon/usr/share/perl5/DateTime/TimeZone/Africa/Freetown.pm
Perl
mit
3,352
use 5.12.0; # • 科技新聞通訊社-林鴻仁's avatar image.科技新聞通訊社-林鴻仁 asked Audrey Tang: ## Audrey Tang's avatar image.Audrey Tang•Jan 26Taiwan’s Digital Minister # • Anonymous asked Audrey Tang: ## Anonymous profile image ## Anonymous•Dec 27 use utf8; my ($id, $title, $user, $body, @replies); my ($r_user, $r_body, $r_date); my @parsed; open my $fh, '<:utf8', "wiselike-2017-01-30-backup.txt"; while (<$fh>) { if (/• (.+) asked Audrey Tang:/) { if ($r_user) { push @replies, { user => $r_user, date => $r_date, body => $r_body }; } if (@replies) { push @parsed, { id => $id, title => $title, user => $user, replies => [@replies] }; @replies = (); } $id = $title = $user = $body = $r_user = $r_body = $r_date = ''; $user = $1; $user =~ s/.*avatar image.//; chomp($title = <$fh>) until $title; $title =~ s/^\s*//; } elsif (/(.+?)•([A-Za-z]+?\s\d+)/) { if ($r_user) { push @replies, { user => $r_user, date => $r_date, body => $r_body }; } $r_user = $1; $r_date = $2; $r_body = ''; $r_user =~ s/.*avatar image\.|^\s*//; $r_date =~ s/Jan\s(\d+)/Jan $1 2017/; $r_date =~ s/([A-Za-z]+?\s\d+)$/$1 2016/; } elsif (m{\[http://wslk.io/(.+)\]}) { $id = $1; } elsif (m!Appreciated? \(\d+|'s avatar image|\[\s{10}\s*\]|•Edit|Anonymous profile image|Appreciate•!) { next; } elsif ($r_user) { s/^\s*//; $r_body .= $_; } else { s/^\s*//; $body .= $_; } } if ($r_user) { push @replies, { user => $r_user, date => $r_date, body => $r_body }; } if (@replies) { push @parsed, { id => $id, title => $title, user => $user, replies => \@replies }; } use JSON; print encode_json(\@parsed); __DATA__ # "id", "title", "user", "body", "replies": [ "user", "body", "date" ]
audreyt/archive.tw
parse-wiselike.pl
Perl
cc0-1.0
1,944
# # Copyright 2009-2013 MongoDB, Inc. # # 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 MongoDB::Cursor; # ABSTRACT: A cursor/iterator for Mongo query results use version; our $VERSION = 'v0.704.1.1'; use Moose; use MongoDB; use MongoDB::Error; use boolean; use Tie::IxHash; use namespace::clean -except => 'meta'; =head1 NAME MongoDB::Cursor - A cursor/iterator for Mongo query results =head1 SYNOPSIS while (my $object = $cursor->next) { ... } my @objects = $cursor->all; =head2 Multithreading Cursors are cloned in threads, but not reset. Iterating the same cursor from multiple threads will give unpredictable results. Only iterate from a single thread. =head1 SEE ALSO Core documentation on cursors: L<http://dochub.mongodb.org/core/cursors>. =cut $MongoDB::Cursor::_request_id = int(rand(1000000)); =head1 STATIC ATTRIBUTES =head2 slave_okay $MongoDB::Cursor::slave_okay = 1; Whether it is okay to run queries on the slave. Defaults to 0. =cut $MongoDB::Cursor::slave_okay = 0; =head2 timeout B<Deprecated, use MongoDB::Connection::query_timeout instead.> How many milliseconds to wait for a response from the server. Set to 30000 (30 seconds) by default. -1 waits forever (or until TCP times out, which is usually a long time). This value is overridden by C<MongoDB::Connection::query_timeout> and never used. =cut $MongoDB::Cursor::timeout = 30000; =head1 ATTRIBUTES =head2 started_iterating If this cursor has queried the database yet. Methods modifying the query will complain if they are called after the database is queried. =cut has started_iterating => ( is => 'rw', isa => 'Bool', required => 1, default => 0, ); has _master => ( is => 'ro', isa => 'MongoDB::MongoClient', required => 1, ); has _client => ( is => 'rw', isa => 'MongoDB::MongoClient', required => 1, ); has _ns => ( is => 'ro', isa => 'Str', required => 1, ); has _query => ( is => 'rw', isa => 'Tie::IxHash', required => 1, ); has _fields => ( is => 'rw', required => 0, ); has _limit => ( is => 'rw', isa => 'Int', required => 0, default => 0, ); # XXX this is here for testing; we can rationalize this later # with _aggregate_batch_size when we convert to pure Perl has _batch_size => ( is => 'rw', isa => 'Int', required => 0, default => 0, ); has _skip => ( is => 'rw', isa => 'Int', required => 0, default => 0, ); has _tailable => ( is => 'rw', isa => 'Bool', required => 0, default => 0, ); =head2 immortal $cursor->immortal(1); Ordinarily, a cursor "dies" on the database server after a certain length of time (approximately 10 minutes), to prevent inactive cursors from hogging resources. This option sets that a cursor should not die until all of its results have been fetched or it goes out of scope in Perl. Boolean value, defaults to 0. C<immortal> is not equivalent to setting a client-side timeout. If you are getting client-side timeouts (e.g., "recv timed out"), set C<query_timeout> on your connection. # wait forever for a query to return results $connection->query_timeout(-1); See L<MongoDB::Connection/query_timeout>. =cut has immortal => ( is => 'rw', isa => 'Bool', required => 0, default => 0, ); =head2 partial If a shard is down, mongos will return an error when it tries to query that shard. If this is set, mongos will just skip that shard, instead. Boolean value, defaults to 0. =cut has partial => ( is => 'rw', isa => 'Bool', required => 0, default => 0, ); =head2 slave_okay $cursor->slave_okay(1); If a query can be done on a slave database server. Boolean value, defaults to 0. =cut has slave_okay => ( is => 'rw', isa => 'Bool', required => 0, default => 0, ); has _request_id => ( is => 'rw', isa => 'Int', default => 0, ); # special attributes for aggregation cursors has _agg_first_batch => ( is => 'ro', isa => 'Maybe[ArrayRef]', ); has _agg_batch_size => ( is => 'rw', isa => 'Int', default => 0, ); # special flag for parallel scan cursors, since they # start out empty has _is_parallel => ( is => 'ro', isa => 'Bool', default => 0, ); =head1 METHODS =cut sub _ensure_nested { my ($self) = @_; if ( ! $self->_query->EXISTS('$query') ) { $self->_query( Tie::IxHash->new('$query' => $self->_query) ); } return; } # this does the query if it hasn't been done yet sub _do_query { my ($self) = @_; $self->_master->rs_refresh(); # in case the refresh caused a repin $self->_client(MongoDB::Collection::_select_cursor_client($self->_master, $self->_ns, $self->_query)); if ($self->started_iterating) { return; } my $opts = ($self->_tailable() << 1) | (($MongoDB::Cursor::slave_okay | $self->slave_okay) << 2) | ($self->immortal << 4) | ($self->partial << 7); my ($query, $info) = MongoDB::write_query($self->_ns, $opts, $self->_skip, $self->_limit || $self->_batch_size, $self->_query, $self->_fields); $self->_request_id($info->{'request_id'}); if ( length($query) > $self->_client->_max_bson_wire_size ) { MongoDB::_CommandSizeError->throw( message => "database command too large", size => length $query, ); } eval { $self->_client->send($query); $self->_client->recv($self); }; if ($@ && $self->_master->_readpref_pinned) { $self->_master->repin(); $self->_client($self->_master->_readpref_pinned); $self->_client->send($query); $self->_client->recv($self); } elsif ($@) { # rethrow the exception if read preference # has not been set die $@; } $self->started_iterating(1); } =head2 fields (\%f) $coll->insert({name => "Fred", age => 20}); my $cursor = $coll->query->fields({ name => 1 }); my $obj = $cursor->next; $obj->{name}; "Fred" $obj->{age}; # undef Selects which fields are returned. The default is all fields. _id is always returned. =cut sub fields { my ($self, $f) = @_; confess "cannot set fields after querying" if $self->started_iterating; confess 'not a hash reference' unless ref $f eq 'HASH' || ref $f eq 'Tie::IxHash'; $self->_fields($f); return $self; } =head2 sort ($order) # sort by name, descending my $sort = {"name" => -1}; $cursor = $coll->query->sort($sort); Adds a sort to the query. Argument is either a hash reference or a Tie::IxHash. Returns this cursor for chaining operations. =cut sub sort { my ($self, $order) = @_; confess "cannot set sort after querying" if $self->started_iterating; confess 'not a hash reference' unless ref $order eq 'HASH' || ref $order eq 'Tie::IxHash'; $self->_ensure_nested; $self->_query->STORE('orderby', $order); return $self; } =head2 limit ($num) $per_page = 20; $cursor = $coll->query->limit($per_page); Returns a maximum of N results. Returns this cursor for chaining operations. =cut sub limit { my ($self, $num) = @_; confess "cannot set limit after querying" if $self->started_iterating; $self->_limit($num); return $self; } =head2 max_time_ms( $millis ) $cursor = $coll->query->max_time_ms( 500 ); Causes the server to abort the operation if the specified time in milliseconds is exceeded. =cut sub max_time_ms { my ( $self, $num ) = @_; $num = 0 unless defined $num; confess "max_time_ms must be non-negative" if $num < 0; confess "can not set max_time_ms after querying" if $self->started_iterating; $self->_ensure_nested; $self->_query->STORE( '$maxTimeMS', $num ); return $self; } =head2 tailable ($bool) $cursor->query->tailable(1); If a cursor should be tailable. Tailable cursors can only be used on capped collections and are similar to the C<tail -f> command: they never die and keep returning new results as more is added to a collection. They are often used for getting log messages. Boolean value, defaults to 0. Returns this cursor for chaining operations. =cut sub tailable { my($self, $bool) = @_; confess "cannot set tailable after querying" if $self->started_iterating; $self->_tailable($bool); return $self; } =head2 skip ($num) $page_num = 7; $per_page = 100; $cursor = $coll->query->limit($per_page)->skip($page_num * $per_page); Skips the first N results. Returns this cursor for chaining operations. See also core documentation on limit: L<http://dochub.mongodb.org/core/limit>. =cut sub skip { my ($self, $num) = @_; confess "cannot set skip after querying" if $self->started_iterating; $self->_skip($num); return $self; } =head2 snapshot my $cursor = $coll->query->snapshot; Uses snapshot mode for the query. Snapshot mode assures no duplicates are returned, or objects missed, which were present at both the start and end of the query's execution (if an object is new during the query, or deleted during the query, it may or may not be returned, even with snapshot mode). Note that short query responses (less than 1MB) are always effectively snapshotted. Currently, snapshot mode may not be used with sorting or explicit hints. =cut sub snapshot { my ($self) = @_; confess "cannot set snapshot after querying" if $self->started_iterating; $self->_ensure_nested; $self->_query->STORE('$snapshot', 1); return $self; } =head2 hint my $cursor = $coll->query->hint({'x' => 1}); Force Mongo to use a specific index for a query. =cut sub hint { my ($self, $index) = @_; confess "cannot set hint after querying" if $self->started_iterating; confess 'not a hash reference' unless ref $index eq 'HASH' || ref $index eq 'Tie::IxHash'; $self->_ensure_nested; $self->_query->STORE('$hint', $index); return $self; } =head2 explain my $explanation = $cursor->explain; This will tell you the type of cursor used, the number of records the DB had to examine as part of this query, the number of records returned by the query, and the time in milliseconds the query took to execute. Requires L<boolean> package. C<explain> resets the cursor, so calling C<next> or C<has_next> after an explain will requery the database. See also core documentation on explain: L<http://dochub.mongodb.org/core/explain>. =cut sub explain { my ($self) = @_; confess "cannot explain a parallel scan" if $self->_is_parallel; my $temp = $self->_limit; if ($self->_limit > 0) { $self->_limit($self->_limit * -1); } $self->_ensure_nested; $self->_query->STORE('$explain', boolean::true); my $retval = $self->reset->next; $self->reset->limit($temp); $self->_query->DELETE('$explain'); return $retval; } =head2 count($all?) my $num = $cursor->count; my $num = $cursor->skip(20)->count(1); Returns the number of document this query will return. Optionally takes a boolean parameter, indicating that the cursor's limit and skip fields should be used in calculating the count. =cut sub count { my ($self, $all) = @_; confess "cannot count a parallel scan" if $self->_is_parallel; my ($db, $coll) = $self->_ns =~ m/^([^\.]+)\.(.*)/; my $cmd = new Tie::IxHash(count => $coll); if ($self->_query->EXISTS('$query')) { $cmd->Push(query => $self->_query->FETCH('$query')); } else { $cmd->Push(query => $self->_query); } if ($all) { $cmd->Push(limit => $self->_limit) if $self->_limit; $cmd->Push(skip => $self->_skip) if $self->_skip; } my $result = $self->_client->get_database($db)->run_command($cmd); # returns "ns missing" if collection doesn't exist return 0 unless ref $result eq 'HASH'; return $result->{'n'}; } sub _add_readpref { my ($self, $prefdoc) = @_; $self->_ensure_nested; $self->_query->STORE('$readPreference', $prefdoc); } # shortcut to make some XS code saner sub _dt_type { my $self = shift; return $self->_client->dt_type; } sub _inflate_dbrefs { my $self = shift; return $self->_client->inflate_dbrefs; } sub _inflate_regexps { my $self = shift; return $self->_client->inflate_regexps; } =head2 reset Resets the cursor. After being reset, pre-query methods can be called on the cursor (sort, limit, etc.) and subsequent calls to next, has_next, or all will re-query the database. =cut sub reset { my ($self) = @_; confess "cannot reset a parallel scan" if $self->_is_parallel; return $self->_reset; } =head2 has_next while ($cursor->has_next) { ... } Checks if there is another result to fetch. =head2 next while (my $object = $cursor->next) { ... } Returns the next object in the cursor. Will automatically fetch more data from the server if necessary. Returns undef if no more data is available. =head2 info Returns a hash of information about this cursor. Currently the fields are: =over 4 =item C<cursor_id> The server-side id for this cursor. A C<cursor_id> of 0 means that there are no more batches to be fetched. =item C<num> The number of results returned so far. =item C<at> The index of the result the cursor is currently at. =item C<flag> If the database could not find the cursor or another error occurred, C<flag> may be set (depending on the error). See L<http://www.mongodb.org/display/DOCS/Mongo+Wire+Protocol#MongoWireProtocol-OPREPLY> for a full list of flag values. =item C<start> The index of the result that the current batch of results starts at. =back =head2 all my @objects = $cursor->all; Returns a list of all objects in the result. =cut sub all { my ($self) = @_; my @ret; while (my $entry = $self->next) { push @ret, $entry; } return @ret; } =head2 read_preference ($mode, $tagsets) my $cursor = $coll->find()->read_preference(MongoDB::MongoClient->PRIMARY_PREFERRED, [{foo => 'bar'}]); Sets read preference for the cursor's connection. The $mode argument should be a constant in MongoClient (PRIMARY, PRIMARY_PREFERRED, SECONDARY, SECONDARY_PREFERRED). The $tagsets specify selection criteria for secondaries in a replica set and should be an ArrayRef whose array elements are HashRefs. This is a convenience method which is identical in function to L<MongoDB::MongoClient/read_preference>. In order to use read preference, L<MongoDB::MongoClient/find_master> must be set. For core documentation on read preference see L<http://docs.mongodb.org/manual/core/read-preference/>. Returns $self so that this method can be chained. =cut sub read_preference { my ($self, $mode, $tagsets) = @_; $self->_master->read_preference($mode, $tagsets); $self->_client($self->_master->_readpref_pinned); return $self; } __PACKAGE__->meta->make_immutable (inline_destructor => 0); 1; =head1 AUTHOR Kristina Chodorow <kristina@mongodb.org>
13pass/mongo-perl-driver
lib/MongoDB/Cursor.pm
Perl
apache-2.0
15,705
# # Copyright 2015 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::juniper::ssg::plugin; use strict; use warnings; use base qw(centreon::plugins::script_snmp); sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; # $options->{options} = options object $self->{version} = '1.0'; %{$self->{modes}} = ( 'cpu' => 'network::juniper::common::screenos::mode::cpu', 'memory' => 'network::juniper::common::screenos::mode::memory', 'sessions' => 'network::juniper::common::screenos::mode::sessions', 'hardware' => 'network::juniper::common::screenos::mode::hardware', 'interfaces' => 'snmp_standard::mode::interfaces', 'list-interfaces' => 'snmp_standard::mode::listinterfaces', ); return $self; } 1; __END__ =head1 PLUGIN DESCRIPTION Check Juniper SSG in SNMP. =cut
s-duret/centreon-plugins
network/juniper/ssg/plugin.pm
Perl
apache-2.0
1,797
# 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::V9::Services::BiddingDataExclusionService; use strict; use warnings; use base qw(Google::Ads::GoogleAds::BaseService); sub get { my $self = shift; my $request_body = shift; my $http_method = 'GET'; my $request_path = 'v9/{+resourceName}'; my $response_type = 'Google::Ads::GoogleAds::V9::Resources::BiddingDataExclusion'; return $self->SUPER::call($http_method, $request_path, $request_body, $response_type); } sub mutate { my $self = shift; my $request_body = shift; my $http_method = 'POST'; my $request_path = 'v9/customers/{+customerId}/biddingDataExclusions:mutate'; my $response_type = 'Google::Ads::GoogleAds::V9::Services::BiddingDataExclusionService::MutateBiddingDataExclusionsResponse'; return $self->SUPER::call($http_method, $request_path, $request_body, $response_type); } 1;
googleads/google-ads-perl
lib/Google/Ads/GoogleAds/V9/Services/BiddingDataExclusionService.pm
Perl
apache-2.0
1,458
# # 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 database::firebird::mode::longqueries; use base qw(centreon::plugins::mode); use strict; use warnings; use centreon::plugins::misc; 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 => { "warning:s" => { name => 'warning', }, "critical:s" => { name => 'critical', }, "seconds:s" => { name => 'seconds', default => 60 }, "filter-user:s" => { name => 'filter_user' }, "filter-state:s" => { name => 'filter_state', default => '^(?!(0)$)' }, }); return $self; } sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); $self->{output}->option_exit(); } if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); $self->{output}->option_exit(); } if (!defined($self->{option_results}->{seconds}) || $self->{option_results}->{seconds} !~ /^[0-9]+$/) { $self->{output}->add_option_msg(short_msg => "Please set the option --seconds."); $self->{output}->option_exit(); } } sub run { my ($self, %options) = @_; # $options{sql} = sqlmode object $self->{sql} = $options{sql}; $self->{sql}->connect(); $self->{sql}->query(query => q{SELECT ma.MON$USER as MYUSER, ms.MON$STATE as MYSTATE, ms.MON$SQL_TEXT as MYQUERY, (DATEDIFF(second, timestamp '1/1/1970 00:00:00', ms.MON$TIMESTAMP)) as MYTIME FROM MON$STATEMENTS ms, MON$ATTACHMENTS ma WHERE ms.MON$ATTACHMENT_ID = ma.MON$ATTACHMENT_ID}); my $long_queries = 0; my @queries = (); while ((my $row = $self->{sql}->fetchrow_hashref())) { $row->{MYUSER} = centreon::plugins::misc::trim($row->{MYUSER}); $row->{MYQUERY} = '-' if (!defined($row->{MYQUERY})); next if (!defined($row->{MYTIME})); next if (defined($self->{option_results}->{filter_user}) && $self->{option_results}->{filter_user} ne '' && $row->{MYUSER} !~ /$self->{option_results}->{filter_user}/i); next if (defined($self->{option_results}->{filter_state}) && $self->{option_results}->{filter_state} ne '' && $row->{MYSTATE} !~ /$self->{option_results}->{filter_state}/i); if (defined($self->{option_results}->{seconds}) && $self->{option_results}->{seconds} ne '' && (time() - $row->{MYTIME}) >= $self->{option_results}->{seconds}) { push @queries, { time => time() - $row->{MYTIME}, query => $row->{MYQUERY} }; $long_queries++; } } my $exit_code = $self->{perfdata}->threshold_check(value => $long_queries, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); $self->{output}->output_add(severity => $exit_code, short_msg => sprintf("%s queries over %s seconds", $long_queries, $self->{option_results}->{seconds})); $self->{output}->perfdata_add(label => 'longqueries', value => $long_queries, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), min => 0); for (my $i = 0; $i < 10 && $i < scalar(@queries); $i++) { $queries[$i]->{query} =~ s/\|/-/mg; $self->{output}->output_add(long_msg => sprintf("[time: %s] [query: %s]", $queries[$i]->{time}, substr($queries[$i]->{query}, 0, 1024))); } $self->{output}->display(); $self->{output}->exit(); } 1; __END__ =head1 MODE Check current number of long queries on the database (firebird version >= 2.1) =over 8 =item B<--warning> Threshold warning (number of long queries). =item B<--critical> Threshold critical (number of long queries). =item B<--seconds> Filter queries over X seconds (Default: 60). =item B<--filter-user> Filter by user (can be a regexp). =item B<--filter-state> Filter by state (can be a regexp. Default: '^(?!(0)$)'). =back =cut
maksimatveev/centreon-plugins
database/firebird/mode/longqueries.pm
Perl
apache-2.0
5,728
#!/usr/bin/perl -w use strict; # Pre: 1., 2. Takes two paired end fastqs as inputs can be gzipped if they end # in .gz, in this case zcat must be present in the path. # 3., 4. Takes two output file names. These will not zip as its written # now. # 5. The quality score at which or be low you want to remove sequences # 6. The number of bases as or below your quality threshold needing to be # present before you remove a sequence from the file. # Post: Writes the filtered fastq to the two output files. # Two more files will be created with your outputfilenames+'.bad' # that contain the removed sequences. It will not overwrite files # -----> If a read failed in one of the of the two mate pairs, both mates # are removed. # Modifies: Creates files. Creates those '.bad' files based on your # output file names. if(scalar(@ARGV) != 6) { die "filter_fastq_based_on_quality.pl <input1> <input2> <output1> <output2> <low quality value to cut on or below> <low quality cutoff count cut on or above>\n"; } my $input1 = shift @ARGV; my $input2 = shift @ARGV; my $output1 = shift @ARGV; my $output2 = shift @ARGV; my $qvalue = shift @ARGV; my $qcount = shift @ARGV; my $isgzip = 0; if($input1=~/\.gz$/) { open(INF1,"zcat $input1 |") or die; $isgzip = 1; } else { open(INF1,"$input1") or die; } if($input2=~/\.gz$/) { open(INF2,"zcat $input2 |") or die; } else { open(INF2,"$input2") or die; } if(-e "$output1") { die "$output1 already exists\n"; } if(-e "$output2") { die "$output1 already exists\n"; } if(-e "$output1.bad") { die "$output1.bad already exists\n"; } if(-e "$output2.bad") { die "$output1.bad already exists\n"; } if($output1=~/\.gz$/ && $output2=~/\.gz$/) { open(OF1,"| gzip >$output1") or die; open(OF2,"| gzip >$output2") or die; open(OF1b,"| gzip >$output1.bad.gz") or die; open(OF2b,"| gzip >$output2.bad.gz") or die; } else { open(OF1,">$output1") or die; open(OF2,">$output2") or die; open(OF1b,">$output1.bad") or die; open(OF2b,">$output2.bad") or die; } while(my $a1 = <INF1>) { chomp($a1); chomp(my $a2=<INF1>); chomp(my $a3=<INF1>); chomp(my $a4=<INF1>); chomp(my $b1=<INF2>); chomp(my $b2=<INF2>); chomp(my $b3=<INF2>); chomp(my $b4=<INF2>); my @chars1 = split(//,$a4); my $lowcount1 = 0; foreach my $char (@chars1) { if(ord($char) <= $qvalue) { $lowcount1++; } } my @chars2 = split(//,$b4); my $lowcount2 = 0; foreach my $char (@chars2) { if(ord($char) <= $qvalue) { $lowcount2++; } } if($qcount <= $lowcount1 || $qcount <= $lowcount2) { print OF1b "$a1\n$a2\n$a3\n$a4\n"; print OF2b "$b1\n$b2\n$b3\n$b4\n"; } else { print OF1 "$a1\n$a2\n$a3\n$a4\n"; print OF2 "$b1\n$b2\n$b3\n$b4\n"; } } close INF1; close INF2;
jason-weirather/Au-public
iron/utilities/filter_paired_fastq_by_quality.pl
Perl
apache-2.0
2,866
# # 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 network::securactive::mode::listbcn; use base qw(centreon::plugins::mode); use strict; use warnings; my $oid_spvBCNName = '.1.3.6.1.4.1.36773.3.2.2.1.1.1'; 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 => { "bcn:s" => { name => 'bcn' }, "name" => { name => 'use_name' }, "regexp" => { name => 'use_regexp' }, "display-transform-src:s" => { name => 'display_transform_src' }, "display-transform-dst:s" => { name => 'display_transform_dst' }, }); $self->{bcn_id_selected} = []; return $self; } sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); } sub manage_selection { my ($self, %options) = @_; $self->{result_names} = $self->{snmp}->get_table(oid => $oid_spvBCNName, nothing_quit => 1); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{result_names}})) { next if ($oid !~ /\.([0-9]+)$/); my $instance = $1; # Get all without a name if (!defined($self->{option_results}->{bcn})) { push @{$self->{bcn_id_selected}}, $instance; next; } # By ID if (!defined($self->{option_results}->{use_name}) && defined($self->{option_results}->{bcn})) { if ($instance == $self->{option_results}->{bcn}) { push @{$self->{bcn_id_selected}}, $instance; } next; } $self->{result_names}->{$oid} = $self->{output}->to_utf8($self->{result_names}->{$oid}); if (!defined($self->{option_results}->{use_regexp}) && $self->{result_names}->{$oid} eq $self->{option_results}->{bcn}) { push @{$self->{bcn_id_selected}}, $instance; } if (defined($self->{option_results}->{use_regexp}) && $self->{result_names}->{$oid} =~ /$self->{option_results}->{bcn}/) { push @{$self->{bcn_id_selected}}, $instance; } } } sub run { my ($self, %options) = @_; $self->{snmp} = $options{snmp}; $self->manage_selection(); foreach my $instance (sort @{$self->{bcn_id_selected}}) { my $name = $self->{result_names}->{$oid_spvBCNName . '.' . $instance}; $name = $self->get_display_value(value => $name); $self->{output}->output_add(long_msg => "'" . $name . "'"); } $self->{output}->output_add(severity => 'OK', short_msg => 'List bcn:'); $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); $self->{output}->exit(); } sub get_display_value { my ($self, %options) = @_; my $value = $options{value}; if (defined($self->{option_results}->{display_transform_src})) { $self->{option_results}->{display_transform_dst} = '' if (!defined($self->{option_results}->{display_transform_dst})); eval "\$value =~ s{$self->{option_results}->{display_transform_src}}{$self->{option_results}->{display_transform_dst}}"; } return $value; } sub disco_format { my ($self, %options) = @_; $self->{output}->add_disco_format(elements => ['name', 'bcnid']); } sub disco_show { my ($self, %options) = @_; $self->{snmp} = $options{snmp}; $self->manage_selection(); foreach my $instance (sort @{$self->{bcn_id_selected}}) { my $name = $self->{result_names}->{$oid_spvBCNName . '.' . $instance}; $name = $self->get_display_value(value => $name); $self->{output}->add_disco_entry(name => $name, bcnid => $instance); } } 1; __END__ =head1 MODE List BCN. =over 8 =item B<--bcn> Set the bcn (number expected) ex: 1, 2,... (empty means 'check all bcn'). =item B<--name> Allows to use bcn name with option --bcn instead of bcn oid index. =item B<--regexp> Allows to use regexp to filter bcn (with option --name). =item B<--display-transform-src> Regexp src to transform display value. (security risk!!!) =item B<--display-transform-dst> Regexp dst to transform display value. (security risk!!!) =back =cut
bcournaud/centreon-plugins
network/securactive/mode/listbcn.pm
Perl
apache-2.0
5,278
# # 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 cloud::azure::common::appservice::mode::iooperations; use base qw(cloud::azure::custom::mode); use strict; use warnings; sub get_metrics_mapping { my ($self, %options) = @_; my $metrics_mapping = { 'iootherbytespersecond' => { 'output' => 'IO Other Bytes Per Second', 'label' => 'other-bytes', 'nlabel' => 'appservice.bytes.other.bytespersecond', 'unit' => 'B/s', 'min' => '0', 'max' => '' }, 'iootheroperationspersecond' => { 'output' => 'IO Other Operations Per Second', 'label' => 'other-operations', 'nlabel' => 'appservice.operations.other.bytespersecond', 'unit' => 'B/s', 'min' => '0', 'max' => '' }, 'ioreadbytespersecond' => { 'output' => 'IO Read Bytes Per Second', 'label' => 'read-bytes', 'nlabel' => 'appservice.bytes.read.bytespersecond', 'unit' => 'B/s', 'min' => '0', 'max' => '' }, 'ioreadoperationspersecond' => { 'output' => 'IO Read Operations Per Second', 'label' => 'read-operations', 'nlabel' => 'appservice.operations.read.bytespersecond', 'unit' => 'B/s', 'min' => '0', 'max' => '' }, 'iowritebytespersecond' => { 'output' => 'IO Write Bytes Per Second', 'label' => 'write-bytes', 'nlabel' => 'appservice.bytes.write.bytespersecond', 'unit' => 'B/s', 'min' => '0', 'max' => '' }, 'iowriteoperationspersecond' => { 'output' => 'IO Write Operations Per Second', 'label' => 'write-operations', 'nlabel' => 'appservice.operations.write.bytespersecond', 'unit' => 'B/s', 'min' => '0', 'max' => '' } }; return $metrics_mapping; } 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 => { 'filter-metric:s' => { name => 'filter_metric' }, 'resource:s' => { name => 'resource' }, 'resource-group:s' => { name => 'resource_group' } }); return $self; } sub check_options { my ($self, %options) = @_; $self->SUPER::check_options(%options); if (!defined($self->{option_results}->{resource}) || $self->{option_results}->{resource} eq '') { $self->{output}->add_option_msg(short_msg => 'Need to specify either --resource <name> with --resource-group option or --resource <id>.'); $self->{output}->option_exit(); } my $resource = $self->{option_results}->{resource}; my $resource_group = defined($self->{option_results}->{resource_group}) ? $self->{option_results}->{resource_group} : ''; if ($resource =~ /^\/subscriptions\/.*\/resourceGroups\/(.*)\/providers\/Microsoft\.Web\/sites\/(.*)$/) { $resource_group = $1; $resource = $2; } $self->{az_resource} = $resource; $self->{az_resource_group} = $resource_group; $self->{az_resource_type} = 'sites'; $self->{az_resource_namespace} = 'Microsoft.Web'; $self->{az_timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 900; $self->{az_interval} = defined($self->{option_results}->{interval}) ? $self->{option_results}->{interval} : 'PT5M'; $self->{az_aggregations} = ['Total']; if (defined($self->{option_results}->{aggregation})) { $self->{az_aggregations} = []; foreach my $stat (@{$self->{option_results}->{aggregation}}) { if ($stat ne '') { push @{$self->{az_aggregations}}, ucfirst(lc($stat)); } } } foreach my $metric (keys %{$self->{metrics_mapping}}) { next if (defined($self->{option_results}->{filter_metric}) && $self->{option_results}->{filter_metric} ne '' && $metric !~ /$self->{option_results}->{filter_metric}/); push @{$self->{az_metrics}}, $metric; } } 1; __END__ =head1 MODE Check Azure App Service I/O operations by the app. Example: Using resource name : perl centreon_plugins.pl --plugin=cloud::azure::common::appservice::plugin --mode=io-operations --custommode=api --resource=<sites_id> --resource-group=<resourcegroup_id> --aggregation='total' --warning-write-bytes='80000' --critical-write-bytes='90000' Using resource id : perl centreon_plugins.pl --plugin=cloud::azure::common::appservice::plugin --mode=io-operations --custommode=api --resource='/subscriptions/<subscription_id>/resourceGroups/<resourcegroup_id>/providers/Microsoft.Web/sites/<sites_id>' --aggregation='total' --warning-write-bytes='80000' --critical-write-bytes='90000' Default aggregation: 'total' / 'minimum', 'maximum' and 'average' are valid. =over 8 =item B<--resource> Set resource name or id (Required). =item B<--resource-group> Set resource group (Required if resource's name is used). =item B<--warning-*> Warning threshold where '*' can be: 'other-bytes', 'other-operations', 'read-bytes', 'read-operations', 'write-bytes', 'write-operations'. =item B<--critical-*> Critical threshold where '*' can be:. 'other-bytes', 'other-operations', 'read-bytes', 'read-operations', 'write-bytes', 'write-operations'. =back =cut
Tpo76/centreon-plugins
cloud/azure/common/appservice/mode/iooperations.pm
Perl
apache-2.0
6,324
package Search::Elasticsearch::Serializer::JSON::XS; $Search::Elasticsearch::Serializer::JSON::XS::VERSION = '1.17'; use Moo; use JSON::XS 2.26; has 'JSON' => ( is => 'ro', default => sub { JSON::XS->new->utf8(1) } ); with 'Search::Elasticsearch::Role::Serializer::JSON'; 1; =pod =encoding UTF-8 =head1 NAME Search::Elasticsearch::Serializer::JSON::XS - A JSON Serializer using JSON::XS =head1 VERSION version 1.17 =head1 SYNOPSIS $e = Search::Elasticsearch( serializer => 'JSON::XS' ); =head1 DESCRIPTION While the default serializer, L<Search::Elasticsearch::Serializer::JSON>, tries to choose the appropriate JSON backend, this module allows you to choose the L<JSON::XS> backend specifically. This class does L<Search::Elasticsearch::Role::Serializer::JSON>. =head1 SEE ALSO =over =item * L<Search::Elasticsearch::Serializer::JSON> =item * L<Search::Elasticsearch::Serializer::JSON::Cpanel> =item * L<Search::Elasticsearch::Serializer::JSON::PP> =back =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 JSON Serializer using JSON::XS
gitpan/Search-Elasticsearch
lib/Search/Elasticsearch/Serializer/JSON/XS.pm
Perl
apache-2.0
1,281
package OpenXPKI::Template::Plugin::Utils; use strict; use warnings; use utf8; use Moose; use Net::DNS; use Template::Plugin; use MIME::Base64; use Data::Dumper; extends 'Template::Plugin'; =head1 OpenXPKI::Template::Plugin::Utils Plugin for Template::Toolkit providing some string manipulation functions. =cut =head2 How to use You need to load the plugin into your template before using it. As we do not export the methods, you need to address them with the plugin name, e.g. [% USE Utils %] [% Utils.ascii_to_hex(value) %] Will output the converted string. =cut has 'uuid_gen' => ( is => 'ro', isa => 'Object', lazy => 1, default => sub { use Data::UUID; return Data::UUID->new(); } ); =head2 Methods =head3 uuid Generate a UUID v3 string (e.g. 4162F712-1DD2-11B2-B17E-C09EFE1DC403) This is simply a wrapper around Data::UUID->gen_str. =cut sub uuid { my $self = shift; return $self->uuid_gen()->create_str(); } =head3 ascii_to_hex Convert a ascii string to its hexadecimal representation, e.g. "OpenXPKI" becomes 4f70656e58504b49. =cut sub ascii_to_hex { my $self = shift; my $string = shift; $string =~ s/(.)/sprintf("%02x",ord($1))/eg; return $string } =head3 to_base64 ( text ) Encode the given (binary) data using Base64 encoding, output is without linebreaks or spaces. =cut sub to_base64 { my $self = shift; my $string = shift; return MIME::Base64::encode_base64($string, ''); } 1;
openxpki/openxpki
core/server/OpenXPKI/Template/Plugin/Utils.pm
Perl
apache-2.0
1,483
# # Copyright 2018 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::redis::restapi::mode::databasesstats; use base qw(centreon::plugins::templates::counter); use strict; use warnings; use Digest::MD5 qw(md5_hex); my $instance_mode; sub custom_usage_perfdata { my ($self, %options) = @_; $self->{output}->perfdata_add(label => $self->{result_values}->{perf}, unit => 'B', value => $self->{result_values}->{used}, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{result_values}->{label}, total => $self->{result_values}->{total}, cast_int => 1), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{result_values}->{label}, total => $self->{result_values}->{total}, cast_int => 1), 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->{result_values}->{label}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{result_values}->{label}, exit_litteral => 'warning' } ]); return $exit; } sub custom_usage_output { my ($self, %options) = @_; my ($used_value, $used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}); my ($free_value, $free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}); my ($total_value, $total_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}); my $msg = sprintf("%s usage: Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", $self->{result_values}->{display}, $total_value . " " . $total_unit, $used_value . " " . $used_unit, $self->{result_values}->{prct_used}, $free_value . " " . $free_unit, $self->{result_values}->{prct_free}); return $msg; } sub custom_usage_calc { my ($self, %options) = @_; $self->{result_values}->{label} = $options{extra_options}->{label}; $self->{result_values}->{perf} = $options{extra_options}->{perf}; $self->{result_values}->{display} = $options{extra_options}->{display}; $self->{result_values}->{used} = $options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{used}}; $self->{result_values}->{total} = $options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{total}}; if ($self->{result_values}->{total} != 0) { $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}; } else { $self->{result_values}->{used} = '0'; $self->{result_values}->{prct_used} = '0'; $self->{result_values}->{prct_free} = '0'; } return 0; } sub custom_status_threshold { my ($self, %options) = @_; my $status = 'ok'; my $message; eval { local $SIG{__WARN__} = sub { $message = $_[0]; }; local $SIG{__DIE__} = sub { $message = $_[0]; }; if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' && eval "$instance_mode->{option_results}->{critical_status}") { $status = 'critical'; } elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' && eval "$instance_mode->{option_results}->{warning_status}") { $status = 'warning'; } }; if (defined($message)) { $self->{output}->output_add(long_msg => 'filter status issue: ' . $message); } return $status; } sub custom_status_output { my ($self, %options) = @_; my $msg = sprintf("Status is '%s' [type: %s] [shard list: %s] [backup status: %s] [export status: %s] [import status: %s]", $self->{result_values}->{status}, $self->{result_values}->{type}, $self->{result_values}->{shard_list}, $self->{result_values}->{backup_status}, $self->{result_values}->{export_status}, $self->{result_values}->{import_status}); return $msg; } sub custom_status_calc { my ($self, %options) = @_; $self->{result_values}->{type} = $options{new_datas}->{$self->{instance} . '_type'}; $self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'}; $self->{result_values}->{backup_status} = $options{new_datas}->{$self->{instance} . '_backup_status'}; $self->{result_values}->{export_status} = $options{new_datas}->{$self->{instance} . '_export_status'}; $self->{result_values}->{import_status} = $options{new_datas}->{$self->{instance} . '_import_status'}; $self->{result_values}->{shard_list} = $options{new_datas}->{$self->{instance} . '_shard_list'}; $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; return 0; } sub custom_cpu_output { my ($self, %options) = @_; my $msg = sprintf("%s CPU usage (user/system): %s/%s %%", $self->{result_values}->{cpu}, $self->{result_values}->{user}, $self->{result_values}->{system}); return $msg; } sub custom_cpu_calc { my ($self, %options) = @_; $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{display}}; $self->{result_values}->{cpu} = $options{extra_options}->{cpu}; $self->{result_values}->{user} = $options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{user}}; $self->{result_values}->{system} = $options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{system}}; return 0; } sub custom_operations_output { my ($self, %options) = @_; my $msg = sprintf("%s operations rates (hits/misses/requests/responses): %s/%s/%s/%s ops/s", $self->{result_values}->{operation}, $self->{result_values}->{hits}, $self->{result_values}->{misses}, $self->{result_values}->{req}, $self->{result_values}->{res}); return $msg; } sub custom_operations_calc { my ($self, %options) = @_; $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{display}}; $self->{result_values}->{operation} = $options{extra_options}->{operation}; $self->{result_values}->{hits} = $options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{hits}}; $self->{result_values}->{misses} = $options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{misses}}; $self->{result_values}->{req} = $options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{req}}; $self->{result_values}->{res} = $options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{res}}; return 0; } sub prefix_output { my ($self, %options) = @_; return "Database '" . $options{instance_value}->{display} . "' "; } sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ { name => 'databases', type => 1, cb_prefix_output => 'prefix_output', message_multiple => 'All databases counters are ok' }, ]; $self->{maps_counters}->{databases} = [ { label => 'status', threshold => 0, set => { key_values => [ { name => 'status' }, { name => 'type' }, { name => 'backup_status' }, { name => 'export_status' }, { name => 'import_status' }, { name => 'shard_list' }, { name => 'display' } ], 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 => $self->can('custom_status_threshold'), } }, { label => 'total-cpu', set => { key_values => [ { name => 'shard_cpu_user' }, { name => 'shard_cpu_system' }, { name => 'display' } ], closure_custom_calc => $self->can('custom_cpu_calc'), closure_custom_calc_extra_options => { cpu => 'Total', user => 'shard_cpu_user', system => 'shard_cpu_system', display => 'display' }, closure_custom_output => $self->can('custom_cpu_output'), perfdatas => [ { label => 'total_cpu_user', value => 'user', template => '%s', min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' }, { label => 'total_cpu_system', value => 'system', template => '%s', min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'fork-cpu', set => { key_values => [ { name => 'fork_cpu_user' }, { name => 'fork_cpu_system' }, { name => 'display' } ], closure_custom_calc => $self->can('custom_cpu_calc'), closure_custom_calc_extra_options => { cpu => 'Fork', user => 'fork_cpu_user', system => 'fork_cpu_system', display => 'display' }, closure_custom_output => $self->can('custom_cpu_output'), perfdatas => [ { label => 'fork_cpu_user', value => 'user', template => '%s', min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' }, { label => 'fork_cpu_system', value => 'system', template => '%s', min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'main-thread-cpu', set => { key_values => [ { name => 'main_thread_cpu_user' }, { name => 'main_thread_cpu_system' }, { name => 'display' } ], closure_custom_calc => $self->can('custom_cpu_calc'), closure_custom_calc_extra_options => { cpu => 'Main thread', user => 'main_thread_cpu_user', system => 'main_thread_cpu_system', display => 'display' }, closure_custom_output => $self->can('custom_cpu_output'), perfdatas => [ { label => 'main_thread_cpu_user', value => 'user', template => '%s', min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' }, { label => 'main_thread_cpu_system', value => 'system', template => '%s', min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'memory', set => { key_values => [ { name => 'used_memory' }, { name => 'memory_size' } ], closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_calc_extra_options => { display => 'Memory', label => 'memory', perf => 'memory', used => 'used_memory', total => 'memory_size' }, 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 => 'mem-frag-ratio', set => { key_values => [ { name => 'mem_frag_ratio' }, { name => 'display' } ], output_template => 'Memory fragmentation ratio: %s', perfdatas => [ { label => 'mem_frag_ratio', value => 'mem_frag_ratio_absolute', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, ], } }, { label => 'connections', set => { key_values => [ { name => 'conns' }, { name => 'display' } ], output_template => 'Connections: %s', perfdatas => [ { label => 'connections', value => 'conns_absolute', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, ], } }, { label => 'total-rates', set => { key_values => [ { name => 'total_hits' }, { name => 'total_misses' }, { name => 'total_req' }, { name => 'total_res' }, { name => 'display' } ], closure_custom_calc => $self->can('custom_operations_calc'), closure_custom_calc_extra_options => { operation => 'Total', hits => 'total_hits', misses => 'total_misses', req => 'total_req', res => 'total_res', display => 'display' }, closure_custom_output => $self->can('custom_operations_output'), perfdatas => [ { label => 'total_hits', value => 'hits', template => '%s', min => 0, unit => 'ops/s', label_extra_instance => 1, instance_use => 'display' }, { label => 'total_misses', value => 'misses', template => '%s', min => 0, unit => 'ops/s', label_extra_instance => 1, instance_use => 'display' }, { label => 'total_req', value => 'req', template => '%s', min => 0, unit => 'ops/s', label_extra_instance => 1, instance_use => 'display' }, { label => 'total_res', value => 'res', template => '%s', min => 0, unit => 'ops/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'latency', set => { key_values => [ { name => 'avg_latency' }, { name => 'display' } ], output_template => 'Average latency: %.2f ms', perfdatas => [ { label => 'latency', value => 'avg_latency_absolute', template => '%.2f', min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'display_absolute' }, ], } }, { label => 'other-rates', set => { key_values => [ { name => 'other_hits' }, { name => 'other_misses' }, { name => 'other_req' }, { name => 'other_res' }, { name => 'display' } ], closure_custom_calc => $self->can('custom_operations_calc'), closure_custom_calc_extra_options => { operation => 'Other', hits => 'other_hits', misses => 'other_misses', req => 'other_req', res => 'other_res', display => 'display' }, closure_custom_output => $self->can('custom_operations_output'), perfdatas => [ { label => 'other_req', value => 'req', template => '%s', min => 0, unit => 'ops/s', label_extra_instance => 1, instance_use => 'display' }, { label => 'other_res', value => 'res', template => '%s', min => 0, unit => 'ops/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'other-latency', set => { key_values => [ { name => 'avg_other_latency' }, { name => 'display' } ], output_template => 'Other latency: %.2f ms', perfdatas => [ { label => 'other_latency', value => 'avg_other_latency_absolute', template => '%.2f', min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'display_absolute' }, ], } }, { label => 'keys', set => { key_values => [ { name => 'no_of_keys' }, { name => 'display' } ], output_template => 'Total keys: %s', perfdatas => [ { label => 'keys', value => 'no_of_keys_absolute', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, ], } }, { label => 'evicted-objects', set => { key_values => [ { name => 'evicted_objects' }, { name => 'display' } ], output_template => 'Evicted objects rate: %s evictions/sec', perfdatas => [ { label => 'evicted_objects', value => 'evicted_objects_absolute', template => '%s', min => 0, unit => 'evictions/sec', label_extra_instance => 1, instance_use => 'display_absolute' }, ], } }, { label => 'expired-objects', set => { key_values => [ { name => 'expired_objects' }, { name => 'display' } ], output_template => 'Expired objects rate: %s expirations/sec', perfdatas => [ { label => 'expired_objects', value => 'expired_objects_absolute', template => '%s', min => 0, unit => 'expirations/sec', label_extra_instance => 1, instance_use => 'display_absolute' }, ], } }, { label => 'read-rates', set => { key_values => [ { name => 'read_hits' }, { name => 'read_misses' }, { name => 'read_req' }, { name => 'read_res' }, { name => 'display' } ], closure_custom_calc => $self->can('custom_operations_calc'), closure_custom_calc_extra_options => { operation => 'Read', hits => 'read_hits', misses => 'read_misses', req => 'read_req', res => 'read_res', display => 'display' }, closure_custom_output => $self->can('custom_operations_output'), perfdatas => [ { label => 'read_hits', value => 'hits', template => '%s', min => 0, unit => 'ops/s', label_extra_instance => 1, instance_use => 'display' }, { label => 'read_misses', value => 'misses', template => '%s', min => 0, unit => 'ops/s', label_extra_instance => 1, instance_use => 'display' }, { label => 'read_req', value => 'req', template => '%s', min => 0, unit => 'ops/s', label_extra_instance => 1, instance_use => 'display' }, { label => 'read_res', value => 'res', template => '%s', min => 0, unit => 'ops/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'read-latency', set => { key_values => [ { name => 'avg_read_latency' }, { name => 'display' } ], output_template => 'Read latency: %.2f ms', perfdatas => [ { label => 'read_latency', value => 'avg_read_latency_absolute', template => '%.2f', min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'display_absolute' }, ], } }, { label => 'write-rates', set => { key_values => [ { name => 'write_hits' }, { name => 'write_misses' }, { name => 'write_req' }, { name => 'write_res' }, { name => 'display' } ], closure_custom_calc => $self->can('custom_operations_calc'), closure_custom_calc_extra_options => { operation => 'Write', hits => 'write_hits', misses => 'write_misses', req => 'write_req', res => 'write_res', display => 'display' }, closure_custom_output => $self->can('custom_operations_output'), perfdatas => [ { label => 'write_hits', value => 'hits', template => '%s', min => 0, unit => 'ops/s', label_extra_instance => 1, instance_use => 'display' }, { label => 'write_misses', value => 'misses', template => '%s', min => 0, unit => 'ops/s', label_extra_instance => 1, instance_use => 'display' }, { label => 'write_req', value => 'req', template => '%s', min => 0, unit => 'ops/s', label_extra_instance => 1, instance_use => 'display' }, { label => 'write_res', value => 'res', template => '%s', min => 0, unit => 'ops/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'write-latency', set => { key_values => [ { name => 'avg_write_latency' }, { name => 'display' } ], output_template => 'Write latency: %.2f ms', perfdatas => [ { label => 'write_latency', value => 'avg_write_latency_absolute', template => '%.2f', min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'display_absolute' }, ], } }, { label => 'traffic-in', set => { key_values => [ { name => 'ingress' }, { name => 'display' } ], output_template => 'Traffic In: %s %s/s', output_change_bytes => 2, perfdatas => [ { label => 'traffic_in', value => 'ingress_absolute', template => '%d', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, ], }, }, { label => 'traffic-out', set => { key_values => [ { name => 'egress' }, { name => 'display' } ], output_template => 'Traffic Out: %s %s/s', output_change_bytes => 2, perfdatas => [ { label => 'traffic_out', value => 'egress_absolute', template => '%d', min => 0, unit => 'b/s', 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-database:s" => { name => 'filter_database' }, "units:s" => { name => 'units', default => '%' }, "free" => { name => 'free' }, "warning-status:s" => { name => 'warning_status', default => '' }, "critical-status:s" => { name => 'critical_status', default => '%{status} =~ /creation-failed/i | %{backup_status} =~ /failed/i | %{export_status} =~ /failed/i | %{import_status} =~ /failed/i' }, }); return $self; } sub check_options { my ($self, %options) = @_; $self->SUPER::check_options(%options); $instance_mode = $self; $self->change_macros(); } sub change_macros { my ($self, %options) = @_; foreach (('warning_status', 'critical_status')) { if (defined($self->{option_results}->{$_})) { $self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g; } } } sub manage_selection { my ($self, %options) = @_; my $result = $options{custom}->get(path => '/v1/bdbs/stats/last?interval='.$options{custom}->get_interval()); my $result2 = $options{custom}->get(path => '/v1/bdbs'); foreach my $database (keys %{$result}) { if (defined($self->{option_results}->{filter_database}) && $self->{option_results}->{filter_database} ne '' && $database !~ /$self->{option_results}->{filter_database}/) { $self->{output}->output_add(long_msg => "skipping database '" . $database . "': no matching filter.", debug => 1); next; } my $shard_list = '-'; if (@{$result2->{$database}->{shard_list}}) { $shard_list = join(", ", @{$result2->{$database}->{shard_list}}); } $self->{databases}->{$database} = { display => $result2->{$database}->{name}, status => defined($result2->{$database}->{status}) ? $result2->{$database}->{status} : '-', type => defined($result2->{$database}->{type}) ? $result2->{$database}->{type} : '-', backup_status => defined($result2->{$database}->{backup_status}) ? $result2->{$database}->{backup_status} : '-', export_status => defined($result2->{$database}->{export_status}) ? $result2->{$database}->{export_status} : '-', import_status => defined($result2->{$database}->{import_status}) ? $result2->{$database}->{import_status} : '-', shard_list => $shard_list, shard_cpu_user => $result->{$database}->{shard_cpu_user} * 100, shard_cpu_system => $result->{$database}->{shard_cpu_system} * 100, main_thread_cpu_user => $result->{$database}->{main_thread_cpu_user} * 100, main_thread_cpu_system => $result->{$database}->{main_thread_cpu_system} * 100, fork_cpu_user => $result->{$database}->{fork_cpu_user} * 100, fork_cpu_system => $result->{$database}->{fork_cpu_system} * 100, used_memory => $result->{$database}->{used_memory}, memory_size => $result2->{$database}->{memory_size}, mem_frag_ratio => $result->{$database}->{mem_frag_ratio}, conns => $result->{$database}->{conns}, total_req => defined($result->{$database}->{total_req}) ? $result->{$database}->{total_req} : $result->{$database}->{instantaneous_ops_per_sec}, total_res => $result->{$database}->{total_res}, total_hits => $result->{$database}->{read_hits} + $result->{$database}->{write_hits}, total_misses => $result->{$database}->{read_misses} + $result->{$database}->{write_misses}, avg_latency => defined($result2->{$database}->{avg_latency}) ? $result->{$database}->{avg_latency} * 1000 : '0', other_req => $result->{$database}->{other_req}, other_res => $result->{$database}->{other_res}, other_hits => '-', other_misses => '-', avg_other_latency => defined($result2->{$database}->{avg_other_latency}) ? $result->{$database}->{avg_other_latency} * 1000 : '0', no_of_keys => $result->{$database}->{no_of_keys}, evicted_objects => $result->{$database}->{evicted_objects}, expired_objects => $result->{$database}->{expired_objects}, read_hits => $result->{$database}->{read_hits}, read_misses => $result->{$database}->{read_misses}, read_req => $result->{$database}->{read_req}, read_res => $result->{$database}->{read_res}, write_hits => $result->{$database}->{write_hits}, write_misses => $result->{$database}->{write_misses}, write_req => $result->{$database}->{write_req}, write_res => $result->{$database}->{write_res}, avg_read_latency => defined($result2->{$database}->{avg_read_latency}) ? $result->{$database}->{avg_read_latency} * 1000 : '0', avg_write_latency => defined($result2->{$database}->{avg_write_latency}) ? $result->{$database}->{avg_write_latency} * 1000 : '0', ingress => $result->{$database}->{ingress_bytes} * 8, egress => $result->{$database}->{egress_bytes} * 8, }; if (scalar(keys %{$self->{databases}}) <= 0) { $self->{output}->add_option_msg(short_msg => 'No databases detected, check your filter ? '); $self->{output}->option_exit(); } } } 1; __END__ =head1 MODE Check RedisLabs Enterprise Cluster databases statistics. =over 8 =item B<--filter-counters> Only display some counters (regexp can be used). Example: --filter-counters='rate|latency' =item B<--warning-status> Set warning threshold for status. Can used special variables like: %{status}, %{type}, %{backup_status}, %{export_status}, %{shard_list}. 'status' can be: 'pending', 'active', 'active-change-pending', 'delete-pending', 'import-pending', 'creation-failed', 'recovery'. 'type' can be: 'redis', 'memcached'. 'backup_status' can be: 'exporting', 'succeeded', 'failed'. 'export_status' can be: 'exporting', 'succeeded', 'failed'. 'import_status' can be: 'idle', 'initializing', 'importing', 'succeeded', 'failed'. =item B<--critical-status> Set critical threshold for status (Default: '%{status} =~ /creation-failed/i | %{backup_status} =~ /failed/i | %{export_status} =~ /failed/i | %{import_status} =~ /failed/i'). Can used special variables like: %{status}, %{type}, %{backup_status}, %{export_status}, %{shard_list}. 'status' can be: 'pending', 'active', 'active-change-pending', 'delete-pending', 'import-pending', 'creation-failed', 'recovery'. 'type' can be: 'redis', 'memcached'. 'backup_status' can be: 'exporting', 'succeeded', 'failed'. '' can be: 'exporting', 'succeeded', 'failed'. 'import_status' can be: 'idle', 'initializing', 'importing', 'succeeded', 'failed'. =item B<--warning-*> Threshold warning. Can be: 'total-cpu', 'fork-cpu', 'main-thread-cpu', 'memory', 'mem-frag-ratio', 'connections', 'total-rates', 'latency', 'other-rates', 'other-latency', 'keys', 'evicted-objects', 'expired-objects', 'read-rates', 'read-latency', 'write-rates', 'write-latency', 'traffic-in', 'traffic-out'. =item B<--critical-*> Threshold critical. Can be: 'total-cpu', 'fork-cpu', 'main-thread-cpu', 'memory', 'mem-frag-ratio', 'connections', 'total-rates', 'latency', 'other-rates', 'other-latency', 'keys', 'evicted-objects', 'expired-objects', 'read-rates', 'read-latency', 'write-rates', 'write-latency', 'traffic-in', 'traffic-out'. =back =cut
wilfriedcomte/centreon-plugins
apps/redis/restapi/mode/databasesstats.pm
Perl
apache-2.0
32,335
# # 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::memory; use base qw(centreon::plugins::mode); use strict; use warnings; 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 => { "warning:s" => { name => 'warning' }, "critical:s" => { name => 'critical' }, "filter-pool:s" => { name => 'filter_pool' }, }); return $self; } sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); $self->{output}->option_exit(); } if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); $self->{output}->option_exit(); } } sub check_table_memory { my ($self, %options) = @_; my $checked = 0; foreach my $oid (keys %{$self->{results}->{$options{entry}}}) { next if ($oid !~ /^$options{poolName}/); $oid =~ /\.([0-9]+)$/; my $instance = $1; my $memory_name = $self->{results}->{$options{entry}}->{$oid}; my $memory_used = $self->{results}->{$options{entry}}->{$options{poolUsed} . '.' . $instance}; my $memory_free = $self->{results}->{$options{entry}}->{$options{poolFree} . '.' . $instance}; next if ($memory_name eq ''); if (defined($self->{option_results}->{filter_pool}) && $self->{option_results}->{filter_pool} ne '' && $memory_name !~ /$self->{option_results}->{filter_pool}/) { $self->{output}->output_add(long_msg => "Skipping pool '" . $memory_name . "'."); next; } $checked = 1; my $total_size = $memory_used + $memory_free; my $prct_used = $memory_used * 100 / $total_size; my $prct_free = 100 - $prct_used; my $exit = $self->{perfdata}->threshold_check(value => $prct_used, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); my ($total_value, $total_unit) = $self->{perfdata}->change_bytes(value => $total_size); my ($used_value, $used_unit) = $self->{perfdata}->change_bytes(value => $memory_used); my ($free_value, $free_unit) = $self->{perfdata}->change_bytes(value => $memory_free); $self->{output}->output_add(long_msg => sprintf("Memory '%s' Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", $memory_name, $total_value . " " . $total_unit, $used_value . " " . $used_unit, $prct_used, $free_value . " " . $free_unit, $prct_free)); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit, short_msg => sprintf("Memory '%s' Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", $memory_name, $total_value . " " . $total_unit, $used_value . " " . $used_unit, $prct_used, $free_value . " " . $free_unit, $prct_free)); } $self->{output}->perfdata_add(label => "used_" . $memory_name, unit => 'B', value => $memory_used, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $total_size), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $total_size), min => 0, max => $total_size); } return $checked; } sub check_percent_memory { my ($self, %options) = @_; my $checked = 0; foreach my $oid (keys %{$self->{results}->{$options{entry}}}) { next if ($oid !~ /^$options{memUsage}/); $oid =~ /\.([0-9]+)$/; my $instance = $1; my $memory_usage = $self->{results}->{$options{entry}}->{$oid}; next if ($memory_usage eq ''); $checked = 1; my $exit = $self->{perfdata}->threshold_check(value => $memory_usage, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit, short_msg => sprintf("Memory used : %.2f%%", $memory_usage)); } $self->{output}->perfdata_add(label => "utilization", value => $memory_usage, unit => "%", warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), min => 0, max => 100); } return $checked; } sub run { my ($self, %options) = @_; # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_ciscoMemoryPoolEntry = '.1.3.6.1.4.1.9.9.48.1.1.1'; my $oid_ciscoMemoryPoolName = '.1.3.6.1.4.1.9.9.48.1.1.1.2'; my $oid_ciscoMemoryPoolUsed = '.1.3.6.1.4.1.9.9.48.1.1.1.5'; # in B my $oid_ciscoMemoryPoolFree = '.1.3.6.1.4.1.9.9.48.1.1.1.6'; # in B # OIDs for Nexus my $oid_cseSysMemoryEntry = '.1.3.6.1.4.1.9.9.305.1.1'; my $oid_cseSysMemoryUtilization = '.1.3.6.1.4.1.9.9.305.1.1.2'; $self->{results} = $self->{snmp}->get_multiple_table(oids => [ { oid => $oid_ciscoMemoryPoolEntry, start => $oid_ciscoMemoryPoolName, end => $oid_ciscoMemoryPoolFree }, { oid => $oid_cseSysMemoryEntry, start => $oid_cseSysMemoryUtilization, end => $oid_cseSysMemoryUtilization }], nothing_quit => 1); $self->{output}->output_add(severity => 'OK', short_msg => 'Memory is ok.'); if (!$self->check_table_memory(entry => $oid_ciscoMemoryPoolEntry, poolName => $oid_ciscoMemoryPoolName, poolUsed => $oid_ciscoMemoryPoolUsed, poolFree => $oid_ciscoMemoryPoolFree) && !$self->check_percent_memory(entry => $oid_cseSysMemoryEntry, memUsage => $oid_cseSysMemoryUtilization) ) { $self->{output}->output_add(severity => 'UNKNOWN', short_msg => sprintf("Cannot find Memory informations.")); } $self->{output}->display(); $self->{output}->exit(); } 1; __END__ =head1 MODE Check memory usage (CISCO-MEMORY-POOL-MIB and CISCO-SYSTEM-EXT-MIB). =over 8 =item B<--warning> Threshold warning in percent. =item B<--critical> Threshold critical in percent. =item B<--filter-pool> Filter pool to check (can use regexp). =back =cut
golgoth31/centreon-plugins
centreon/common/cisco/standard/snmp/mode/memory.pm
Perl
apache-2.0
8,693
# # 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 os::aix::local::mode::cmdreturn; use base qw(centreon::plugins::mode); use strict; use warnings; 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 => { 'exec-command:s' => { name => 'exec_command' }, 'exec-command-path:s' => { name => 'exec_command_path' }, 'exec-command-options:s' => { name => 'exec_command_options' }, 'manage-returns:s' => { name => 'manage_returns', default => '' }, 'separator:s' => { name => 'separator', default => '#' } }); return $self; } sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); if (!defined($self->{option_results}->{exec_command})) { $self->{output}->add_option_msg(short_msg => "Need to specify exec-command option."); $self->{output}->option_exit(); } $self->{manage_returns} = {}; foreach my $entry (split(/$self->{option_results}->{separator}/, $self->{option_results}->{manage_returns})) { next if (!($entry =~ /(.*?),(.*?),(.*)/)); next if (!$self->{output}->is_litteral_status(status => $2)); if ($1 ne '') { $self->{manage_returns}->{$1} = {return => $2, msg => $3}; } else { $self->{manage_returns}->{default} = {return => $2, msg => $3}; } } if ($self->{option_results}->{manage_returns} eq '' || scalar(keys %{$self->{manage_returns}}) == 0) { $self->{output}->add_option_msg(short_msg => "Need to specify manage-returns option correctly."); $self->{output}->option_exit(); } } sub run { my ($self, %options) = @_; my ($stdout, $exit_code) = $options{custom}->execute_command( command => $self->{option_results}->{exec_command}, command_path => $self->{option_results}->{exec_command_path}, command_options => $self->{option_results}->{exec_command_options}, no_quit => 1 ); my $long_msg = $stdout; $long_msg =~ s/\|/~/mg; $self->{output}->output_add(long_msg => $long_msg); if (defined($self->{manage_returns}->{$exit_code})) { $self->{output}->output_add( severity => $self->{manage_returns}->{$exit_code}->{return}, short_msg => $self->{manage_returns}->{$exit_code}->{msg} ); } elsif (defined($self->{manage_returns}->{default})) { $self->{output}->output_add( severity => $self->{manage_returns}->{default}->{return}, short_msg => $self->{manage_returns}->{default}->{msg} ); } else { $self->{output}->output_add( severity => 'UNKNWON', short_msg => 'Exit code from command' ); } if (defined($exit_code)) { $self->{output}->perfdata_add( nlabel => 'command.exit.code.count', value => $exit_code ); } $self->{output}->display(); $self->{output}->exit(); } 1; __END__ =head1 MODE Check command returns. =over 8 =item B<--manage-returns> Set action according command exit code. Example: 0,OK,File xxx exist#1,CRITICAL,File xxx not exist#,UNKNOWN,Command problem =item B<--separator> Set the separator used in --manage-returns (default : #) =item B<--exec-command> Command to test (Default: none). You can use 'sh' to use '&&' or '||'. =item B<--exec-command-path> Command path (Default: none). =item B<--exec-command-options> Command options (Default: none). =back =cut
Tpo76/centreon-plugins
os/aix/local/mode/cmdreturn.pm
Perl
apache-2.0
4,373
package VMOMI::MemorySnapshotOnIndependentDisk; use parent 'VMOMI::SnapshotFault'; use strict; use warnings; our @class_ancestors = ( 'SnapshotFault', 'VimFault', 'MethodFault', ); our @class_members = ( ); 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/MemorySnapshotOnIndependentDisk.pm
Perl
apache-2.0
440
# # 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 apps::openldap::ldap::mode::systemusage; use base qw(centreon::plugins::templates::counter); use strict; use warnings; use Digest::MD5 qw(md5_hex); use centreon::common::protocols::ldap::lib::ldap; sub prefix_operation_output { my ($self, %options) = @_; return 'Operation completed '; } sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ { name => 'global', type => 0, message_separator => ' - ', skipped_code => { -10 => 1 } }, { name => 'operation', type => 0, cb_prefix_output => 'prefix_operation_output', skipped_code => { -10 => 1 } }, ]; $self->{maps_counters}->{operation} = []; foreach ('search', 'add', 'bind', 'unbind', 'delete') { push @{$self->{maps_counters}->{operation}}, { label => 'op-' . $_, nlabel => 'system.operations.' . $_ . '.completed.count', set => { key_values => [ { name => 'operations_completed_' . $_, diff => 1 } ], output_template => $_ . ' %s', perfdatas => [ { template => '%.2f', min => 0 } ] } }; } $self->{maps_counters}->{global} = [ { label => 'con-current', nlabel => 'system.connections.current.count', set => { key_values => [ { name => 'connections_current' } ], output_template => 'Current connections %s', perfdatas => [ { template => '%s', min => 0 } ] } }, { label => 'con-total', nlabel => 'system.connections.total.count', set => { key_values => [ { name => 'connections_total', diff => 1 } ], output_template => 'Total connections %s', perfdatas => [ { template => '%s', min => 0 } ] } }, { label => 'threads-active', nlabel => 'system.threads.active.percentage', set => { key_values => [ { name => 'threads_active_prct' } ], output_template => 'Current active threads %.2f %%', perfdatas => [ { template => '%.2f', min => 0, max => 100, unit => '%' } ] } }, { label => 'traffic', nlabel => 'system.traffic.bytespersecond', set => { key_values => [ { name => 'traffic', per_second => 1 } ], output_template => 'traffic %s %s/s', output_change_bytes => 1, perfdatas => [ { template => '%s', min => 0, unit => 'B/s', cast_int => 1 } ] } } ]; } sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1, force_new_perfdata => 1); bless $self, $class; $options{options}->add_options(arguments => { 'hostname:s' => { name => 'hostname' }, 'search-base:s' => { name => 'search_base', default => 'cn=monitor' }, 'ldap-connect-options:s@' => { name => 'ldap_connect_options' }, 'ldap-starttls-options:s@' => { name => 'ldap_starttls_options' }, 'ldap-bind-options:s@' => { name => 'ldap_bind_options' }, 'tls' => { name => 'use_tls' }, 'username:s' => { name => 'username' }, 'password:s' => { name => 'password' }, 'timeout:s' => { name => 'timeout', default => '30' } }); return $self; } sub check_options { my ($self, %options) = @_; $self->SUPER::check_options(%options); if (!defined($self->{option_results}->{hostname})) { $self->{output}->add_option_msg(short_msg => 'Please set the hostname option'); $self->{output}->option_exit(); } if (defined($self->{option_results}->{username}) && $self->{option_results}->{username} ne '' && !defined($self->{option_results}->{password})) { $self->{output}->add_option_msg(short_msg => "Please set --password option."); $self->{output}->option_exit(); } } sub ldap_error { my ($self, %options) = @_; if ($options{code} == 1) { $self->{output}->output_add( severity => 'unknown', short_msg => $options{err_msg} ); $self->{output}->display(); $self->{output}->exit(); } } sub search_monitor { my ($self, %options) = @_; my ($ldap_handle, $code, $err_msg) = centreon::common::protocols::ldap::lib::ldap::connect( hostname => $self->{option_results}->{hostname}, username => $self->{option_results}->{username}, password => $self->{option_results}->{password}, timeout => $self->{option_results}->{timeout}, ldap_connect_options => $self->{option_results}->{ldap_connect_options}, use_tls => $self->{option_results}->{use_tls}, ldap_starttls_options => $self->{option_results}->{ldap_starttls_options}, ldap_bind_options => $self->{option_results}->{ldap_bind_options}, ); $self->ldap_error(code => $code, err_msg => $err_msg); (my $search_result, $code, $err_msg) = centreon::common::protocols::ldap::lib::ldap::search( ldap_handle => $ldap_handle, search_base => $self->{option_results}->{search_base}, search_filter => '(objectclass=*)', ldap_search_options => ['attrs=monitoredInfo', 'attrs=monitorCounter', 'attrs=MonitorOpCompleted'], ); $self->ldap_error(code => $code, err_msg => $err_msg); centreon::common::protocols::ldap::lib::ldap::quit(ldap_handle => $ldap_handle); return $search_result; } sub manage_selection { my ($self, %options) = @_; $self->{operation} = {}; $self->{global} = {}; my $search_result = $self->search_monitor(); foreach my $entry ($search_result->entries()) { my $dn = $entry->dn(); if ($dn =~ /cn=(Current|Total),cn=Connections/i) { $self->{global}->{'connections_' . lc($1)} = $entry->get_value('monitorCounter'); } elsif ($dn =~ /cn=(.*?),cn=Operations/i) { $self->{operation}->{'operations_completed_' . lc($1)} = $entry->get_value('MonitorOpCompleted'); } elsif ($dn =~ /cn=(Max|Active),cn=Threads/i) { $self->{global}->{'threads_' . lc($1)} = $entry->get_value('monitoredInfo'); } elsif ($dn =~ /cn=Bytes,cn=Statistics/i) { $self->{global}->{traffic} = $entry->get_value('monitorCounter'); } } if (scalar(keys %{$self->{global}}) <= 0) { $self->{output}->add_option_msg(short_msg => 'cannot get informations from OpenLDAP monitor backend'); $self->{output}->option_exit(); } $self->{global}->{threads_active_prct} = $self->{global}->{threads_active} * 100 / $self->{global}->{threads_max} if (defined($self->{global}->{threads_max}) && $self->{global}->{threads_max} > 0); $self->{cache_name} = 'openldap_' . $self->{mode} . '_' . $self->{option_results}->{hostname} . '_' . (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); } 1; __END__ =head1 MODE Check system usage (connections, threads, requests). =over 8 =item B<--hostname> IP Addr/FQDN of the openldap host (required). =item B<--search-base> Set the DN that is the base object entry relative to the backend monitor (Default: cn=monitor). =item B<--ldap-connect-options> Add custom ldap connect options: =over 16 =item B<Set SSL connection> --ldap-connect-options='scheme=ldaps' =item B<Set LDAP version 2> --ldap-connect-options='version=2' =back =item B<--ldap-starttls-options> Add custom start tls options (need --tls option): =over 16 =item B<An example> --ldap-starttls-options='verify=none' =back =item B<--ldap-bind-options> Add custom bind options (can force noauth) (not really useful now). =item B<--username> Specify username for authentification (can be a DN) =item B<--password> Specify password for authentification =item B<--timeout> Connection timeout in seconds (Default: 30) =item B<--warning-*> B<--critical-*> Thresholds. Can be: 'con-current', 'con-total', 'threads-active', 'traffic', 'op-add', 'op-search', 'op-bind', 'op-unbind', 'op-delete'. =back =cut
centreon/centreon-plugins
apps/openldap/ldap/mode/systemusage.pm
Perl
apache-2.0
9,152
# # 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 os::hpux::local::mode::storage; use base qw(centreon::plugins::templates::counter); use strict; use warnings; use centreon::plugins::misc; sub custom_usage_perfdata { my ($self, %options) = @_; my $label = 'used'; my $value_perf = $self->{result_values}->{used}; if (defined($self->{instance_mode}->{option_results}->{free})) { $label = 'free'; $value_perf = $self->{result_values}->{free}; } my %total_options = (); if ($self->{instance_mode}->{option_results}->{units} eq '%') { $total_options{total} = $self->{result_values}->{total}; $total_options{cast_int} = 1; } $self->{output}->perfdata_add( label => $label, unit => 'B', instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef, value => $value_perf, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, %total_options), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}, %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($self->{instance_mode}->{option_results}->{free})); if ($self->{instance_mode}->{option_results}->{units} eq '%') { $threshold_value = $self->{result_values}->{prct_used}; $threshold_value = $self->{result_values}->{prct_free} if (defined($self->{instance_mode}->{option_results}->{free})); } $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{thlabel}, 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) = @_; if ($options{new_datas}->{$self->{instance} . '_total'} == 0) { $self->{error_msg} = "total size is 0"; return -2; } $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; $self->{result_values}->{total} = $options{new_datas}->{$self->{instance} . '_total'}; $self->{result_values}->{used} = $options{new_datas}->{$self->{instance} . '_used'}; $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 => 'disks', type => 1, cb_prefix_output => 'prefix_disks_output', message_multiple => 'All storages are ok' } ]; $self->{maps_counters}->{disks} = [ { label => 'usage', set => { key_values => [ { name => 'display' }, { name => 'used' }, { name => 'total' } ], 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'), } }, ]; } sub prefix_disks_output { my ($self, %options) = @_; return "Storage '" . $options{instance_value}->{display} . "' "; } sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; $options{options}->add_options(arguments => { "hostname:s" => { name => 'hostname' }, "remote" => { name => 'remote' }, "ssh-option:s@" => { name => 'ssh_option' }, "ssh-path:s" => { name => 'ssh_path' }, "ssh-command:s" => { name => 'ssh_command', default => 'ssh' }, "timeout:s" => { name => 'timeout', default => 30 }, "sudo" => { name => 'sudo' }, "command:s" => { name => 'command', default => 'bdf' }, "command-path:s" => { name => 'command_path' }, "command-options:s" => { name => 'command_options', default => ' 2>&1' }, "filter-fs:s" => { name => 'filter_fs', }, "units:s" => { name => 'units', default => '%' }, "free" => { name => 'free' }, "name:s" => { name => 'name' }, "regexp" => { name => 'use_regexp' }, "regexp-isensitive" => { name => 'use_regexpi' }, "space-reservation:s" => { name => 'space_reservation' }, }); $self->{result} = {}; return $self; } sub manage_selection { my ($self, %options) = @_; my ($stdout, $exit_code) = centreon::plugins::misc::execute( output => $self->{output}, options => $self->{option_results}, sudo => $self->{option_results}->{sudo}, command => $self->{option_results}->{command}, command_path => $self->{option_results}->{command_path}, command_options => $self->{option_results}->{command_options}, no_quit => 1 ); $self->{disks} = {}; my @lines = split /\n/, $stdout; # Header not needed shift @lines; while (my $line = shift @lines) { # When the line is too long, the FS name is printed on a separated line if ($line !~ /^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)/) { $line .= " ".shift @lines; } next if ($line !~ /^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)/); my ($fs, $size, $used, $available, $percent, $mount) = ($1, $2, $3, $4, $5, $6); next if (defined($self->{option_results}->{filter_fs}) && $self->{option_results}->{filter_fs} ne '' && $fs !~ /$self->{option_results}->{filter_fs}/); next if (defined($self->{option_results}->{name}) && defined($self->{option_results}->{use_regexp}) && defined($self->{option_results}->{use_regexpi}) && $mount !~ /$self->{option_results}->{name}/i); next if (defined($self->{option_results}->{name}) && defined($self->{option_results}->{use_regexp}) && !defined($self->{option_results}->{use_regexpi}) && $mount !~ /$self->{option_results}->{name}/); next if (defined($self->{option_results}->{name}) && !defined($self->{option_results}->{use_regexp}) && !defined($self->{option_results}->{use_regexpi}) && $mount ne $self->{option_results}->{name}); $size *= 1024; if (defined($self->{option_results}->{space_reservation})) { $size = int($size - ($self->{option_results}->{space_reservation} * $size / 100)); } $self->{disks}->{$mount} = { display => $mount, fs => $fs, total => $size, used => $used * 1024 }; } if (scalar(keys %{$self->{disks}}) <= 0) { if ($exit_code != 0) { $self->{output}->output_add(long_msg => "command output:" . $stdout); } $self->{output}->add_option_msg(short_msg => "No storage found (filters or command issue)"); $self->{output}->option_exit(); } } 1; __END__ =head1 MODE Check storage usages. =over 8 =item B<--remote> Execute command remotely in 'ssh'. =item B<--hostname> Hostname to query (need --remote). =item B<--ssh-option> Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52'). =item B<--ssh-path> Specify ssh command path (default: none) =item B<--ssh-command> Specify ssh command (default: 'ssh'). Useful to use 'plink'. =item B<--timeout> Timeout in seconds for the command (Default: 30). =item B<--sudo> Use 'sudo' to execute the command. =item B<--command> Command to get information (Default: 'bdf'). Can be changed if you have output in a file. =item B<--command-path> Command path (Default: none). =item B<--command-options> Command options (Default: ' 2>&1'). =item B<--warning-usage> Threshold warning. =item B<--critical-usage> Threshold critical. =item B<--units> Units of thresholds (Default: '%') ('%', 'B'). =item B<--free> Thresholds are on free space left. =item B<--name> Set the storage mount point (empty means 'check all storages') =item B<--regexp> Allows to use regexp to filter storage mount point (with option --name). =item B<--regexp-isensitive> Allows to use regexp non case-sensitive (with --regexp). =item B<--filter-fs> Filter filesystem (regexp can be used). =item B<--space-reservation> Some filesystem has space reserved (like ext4 for root). The value is in percent of total (Default: none). =back =cut
Tpo76/centreon-plugins
os/hpux/local/mode/storage.pm
Perl
apache-2.0
10,462
%------------------------------------------------------------------------------ % % Arithmetic expressions % % Martin Dvorak % 1999 %------------------------------------------------------------------------------ % Init & libraries :- ['../../loadSWI']. % SWI Prolog %:- ['../../loadBP-2']. % BinProlog %------------------------------------------------------------------------------ % Demo %------------------------------------------------------------------------------ go1:- expr(s("1+(5+6)*(8+9-10)")+L), printf([L,nl]). % L= [[]> 78] % Yes % --- % some demo function: prumer(A,B,C,P):- P is (A+B+C)/3. go2:- expr(s("1+prumer(12,6,3)*(8+9-10)")+L), printf([L,nl]). % L= [[]> 50] % Yes % --- go3:- expr(s("1+prumer(12,6*2-6*2,prumer(3*4,1+1,1))")+L), printf([L,nl]). % L= [[]> 6.66667] % Yes %------------------------------------------------------------------------------ % Code %------------------------------------------------------------------------------ /** fact(?Wrapper) */ % - object: number, identifier, function or (...) fact(W):- W :-> ( int <: (poorIdf <&> parentheses(commaListOf expr)<?>) <@ evalFact <: parentheses(expr)). evalFact(L,R):- append(L,[R],F), :-@ F. %------------------------------------------------------------------------------ /** term(?Wrapper) */ % - chaining priority high: * and / sequence term(W):- W :-> fact lchainedBy (symbolA("*") <: symbolA("/")). %------------------------------------------------------------------------------ /** expr(?Wrapper) */ % chaining priority low: + and - sequence expr(W):- W :-> term lchainedBy (symbolA("+") <: symbolA("-")). %- EOF ------------------------------------------------------------------------
dvorka/parser-combinators
src/prolog/demo/expr/geneze/1chains.pl
Perl
apache-2.0
2,004
#!/usr/bin/perl package Pipeline::SmallRNA; use strict; use warnings; use CQS::FileUtils; use CQS::SystemUtils; use CQS::ConfigUtils; use CQS::ClassFactory; use Data::Dumper; use Hash::Merge qw( merge ); require Exporter; our @ISA = qw(Exporter); our %EXPORT_TAGS = ( 'all' => [qw(performSmallRNA performSmallRNATask)] ); our @EXPORT = ( @{ $EXPORT_TAGS{'all'} } ); our $VERSION = '0.01'; sub getSmallRNAConfig { my ($def) = @_; create_directory_or_die( $def->{target_dir} ); my $cluster = $def->{cluster}; if ( !defined $cluster ) { $cluster = "slurm"; } my $fastq_remove_N = $def->{fastq_remove_N}; my $run_cutadapt = $def->{run_cutadapt}; my $config = { general => { task_name => $def->{task_name}, cluster => $cluster }, files => $def->{files} }; my @individual = (); my @summary = (); my $source_ref = "files"; my $len_ref = "files"; if ( !defined $fastq_remove_N || $fastq_remove_N ) { $config->{fastq_remove_N} = { class => "CQS::FastqTrimmer", perform => $fastq_remove_N, target_dir => $def->{target_dir} . "/fastq_remove_N", option => "-n -z", extension => "_trim.fastq.gz", source_ref => "files", cqstools => $def->{cqstools}, cluster => $cluster, sh_direct => 1, pbs => { "email" => $def->{email}, "nodes" => "1:ppn=1", "walltime" => "2", "mem" => "10gb" } }; $source_ref = "fastq_remove_N"; $len_ref = "fastq_remove_N"; push @individual, "fastq_remove_N"; } my $qc = {}; if ( !defined $run_cutadapt || $run_cutadapt ) { my $adapter = $def->{adapter}; if ( !defined $adapter ) { $adapter = "TGGAATTCTCGGGTGCCAAGG"; } $qc = { fastqc_pre_trim => { class => "QC::FastQC", perform => 1, target_dir => $def->{target_dir} . "/fastqc_pre_trim", option => "", source_ref => $source_ref, cluster => $cluster, pbs => { "email" => $def->{email}, "nodes" => "1:ppn=1", "walltime" => "2", "mem" => "10gb" }, }, fastqc_pre_trim_summary => { class => "QC::FastQCSummary", perform => 1, target_dir => $def->{target_dir} . "/fastqc_pre_trim", cqstools => $def->{cqstools}, option => "", cluster => $cluster, pbs => { "email" => $def->{email}, "nodes" => "1:ppn=1", "walltime" => "2", "mem" => "10gb" }, }, cutadapt => { class => "Cutadapt", perform => 1, target_dir => $def->{target_dir} . "/cutadapt", option => "-O 10 -m " . $def->{min_read_length}, source_ref => $source_ref, adapter => $adapter, extension => "_clipped.fastq", sh_direct => 1, cluster => $cluster, pbs => { "email" => $def->{email}, "nodes" => "1:ppn=1", "walltime" => "24", "mem" => "20gb" }, }, fastqc_post_trim => { class => "QC::FastQC", perform => 1, target_dir => $def->{target_dir} . "/fastqc_post_trim", option => "", source_ref => [ "cutadapt", ".fastq.gz" ], cluster => $cluster, pbs => { "email" => $def->{email}, "nodes" => "1:ppn=1", "walltime" => "2", "mem" => "10gb" }, }, fastqc_post_trim_summary => { class => "QC::FastQCSummary", perform => 1, target_dir => $def->{target_dir} . "/fastqc_post_trim", cqstools => $def->{cqstools}, option => "", cluster => $cluster, pbs => { "email" => $def->{email}, "nodes" => "1:ppn=1", "walltime" => "2", "mem" => "10gb" }, } }; $source_ref = [ "cutadapt", ".fastq.gz" ]; $len_ref = "cutadapt"; push @individual, ( "fastqc_pre_trim", "cutadapt", "fastqc_post_trim" ); push @summary, ( "fastqc_pre_trim_summary", "fastqc_post_trim_summary" ); } else { $qc = { fastqc => { class => "QC::FastQC", perform => 1, target_dir => $def->{target_dir} . "/fastqc", option => "", source_ref => $source_ref, cluster => $cluster, pbs => { "email" => $def->{email}, "nodes" => "1:ppn=1", "walltime" => "2", "mem" => "10gb" }, }, fastqc_summary => { class => "QC::FastQCSummary", perform => 1, target_dir => $def->{target_dir} . "/fastqc", cqstools => $def->{cqstools}, option => "", cluster => $cluster, pbs => { "email" => $def->{email}, "nodes" => "1:ppn=1", "walltime" => "2", "mem" => "10gb" }, } }; push @individual, ("fastqc"); push @summary, ("fastqc_summary"); } $config = merge( $config, $qc ); #print Dumper($config); my $preparation = { fastq_len => { class => "FastqLen", perform => 1, target_dir => $def->{target_dir} . "/fastq_len", option => "", source_ref => $len_ref, cqstools => $def->{cqstools}, sh_direct => 1, cluster => $cluster, pbs => { "email" => $def->{email}, "nodes" => "1:ppn=1", "walltime" => "24", "mem" => "20gb" }, }, identical => { class => "FastqIdentical", perform => 1, target_dir => $def->{target_dir} . "/identical", option => "", source_ref => $source_ref, cqstools => $def->{cqstools}, extension => "_clipped_identical.fastq.gz", sh_direct => 1, cluster => $cluster, pbs => { "email" => $def->{email}, "nodes" => "1:ppn=1", "walltime" => "24", "mem" => "20gb" }, }, identical_sequence_table => { class => "CQS::SmallRNASequenceCountTable", perform => 1, target_dir => $def->{target_dir} . "/identical_sequence_count_table", option => "", source_ref => [ "identical", ".dupcount\$" ], cqs_tools => $def->{cqstools}, suffix => "_sequence", sh_direct => 1, cluster => $cluster, pbs => { "email" => $def->{email}, "nodes" => "1:ppn=1", "walltime" => "10", "mem" => "10gb" }, }, identical_NTA => { class => "CQS::FastqMirna", perform => 1, target_dir => $def->{target_dir} . "/identical_NTA", option => "-l " . $def->{min_read_length}, source_ref => [ "identical", ".fastq.gz\$" ], seqcount_ref => [ "identical", ".dupcount\$" ], cqstools => $def->{cqstools}, extension => "_clipped_identical_NTA.fastq.gz", sh_direct => 1, cluster => $cluster, pbs => { "email" => $def->{email}, "nodes" => "1:ppn=1", "walltime" => "24", "mem" => "20gb" }, }, #1 mismatch search, NTA bowtie1_genome_1mm_NTA => { class => "Bowtie1", perform => 1, target_dir => $def->{target_dir} . "/bowtie1_genome_1mm_NTA", option => $def->{bowtie1_option_1mm}, source_ref => [ "identical_NTA", ".fastq.gz\$" ], bowtie1_index => $def->{bowtie1_index}, samonly => 0, sh_direct => 1, cluster => $cluster, pbs => { "email" => $def->{email}, "nodes" => "1:ppn=" . $def->{max_thread}, "walltime" => "72", "mem" => "40gb" }, }, #not identical, for IGV bowtie1_genome_1mm_notidentical => { class => "Bowtie1", perform => 1, target_dir => $def->{target_dir} . "/bowtie1_genome_1mm_notidentical", option => $def->{bowtie1_option_1mm}, source_ref => $source_ref, bowtie1_index => $def->{bowtie1_index}, samonly => 0, sh_direct => 0, cluster => $cluster, pbs => { "email" => $def->{email}, "nodes" => "1:ppn=" . $def->{max_thread}, "walltime" => "72", "mem" => "40gb" }, }, }; push @individual, ( "fastq_len", "identical", "identical_NTA", "bowtie1_genome_1mm_NTA", "bowtie1_genome_1mm_notidentical" ); push @summary, ("identical_sequence_table"); $config = merge( $config, $preparation ); if ( defined $def->{coordinate} ) { push @individual, ( "bowtie1_genome_1mm_NTA_smallRNA_count", "bowtie1_genome_1mm_NTA_pmnames", "bowtie1_miRbase_pm", "bowtie1_miRbase_pm_count" ); push @summary, ( "bowtie1_genome_1mm_NTA_smallRNA_table", "bowtie1_genome_1mm_NTA_smallRNA_category", "bowtie1_miRbase_pm_table" ); my $count = { bowtie1_genome_1mm_NTA_smallRNA_count => { class => "CQS::SmallRNACount", perform => 1, target_dir => $def->{target_dir} . "/bowtie1_genome_1mm_NTA_smallRNA_count", option => $def->{smallrnacount_option}, source_ref => "bowtie1_genome_1mm_NTA", fastq_files_ref => "identical_NTA", seqcount_ref => [ "identical_NTA", ".dupcount\$" ], cqs_tools => $def->{cqstools}, coordinate_file => $def->{coordinate}, fasta_file => $def->{coordinate_fasta}, samtools => $def->{samtools}, sh_direct => 1, cluster => $cluster, pbs => { "email" => $def->{email}, "nodes" => "1:ppn=1", "walltime" => "72", "mem" => "40gb" }, }, bowtie1_genome_1mm_NTA_smallRNA_table => { class => "CQS::SmallRNATable", perform => 1, target_dir => $def->{target_dir} . "/bowtie1_genome_1mm_NTA_smallRNA_table", option => "", source_ref => [ "bowtie1_genome_1mm_NTA_smallRNA_count", ".mapped.xml" ], cqs_tools => $def->{cqstools}, prefix => "smallRNA_1mm_", sh_direct => 1, cluster => $cluster, pbs => { "email" => $def->{email}, "nodes" => "1:ppn=1", "walltime" => "10", "mem" => "10gb" }, }, bowtie1_genome_1mm_NTA_smallRNA_category => { class => "CQS::SmallRNACategory", perform => 1, target_dir => $def->{target_dir} . "/bowtie1_genome_1mm_NTA_smallRNA_category", option => "", source_ref => [ "bowtie1_genome_1mm_NTA_smallRNA_count", ".info\$" ], cqs_tools => $def->{cqstools}, sh_direct => 1, cluster => $cluster, pbs => { "email" => $def->{email}, "nodes" => "1:ppn=1", "walltime" => "72", "mem" => "40gb" }, }, #perfect match search to mirbase only bowtie1_genome_1mm_NTA_pmnames => { class => "Samtools::PerfectMappedReadNames", perform => 1, target_dir => $def->{target_dir} . "/bowtie1_genome_1mm_NTA_pmnames", option => "", source_ref => "bowtie1_genome_1mm_NTA", sh_direct => 1, cluster => $cluster, pbs => { "email" => $def->{email}, "nodes" => "1:ppn=" . $def->{max_thread}, "walltime" => "72", "mem" => "40gb" }, }, bowtie1_miRbase_pm => { class => "Alignment::Bowtie1", perform => 1, target_dir => $def->{target_dir} . "/bowtie1_miRbase_pm", option => $def->{bowtie1_option_pm}, source_ref => [ "identical", ".fastq.gz\$" ], bowtie1_index => $def->{bowtie1_miRBase_index}, samonly => 0, sh_direct => 1, cluster => $cluster, pbs => { "email" => $def->{email}, "nodes" => "1:ppn=" . $def->{max_thread}, "walltime" => "72", "mem" => "40gb" }, }, bowtie1_miRbase_pm_count => { class => "CQS::CQSChromosomeCount", perform => 1, target_dir => $def->{target_dir} . "/bowtie1_miRbase_pm_count", option => $def->{mirbase_count_option}, source_ref => "bowtie1_miRbase_pm", seqcount_ref => [ "identical", ".dupcount\$" ], perfect_mapped_name_ref => "bowtie1_genome_1mm_NTA_pmnames", cqs_tools => $def->{cqstools}, samtools => $def->{samtools}, sh_direct => 1, cluster => $cluster, pbs => { "email" => $def->{email}, "nodes" => "1:ppn=1", "walltime" => "72", "mem" => "40gb" }, }, bowtie1_miRbase_pm_table => { class => "CQS::CQSChromosomeTable", perform => 1, target_dir => $def->{target_dir} . "/bowtie1_miRbase_pm_table", option => "", source_ref => [ "bowtie1_miRbase_pm_count", ".xml" ], cqs_tools => $def->{cqstools}, prefix => "miRBase_pm_", sh_direct => 1, cluster => $cluster, pbs => { "email" => $def->{email}, "nodes" => "1:ppn=1", "walltime" => "10", "mem" => "10gb" }, }, sequencetask => { class => "CQS::SequenceTask", perform => 1, target_dir => $def->{target_dir} . "/sequencetask", option => "", source => { step1 => \@individual, step2 => \@summary, }, sh_direct => 0, cluster => $cluster, pbs => { "email" => $def->{email}, "nodes" => "1:ppn=" . $def->{max_thread}, "walltime" => "72", "mem" => "40gb" }, } }; $config = merge( $config, $count ); } return ($config); } sub performSmallRNA { my ( $def, $perform ) = @_; if ( !defined $perform ) { $perform = 1; } my $config = getSmallRNAConfig($def); if ($perform) { my $configFile = $def->{target_dir} . "/" . $def->{task_name} . ".config"; open( SH, ">$configFile" ) or die "Cannot create $configFile"; print SH Dumper($config); close(SH); performConfig($config); } return $config; } sub performSmallRNATask { my ( $def, $task ) = @_; my $config = getSmallRNAConfig($def); performTask( $config, $task ); return $config; } 1;
realizor/ngsperl
lib/Pipeline/SmallRNA.pm
Perl
apache-2.0
15,687
=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 XrefParser::GOSlimParser; use strict; use warnings; use DBI; use Carp; use base qw( XrefParser::BaseParser ); use Bio::EnsEMBL::Registry; my $reg = "Bio::EnsEMBL::Registry"; use XrefParser::Database; sub run_script { my ($self, $ref_arg) = @_; my $source_id = $ref_arg->{source_id}; my $species_id = $ref_arg->{species_id}; my $file = $ref_arg->{file}; my $verbose = $ref_arg->{verbose}; 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 $user = "ensro"; my $host; my $port = "3306"; my $dbname; my $pass; if($file =~ /host[=][>](\S+?)[,]/x){ $host = $1; } if($file =~ /port[=][>](\S+?)[,]/x){ $port = $1; } if($file =~ /dbname[=][>](\S+?)[,]/x){ $dbname = $1; } if($file =~ /pass[=][>](\S+?)[,]/x){ $pass = $1; } if($file =~ /user[=][>](\S+?)[,]/x){ $user = $1; } my $dbi2; if(!defined($dbname)){ $reg->load_registry_from_db( -host => $host, -user => $user, -group => "ontology"); my $dbc = $reg->get_adaptor("multi","ontology","GOTerm"); $dbi2 = $dbc->dbc; } else{ my $db = XrefParser::Database->new({ host => $host, port => $port, user => $user, dbname => $dbname, pass => $pass}); $dbi2 = $db->dbi(); } my $add_dependent_xref_sth = $self->dbi->prepare("INSERT INTO dependent_xref (master_xref_id,dependent_xref_id, linkage_annotation, linkage_source_id) VALUES (?, ?, 'IEA', $source_id)"); if(!defined($dbi2)){ print STDERR "Could not connect to ontology database\n"; return 1; } my (%go) = %{$self->get_valid_codes("GO",$species_id)}; my $count = 0; my $xref_sth = $dbi2->prepare("SELECT t.accession, s.name, s.accession FROM term t, term s, aux_GO_goslim_generic_map ts WHERE ts.term_id = t.term_id and ts.subset_term_id = s.term_id"); $xref_sth->execute() or croak( $dbi2->errstr() ); while ( my @row = $xref_sth->fetchrow_array() ) { my $term_acc = $row[0]; my $desc = $row[1]; my $subterm_acc = $row[2]; if(defined($go{$term_acc})){ foreach my $go_xref_id (@{$go{$term_acc}}) { my $xref_id = $self->add_xref({ acc => $subterm_acc, label => $subterm_acc, desc => $desc, source_id => $source_id, species_id => $species_id, info_type => "DEPENDENT"} ); $add_dependent_xref_sth->execute($go_xref_id, $xref_id); $count++; } } } $xref_sth->finish; print "Parsed GOSlim Generic identifiers from $file, added $count dependent_xrefs\n" if($verbose); return 0; } 1;
muffato/ensembl
misc-scripts/xref_mapping/XrefParser/GOSlimParser.pm
Perl
apache-2.0
3,468
package Paws::DeviceFarm::GetSuite; use Moose; has Arn => (is => 'ro', isa => 'Str', traits => ['NameInRequest'], request_name => 'arn' , required => 1); use MooseX::ClassAttribute; class_has _api_call => (isa => 'Str', is => 'ro', default => 'GetSuite'); class_has _returns => (isa => 'Str', is => 'ro', default => 'Paws::DeviceFarm::GetSuiteResult'); class_has _result_key => (isa => 'Str', is => 'ro'); 1; ### main pod documentation begin ### =head1 NAME Paws::DeviceFarm::GetSuite - Arguments for method GetSuite on Paws::DeviceFarm =head1 DESCRIPTION This class represents the parameters used for calling the method GetSuite on the AWS Device Farm service. Use the attributes of this class as arguments to method GetSuite. You shouldn't make instances of this class. Each attribute should be used as a named argument in the call to GetSuite. As an example: $service_obj->GetSuite(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 B<REQUIRED> Arn => Str The suite's ARN. =head1 SEE ALSO This class forms part of L<Paws>, documenting arguments for method GetSuite in L<Paws::DeviceFarm> =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/DeviceFarm/GetSuite.pm
Perl
apache-2.0
1,568
%jc%:- use_module(library('persdb_sql/pl2sql')). :- use_module(library('persdb_odbc/pl2sql_sql')). %jcf% :- use_module(library(strings)). :- multifile [relation/3,attribute/4]. :- data [relation/3,attribute/4]. relation(product,3,'PRODUCT'). attribute(1,'PRODUCT','ID',int). attribute(2,'PRODUCT','QUANTITY',int). attribute(3,'PRODUCT','NAME',string). main :- pl2sqlstring( f(L,K), ((product(L,N,a); product(L,N,b)), \+ product(2,3,b), L + 2 > avg(Y, Z^product(Z,Y,a)), K is N + max(X, product(X,2,b)) ), T), write_string(T). %% printqueries(T).
leuschel/ecce
www/CiaoDE/ciao/library/persdb_odbc/examples/pl2sql_example.pl
Perl
apache-2.0
605
# # highmon.pl - Highlight Monitoring for weechat 0.3.0 # Version 2.3.1 # # Add 'Highlight Monitor' buffer/bar to log all highlights in one spot # # Usage: # /highmon [help] | [monitor [channel [server]]] | [clean default|orphan|all] # Command wrapper for highmon commands # # /highmon clean default|orphan|all will clean the config section of default 'on' entries, # channels you are no longer joined, or both # # /highmon monitor [channel] [server] is used to toggle a highlight monitoring on and off, this # can be used in the channel buffer for the channel you wish to toggle, or be given # with arguments e.g. /highmon monitor #weechat freenode # # /set plugins.var.perl.highmon.alignment # The config setting "alignment" can be changed to; # "channel", "schannel", "nchannel", "channel,nick", "schannel,nick", "nchannel,nick" # to change how the monitor appears # The 'channel' value will show: "#weechat" # The 'schannel' value will show: "6" # The 'nchannel' value will show: "6:#weechat" # # /set plugins.var.perl.highmon.short_names # Setting this to 'on' will trim the network name from highmon, ala buffers.pl # # /set plugins.var.perl.highmon.merge_private # Setting this to 'on' will merge private messages to highmon's display # # /set plugins.var.perl.highmon.color_buf # This turns colored buffer names on or off, you can also set a single fixed color by using a weechat color name. # This *must* be a valid color name, or weechat will likely do unexpected things :) # # /set plugins.var.perl.highmon.hotlist_show # Setting this to 'on' will let the highmon buffer appear in hotlists # (status bar/buffer.pl) # # /set plugins.var.perl.highmon.away_only # Setting this to 'on' will only put messages in the highmon buffer when # you set your status to away # # /set plugins.var.perl.highmon.logging # Toggles logging status for highmon buffer (default: off) # # /set plugins.var.perl.highmon.output # Changes where output method of highmon; takes either "bar" or "buffer" (default; buffer) # /set plugins.var.perl.highmon.bar_lines # Changes the amount of lines the output bar will hold. # (Only appears once output has been set to bar, defaults to 10) # /set plugins.var.perl.highmon.bar_scrolldown # Toggles the bar scrolling at the bottom when new highlights are received # (Only appears once output has been set to bar, defaults to off) # # /set plugins.var.perl.highmon.nick_prefix # /set plugins.var.perl.highmon.nick_suffix # Sets the prefix and suffix chars in the highmon buffer # (Defaults to <> if nothing set, and blank if there is) # # servername.#channel # servername is the internal name for the server (set when you use /server add) # #channel is the channel name, (where # is whatever channel type that channel happens to be) # # History: # 2012-04-15, KenjiE20 <longbow@longbowslair.co.uk>: # v2.3.1: -fix: Colour tags in bar timestamp string # 2012-02-28, KenjiE20 <longbow@longbowslair.co.uk>: # v2.3: -feature: Added merge_private option to display private messages (default: off) # -fix: Channel name colours now show correctly when set to on # 2011-08-07, Sitaktif <romainchossart_at_gmail.com>: # v2.2.1: -feature: Add "bar_scrolldown" option to have the bar display the latest hl at anytime # -fix: Set up bar-specific config at startup if 'output' is already configured as 'bar' # 2010-12-22, KenjiE20 <longbow@longbowslair.co.uk>: # v2.2: -change: Use API instead of config to find channel colours, ready for 0.3.4 and 256 colours # 2010-12-13, idl0r & KenjiE20 <longbow@longbowslair.co.uk>: # v2.1.3: -fix: perl errors caused by bar line counter # -fix: Add command list to inbuilt help # 2010-09-30, KenjiE20 <longbow@longbowslair.co.uk>: # v2.1.2: -fix: logging config was not correctly toggling back on (thanks to sleo for noticing) # -version sync w/ chanmon # 2010-08-27, KenjiE20 <longbow@longbowslair.co.uk>: # v2.1: -feature: Add 'nchannel' option to alignment to display buffer and name # 2010-04-25, KenjiE20 <longbow@longbowslair.co.uk>: # v2.0: Release as version 2.0 # 2010-04-24, KenjiE20 <longbow@longbowslair.co.uk>: # v1.9: Rewrite for v2.0 # Bring feature set in line with chanmon 2.0 # -code change: Made more subs to shrink the code down in places # -fix: Stop highmon attempting to double load/hook # -fix: Add version dependant check for away status # 2010-01-25, KenjiE20 <longbow@longbowslair.co.uk>: # v1.7: -fixture: Let highmon be aware of nick_prefix/suffix # and allow custom prefix/suffix for chanmon buffer # (Defaults to <> if nothing set, and blank if there is) # (Thanks to m4v for these) # 2009-09-07, KenjiE20 <longbow@longbowslair.co.uk>: # v1.6: -feature: colored buffer names # -change: version sync with chanmon # 2009-09-05, KenjiE20 <longbow@longbowslair.co.uk>: # v1.2: -fix: disable buffer highlight # 2009-09-02, KenjiE20 <longbow@longbowslair.co.uk>: # v.1.1.1 -change: Stop unsightly text block on '/help' # 2009-08-10, KenjiE20 <longbow@longbowslair.co.uk>: # v1.1: In-client help added # 2009-08-02, KenjiE20 <longbow@longbowslair.co.uk>: # v1.0: Initial Public Release # Copyright (c) 2009 by KenjiE20 <longbow@longbowslair.co.uk> # # 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 3 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, see <http://www.gnu.org/licenses/>. # @bar_lines = (); @bar_lines_time = (); # Replicate info earlier for in-client help $highmonhelp = weechat::color("bold")."/highmon [help] | [monitor [channel [server]]] | [clean default|orphan|all]".weechat::color("-bold")." Command wrapper for highmon commands ".weechat::color("bold")."/highmon clean default|orphan|all".weechat::color("-bold")." will clean the config section of default 'on' entries, channels you are no longer joined, or both ".weechat::color("bold")."/highmon monitor [channel] [server]".weechat::color("-bold")." is used to toggle a highlight monitoring on and off, this can be used in the channel buffer for the channel you wish to toggle, or be given with arguments e.g. /highmon monitor #weechat freenode ".weechat::color("bold")."/set plugins.var.perl.highmon.alignment".weechat::color("-bold")." The config setting \"alignment\" can be changed to; \"channel\", \"schannel\", \"nchannel\", \"channel,nick\", \"schannel,nick\", \"nchannel,nick\" to change how the monitor appears The 'channel' value will show: \"#weechat\" The 'schannel' value will show: \"6\" The 'nchannel' value will show: \"6:#weechat\" ".weechat::color("bold")."/set plugins.var.perl.highmon.short_names".weechat::color("-bold")." Setting this to 'on' will trim the network name from highmon, ala buffers.pl ".weechat::color("bold")."/set plugins.var.perl.highmon.merge_private".weechat::color("-bold")." Setting this to 'on' will merge private messages to highmon's display ".weechat::color("bold")."/set plugins.var.perl.highmon.color_buf".weechat::color("-bold")." This turns colored buffer names on or off, you can also set a single fixed color by using a weechat color name. This ".weechat::color("bold")."must".weechat::color("-bold")." be a valid color name, or weechat will likely do unexpected things :) ".weechat::color("bold")."/set plugins.var.perl.highmon.hotlist_show".weechat::color("-bold")." Setting this to 'on' will let the highmon buffer appear in hotlists (status bar/buffer.pl) ".weechat::color("bold")."/set plugins.var.perl.highmon.away_only".weechat::color("-bold")." Setting this to 'on' will only put messages in the highmon buffer when you set your status to away ".weechat::color("bold")."/set plugins.var.perl.highmon.logging".weechat::color("-bold")." Toggles logging status for highmon buffer (default: off) ".weechat::color("bold")."/set plugins.var.perl.highmon.output".weechat::color("-bold")." Changes where output method of highmon; takes either \"bar\" or \"buffer\" (default; buffer) ".weechat::color("bold")."/set plugins.var.perl.highmon.bar_lines".weechat::color("-bold")." Changes the amount of lines the output bar will hold. (Only appears once output has been set to bar, defaults to 10) ".weechat::color("bold")."/set plugins.var.perl.highmon.bar_scrolldown".weechat::color("-bold")." Toggles the bar scrolling at the bottom when new highlights are received (Only appears once output has been set to bar, defaults to off) ".weechat::color("bold")."/set plugins.var.perl.highmon.nick_prefix".weechat::color("-bold")." ".weechat::color("bold")."/set plugins.var.perl.highmon.nick_suffix".weechat::color("-bold")." Sets the prefix and suffix chars in the highmon buffer (Defaults to <> if nothing set, and blank if there is) ".weechat::color("bold")."servername.#channel".weechat::color("-bold")." servername is the internal name for the server (set when you use /server add) #channel is the channel name, (where # is whatever channel type that channel happens to be)"; # Print verbose help sub print_help { weechat::print("", "\t".weechat::color("bold")."Highmon Help".weechat::color("-bold")."\n\n"); weechat::print("", "\t".$highmonhelp); return weechat::WEECHAT_RC_OK; } # Bar item build sub highmon_bar_build { # Get max lines $max_lines = weechat::config_get_plugin("bar_lines"); $max_lines = $max_lines ? $max_lines : 10; $str = ''; $align_num = 0; $count = 0; # Keep lines within max while ($#bar_lines > $max_lines) { shift(@bar_lines); shift(@bar_lines_time); } # So long as we have some lines, build a string if (@bar_lines) { # Build loop foreach(@bar_lines) { # Find max align needed $prefix_num = (index(weechat::string_remove_color($_, ""), " | ")); $align_num = $prefix_num if ($prefix_num > $align_num); } foreach(@bar_lines) { # Get align for this line $prefix_num = (index(weechat::string_remove_color($_, ""), " | ")); # Make string $str = $str.$bar_lines_time[$count]." ".(" " x ($align_num - $prefix_num)).$_."\n"; # Increment count for sync with time list $count++; } } return $str; } # Make a new bar sub highmon_bar_open { # Make the bar item weechat::bar_item_new("highmon", "highmon_bar_build", ""); $highmon_bar = weechat::bar_new ("highmon", "off", 100, "root", "", "bottom", "vertical", "vertical", 0, 0, "default", "cyan", "default", "on", "highmon"); return weechat::WEECHAT_RC_OK; } # Close bar sub highmon_bar_close { # Find if bar exists $highmon_bar = weechat::bar_search("highmon"); # If is does, close it if ($highmon_bar ne "") { weechat::bar_remove($highmon_bar); } # Find if bar item exists $highmon_bar_item = weechat::bar_item_search("highmon_bar"); # If is does, close it if ($highmon_bar_item ne "") { weechat::bar_remove($highmon_bar_item); } @bar_lines = (); return weechat::WEECHAT_RC_OK; } # Make a new buffer sub highmon_buffer_open { # Search for pre-existing buffer $highmon_buffer = weechat::buffer_search("perl", "highmon"); # Make a new buffer if ($highmon_buffer eq "") { $highmon_buffer = weechat::buffer_new("highmon", "highmon_buffer_input", "", "highmon_buffer_close", ""); } # Turn off notify, highlights if ($highmon_buffer ne "") { if (weechat::config_get_plugin("hotlist_show" eq "off")) { weechat::buffer_set($highmon_buffer, "notify", "0"); } weechat::buffer_set($highmon_buffer, "highlight_words", "-"); weechat::buffer_set($highmon_buffer, "title", "Highlight Monitor"); # Set no_log if (weechat::config_get_plugin("logging") eq "off") { weechat::buffer_set($highmon_buffer, "localvar_set_no_log", "1"); } } return weechat::WEECHAT_RC_OK; } # Buffer input has no action sub highmon_buffer_input { return weechat::WEECHAT_RC_OK; } # Close up sub highmon_buffer_close { $highmon_buffer = ""; return weechat::WEECHAT_RC_OK; } # Highmon command wrapper sub highmon_command_cb { $data = $_[0]; $buffer = $_[1]; $args = $_[2]; my $cmd = ''; my $arg = ''; if ($args ne "") { # Split argument up @arg_array = split(/ /,$args); # Take first as command $cmd = shift(@arg_array); # Rebuild string to pass to subs if (@arg_array) { $arg = join(" ", @arg_array); } } # Help command if ($cmd eq "" || $cmd eq "help") { print_help(); } # /monitor command elsif ($cmd eq "monitor") { highmon_toggle($data, $buffer, $arg); } # /highclean command elsif ($cmd eq "clean") { highmon_config_clean($data, $buffer, $arg); } return weechat::WEECHAT_RC_OK; } # Clean up config entries sub highmon_config_clean { $data = $_[0]; $buffer = $_[1]; $args = $_[2]; # Don't do anything if bad option given if ($args ne "default" && $args ne "orphan" && $args ne "all") { weechat::print("", "\thighmon.pl: Unknown option"); return weechat::WEECHAT_RC_OK; } @chans = (); # Load an infolist of highmon options $infolist = weechat::infolist_get("option", "", "*highmon*"); while (weechat::infolist_next($infolist)) { $name = weechat::infolist_string($infolist, "option_name"); $name =~ s/perl\.highmon\.(\w*)\.([#&\+!])(.*)/$1.$2$3/; if ($name =~ /^(.*)\.([#&\+!])(.*)$/) { $action = 0; # Clean up all 'on's if ($args eq "default" || $args eq "all") { # If value in config is "on" if (weechat::config_get_plugin($name) eq "on") { # Unset and if successful flag as changed $rc = weechat::config_unset_plugin($name); if ($rc eq weechat::WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED) { $action = 1; } } } # Clean non joined if ($args eq "orphan" || $args eq "all") { # If we can't find the buffer for this entry if (weechat::buffer_search("irc", $name) eq "") { # Unset and if successful flag as changed $rc = weechat::config_unset_plugin($name); if ($rc eq weechat::WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED) { $action = 1; } } } # Add changed entry names to list push (@chans, $name) if ($action); } } weechat::infolist_free($infolist); # If channels were cleaned from config if (@chans) { # If only one entry if (@chans == 1) { $str = "\thighmon.pl: Cleaned ".@chans." entry from the config:"; } else { $str = "\thighmon.pl: Cleaned ".@chans." entries from the config:"; } # Build a list of channels foreach(@chans) { $str = $str." ".$_; } # Print what happened weechat::print("",$str); } # Config seemed to be clean else { weechat::print("", "\thighmon.pl: No entries removed"); } return weechat::WEECHAT_RC_OK; } # Check config elements sub highmon_config_init { # Alignment default if (!(weechat::config_is_set_plugin ("alignment"))) { weechat::config_set_plugin("alignment", "channel"); } if (weechat::config_get_plugin("alignment") eq "") { weechat::config_set_plugin("alignment", "none"); } # Short name default if (!(weechat::config_is_set_plugin ("short_names"))) { weechat::config_set_plugin("short_names", "off"); } # Coloured names default if (!(weechat::config_is_set_plugin ("color_buf"))) { weechat::config_set_plugin("color_buf", "on"); } # Hotlist show default if (!(weechat::config_is_set_plugin ("hotlist_show"))) { weechat::config_set_plugin("hotlist_show", "off"); } # Away only default if (!(weechat::config_is_set_plugin ("away_only"))) { weechat::config_set_plugin("away_only", "off"); } # highmon log default if (!(weechat::config_is_set_plugin ("logging"))) { weechat::config_set_plugin("logging", "off"); } # Output default if (!(weechat::config_is_set_plugin ("output"))) { weechat::config_set_plugin("output", "buffer"); } # Private message merging if (!(weechat::config_is_set_plugin ("merge_private"))) { weechat::config_set_plugin("merge_private", "off"); } # Set bar config in case output was set to "bar" before even changing the setting if (weechat::config_get_plugin("output") eq "bar") { # Output bar lines default if (!(weechat::config_is_set_plugin ("bar_lines"))) { weechat::config_set_plugin("bar_lines", "10"); } if (!(weechat::config_is_set_plugin ("bar_scrolldown"))) { weechat::config_set_plugin("bar_scrolldown", "off"); } } # Check for exisiting prefix/suffix chars, and setup accordingly $prefix = weechat::config_get("irc.look.nick_prefix"); $prefix = weechat::config_string($prefix); $suffix = weechat::config_get("irc.look.nick_suffix"); $suffix = weechat::config_string($suffix); if (!(weechat::config_is_set_plugin("nick_prefix"))) { if ($prefix eq "" && $suffix eq "") { weechat::config_set_plugin("nick_prefix", "<"); } else { weechat::config_set_plugin("nick_prefix", ""); } } if (!(weechat::config_is_set_plugin("nick_suffix"))) { if ($prefix eq "" && $suffix eq "") { weechat::config_set_plugin("nick_suffix", ">"); } else { weechat::config_set_plugin("nick_suffix", ""); } } } # Get config updates sub highmon_config_cb { $point = $_[0]; $name = $_[1]; $value = $_[2]; $name =~ s/^plugins\.var\.perl\.highmon\.//; # Set logging on buffer if ($name eq "logging") { # Search for pre-existing buffer $highmon_buffer = weechat::buffer_search("perl", "highmon"); if ($value eq "off") { weechat::buffer_set($highmon_buffer, "localvar_set_no_log", "1"); } else { weechat::buffer_set($highmon_buffer, "localvar_del_no_log", ""); } } # Output changer elsif ($name eq "output") { if ($value eq "bar") { # Search for pre-existing buffer $highmon_buffer = weechat::buffer_search("perl", "highmon"); # Close if it exists if ($highmon_buffer ne "") { weechat::buffer_close($highmon_buffer) } # Output bar lines default if (!(weechat::config_is_set_plugin ("bar_lines"))) { weechat::config_set_plugin("bar_lines", "10"); } if (!(weechat::config_is_set_plugin ("bar_scrolldown"))) { weechat::config_set_plugin("bar_scrolldown", "off"); } # Make a bar if doesn't exist highmon_bar_open(); } elsif ($value eq "buffer") { # If a bar exists, close it highmon_bar_close(); # Open buffer highmon_buffer_open(); } } # Change if hotlist config changes elsif ($name eq "hotlist_show") { # Search for pre-existing buffer $highmon_buffer = weechat::buffer_search("perl", "highmon"); if ($value eq "off" && $highmon_buffer) { weechat::buffer_set($highmon_buffer, "notify", "0"); } elsif ($value ne "off" && $highmon_buffer) { weechat::buffer_set($highmon_buffer, "notify", "3"); } } return weechat::WEECHAT_RC_OK; } # Set up weechat hooks / commands sub highmon_hook { weechat::hook_print("", "", "", 0, "highmon_new_message", ""); weechat::hook_command("highclean", "Highmon config clean up", "default|orphan|all", " default: Cleans all config entries with the default \"on\" value\n orphan: Cleans all config entries for channels you aren't currently joined\n all: Does both defaults and orphan", "default|orphan|all", "highmon_config_clean", ""); weechat::hook_command("highmon", "Highmon help", "[help] | [monitor [channel [server]]] | [clean default|orphan|all]", " help: Print help on config options for highmon\n monitor: Toggles monitoring for a channel\n clean: Highmon config clean up (/highclean)", "help || monitor %(irc_channels) %(irc_servers) || clean default|orphan|all", "highmon_command_cb", ""); weechat::hook_config("plugins.var.perl.highmon.*", "highmon_config_cb", ""); } # Main body, Callback for hook_print sub highmon_new_message { my $net = ""; my $chan = ""; my $nick = ""; my $outstr = ""; my $window_displayed = ""; my $dyncheck = "0"; # DEBUG point # $string = "\t"."0: ".$_[0]." 1: ".$_[1]." 2: ".$_[2]." 3: ".$_[3]." 4: ".$_[4]." 5: ".$_[5]." 6: ".$_[6]." 7: ".$_[7]; # weechat::print("", "\t".$string); $cb_datap = $_[0]; $cb_bufferp = $_[1]; $cb_date = $_[2]; $cb_tags = $_[3]; $cb_disp = $_[4]; $cb_high = $_[5]; $cb_prefix = $_[6]; $cb_msg = $_[7]; # Only work on highlighted messages or private message when enabled if ($cb_high == "1" || (weechat::config_get_plugin("merge_private") eq "on" && $cb_tags =~ /notify_private/)) { # Pre bug #29618 (0.3.3) away detect if (weechat::info_get("version_number", "") <= 197120) { $away = ''; # Get infolist for this server $infolist = weechat::infolist_get("irc_server", "", weechat::buffer_get_string($cb_bufferp, "localvar_server")); while (weechat::infolist_next($infolist)) { # Get away message is is_away is on $away = weechat::infolist_string($infolist, "away_message") if (weechat::infolist_integer($infolist, "is_away")); } weechat::infolist_free($infolist); } # Post bug #29618 fix else { $away = weechat::buffer_get_string($cb_bufferp, "localvar_away"); } if (weechat::config_get_plugin("away_only") ne "on" || ($away ne "")) { # Check buffer name is an IRC channel $bufname = weechat::buffer_get_string($cb_bufferp, 'name'); if ($bufname =~ /(.*)\.([#&\+!])(.*)/) { # Are we running on this channel if (weechat::config_get_plugin($bufname) ne "off" && $cb_disp eq "1") { # Format nick # Line isn't action or topic notify if (!($cb_tags =~ /irc_action/) && !($cb_tags =~ /irc_topic/)) { # Strip nick colour $uncolnick = weechat::string_remove_color($cb_prefix, ""); # Format nick $nick = " ".weechat::config_get_plugin("nick_prefix").weechat::color("chat_highlight").$uncolnick.weechat::color("reset").weechat::config_get_plugin("nick_suffix"); } # Topic line elsif ($cb_tags =~ /irc_topic/) { $nick = " ".$cb_prefix.weechat::color("reset"); } # Action line else { $uncolnick = weechat::string_remove_color($cb_prefix, ""); $nick = weechat::color("chat_highlight").$uncolnick.weechat::color("reset"); } # Send to output highmon_print ($cb_msg, $cb_bufferp, $nick); } } # Or is private message elsif (weechat::config_get_plugin("merge_private") eq "on" && $cb_tags =~ /notify_private/) { # Strip nick colour $uncolnick = weechat::buffer_get_string($cb_bufferp, 'short_name'); # Format nick $nick = " ".weechat::config_get_plugin("nick_prefix").weechat::color("chat_highlight").$uncolnick.weechat::color("reset").weechat::config_get_plugin("nick_suffix"); #Send to output highmon_print ($cb_msg, $cb_bufferp, $nick); } } } return weechat::WEECHAT_RC_OK; } # Output formatter and printer takes (msg bufpointer nick) sub highmon_print { $cb_msg = $_[0]; my $cb_bufferp = $_[1] if ($_[1]); my $nick = $_[2] if ($_[2]); #Normal channel message if ($cb_bufferp && $nick) { # Format buffer name $bufname = format_buffer_name($cb_bufferp); # If alignment is #channel | nick msg if (weechat::config_get_plugin("alignment") eq "channel") { $nick =~ s/\s(.*)/$1/; # Build string $outstr = $bufname."\t".$nick." ".$cb_msg; } # or if it is channel number | nick msg elsif (weechat::config_get_plugin("alignment") eq "schannel") { $nick =~ s/\s(.*)/$1/; # Use channel number instead $bufname = weechat::color("chat_prefix_buffer").weechat::buffer_get_integer($cb_bufferp, 'number').weechat::color("reset"); # Build string $outstr = $bufname."\t".$nick." ".$cb_msg; } # or if it is number:#channel | nick msg elsif (weechat::config_get_plugin("alignment") eq "nchannel") { $nick =~ s/\s(.*)/$1/; # Place channel number in front of formatted name $bufname = weechat::color("chat_prefix_buffer").weechat::buffer_get_integer($cb_bufferp, 'number').":".weechat::color("reset").$bufname; # Build string $outstr = $bufname."\t".$nick." ".$cb_msg; } # or if it is #channel nick | msg elsif (weechat::config_get_plugin("alignment") eq "channel,nick") { # Build string $outstr = $bufname.":".$nick."\t".$cb_msg; } # or if it is channel number nick | msg elsif (weechat::config_get_plugin("alignment") eq "schannel,nick") { # Use channel number instead $bufname = weechat::color("chat_prefix_buffer").weechat::buffer_get_integer($cb_bufferp, 'number').weechat::color("reset"); # Build string $outstr = $bufname.":".$nick."\t".$cb_msg; } # or if it is number:#channel nick | msg elsif (weechat::config_get_plugin("alignment") eq "nchannel,nick") { # Place channel number in front of formatted name $bufname = weechat::color("chat_prefix_buffer").weechat::buffer_get_integer($cb_bufferp, 'number').":".weechat::color("reset").$bufname; # Build string $outstr = $bufname.":".$nick."\t".$cb_msg; } # or finally | #channel nick msg else { # Build string $outstr = "\t".$bufname.":".$nick." ".$cb_msg; } } # highmon channel toggle message elsif ($cb_bufferp && !$nick) { # Format buffer name $bufname = format_buffer_name($cb_bufferp); # If alignment is #channel * | * if (weechat::config_get_plugin("alignment") =~ /channel/) { # If it's actually channel number * | * if (weechat::config_get_plugin("alignment") =~ /schannel/) { # Use channel number instead $bufname = weechat::color("chat_prefix_buffer").weechat::buffer_get_integer($cb_bufferp, 'number').weechat::color("reset"); } # Or if it's actually number:#channel * | * if (weechat::config_get_plugin("alignment") =~ /nchannel/) { # Place channel number in front of formatted name $bufname = weechat::color("chat_prefix_buffer").weechat::buffer_get_integer($cb_bufferp, 'number').":".weechat::color("reset").$bufname; } $outstr = $bufname."\t".$cb_msg; } # or if alignment is | * else { $outstr = $bufname.": ".$cb_msg; } } # highmon dynmon elsif (!$cb_bufferp && !$nick) { $outstr = "\t".$cb_msg; } # Send string to buffer if (weechat::config_get_plugin("output") eq "buffer") { # Search for and confirm buffer $highmon_buffer = weechat::buffer_search("perl", "highmon"); # Print weechat::print($highmon_buffer, $outstr); } elsif (weechat::config_get_plugin("output") eq "bar") { # Add time string use POSIX qw(strftime); $time = strftime(weechat::config_string(weechat::config_get("weechat.look.buffer_time_format")), localtime); # Colourise if ($time =~ /\$\{\w+\}/) # Coloured string { while ($time =~ /\$\{(\w+)\}/) { $color = weechat::color($1); $time =~ s/\$\{\w+\}/$color/; } } else # Default string { $colour = weechat::color(weechat::config_string(weechat::config_get("weechat.color.chat_time_delimiters"))); $reset = weechat::color("reset"); $time =~ s/(\d*)(.)(\d*)/$1$colour$2$reset$3/g; } # Push updates to bar lists push (@bar_lines_time, $time); # Change tab char $delim = weechat::color(weechat::config_string(weechat::config_get("weechat.color.chat_delimiters")))." | ".weechat::color("reset"); $outstr =~ s/\t/$delim/; push (@bar_lines, $outstr); # Trigger update weechat::bar_item_update("highmon"); if (weechat::config_get_plugin("bar_scrolldown") eq "on") { weechat::command("", "/bar scroll highmon * ye") } } } # Start the output display sub highmon_start { if (weechat::config_get_plugin("output") eq "buffer") { highmon_buffer_open(); } elsif (weechat::config_get_plugin("output") eq "bar") { highmon_bar_open(); } } # Takes two optional args (channel server), toggles monitoring on/off sub highmon_toggle { $data = $_[0]; $buffer = $_[1]; $args = $_[2]; # Check if we've been told what channel to act on if ($args ne "") { # Split argument up @arg_array = split(/ /,$args); # Check if a server was given if ($arg_array[1]) { # Find matching $bufp = weechat::buffer_search("irc", $arg_array[1].".".$arg_array[0]); } else { $found_chans = 0; # Loop through defined servers $infolist = weechat::infolist_get("buffer", "", ""); while (weechat::infolist_next($infolist)) { # Only interesting in IRC buffers if (weechat::infolist_string($infolist, "plugin_name") eq "irc") { # Find buffers that maych $sname = weechat::infolist_string($infolist, "short_name"); if ($sname eq $arg_array[0]) { $found_chans++; $bufp = weechat::infolist_pointer($infolist, "pointer"); } } } weechat::infolist_free($infolist); # If the infolist found more than one channel, halt as we need to know which one if ($found_chans > 1) { weechat::print("", "Channel name is not unique, please define server"); return weechat::WEECHAT_RC_OK; } } # Something didn't return right if ($bufp eq "") { weechat::print("", "Could not find buffer"); return weechat::WEECHAT_RC_OK; } } else { # Get pointer from where we are $bufp = weechat::current_buffer(); } # Get buffer name $bufname = weechat::buffer_get_string($bufp, 'name'); # Test if buffer is an IRC channel if ($bufname =~ /(.*)\.([#&\+!])(.*)/) { if (weechat::config_get_plugin($bufname) eq "off") { # If currently off, set on weechat::config_set_plugin($bufname, "on"); # Send to output formatter highmon_print("Highlight Monitoring Enabled", $bufp); return weechat::WEECHAT_RC_OK; } elsif (weechat::config_get_plugin($bufname) eq "on" || weechat::config_get_plugin($bufname) eq "") { # If currently on, set off weechat::config_set_plugin($bufname, "off"); # Send to output formatter highmon_print("Highlight Monitoring Disabled", $bufp); return weechat::WEECHAT_RC_OK; } } } # Takes a buffer pointer and returns a formatted name sub format_buffer_name { $cb_bufferp = $_[0]; $bufname = weechat::buffer_get_string($cb_bufferp, 'name'); # Set colour from buffer name if (weechat::config_get_plugin("color_buf") eq "on") { # Determine what colour to use $color = weechat::info_get("irc_nick_color", $bufname); if (!$color) { $color = 0; @char_array = split(//,$bufname); foreach $char (@char_array) { $color += ord($char); } $color %= 10; $color = sprintf "weechat.color.chat_nick_color%02d", $color+1; $color = weechat::config_get($color); $color = weechat::config_string($color); $color = weechat::color($color); } # Private message just show network if (weechat::config_get_plugin("merge_private") eq "on" && weechat::buffer_get_string($cb_bufferp, "localvar_type") eq "private") { $bufname = weechat::buffer_get_string($cb_bufferp, "localvar_server"); } # Format name to short or 'nicename' elsif (weechat::config_get_plugin("short_names") eq "on") { $bufname = weechat::buffer_get_string($cb_bufferp, 'short_name'); } else { $bufname =~ s/(.*)\.([#&\+!])(.*)/$1$2$3/; } # Build a coloured string $bufname = $color.$bufname.weechat::color("reset"); } # User set colour name elsif (weechat::config_get_plugin("color_buf") ne "off") { # Private message just show network if (weechat::config_get_plugin("merge_private") eq "on" && weechat::buffer_get_string($cb_bufferp, "localvar_type") eq "private") { $bufname = weechat::buffer_get_string($cb_bufferp, "localvar_server"); } # Format name to short or 'nicename' elsif (weechat::config_get_plugin("short_names") eq "on") { $bufname = weechat::buffer_get_string($cb_bufferp, 'short_name'); } else { $bufname =~ s/(.*)\.([#&\+!])(.*)/$1$2$3/; } $color = weechat::config_get_plugin("color_buf"); $bufname = weechat::color($color).$bufname.weechat::color("reset"); } # Stick with default colour else { # Private message just show network if (weechat::config_get_plugin("merge_private") eq "on" && weechat::buffer_get_string($cb_bufferp, "localvar_type") eq "private") { $bufname = weechat::buffer_get_string($cb_bufferp, "localvar_server"); } # Format name to short or 'nicename' elsif (weechat::config_get_plugin("short_names") eq "on") { $bufname = weechat::buffer_get_string($cb_bufferp, 'short_name'); } else { $bufname =~ s/(.*)\.([#&\+!])(.*)/$1$2$3/; } } return $bufname; } # Check result of register, and attempt to behave in a sane manner if (!weechat::register("highmon", "KenjiE20", "2.3.1", "GPL3", "Highlight Monitor", "", "")) { # Double load weechat::print ("", "\tHighmon is already loaded"); return weechat::WEECHAT_RC_OK; } else { # Start everything highmon_hook(); highmon_config_init(); highmon_start(); }
marpaia/chef-osx
cookbooks/weechat/files/default/weechat/perl/highmon.pl
Perl
apache-2.0
32,837
#!/usr/bin/perl require "bptest.pl"; $skiptests = 0; # to skip early tests during development $timing = 0; # to use the same seed for timing tests # # This test covers the 8859-1, apple, TeX, troff, and HTML # character sets. It also tests the canon<->unicode routines # from bp-p-utils.pl. # # It does not test the 'none' and 'auto' character sets. The # auto character set doesn't exist, so it tests all the charsets # that are currently in bp. # # For each charset, we run through an iso string, which contains # the 8-bit characters 0 through 255. Before processing, certain # characters known to not be supported are removed (generally # 200-237 octal, but sometimes others). This is to prevent # excessive warnings and make the tests easier to perform. We # run the fromcanon code, then the tocanon code, and check to # see that the outputs match. # # In addition, we do the same thing for a long string of random # 8-bit characters, with the hope that this will test combinations # of characters we may not have thought of. # # Some formats also test a few special strings that we want to # test. These usually are selected by looking at the source # code for the converter, and checking any seemingly weak points. # # Lastly, we run these strings through a loop: # 88591->can->troff->can->html->can->88591 # and check that they match. After removing some characters, we try # 88591->can->troff->can->apple->can->html->can->88591 # # Generate a string with each 8bit character. $isostring = ''; for (0..255) { $isostring .= pack("C", $_); } # Generate a random string of 8bit characters. This should # be a long string so we test lots of things. # We do this because although testing the 8bit characters in order # should find any problems, certain character combinations can # cause problems if the routine isn't written properly. This may # stumble across a combination I didn't think of. # We must print out the seed if there is an error, so that we can # duplicate the string that caused the error. # # Argh! Perl4 coredumps with srand, and Perl5 coredumps with MSRNG. # I don't know why they crash. Perl5.002 seems to work with MSRNG. # $randstring = ''; $randstringlength = 16385; # should be at least 8192 $seed = undef; $seed = 42 if $timing; if ( ($] >= 5) && ($] < 5.002) ) { srand($seed) unless defined $seed; $n = 0; while ($n++ < $randstringlength) { $randstring .= pack("C", int(rand(256)) ); } } else { if (defined $seed) { $seed = &msrand($seed); } else { $seed = &msrand; } $n = 0; while ($n++ < $randstringlength) { $randstring .= pack("C", int(&mrand(256)) ); } } $randstring = $randstring x 5 if $timing; $cantest = "${bib'cs_ext}0026"; # The character conversion routines assume that the strings will # already be escaped. They also do not do any unescaping (except # for cs_ext and cs_meta, which they are supposed to handle). $isostring =~ s/$bib'cs_escape/$bib'cs_char_escape/go; $randstring =~ s/$bib'cs_escape/$bib'cs_char_escape/go; print "Testing character set routines, seed=$seed.\n"; if (!$skiptests) { &begintest("bib'unicode", 12); &check('', "bib'canon_to_unicode", '006C', 'l'); &check('', "bib'canon_to_unicode", '00C4', "\304"); &check('', "bib'canon_to_unicode", 'A1C6', "${bib'cs_ext}A1c6"); &check('', "bib'canon_to_unicode", '001C', $bib'cs_char_escape); &check('', "bib'unicode_to_canon", '5', '0035'); &check('', "bib'unicode_to_canon", "\xE9", '00E9'); &check('', "bib'unicode_to_canon", "${bib'cs_ext}CF8A", 'CF8A'); &check('', "bib'decimal_to_unicode", '0023', 35); &check('', "bib'decimal_to_unicode", '359B', 13723); &check('', "bib'unicode_to_decimal", 35, '0023'); &check('', "bib'unicode_to_decimal", 13723, '359b'); $f = $failed; for (0..512) { $can = &bib'unicode_to_canon(&bib'decimal_to_unicode($_)); $val = &bib'unicode_to_decimal(&bib'canon_to_unicode($can)); &check('nostatus,norun',"unicode loop", $_, $val); } $can = $val = undef; &check('partial', "unicode loop", $f, $failed); &endtest; # Test ISO-8859-1 &testcharset("8859-1", 5); $caniso = $isostring; &check('', "bp_cs_88591'tocanon", $caniso, $isostring); &check('', "bp_cs_88591'fromcanon", $isostring, $caniso); $canran = $randstring; &check('', "bp_cs_88591'tocanon", $canran, $randstring); &check('', "bp_cs_88591'fromcanon", $randstring, $canran); &check('', "bp_cs_88591'fromcanon", '&', $cantest); &endtest; # Test Apple &bib'errors('print'); &testcharset("apple", 5); # get rid of characters we don't handle. $c = $caniso; $c =~ s/[\200-\237\246\255\262\263\271\274\275\276\320\327\335\336\360\375\376]//g; $appiso = &bp_cs_apple'fromcanon($c); &check('partial', "apple'fromcanon", 1, 1); &check('', "bp_cs_apple'tocanon", $c, $appiso); $c = $appiso = undef; $c = $canran; $c =~ s/[\200-\237\246\255\262\263\271\274\275\276\320\327\335\336\360\375\376]//g; $appran = &bp_cs_apple'fromcanon($c); &check('partial', "apple'fromcanon", 1, 1); &check('', "bp_cs_apple'tocanon", $c, $appran); $c = $appran = undef; &check('', "bp_cs_apple'fromcanon", '&', $cantest); &endtest; # Test troff &testcharset("troff", 5); ($c = $caniso) =~ s/[\200-\237]//g; # troff can't handle these $troiso = &bp_cs_troff'fromcanon($c); &check('partial', "troff'fromcanon", 1, 1); &check('', "bp_cs_troff'tocanon", $c, $troiso); $c = $troiso = undef; ($c = $canran) =~ s/[\200-\237]//g; # troff can't handle these $troran = &bp_cs_troff'fromcanon($c); &check('partial', "troff'fromcanon", 1, 1); &check('', "bp_cs_troff'tocanon", $c, $troran); $c = $troran = undef; &check('', "bp_cs_troff'fromcanon", '&', $cantest); &endtest; # Test TeX &testcharset("tex", 3); ($c = $caniso) =~ s/[\200-\337]//g; # TeX can't handle these $texiso = &bp_cs_tex'fromcanon($c, 1); &check('partial', "tex'fromcanon", 1, 1); &check('', "bp_cs_tex'tocanon", $c, $texiso, 1); $c = $texiso = undef; # XXXXX Fix me! Something in here is broken. #($c = $canran) =~ s/[\200-\237]//g; #$texran = &bp_cs_tex'fromcanon($c, 1); #&check('partial', "tex'fromcanon", 1, 1); #&check('', "bp_cs_tex'tocanon", $c, $texran, 1); #$c = $texran = undef; &check('', "bp_cs_tex'fromcanon", '&', $cantest); &endtest; # Test HTML &testcharset("html", 7); &check('', "bp_cs_html'fromcanon", '&amp;', $cantest); &check('', "bp_cs_html'tocanon", pack("C", 199), '&Ccedil;' ); # This should generate a warning $oldwlev = $bib'glb_warn_level; $bib'glb_warn_level = 0; &check('', "bp_cs_html'tocanon", '', '&fo??o*+?/g;' ); $bib'glb_warn_level = $oldwlev; $c = $caniso; $htmiso = &bp_cs_html'fromcanon($c); &check('partial', "html'fromcanon", 1, 1); $t = &bp_cs_html'tocanon($htmiso); $t =~ s/${bib'cs_ext}0026/&/g; # html leaves & characters in extended form. &check('norun', "bp_cs_html'tocanon", $c, $t); $c = $htmiso = $t = undef; $c = $canran; $htmran = &bp_cs_html'fromcanon($c); &check('partial', "html'fromcanon", 1, 1); $t = &bp_cs_html'tocanon($htmran); $t =~ s/${bib'cs_ext}0026/&/g; # html leaves & characters in extended form. &check('norun', "bp_cs_html'tocanon", $c, $t); $c = $htmran = $t = undef; &endtest; } else { # end of skipped tests &bib'load_charset('8859-1'); &bib'load_charset('apple'); &bib'load_charset('troff'); &bib'load_charset('html'); } # Test troff / HTML / 8859-1 loop &begintest("cs conversion loops", 5); $f = $failed; for $iso ( "\000" .. "\377" ) { next if $iso =~ /[\200-\237]/; $can = &bp_cs_88591'tocanon($iso); $imd = &bp_cs_troff'fromcanon($can); $can = &bp_cs_troff'tocanon($imd); $imd = &bp_cs_html'fromcanon($can); $can = &bp_cs_html'tocanon($imd); $isr = &bp_cs_88591'fromcanon($can); &check('nostatus,norun', "cs conversion loop ".ord($iso), $iso, $isr); } $can = $imd = $isr = undef; &check('partial', "cs conversion loop", $f, $failed); $can = &bp_cs_88591'tocanon($isostring); $imd = &bp_cs_html'fromcanon($can); $can = &bp_cs_html'tocanon($imd); $isr = &bp_cs_88591'fromcanon($can); &check('norun', "iso conversion loop 1", $isostring, $isr); $can = $imd = $isr = undef; ($iso = $isostring) =~ s/[\200-\237]//g; $can = &bp_cs_88591'tocanon($iso); $imd = &bp_cs_troff'fromcanon($can); $can = &bp_cs_troff'tocanon($imd); $imd = &bp_cs_html'fromcanon($can); $can = &bp_cs_html'tocanon($imd); $isr = &bp_cs_88591'fromcanon($can); &check('norun', "iso conversion loop 2", $iso, $isr); $can = $imd = $isr = undef; # leave $iso $iso =~ s/[\200-\237\246\255\262\263\271\274\275\276\320\327\335\336\360\375\376]//g; $can = &bp_cs_88591'tocanon($iso); $imd = &bp_cs_troff'fromcanon($can); $can = &bp_cs_troff'tocanon($imd); $imd = &bp_cs_apple'fromcanon($can); $can = &bp_cs_apple'tocanon($imd); $imd = &bp_cs_html'fromcanon($can); $can = &bp_cs_html'tocanon($imd); $isr = &bp_cs_88591'fromcanon($can); &check('norun', "iso conversion loop 3", $iso, $isr); $can = $imd = $isr = $iso = undef; $can = &bp_cs_88591'tocanon($randstring); $imd = &bp_cs_html'fromcanon($can); $can = &bp_cs_html'tocanon($imd); $rnr = &bp_cs_88591'fromcanon($can); &check('norun', "random conversion loop 1", $randstring, $rnr); $can = $imd = $rnr = undef; &endtest; &bib'load_charset("html"); # We need an options routine for charsets... $bp_cs_html'opt_html3 = 1; &begintest("HTML 3", 4); &check('', "bp_cs_html'tocanon", pack("C", 222), '&THORN;' ); &check('', "bp_cs_html'tocanon", pack("C", 165), '&#165;' ); &check('', "bp_cs_html'tocanon", "${bib'cs_ext}AB7F", '&U+AB7F;' ); &check('', "bp_cs_html'fromcanon", '&U+AB7F;', "${bib'cs_ext}AB7F" ); &endtest;
gitpan/Bundle-PBib
lib/Biblio/bp/tests/newcset.pl
Perl
bsd-3-clause
9,506
% BEGIN LICENSE BLOCK % Version: CMPL 1.1 % % The contents of this file are subject to the Cisco-style Mozilla Public % License Version 1.1 (the "License"); you may not use this file except % in compliance with the License. You may obtain a copy of the License % at www.eclipse-clp.org/license. % % Software distributed under the License is distributed on an "AS IS" % basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See % the License for the specific language governing rights and limitations % under the License. % % The Original Code is The ECLiPSe Constraint Logic Programming System. % The Initial Developer of the Original Code is Cisco Systems, Inc. % Portions created by the Initial Developer are % Copyright (C) 2006 Cisco Systems, Inc. All Rights Reserved. % % Contributor(s): % % END LICENSE BLOCK :- lib(toplevel). gen_errors :- toplevel_init(tty), % to get the toplevel-related handlers installed open('err0.tex', write, errtex), p(1, 10), close(errtex), open('err1.tex', write, errtex), p(12, 39), close(errtex), open('err2.tex', write, errtex), p(40, 79), close(errtex), open('err3.tex', write, errtex), p(80, 109), close(errtex), open('err4.tex', write, errtex), p(110, 129), close(errtex), open('err5.tex', write, errtex), p(130, 149), close(errtex), open('err6.tex', write, errtex), p(150, 159), close(errtex), open('err7.tex', write, errtex), p(160, 169), close(errtex), open('err8.tex', write, errtex), p(170, 229), close(errtex), open('err9.tex', write, errtex), p(230, 269), close(errtex), open('err10.tex', write, errtex), p(270, 299), close(errtex). p(From, To) :- writeln(errtex, "\ % BEGIN LICENSE BLOCK % Version: CMPL 1.1 % % The contents of this file are subject to the Cisco-style Mozilla Public % License Version 1.1 (the \"License\"); you may not use this file except % in compliance with the License. You may obtain a copy of the License % at www.eclipse-clp.org/license. % % Software distributed under the License is distributed on an \"AS IS\" % basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See % the License for the specific language governing rights and limitations % under the License. % % The Original Code is The ECLiPSe Constraint Logic Programming System. % The Initial Developer of the Original Code is Cisco Systems, Inc. % Portions created by the Initial Developer are % Copyright (C) 2006 Cisco Systems, Inc. All Rights Reserved. % % Contributor(s): % % END LICENSE BLOCK "), current_error(E), E >= From, E =< To, error_id(E,M), get_error_handler(E,H,_), H \= boot_error/2, printf(errtex, "%d & %s & %w \\\\\n",[E,M,H]), fail. p(_, _).
BarrelfishOS/barrelfish
usr/eclipseclp/documents/userman/gen_error.pl
Perl
mit
2,824
package DBIx::Class::Storage::DBI::Sybase::ASE::NoBindVars; use warnings; use strict; use base qw/ DBIx::Class::Storage::DBI::NoBindVars DBIx::Class::Storage::DBI::Sybase::ASE /; use mro 'c3'; use List::Util 'first'; use Scalar::Util 'looks_like_number'; use namespace::clean; sub _init { my $self = shift; $self->disable_sth_caching(1); $self->_identity_method('@@IDENTITY'); $self->next::method (@_); } sub _fetch_identity_sql { 'SELECT ' . $_[0]->_identity_method } my $number = sub { looks_like_number $_[0] }; my $decimal = sub { $_[0] =~ /^ [-+]? \d+ (?:\.\d*)? \z/x }; my %noquote = ( int => sub { $_[0] =~ /^ [-+]? \d+ \z/x }, bit => => sub { $_[0] =~ /^[01]\z/ }, money => sub { $_[0] =~ /^\$ \d+ (?:\.\d*)? \z/x }, float => $number, real => $number, double => $number, decimal => $decimal, numeric => $decimal, ); sub interpolate_unquoted { my $self = shift; my ($type, $value) = @_; return $self->next::method(@_) if not defined $value or not defined $type; if (my $key = first { $type =~ /$_/i } keys %noquote) { return 1 if $noquote{$key}->($value); } elsif ($self->is_datatype_numeric($type) && $number->($value)) { return 1; } return $self->next::method(@_); } sub _prep_interpolated_value { my ($self, $type, $value) = @_; if ($type =~ /money/i && defined $value) { # change a ^ not followed by \$ to a \$ $value =~ s/^ (?! \$) /\$/x; } return $value; } 1; =head1 NAME DBIx::Class::Storage::DBI::Sybase::ASE::NoBindVars - Storage::DBI subclass for Sybase ASE without placeholder support =head1 DESCRIPTION If you're using this driver then your version of Sybase or the libraries you use to connect to it do not support placeholders. You can also enable this driver explicitly using: my $schema = SchemaClass->clone; $schema->storage_type('::DBI::Sybase::ASE::NoBindVars'); $schema->connect($dsn, $user, $pass, \%opts); See the discussion in L<< DBD::Sybase/Using ? Placeholders & bind parameters to $sth->execute >> for details on the pros and cons of using placeholders with this particular driver. One advantage of not using placeholders is that C<select @@identity> will work for obtaining the last insert id of an C<IDENTITY> column, instead of having to do C<select max(col)> in a transaction as the base Sybase driver does. When using this driver, bind variables will be interpolated (properly quoted of course) into the SQL query itself, without using placeholders. The caching of prepared statements is also explicitly disabled, as the interpolation renders it useless. =head1 FURTHER QUESTIONS? Check the list of L<additional DBIC resources|DBIx::Class/GETTING HELP/SUPPORT>. =head1 COPYRIGHT AND LICENSE This module is free software L<copyright|DBIx::Class/COPYRIGHT AND LICENSE> by the L<DBIx::Class (DBIC) authors|DBIx::Class/AUTHORS>. You can redistribute it and/or modify it under the same terms as the L<DBIx::Class library|DBIx::Class/COPYRIGHT AND LICENSE>.
ray66rus/vndrv
local/lib/perl5/DBIx/Class/Storage/DBI/Sybase/ASE/NoBindVars.pm
Perl
apache-2.0
3,010
package Google::Ads::AdWords::v201406::AdGroupServiceError::Reason; use strict; use warnings; sub get_xmlns { 'https://adwords.google.com/api/adwords/cm/v201406'}; # derivation by restriction use base qw( SOAP::WSDL::XSD::Typelib::Builtin::string); 1; __END__ =pod =head1 NAME =head1 DESCRIPTION Perl data type class for the XML Schema defined simpleType AdGroupServiceError.Reason from the namespace https://adwords.google.com/api/adwords/cm/v201406. The reasons for the adgroup service error. This clase is derived from SOAP::WSDL::XSD::Typelib::Builtin::string . SOAP::WSDL's schema implementation does not validate data, so you can use it exactly like it's base type. # Description of restrictions not implemented yet. =head1 METHODS =head2 new Constructor. =head2 get_value / set_value Getter and setter for the simpleType's value. =head1 OVERLOADING Depending on the simple type's base type, the following operations are overloaded Stringification Numerification Boolification Check L<SOAP::WSDL::XSD::Typelib::Builtin> for more information. =head1 AUTHOR Generated by SOAP::WSDL =cut
gitpan/GOOGLE-ADWORDS-PERL-CLIENT
lib/Google/Ads/AdWords/v201406/AdGroupServiceError/Reason.pm
Perl
apache-2.0
1,134
=pod =head1 NAME life_cycle-kdf - The KDF algorithm life-cycle =head1 DESCRIPTION All key derivation functions (KDFs) and pseudo random functions (PRFs) go through a number of stages in their life-cycle: =over 4 =item start This state represents the KDF/PRF before it has been allocated. It is the starting state for any life-cycle transitions. =item newed This state represents the KDF/PRF after it has been allocated. =item deriving This state represents the KDF/PRF when it is set up and capable of generating output. =item freed This state is entered when the KDF/PRF is freed. It is the terminal state for all life-cycle transitions. =back =head2 State Transition Diagram The usual life-cycle of a KDF/PRF is illustrated: =begin man +-------------------+ | start | +-------------------+ | | EVP_KDF_CTX_new v +-------------------+ | newed | <+ +-------------------+ | | | | EVP_KDF_derive | v | EVP_KDF_CTX_reset EVP_KDF_derive +-------------------+ | + - - - - - - - - | | | ' | deriving | | + - - - - - - - -> | | -+ +-------------------+ | | EVP_KDF_CTX_free v +-------------------+ | freed | +-------------------+ =end man =for html <img src="img/kdf.png"> =head2 Formal State Transitions This section defines all of the legal state transitions. This is the canonical list. =begin man Function Call ------------- Current State ------------- start newed deriving freed EVP_KDF_CTX_new newed EVP_KDF_derive deriving deriving EVP_KDF_CTX_free freed freed freed EVP_KDF_CTX_reset newed newed EVP_KDF_CTX_get_params newed deriving EVP_KDF_CTX_set_params newed deriving EVP_KDF_CTX_gettable_params newed deriving EVP_KDF_CTX_settable_params newed deriving =end man =begin html <table style="border:1px solid; border-collapse:collapse"> <tr><th style="border:1px solid" align="left">Function Call</th> <th style="border:1px solid" colspan="4">Current State</th></tr> <tr><th style="border:1px solid"></th> <th style="border:1px solid" align="center">start</th> <th style="border:1px solid" align="center">newed</th> <th style="border:1px solid" align="center">deriving</th> <th style="border:1px solid" align="center">freed</th></tr> <tr><th style="border:1px solid" align="left">EVP_KDF_CTX_new</th> <td style="border:1px solid" align="center">newed</td> <td style="border:1px solid"></td> <td style="border:1px solid"></td> <td style="border:1px solid"></td></tr> <tr><th style="border:1px solid" align="left">EVP_KDF_derive</th> <td style="border:1px solid" align="center"></td> <td style="border:1px solid" align="center">newed</td> <td style="border:1px solid" align="center">deriving</td> <td style="border:1px solid"></td></tr> <tr><th style="border:1px solid" align="left">EVP_KDF_CTX_free</th> <td style="border:1px solid" align="center"></td> <td style="border:1px solid" align="center">newed</td> <td style="border:1px solid" align="center">deriving</td> <td style="border:1px solid"></td></tr> <tr><th style="border:1px solid" align="left">EVP_KDF_CTX_reset</th> <td style="border:1px solid" align="center">freed</td> <td style="border:1px solid" align="center">freed</td> <td style="border:1px solid" align="center">freed</td> <td style="border:1px solid"></td></tr> <tr><th style="border:1px solid" align="left">EVP_KDF_CTX_get_params</th> <td style="border:1px solid" align="center"></td> <td style="border:1px solid" align="center">newed</td> <td style="border:1px solid" align="center">deriving</td> <td style="border:1px solid"></td></tr> <tr><th style="border:1px solid" align="left">EVP_KDF_CTX_set_params</th> <td style="border:1px solid" align="center"></td> <td style="border:1px solid" align="center">newed</td> <td style="border:1px solid" align="center">deriving</td> <td style="border:1px solid"></td></tr> <tr><th style="border:1px solid" align="left">EVP_KDF_CTX_gettable_params</th> <td style="border:1px solid" align="center"></td> <td style="border:1px solid" align="center">newed</td> <td style="border:1px solid" align="center">deriving</td> <td style="border:1px solid"></td></tr> <tr><th style="border:1px solid" align="left">EVP_KDF_CTX_settable_params</th> <td style="border:1px solid" align="center"></td> <td style="border:1px solid" align="center">newed</td> <td style="border:1px solid" align="center">deriving</td> <td style="border:1px solid"></td></tr> </table> =end html =head1 NOTES At some point the EVP layer will begin enforcing the transitions described herein. =head1 SEE ALSO L<provider-kdf(7)>, L<EVP_KDF(3)>. =head1 HISTORY The provider KDF interface was introduced in OpenSSL 3.0. =head1 COPYRIGHT Copyright 2021 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/man7/life_cycle-kdf.pod
Perl
bsd-3-clause
5,926
# IO::Select.pm # # Copyright (c) 1997-8 Graham Barr <gbarr@pobox.com>. All rights reserved. # This program is free software; you can redistribute it and/or # modify it under the same terms as Perl itself. package IO::Select; use strict; use warnings::register; use vars qw($VERSION @ISA); require Exporter; $VERSION = "1.22"; @ISA = qw(Exporter); # This is only so we can do version checking sub VEC_BITS () {0} sub FD_COUNT () {1} sub FIRST_FD () {2} sub new { my $self = shift; my $type = ref($self) || $self; my $vec = bless [undef,0], $type; $vec->add(@_) if @_; $vec; } sub add { shift->_update('add', @_); } sub remove { shift->_update('remove', @_); } sub exists { my $vec = shift; my $fno = $vec->_fileno(shift); return undef unless defined $fno; $vec->[$fno + FIRST_FD]; } sub _fileno { my($self, $f) = @_; return unless defined $f; $f = $f->[0] if ref($f) eq 'ARRAY'; ($f =~ /^\d+$/) ? $f : fileno($f); } sub _update { my $vec = shift; my $add = shift eq 'add'; my $bits = $vec->[VEC_BITS]; $bits = '' unless defined $bits; my $count = 0; my $f; foreach $f (@_) { my $fn = $vec->_fileno($f); if ($add) { next unless defined $fn; my $i = $fn + FIRST_FD; if (defined $vec->[$i]) { $vec->[$i] = $f; # if array rest might be different, so we update next; } $vec->[FD_COUNT]++; vec($bits, $fn, 1) = 1; $vec->[$i] = $f; } else { # remove if ( ! defined $fn ) { # remove if fileno undef'd $fn = 0; for my $fe (@{$vec}[FIRST_FD .. $#$vec]) { if (defined($fe) && $fe == $f) { $vec->[FD_COUNT]--; $fe = undef; vec($bits, $fn, 1) = 0; last; } ++$fn; } } else { my $i = $fn + FIRST_FD; next unless defined $vec->[$i]; $vec->[FD_COUNT]--; vec($bits, $fn, 1) = 0; $vec->[$i] = undef; } } $count++; } $vec->[VEC_BITS] = $vec->[FD_COUNT] ? $bits : undef; $count; } sub can_read { my $vec = shift; my $timeout = shift; my $r = $vec->[VEC_BITS]; defined($r) && (select($r,undef,undef,$timeout) > 0) ? handles($vec, $r) : (); } sub can_write { my $vec = shift; my $timeout = shift; my $w = $vec->[VEC_BITS]; defined($w) && (select(undef,$w,undef,$timeout) > 0) ? handles($vec, $w) : (); } sub has_exception { my $vec = shift; my $timeout = shift; my $e = $vec->[VEC_BITS]; defined($e) && (select(undef,undef,$e,$timeout) > 0) ? handles($vec, $e) : (); } sub has_error { warnings::warn("Call to deprecated method 'has_error', use 'has_exception'") if warnings::enabled(); goto &has_exception; } sub count { my $vec = shift; $vec->[FD_COUNT]; } sub bits { my $vec = shift; $vec->[VEC_BITS]; } sub as_string # for debugging { my $vec = shift; my $str = ref($vec) . ": "; my $bits = $vec->bits; my $count = $vec->count; $str .= defined($bits) ? unpack("b*", $bits) : "undef"; $str .= " $count"; my @handles = @$vec; splice(@handles, 0, FIRST_FD); for (@handles) { $str .= " " . (defined($_) ? "$_" : "-"); } $str; } sub _max { my($a,$b,$c) = @_; $a > $b ? $a > $c ? $a : $c : $b > $c ? $b : $c; } sub select { shift if defined $_[0] && !ref($_[0]); my($r,$w,$e,$t) = @_; my @result = (); my $rb = defined $r ? $r->[VEC_BITS] : undef; my $wb = defined $w ? $w->[VEC_BITS] : undef; my $eb = defined $e ? $e->[VEC_BITS] : undef; if(select($rb,$wb,$eb,$t) > 0) { my @r = (); my @w = (); my @e = (); my $i = _max(defined $r ? scalar(@$r)-1 : 0, defined $w ? scalar(@$w)-1 : 0, defined $e ? scalar(@$e)-1 : 0); for( ; $i >= FIRST_FD ; $i--) { my $j = $i - FIRST_FD; push(@r, $r->[$i]) if defined $rb && defined $r->[$i] && vec($rb, $j, 1); push(@w, $w->[$i]) if defined $wb && defined $w->[$i] && vec($wb, $j, 1); push(@e, $e->[$i]) if defined $eb && defined $e->[$i] && vec($eb, $j, 1); } @result = (\@r, \@w, \@e); } @result; } sub handles { my $vec = shift; my $bits = shift; my @h = (); my $i; my $max = scalar(@$vec) - 1; for ($i = FIRST_FD; $i <= $max; $i++) { next unless defined $vec->[$i]; push(@h, $vec->[$i]) if !defined($bits) || vec($bits, $i - FIRST_FD, 1); } @h; } 1; __END__ =head1 NAME IO::Select - OO interface to the select system call =head1 SYNOPSIS use IO::Select; $s = IO::Select->new(); $s->add(\*STDIN); $s->add($some_handle); @ready = $s->can_read($timeout); @ready = IO::Select->new(@handles)->can_read(0); =head1 DESCRIPTION The C<IO::Select> package implements an object approach to the system C<select> function call. It allows the user to see what IO handles, see L<IO::Handle>, are ready for reading, writing or have an exception pending. =head1 CONSTRUCTOR =over 4 =item new ( [ HANDLES ] ) The constructor creates a new object and optionally initialises it with a set of handles. =back =head1 METHODS =over 4 =item add ( HANDLES ) Add the list of handles to the C<IO::Select> object. It is these values that will be returned when an event occurs. C<IO::Select> keeps these values in a cache which is indexed by the C<fileno> of the handle, so if more than one handle with the same C<fileno> is specified then only the last one is cached. Each handle can be an C<IO::Handle> object, an integer or an array reference where the first element is an C<IO::Handle> or an integer. =item remove ( HANDLES ) Remove all the given handles from the object. This method also works by the C<fileno> of the handles. So the exact handles that were added need not be passed, just handles that have an equivalent C<fileno> =item exists ( HANDLE ) Returns a true value (actually the handle itself) if it is present. Returns undef otherwise. =item handles Return an array of all registered handles. =item can_read ( [ TIMEOUT ] ) Return an array of handles that are ready for reading. C<TIMEOUT> is the maximum amount of time to wait before returning an empty list, in seconds, possibly fractional. If C<TIMEOUT> is not given and any handles are registered then the call will block. =item can_write ( [ TIMEOUT ] ) Same as C<can_read> except check for handles that can be written to. =item has_exception ( [ TIMEOUT ] ) Same as C<can_read> except check for handles that have an exception condition, for example pending out-of-band data. =item count () Returns the number of handles that the object will check for when one of the C<can_> methods is called or the object is passed to the C<select> static method. =item bits() Return the bit string suitable as argument to the core select() call. =item select ( READ, WRITE, EXCEPTION [, TIMEOUT ] ) C<select> is a static method, that is you call it with the package name like C<new>. C<READ>, C<WRITE> and C<EXCEPTION> are either C<undef> or C<IO::Select> objects. C<TIMEOUT> is optional and has the same effect as for the core select call. The result will be an array of 3 elements, each a reference to an array which will hold the handles that are ready for reading, writing and have exceptions respectively. Upon error an empty list is returned. =back =head1 EXAMPLE Here is a short example which shows how C<IO::Select> could be used to write a server which communicates with several sockets while also listening for more connections on a listen socket use IO::Select; use IO::Socket; $lsn = IO::Socket::INET->new(Listen => 1, LocalPort => 8080); $sel = IO::Select->new( $lsn ); while(@ready = $sel->can_read) { foreach $fh (@ready) { if($fh == $lsn) { # Create a new socket $new = $lsn->accept; $sel->add($new); } else { # Process socket # Maybe we have finished with the socket $sel->remove($fh); $fh->close; } } } =head1 AUTHOR Graham Barr. Currently maintained by the Perl Porters. Please report all bugs to <perlbug@perl.org>. =head1 COPYRIGHT Copyright (c) 1997-8 Graham Barr <gbarr@pobox.com>. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut
operepo/ope
bin/usr/lib/perl5/core_perl/IO/Select.pm
Perl
mit
8,349
#!/usr/bin/env perl6 use v6; use lib 'ext/File__Find/lib/'; use lib 'ext/Shell__Command/lib'; use Shell::Command; %*ENV<PANDA_SUBMIT_TESTREPORTS>:delete; # Find old state file my ($prefix, $state-file, $reports-file); for grep(*.defined, %*ENV<DESTDIR>, %*CUSTOM_LIB<site home>) { if "$_/panda/state".IO.e { $prefix = $_; $state-file = "$_/panda/state"; $reports-file = "$_/panda/reports.{$*PERL.compiler.version}" if "$_/panda/reports.{$*PERL.compiler.version}".IO.e; } } if not $state-file.defined { say "No need to rebootstrap, running normal bootstrap"; shell "$*EXECUTABLE bootstrap.pl"; exit 0; } # Save a copy of the old state file to be written *after* bootstrapping again my $old-state = slurp $state-file; my $old-reports = slurp $reports-file if $reports-file; # Find modules that were installed by request # (as opposed to just for dependency resolution) my @modules; given open($state-file) { for .lines() -> $line { my ($name, $state) = split /\s/, $line; next if $name eq any(<File::Find Shell::Command JSON::Tiny panda>); if $state eq 'installed' { @modules.push: $name; } } .close; } # Clean old directories, boostrap a fresh panda, # and reinstall all manually-installed modules rm_f(dir(~$prefix)».grep({$_.basename ~~ /^ \d+ | MANIFEST $/})) if $prefix.IO.d; rm_rf "$prefix/lib"; rm_rf "$prefix/panda"; shell "$*EXECUTABLE bootstrap.pl"; say "==> Reinstalling @modules[]"; shell "$*EXECUTABLE bin/panda install @modules[]"; # Save the backup state file back to $prefix/panda/ spurt "$state-file.bak", $old-state if $old-state; spurt $reports-file, $old-reports if $old-reports;
cygx/panda
rebootstrap.pl
Perl
mit
1,715
package DDG::Goodie::IsAwesome::abrahimladha; # ABSTRACT: abrahimladha's first Goodie use DDG::Goodie; use strict; zci answer_type => "is_awesome_abrahimladha"; zci is_cached => 1; triggers start => "duckduckhack abrahimladha"; handle remainder => sub { return if $_; return "abrahimladha is awesome and has successfully completed the DuckDuckHack Goodie tutorial!"; }; 1;
roxxup/zeroclickinfo-longtail
lib/DDG/Goodie/IsAwesome/abrahimladha.pm
Perl
apache-2.0
389
#------------------------------------------------------------------------------ # File: ITC.pm # # Description: Read iTunes Cover Flow meta information # # Revisions: 01/12/2008 - P. Harvey Created # # References: 1) http://www.waldoland.com/dev/Articles/ITCFileFormat.aspx # 2) http://www.falsecognate.org/2007/01/deciphering_the_itunes_itc_fil/ #------------------------------------------------------------------------------ package Image::ExifTool::ITC; use strict; use vars qw($VERSION); use Image::ExifTool qw(:DataAccess :Utils); $VERSION = '1.02'; sub ProcessITC($$); # tags used in ITC files %Image::ExifTool::ITC::Main = ( NOTES => 'This information is found in iTunes Cover Flow data files.', itch => { SubDirectory => { TagTable => 'Image::ExifTool::ITC::Header' } }, item => { SubDirectory => { TagTable => 'Image::ExifTool::ITC::Item' } }, data => { Name => 'ImageData', Notes => 'embedded JPEG or PNG image, depending on ImageType', }, ); # ITC header information %Image::ExifTool::ITC::Header = ( PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData, GROUPS => { 2 => 'Image' }, 0x10 => { Name => 'DataType', Format => 'undef[4]', PrintConv => { artw => 'Artwork' }, }, ); # ITC item information %Image::ExifTool::ITC::Item = ( PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData, GROUPS => { 2 => 'Image' }, FORMAT => 'int32u', FIRST_ENTRY => 0, 0 => { Name => 'LibraryID', Format => 'undef[8]', ValueConv => 'uc unpack "H*", $val', }, 2 => { Name => 'TrackID', Format => 'undef[8]', ValueConv => 'uc unpack "H*", $val', }, 4 => { Name => 'DataLocation', Format => 'undef[4]', PrintConv => { down => 'Downloaded Separately', locl => 'Local Music File', }, }, 5 => { Name => 'ImageType', Format => 'undef[4]', ValueConv => { # (not PrintConv because the unconverted JPEG value is nasty) 'PNGf' => 'PNG', "\0\0\0\x0d" => 'JPEG', }, }, 7 => 'ImageWidth', 8 => 'ImageHeight', ); #------------------------------------------------------------------------------ # Process an iTunes Cover Flow (ITC) file # Inputs: 0) ExifTool object reference, 1) Directory information reference # Returns: 1 on success, 0 if this wasn't a valid ITC file sub ProcessITC($$) { my ($et, $dirInfo) = @_; my $raf = $$dirInfo{RAF}; my $rtnVal = 0; my ($buff, $err, $pos, $tagTablePtr, %dirInfo); # loop through all blocks in this image for (;;) { # read the block header my $n = $raf->Read($buff, 8); unless ($n == 8) { # no error if we reached the EOF normally undef $err unless $n; last; } my ($size, $tag) = unpack('Na4', $buff); if ($rtnVal) { last unless $size >= 8 and $size < 0x80000000; } else { # check to be sure this is a valid ITC image # (first block must be 'itch') last unless $tag eq 'itch'; last unless $size >= 0x1c and $size < 0x10000; $et->SetFileType(); SetByteOrder('MM'); $rtnVal = 1; # this is an ITC file $err = 1; # format error unless we read to EOF } if ($tag eq 'itch') { $pos = $raf->Tell(); $size -= 8; # size of remaining data in block $raf->Read($buff,$size) == $size or last; # extract header information %dirInfo = ( DirName => 'ITC Header', DataPt => \$buff, DataPos => $pos, ); my $tagTablePtr = GetTagTable('Image::ExifTool::ITC::Header'); $et->ProcessDirectory(\%dirInfo, $tagTablePtr); } elsif ($tag eq 'item') { # don't want to read the entire item data (includes image) $size > 12 or last; $raf->Read($buff, 4) == 4 or last; my $len = unpack('N', $buff); $len >= 0xd0 and $len <= $size or last; $size -= $len; # size of data after item header $len -= 12; # length of remaining item header # read in 4-byte blocks until we find the null terminator # (this is just a guess about how to parse this variable-length part) while ($len >= 4) { $raf->Read($buff, 4) == 4 or last; $len -= 4; last if $buff eq "\0\0\0\0"; } last if $len < 4; $pos = $raf->Tell(); $raf->Read($buff, $len) == $len or last; unless ($len >= 0xb4 and substr($buff, 0xb0, 4) eq 'data') { $et->Warn('Parsing error. Please submit this ITC file for testing'); last; } %dirInfo = ( DirName => 'ITC Item', DataPt => \$buff, DataPos => $pos, ); $tagTablePtr = GetTagTable('Image::ExifTool::ITC::Item'); $et->ProcessDirectory(\%dirInfo, $tagTablePtr); # extract embedded image $pos += $len; if ($size > 0) { $tagTablePtr = GetTagTable('Image::ExifTool::ITC::Main'); my $tagInfo = $et->GetTagInfo($tagTablePtr, 'data'); my $image = $et->ExtractBinary($pos, $size, $$tagInfo{Name}); $et->FoundTag($tagInfo, \$image); # skip the rest of the block if necessary $raf->Seek($pos+$size, 0) or last } elsif ($size < 0) { last; } } else { $et->VPrint(0, "Unknown $tag block ($size bytes)\n"); $raf->Seek($size-8, 1) or last; } } $err and $et->Warn('ITC file format error'); return $rtnVal; } 1; # end __END__ =head1 NAME Image::ExifTool::ITC - Read iTunes Cover Flow meta information =head1 SYNOPSIS This module is used by Image::ExifTool =head1 DESCRIPTION This module contains the routines required by Image::ExifTool to read meta information (including artwork images) from iTunes Cover Flow files. =head1 AUTHOR Copyright 2003-2015, 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<http://www.waldoland.com/dev/Articles/ITCFileFormat.aspx> =item L<http://www.falsecognate.org/2007/01/deciphering_the_itunes_itc_fil/> =back =head1 SEE ALSO L<Image::ExifTool::TagNames/ITC Tags>, L<Image::ExifTool(3pm)|Image::ExifTool> =cut
mudasobwa/exifice
vendor/Image-ExifTool-10.02/lib/Image/ExifTool/ITC.pm
Perl
mit
6,793
package LWP::ConnCache; use strict; use vars qw($VERSION $DEBUG); $VERSION = "6.15"; sub new { my($class, %cnf) = @_; my $total_capacity = 1; if (exists $cnf{total_capacity}) { $total_capacity = delete $cnf{total_capacity}; } if (%cnf && $^W) { require Carp; Carp::carp("Unrecognised options: @{[sort keys %cnf]}") } my $self = bless { cc_conns => [] }, $class; $self->total_capacity($total_capacity); $self; } sub deposit { my($self, $type, $key, $conn) = @_; push(@{$self->{cc_conns}}, [$conn, $type, $key, time]); $self->enforce_limits($type); return; } sub withdraw { my($self, $type, $key) = @_; my $conns = $self->{cc_conns}; for my $i (0 .. @$conns - 1) { my $c = $conns->[$i]; next unless $c->[1] eq $type && $c->[2] eq $key; splice(@$conns, $i, 1); # remove it return $c->[0]; } return undef; } sub total_capacity { my $self = shift; my $old = $self->{cc_limit_total}; if (@_) { $self->{cc_limit_total} = shift; $self->enforce_limits; } $old; } sub capacity { my $self = shift; my $type = shift; my $old = $self->{cc_limit}{$type}; if (@_) { $self->{cc_limit}{$type} = shift; $self->enforce_limits($type); } $old; } sub enforce_limits { my($self, $type) = @_; my $conns = $self->{cc_conns}; my @types = $type ? ($type) : ($self->get_types); for $type (@types) { next unless $self->{cc_limit}; my $limit = $self->{cc_limit}{$type}; next unless defined $limit; for my $i (reverse 0 .. @$conns - 1) { next unless $conns->[$i][1] eq $type; if (--$limit < 0) { $self->dropping(splice(@$conns, $i, 1), "$type capacity exceeded"); } } } if (defined(my $total = $self->{cc_limit_total})) { while (@$conns > $total) { $self->dropping(shift(@$conns), "Total capacity exceeded"); } } } sub dropping { my($self, $c, $reason) = @_; print "DROPPING @$c [$reason]\n" if $DEBUG; } sub drop { my($self, $checker, $reason) = @_; if (ref($checker) ne "CODE") { # make it so if (!defined $checker) { $checker = sub { 1 }; # drop all of them } elsif (_looks_like_number($checker)) { my $age_limit = $checker; my $time_limit = time - $age_limit; $reason ||= "older than $age_limit"; $checker = sub { $_[3] < $time_limit }; } else { my $type = $checker; $reason ||= "drop $type"; $checker = sub { $_[1] eq $type }; # match on type } } $reason ||= "drop"; local $SIG{__DIE__}; # don't interfere with eval below local $@; my @c; for (@{$self->{cc_conns}}) { my $drop; eval { if (&$checker(@$_)) { $self->dropping($_, $reason); $drop++; } }; push(@c, $_) unless $drop; } @{$self->{cc_conns}} = @c; } sub prune { my $self = shift; $self->drop(sub { !shift->ping }, "ping"); } sub get_types { my $self = shift; my %t; $t{$_->[1]}++ for @{$self->{cc_conns}}; return keys %t; } sub get_connections { my($self, $type) = @_; my @c; for (@{$self->{cc_conns}}) { push(@c, $_->[0]) if !$type || ($type && $type eq $_->[1]); } @c; } sub _looks_like_number { $_[0] =~ /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/; } 1; __END__ =head1 NAME LWP::ConnCache - Connection cache manager =head1 NOTE This module is experimental. Details of its interface is likely to change in the future. =head1 SYNOPSIS use LWP::ConnCache; my $cache = LWP::ConnCache->new; $cache->deposit($type, $key, $sock); $sock = $cache->withdraw($type, $key); =head1 DESCRIPTION The C<LWP::ConnCache> class is the standard connection cache manager for LWP::UserAgent. The following basic methods are provided: =over =item $cache = LWP::ConnCache->new( %options ) This method constructs a new C<LWP::ConnCache> object. The only option currently accepted is 'total_capacity'. If specified it initialize the total_capacity option. It defaults to the value 1. =item $cache->total_capacity( [$num_connections] ) Get/sets the number of connection that will be cached. Connections will start to be dropped when this limit is reached. If set to C<0>, then all connections are immediately dropped. If set to C<undef>, then there is no limit. =item $cache->capacity($type, [$num_connections] ) Get/set a limit for the number of connections of the specified type that can be cached. The $type will typically be a short string like "http" or "ftp". =item $cache->drop( [$checker, [$reason]] ) Drop connections by some criteria. The $checker argument is a subroutine that is called for each connection. If the routine returns a TRUE value then the connection is dropped. The routine is called with ($conn, $type, $key, $deposit_time) as arguments. Shortcuts: If the $checker argument is absent (or C<undef>) all cached connections are dropped. If the $checker is a number then all connections untouched that the given number of seconds or more are dropped. If $checker is a string then all connections of the given type are dropped. The $reason argument is passed on to the dropped() method. =item $cache->prune Calling this method will drop all connections that are dead. This is tested by calling the ping() method on the connections. If the ping() method exists and returns a FALSE value, then the connection is dropped. =item $cache->get_types This returns all the 'type' fields used for the currently cached connections. =item $cache->get_connections( [$type] ) This returns all connection objects of the specified type. If no type is specified then all connections are returned. In scalar context the number of cached connections of the specified type is returned. =back The following methods are called by low-level protocol modules to try to save away connections and to get them back. =over =item $cache->deposit($type, $key, $conn) This method adds a new connection to the cache. As a result other already cached connections might be dropped. Multiple connections with the same $type/$key might added. =item $conn = $cache->withdraw($type, $key) This method tries to fetch back a connection that was previously deposited. If no cached connection with the specified $type/$key is found, then C<undef> is returned. There is not guarantee that a deposited connection can be withdrawn, as the cache manger is free to drop connections at any time. =back The following methods are called internally. Subclasses might want to override them. =over =item $conn->enforce_limits([$type]) This method is called with after a new connection is added (deposited) in the cache or capacity limits are adjusted. The default implementation drops connections until the specified capacity limits are not exceeded. =item $conn->dropping($conn_record, $reason) This method is called when a connection is dropped. The record belonging to the dropped connection is passed as the first argument and a string describing the reason for the drop is passed as the second argument. The default implementation makes some noise if the $LWP::ConnCache::DEBUG variable is set and nothing more. =back =head1 SUBCLASSING For specialized cache policy it makes sense to subclass C<LWP::ConnCache> and perhaps override the deposit(), enforce_limits() and dropping() methods. The object itself is a hash. Keys prefixed with C<cc_> are reserved for the base class. =head1 SEE ALSO L<LWP::UserAgent> =head1 COPYRIGHT Copyright 2001 Gisle Aas. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
jkb78/extrajnm
local/lib/perl5/LWP/ConnCache.pm
Perl
mit
7,621
use strict; use File::Temp; # test trns_transform_KBaseGenomes.Genome-to-EMBL.pl my $temp = File::Temp->new(); close($temp); my @url = ("--url", "http://tutorial.theseed.org/services/genome_annotation"); my @cmd = ('trns_transform_KBaseGenomes.Genome-to-EMBL', '-i', 'Rhodobacter_sphaeroides_2.4.1', '--workspace', 'KBaseExampleData', '-o', "$temp", @url); my $rc = system(@cmd); if ($rc != 0) { die "Test failed with rc=$rc: @cmd\n"; } if (! -s "$temp") { die "Export did not write any data\n"; }
kbase/transform
t/test_ws_KBaseGenomes.Genome-to-EMBL.pl
Perl
mit
511