CTKlib
view release on metacpan or search on metacpan
2.05 Tue Sep 1 00:01:22 MSK 2020
* Bug fixed - incorrect default value of _get_path()
2.06 Wed 2 Sep 09:13:22 MSK 2020
* Bug fixed - now added supporting 32 bit platforms for FNV digest function
2.07 Mon 23 Nov 20:41:07 MSK 2020
* Added File::Pid implementation (RT#19)
2.08 Tue 06 Sep 2022 19:41:34 MSK
* Added CTK::Timeout and removed Sys::SigAction dependency
* CTK::DBI: Has removed the Sys::SigAction dependency
* Removed Class::C3::Adopt::NEXT and MRO::Compat dependencies
* CTK::ConfGenUtil: added lvalue function
* CTK::Log: Added log_critical method
* CTK::Configuration: added the load and reload methods
* CTK::Daemon: added the cleanup and reload methods
2.09 Fri 09 Sep 2022 08:32:56 MSK
* CTK::Daemon: deleted outer eval construction for the run method
lib/CTK/Configuration.pm Configuration class
lib/CTK/Crypt.pm Crypt frontend
lib/CTK/DBI.pm Database independent interface for CTKlib
lib/CTK/FilePid.pm File::Pid patched interface
lib/CTK/Helper.pm CTK Helper
lib/CTK/Log.pm Logger class
lib/CTK/Plugin.pm Plugin base class
lib/CTK/TFVals.pm True and False values conversions
lib/CTK/Util.pm CTK Utilities
lib/CTK/Serializer.pm Base class for serialization perl structures
lib/CTK/Timeout.pm Timeout module
lib/CTK/UtilXS.pm CTK XS Utilities
lib/CTK/Skel.pm Skel render class
lib/CTK/Daemon.pm Abstract class to implement Daemons
lib/CTK/Digest.pm Digest base class
# Skeletons
lib/CTK/Skel/Regular.pm Regular project skeleton
lib/CTK/Skel/Tiny.pm Tiny project skeleton
lib/CTK/Skel/Module.pm Module project skeleton
lib/CTK/Skel/Common.pm Common skeleton
t/17-crypt-tcd04.t Crypt: TCD04
t/18-crypt.t Crypt
t/19-crypt-gpg.t Crypt: GPG
t/20-plugin-net.t Plugin: Net
t/21-sendmail.t Sendmail testing
t/22-dbi.t CTK::DBI
t/23-attrs.t CTK::Util::read_attributes in the new edition
t/24-digest.t Digest tests
t/25-plugins-ext.t Extended plugins test (since 2.04)
t/26-filepid.t CTK::FilePid
t/27-timeout.t Timeout check
t/28-cgu-lvalue.t LastValue for value method
# Other
src/test.conf Config file for tests
src/conf/test_inc.conf Include config file for tests
src/myprivate.key Test private GPG key
src/mypublic.key Test public GPG key
META.yml Module YAML meta-data (added by MakeMaker)
META.json Module JSON meta-data (added by MakeMaker)
lib/CTK/DBI.pm view on Meta::CPAN
=cut
use vars qw/$VERSION/;
$VERSION = '2.31';
our $CTK_DBI_DEBUG = 0;
our $CTK_DBI_ERROR = "";
use Carp;
use CTK::Util qw( :API );
use CTK::Timeout;
use DBI qw();
# Create global Timeout object
my $to = CTK::Timeout->new();
sub new {
my $class = shift;
my @in = read_attributes([
['DSN','STRING','STR'],
['USER','USERNAME','LOGIN'],
['PASSWORD','PASS'],
['TIMEOUT_CONNECT','CONNECT_TIMEOUT','CNT_TIMEOUT','TIMEOUT_CNT','TO_CONNECT','CONNECT_TO'],
['TIMEOUT_REQUEST','REQUEST_TIMEOUT','REQ_TIMEOUT','TIMEOUT_REQ','TO_REQUEST','REQUEST_TO'],
['ATTRIBUTES','ATTR','ATTRS','ATTRHASH','PARAMS'],
lib/CTK/DBI.pm view on Meta::CPAN
sub DESTROY {
my $self = shift;
$self->disconnect();
}
sub DBI_CONNECT {
# $dbh = DBI_CONNECT($dsn, $user, $password, $attr, $timeout, \$error)
my $db_dsn = shift || ''; # DSN
my $db_user = shift // ''; # DB Username
my $db_password = shift // ''; # DB Password
my $db_attr = shift || {}; # Attributes DBD::* (hash-ref) E.g., {ORACLE_enable_utf8 => 1}
my $db_tocnt = shift // 0; # Timeout value
my $rerr = shift; # Reference to error scalar
$rerr = \$CTK_DBI_ERROR unless $rerr && ref($rerr) eq 'SCALAR';
my $dbh;
# Connect
my $err = "";
my $retval = $to->timeout_call(sub {
$dbh = DBI->connect($db_dsn, "$db_user", "$db_password", $db_attr);
unless ($dbh) {
$err = $DBI::errstr || "the DBI::connect method has returned false status";
lib/CTK/Plugin/FTP.pm view on Meta::CPAN
Version 1.02
=head1 SYNOPSIS
use CTK;
my $ctk = CTK->new(
plugins => "ftp",
);
$ctk->fetch_ftp(
-url => 'ftp://anonymous:anonymous@192.168.0.1/Public/test?Timeout=30',
-op => "copy", # copy / move
-uniq => 1, # 0 -- off; 1 -- on
-mode => "binary", # ascii / binary (default)
-dirdst => "/path/to/destination/dir", # Destination directory
-filter => qr/\.tmp$/,
);
$ctk->store_ftp(
-url => 'ftp://anonymous:anonymous@192.168.0.1/Public/test?Timeout=30',
-op => "copy", # copy / move
-uniq => 1, # 0 -- off; 1 -- on
-mode => "binary", # ascii / binary (default)
-dirsrc => "/path/to/source/dir", # Source directory
-filter => qr/\.tmp$/,
)
=head1 DESCRIPTION
FTP plugin
=head1 METHODS
=head2 fetch_ftp
$ctk->fetch_ftp(
-url => 'ftp://anonymous:anonymous@192.168.0.1/Public/test?Timeout=30',
-op => "copy", # copy / move
-uniq => 1, # 0 -- off; 1 -- on
-mode => "binary", # ascii / binary (default)
-dirdst => "/path/to/destination/dir", # Destination directory
-files => ['foo.tgz', 'bar.tgz', 'baz.tgz'],
);
Download specified files from resource
$ctk->fetch_ftp(
-url => 'ftp://anonymous:anonymous@192.168.0.1/Public/test?Timeout=30',
-op => "copy", # copy / move
-uniq => 1, # 0 -- off; 1 -- on
-mode => "binary", # ascii / binary (default)
-dirdst => "/path/to/destination/dir", # Destination directory
-filter => qr/\.tmp$/,
);
Download files from remote resource by regexp mask
=over 8
=item B<-url>
URL of resource.
For example:
ftp://anonymous:anonymous@192.168.0.1/Public/test?timeout=30
Timeout=30 -- FTP atrtributes. See L<Net::FTP>
=item B<-dirout>, B<-out>, B<-dirdst>, B<-dst>, B<-target>
Specifies destination directory
Default: current directory
=item B<-filter>, B<-list>, B<-mask>, B<-files>, B<-regexp>
-list => [qw/ file1.txt file2.txt /]
lib/CTK/Plugin/FTP.pm view on Meta::CPAN
-mode => "binary", # ascii / binary (default)
Default: binary
=back
=head2 store_ftp
$ctk->store_ftp(
-url => 'ftp://anonymous:anonymous@192.168.0.1/Public/test?Timeout=30',
-op => "copy", # copy / move
-uniq => 1, # 0 -- off; 1 -- on
-mode => "binary", # ascii / binary (default)
-dirsrc => "/path/to/source/dir", # Source directory
-filter => qr/\.tmp$/,
)
Upload files from local directory to remote resource by regexp mask
=over 8
=item B<-url>
URL of resource.
For example:
ftp://anonymous:anonymous@192.168.0.1/Public/test?Timeout=30
Timeout=30 -- FTP atrtributes. See L<Net::FTP>
=item B<-dirin>, B<-in>, B<-dirsrc>, B<-src>, B<-source>
Specifies source directory
Default: current directory
=item B<-filter>, B<-list>, B<-mask>, B<-files>, B<-regexp>, B<-glob>
-list => [qw/ file1.zip file2.zip /]
lib/CTK/Plugin/Net.pm view on Meta::CPAN
Version 1.02
=head1 SYNOPSIS
use CTK;
my $ctk = CTK->new(
plugins => "net",
);
$ctk->fetch(
-url => 'ftp://anonymous:anonymous@192.168.200.8/path/srs?Timeout=30&Passive=1',
-command => "copy", # copy / move
-uniq => "off",
-dirdst => "/path/to/destination/dir", # Destination directory
-regexp => qr/tmp$/,
);
$ctk->store(
-url => 'ftp://anonymous:anonymous@192.168.200.8/path/dst?Timeout=30&Passive=1',
-command => "copy", # copy / move
-uniq => "off",
-dirsrc => "/path/to/source/dir", # Source directory
-regexp => qr/tmp$/,
)
=head1 DESCRIPTION
Net plugin. This plugin is proxy to L<CTK::Plugin::FTP> and L<CTK::Plugin::SFTP> plugins
lib/CTK/Timeout.pm view on Meta::CPAN
package CTK::Timeout;
use strict;
use utf8;
=encoding utf-8
=head1 NAME
CTK::Timeout - Provides execute the code reference wrapped with timeout
=head1 VERSION
Version 1.00
=head1 SYNOPSIS
use CTK::Timeout;
# Create the timeout object
my $to = CTK::Timeout->new();
# Execute
unless ($to->timeout_call(sub { sleep 2 } => 1)) {
die $to->error if $to->error;
}
=head1 DESCRIPTION
This class provides execute the code reference wrapped with timeout
=head2 new
Creates the timeout object
my $to = CTK::Timeout->new();
Creates the timeout object without the POSIX "sigaction" supporting (forced off)
my $to = CTK::Timeout->new(0);
=head2 error
die $to->error if $to->error;
Returns error string
=head2 timeout_call
Given a code reference (with optional arguments @args) will execute
lib/CTK/Timeout.pm view on Meta::CPAN
=head1 DEPENDENCIES
L<POSIX>, L<Config>
=head1 TO DO
See C<TODO> file
=head1 SEE ALSO
L<DBI/Timeout>, L<Sys::SigAction>
=head1 AUTHOR
Serż Minus (Sergey Lepenkov) L<https://www.serzik.com> E<lt>abalama@cpan.orgE<gt>
=head1 COPYRIGHT
Copyright (C) 1998-2022 D&D Corporation. All Rights Reserved
=head1 LICENSE
t/20-plugin-net.t view on Meta::CPAN
plan skip_all => "Currently a developer-only test" unless -d '.svn' || -d ".git";
plan skip_all => "TEST_NET environment variable required" unless $ENV{TEST_NET};
plan tests => 11;
use File::Spec;
use CTK;
use CTK::Util qw/fsave randchars preparedir/;
use constant {
FILEMASK => 'test%d.tmp',
TESTURL_FTP => 'ftp://anonymous:anonymous@192.168.200.8/mbutiny/test?Passive=1&Timeout=10&Debug=0',
TESTURL_SFTP=> 'sftp://guest@192.168.123.8/home/guest/Public?timeout=10',
};
my $ctk = CTK->new(
plugins => [qw/log net/],
verbose => 1,
debug => 1,
log => 1,
);
ok($ctk->logger_init(file => "error.log"), "Logger initialize");
t/25-plugins-ext.t view on Meta::CPAN
plan skip_all => "TEST_NET environment variable required" unless $ENV{TEST_NET};
plan tests => 23;
use File::Spec;
use CTK;
use CTK::Util qw/fsave randchars preparedir/;
use constant {
FILEMASK => 'test%d.tmp',
FILENAME => 'test.tmp',
TESTURL_FTP => 'ftp://anonymous:anonymous@192.168.200.8/mbutiny/test?Passive=1&Timeout=10',
TESTURL_SFTP=> 'sftp://guest@192.168.123.8/home/guest/Public?timeout=10',
};
my $ctk = CTK->new(
plugins => [qw/log file archive ftp sftp/],
#verbose => 1,
#debug => 1,
#log => 1,
);
ok($ctk->logger_init(file => "error.log"), "Logger initialize");
t/27-timeout.t view on Meta::CPAN
# This is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
#
#########################################################################
use strict;
use warnings;
use Test::More; # qw/no_plan/
plan tests => 6;
use_ok qw/CTK::Timeout/;
my $to = CTK::Timeout->new();
# TimeOut
{
my $cd = sub {
#note shift;
sleep 2;
#note shift;
1;
};
( run in 0.637 second using v1.01-cache-2.11-cpan-fd5d4e115d8 )