Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I use ActiveState perl, and I like managing my modules with ppm rather than making them manually. Problem is, for the less common modules, it's often difficult to find a repository that has them, if they're not in one of the two ppm repositories installed by default with ActiveState.

PPM::Repositories was supposed to improve this situation by centralizing all known ppm repositories, as the venerable holli explained at A guide to installing modules for Win32. However, ppm::repositories lists a lot of repositories that are dead or down for maintenance. If you are unlucky enough to have a dead repository in your list of repositories, this can cause major headaches when, for instance, you try searching for a module -- it just takes forever to fail and ppm doesn't tell you it's trying to ping the repository or whatever, it just sits there all stubborn. Annoying.

So, I wrote a program to hopefully take away some of the pain and make things easier to the perl on windows crowd. It synchronizes the ppm repositories on my system with the functioning ppm repositories listed on PPM::Repositories, working as follows. It first removes all repositories other than the two standard ones that come with ActiveState. Then, it goes through the repositories listed on PPM::Repositories, pings them, and if they're okay, adds them to the active repository list.

Hope this helps someone!

#updateWorkingRepositories.pl use strict; use warnings; use PPM::Repositories; use Net::Ping; remove_non_active_state_repositories(); add_repositories(); #remove all repositories, except the repositories that come installed +by default with ActiveState. sub remove_non_active_state_repositories { my @repositories; my $result = `ppm rep`; for (split /[\r\n]/, $result) { #parsing lines that looks like #[ 3] jenda my ($number, $repository) = $_ =~ /(\[[^>]*\]\s)(.*)/; if ($repository) { unless ($repository =~ /activestate/i) { print `ppm rep de +lete $repository` unless (/activestate/i); } } } } sub add_repositories { for ( keys %Repositories ) { my $repository = $_; my $location = $Repositories{$_}->{location}; my $domain = trim_domain($location); my $p = Net::Ping->new('icmp'); if ( $p->ping($domain) ) { print "$repository is alive.\n"; print `ppm repository add $repository $location` . "\n\n"; } else { print "$repository is dead.\n"; } } } #function that trims a domain sub trim_domain { $_ = my $original_input = shift; $_ =~ s/^\s+//; #strip spaces at start of string $_ =~ s/\s+$//; #strip spaces at end of string $_ =~ s|^http://||; # strip http:// at begining $_ =~ s|/.*$||; # strip everything after the first / my $trimmed_domain = $_; unless ($trimmed_domain) { logMessage("trim_domain had a problem trimming $original_input +"); carp ("trim_domain had a problem trimming $original_input"); $trimmed_domain = "$original_input couldn't be trimmed in trim +_domain"; } return $trimmed_domain; }

Output :

Repositories: [1] ActiveState PPM2 Repository [2] rto [3] soulcage [4] devhelp [5] roth [6] ActiveState Package Repository Repositories: [1] ActiveState PPM2 Repository [2] soulcage [3] devhelp [4] roth [5] ActiveState Package Repository Repositories: [1] ActiveState PPM2 Repository [2] devhelp [3] roth [4] ActiveState Package Repository Repositories: [1] ActiveState PPM2 Repository [2] roth [3] ActiveState Package Repository Repositories: [1] ActiveState PPM2 Repository [2] ActiveState Package Repository dada is dead. smueller is alive. Repositories: [1] ActiveState PPM2 Repository [2] ActiveState Package Repository [3] smueller perlxml is dead. crazy58 is alive. Repositories: [1] ActiveState PPM2 Repository [2] ActiveState Package Repository [3] smueller [4] crazy58 crazy is alive. Repositories: [1] ActiveState PPM2 Repository [2] ActiveState Package Repository [3] smueller [4] crazy58 [5] crazy datetime is alive. Repositories: [1] ActiveState PPM2 Repository [2] ActiveState Package Repository [3] smueller [4] crazy58 [5] crazy [6] datetime soulcage58 is alive. Repositories: [1] ActiveState PPM2 Repository [2] ActiveState Package Repository [3] smueller [4] crazy58 [5] crazy [6] datetime [7] soulcage58 sablot is dead. bribes is alive. Repositories: [1] ActiveState PPM2 Repository [2] ActiveState Package Repository [3] smueller [4] crazy58 [5] crazy [6] datetime [7] soulcage58 [8] bribes gtk is dead. xray is dead. rto is alive. Repositories: [1] ActiveState PPM2 Repository [2] ActiveState Package Repository [3] smueller [4] crazy58 [5] crazy [6] datetime [7] soulcage58 [8] bribes [9] rto spurkis is dead. theoryS is dead. jenda is dead. theory58S is dead. esoft is dead. log4perl is dead. theory58 is dead. soulcage is alive. Repositories: [ 1] ActiveState PPM2 Repository [ 2] ActiveState Package Repository [ 3] smueller [ 4] crazy58 [ 5] crazy [ 6] datetime [ 7] soulcage58 [ 8] bribes [ 9] rto [10] soulcage savage is dead. devhelp is alive. Repositories: [ 1] ActiveState PPM2 Repository [ 2] ActiveState Package Repository [ 3] smueller [ 4] crazy58 [ 5] crazy [ 6] datetime [ 7] soulcage58 [ 8] bribes [ 9] rto [10] soulcage [11] devhelp theory is dead. openi is dead. roth is alive. Repositories: [ 1] ActiveState PPM2 Repository [ 2] ActiveState Package Repository [ 3] smueller [ 4] crazy58 [ 5] crazy [ 6] datetime [ 7] soulcage58 [ 8] bribes [ 9] rto [10] soulcage [11] devhelp [12] roth
UPDATE: Now strict and warnings safe, thanks to QM for reminding me of that. (Thought I always did that automatically, but I guess I slipped up.)
Update 2: Now with icmp ping, thanks to eibwen and pboin. I should have done this a long time ago.
UPDATE 3: If you think you may be behind a ping-restricted firewall, you may want to try holli's version of the script which modifies the above to use some kind of LWP authentication instead of ping: Re: Script to update your PPM Repositories.

In reply to Script to update your PPM Repositories by tphyahoo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    [marto]: the ticketing system does not accept calls via email, nor has it a working API. It's tied into Active Directory for authentication and the Solaris boxes aren't on that domain
    [Corion]: The one thing I haven't figured out a solution to is how to get an edge-trigger instead of sending an email every 5 minutes if the usage is above 90%. I want one mail when it goes over 90% but no more emails as long as it stays between 90% and 95%.
    [Corion]: marto: Clever! ;)
    [Corion]: You can only reach me by pager
    [Corion]: Maybe the solution would be to launch a cron job every minute that takes two measurements a minute apart and sends a mail if the usage is below on the first and above threshold on the last measurement
    [marto]: that's essentially it :)
    [marto]: I think the long term solution would be to have sysadmins that do their job, so I don't have to do everything :P
    [marto]: they already have an entire BMC patrol system, which they disabled, because it was sending out spurious messages. So rather than fix the issue, or even find out what it was, they turned it off. No messages, can't be any problems, right?
    [Corion]: marto: But having open tickets / incidents increases the pressure on them ;) Of course, likely your contract / SLA specifies an upper limit for the number of incidents :-D
    [Corion]: marto: Ow ...

    How do I use this? | Other CB clients
    Other Users?
    Others taking refuge in the Monastery: (10)
    As of 2017-01-24 10:14 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      Do you watch meteor showers?




      Results (203 votes). Check out past polls.