• 0

    posted a message on perl script updateing addons from /files/
    Using this code
    #!/usr/bin/perl -w
    use strict;
    use LWP::Simple; #Contains the function used to download files.
    use XML::Simple; #Contains the function need to parse the xml file :P
    #use Data::Dumper; #Used by the currently commented out Dumper function.
    use XML::Dumper; #Used to save our cache file. Dunno why XMLout() wouldn't work.
    use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); # The archive extractor, duh!
    my $basedir = qq(/home/username/.wine/drive_c/Games/World of Warcraft/Interface); #only used by the default values of $addondir and $addonzip
    my $addondir = qq($basedir/AddOns); #location extract the addon zips too
    my $addonzip = qq($basedir/addonszips); #location to save the downloaded zips
    # You shouldn't need to mess with anything below here.
    # Unless of course there is an update to how you get the wowace zip files.
    my $wowaceurl = "[url]http://files.wowace.com";[/url] #Base url used to fetch the addon zips and for fetching the XML file below.
    my $wowacefile = "latest.xml"; # name of the XML file containing the info on all the addon revisions.
    my $configfile = $addondir."/cache.xml";
    my $wowacelatesturl = "$wowaceurl/$wowacefile";
    my $wowacelatestfile = "$addondir/$wowacefile";
    my $config = {};
    sub get_wowace_addonlist
      my $addons = {};
      my $doc = XMLin($wowacelatestfile);
      #PERL sucks. It made what should be a simple for loop
      # and made it this horrible disfigured for loop.....
      for my $item ( @{ $doc->{channel}->{item} } ) {
        $addons->{lc $item->{title}} = [$item->{title},$item->{'wowaddon:version'}];
      return $addons
    sub get_wowace_updateable_addonlist
      $config = shift @_;
      my @addons;
      opendir DIR, $addondir;
      while (my $addon = readdir(DIR))
        next if (($addon eq ".")||($addon eq ".."));
        next if (! -d "$addondir/$addon" );
        $addon = lc $addon;
        if ($config->{wowace}->{$addon})
          push @addons, $addon;
      closedir DIR;
      return @addons;
    sub check_update_wowace_addon
      my ($addon) = @_;
      my $addonname = $config->{wowace}->{$addon}[0];
      my $availversion = $config->{wowace}->{$addon}[1];
      if ((!$config->{updated}->{$addon}) || ( $config->{updated}->{$addon} < $availversion))
        print "UPDATING: $addonname (r".$config->{updated}->{$addon}." -> r$availversion)\n";
        my $zip = Archive::Zip->new("$addonzip/$addonname.zip");
        $config->{updated}->{$addon} = $availversion;
      } else {
        print "uptodate: $addonname (r$availversion)\n";
    print "checking addons directory... ";
    if ( -d $addondir ) { print "ok.\n"; } else { print "failed.\n"; }
    print "checking addonszips directory... ";
    if ( -d $addonzip ) { print "ok.\n"; } else { print "failed.\n"; }
    if ( -f $configfile )
      print "Loading cache...\n";
      $config = xml2pl( $configfile );
    } else {
      print "New cache...\n";
    print "Get Addonlist from wowace.com...\n";
    $config->{wowace} = get_wowace_addonlist;
    print "Checking updateable Addons...\n";
    my @updateable = sort(get_wowace_updateable_addonlist($config));
    print "Update Addons...\n";
    foreach (@updateable)
    #print Dumper($config);
    #XMLout($config, AttrIndent => 1, OutputFile => $configfile);
    undef $config->{wowace};
    pl2xml( $config,$configfile );
    print "Done!\n";

    I get this error or warning (I'm not a perl expert)

    Use of uninitialized value in concatenation (.) or string at '/home/username/.wine/drive_c/Games/World of Warcraft/Interface' line 73
    print "UPDATING: $addonname (r".$config->{updated}->{$addon}." -> r$availversion)\n";

    But the script continues normally.

    If I try to re-execute the script, I have the following output

    uptodate: !BugGrabber (r70964)
    uptodate: !SurfaceControl (r74570.2)
    uptodate: Ace2 (r79524)
    uptodate: Ace3 (r76326)
    uptodate: AHsearch (r66857.5)
    uptodate: AllPlayed (r80141)

    so I think it went well... or not?

    Edit: after two days and new addons released, I have this output:

    uptodate: IFrameManager (r63395)
    uptodate: Incubator (r78750.2)
    uptodate: InFlight (r74636.1)
    uptodate: InFlight_Load (r79601)
    uptodate: ItemSync (r70922.4)
    uptodate: JostleLib (r59177.1)
    uptodate: Manufac (r66237.25)
    uptodate: ManufacSnoop (r66237.3)
    UPDATING: Mendeleev (r80526.1 -> r80575) <------------------- So I'm pretty sure It is working!
    Posted in: General Chat
  • To post a comment, please or register a new account.