Author: sparky
Date: Tue Nov  3 01:39:17 2009
New Revision: 10931

Modified:
   toys/rsget.pl/README
   toys/rsget.pl/RSGet/CaptchaImage.pm
   toys/rsget.pl/RSGet/Get.pm
   toys/rsget.pl/RSGet/MortalObject.pm
   toys/rsget.pl/RSGet/Tools.pm
Log:
- added randid function - 16 random bytes as hexadecimal string


Modified: toys/rsget.pl/README
==============================================================================
--- toys/rsget.pl/README        (original)
+++ toys/rsget.pl/README        Tue Nov  3 01:39:17 2009
@@ -6,6 +6,8 @@
 - Add commands: pause downloads, allow/don't allow captcha, clean done
   downloads, and more
 - File group support (first step for multiuser support)
+- Finish daemon option - use Proc::Deamon
+- Selectable temporary directory.
 
 Planned features:
 - Multiuser support (may require major changes in the code).

Modified: toys/rsget.pl/RSGet/CaptchaImage.pm
==============================================================================
--- toys/rsget.pl/RSGet/CaptchaImage.pm (original)
+++ toys/rsget.pl/RSGet/CaptchaImage.pm Tue Nov  3 01:39:17 2009
@@ -260,15 +260,14 @@
 {
        my $self = shift;
 
-       my $rand = sprintf "%.6x", int rand 1 << 24;
-
-       my $bmp = "cap$rand.bmp";
-       my $txt = "cap$rand.txt";
+       my $file = "cap_" . randid();
+       my $bmp = "$file.bmp";
+       my $txt = "$file.txt";
 
        unlink $bmp, $txt;
        $self->write_bmp( $bmp );
        
-       system "tesseract $bmp cap$rand 2>/dev/null";
+       system "tesseract $bmp $file 2>/dev/null";
        
        my $text;
        if ( open my $f_in, "<", $txt ) {

Modified: toys/rsget.pl/RSGet/Get.pm
==============================================================================
--- toys/rsget.pl/RSGet/Get.pm  (original)
+++ toys/rsget.pl/RSGet/Get.pm  Tue Nov  3 01:39:17 2009
@@ -57,7 +57,7 @@
                _cmd => $cmd,
                _pkg => $getter->{pkg},
                _outif => $outif,
-               _id => (sprintf "%.6x", int rand 1 << 24),
+               _id => randid(),
                _last_dump => 0,
                make_cookie( $getter->{cookie}, $cmd ),
        };
@@ -260,7 +260,7 @@
 {
        my $self = shift;
        my $msg = shift || "multi-download not allowed";
-       return $self->wait( \&start, -60 - 240 * rand, $msg, "multi" );
+       return $self->wait( \&start, - irand( 60, 300 ), $msg, "multi" );
 }
 
 sub finish

Modified: toys/rsget.pl/RSGet/MortalObject.pm
==============================================================================
--- toys/rsget.pl/RSGet/MortalObject.pm (original)
+++ toys/rsget.pl/RSGet/MortalObject.pm Tue Nov  3 01:39:17 2009
@@ -25,7 +25,7 @@
 
        my $time = time;
 
-       my $id = sprintf "%d_%.6x", ++$last_id, int rand 1 << 24;
+       my $id = ++$last_id . "_" . randid();
 
        my $holder = {
                obj => $obj,

Modified: toys/rsget.pl/RSGet/Tools.pm
==============================================================================
--- toys/rsget.pl/RSGet/Tools.pm        (original)
+++ toys/rsget.pl/RSGet/Tools.pm        Tue Nov  3 01:39:17 2009
@@ -15,7 +15,7 @@
 require Exporter;
 @ISA = qw(Exporter);
 @EXPORT = qw(set_rev s2string bignum de_ml hadd hprint p isotime require_prog
-       irand jstime def_settings setting verbose
+       irand randid jstime def_settings setting verbose
        data_file dump_to_file randomize);
 @EXPORT_OK = qw();
 
@@ -98,6 +98,11 @@
        return int ( $arg + rand ( (shift) - $arg ) );
 }
 
+sub randid()
+{
+       return join "", map { sprintf "%.4x", int rand 1 << 16 } (0..7);
+}
+
 sub isotime()
 {
        my @l = localtime;
_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to