Changeset 28769 in osm for applications/editors/josm


Ignore:
Timestamp:
2012-10-03T23:53:54+02:00 (12 years ago)
Author:
stoecker
Message:

add two new options

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/i18n/launchpad.pl

    r28491 r28769  
    2626my $agent = "JOSM_Launchpad/1.$revision";
    2727
    28 my $count = 0;#11;
    2928my $cleanall = 0;#1;
    30 my $upload = 0;#1;
    3129
    3230if($#ARGV != 0)
     
    4745    {
    4846      system "ant";
    49       makeupload();
    5047    }
    5148}
     
    5350{
    5451    potupload();
     52}
     53elsif($ARGV[0] eq "uploadall")
     54{
     55    makeupload();
     56}
     57elsif($ARGV[0] eq "approveall")
     58{
     59  approveall(dologin());
    5560}
    5661elsif($ARGV[0] eq "download")
     
    7681}
    7782
     83sub approveall
     84{
     85    my ($mech) = @_;
     86    print "Trying to approve upload.\n";
     87    $mech->get("https://translations.launchpad.net/josm/trunk/+imports?field.filter_status=NEEDS_REVIEW&field.filter_extension=all");
     88    my @links;
     89    foreach my $line (split("\n", $mech->content()))
     90    {
     91        push (@links, $1) if $line =~ /href="(\/\+imports\/\d+)"/;
     92    }
     93    if(!@links)
     94    {
     95        warn "No upload found in import list, upload possibly failed.";
     96    }
     97    else
     98    {
     99        foreach my $link (@links)
     100        {
     101            eval
     102            {
     103                print "Approve $link upload.\n";
     104                $mech->get("https://translations.launchpad.net$link");
     105                $mech->form_with_fields("field.potemplate");
     106                $mech->select("field.potemplate", "josm");
     107                $mech->click_button(name => "field.actions.approve");
     108            };
     109            print $@ if $@;
     110        }
     111    }
     112}
     113
    78114sub makeupload
    79115{
    80     if($upload)
    81     {
    82         my $outdate = `date -u +"%Y-%m-%dT%H_%M_%S"`;
    83         chomp $outdate;
    84         mkdir "build/josm";
    85         system "cp po/*.po po/josm.pot build/josm";
    86         chdir "build";
    87         if(!$count)
    88         {
    89           system "tar -cjf ../launchpad_upload_josm_$outdate.tar.bz2 josm";
    90         }
    91         else
    92         {
    93           my @files = sort glob("josm/*.po");
    94           my $num = 1;
    95           while($#files >= 0)
    96           {
    97             my @f = splice(@files, 0, $count);
    98             system "tar -cjf ../launchpad_upload_josm_${outdate}_$num.tar.bz2 josm/josm.pot ".join(" ",@f);
    99             ++$num;
    100           }
    101         }
    102         system "rm -rv josm";
    103         chdir "..";
    104     }
     116    my $count = 11;
     117    my $outdate = `date -u +"%Y-%m-%dT%H_%M_%S"`;
     118    my $mech = dologin();
     119    $outdate =~ s/[\r\n]+//;
     120    mkdir "build/josm";
     121    system "cp po/*.po po/josm.pot build/josm";
     122    chdir "build";
     123    print "Starting upload ($outdate).\n";
     124    if(!$count)
     125    {
     126      system "tar -cjf launchpad_upload_josm_$outdate.tar.bz2 josm";
     127      $mech->get("https://translations.launchpad.net/josm/trunk/+translations-upload");
     128      $mech->submit_form(with_fields => {"file" => "launchpad_upload_josm_$outdate.tar.bz2"});
     129      sleep(10);
     130    }
     131    else
     132    {
     133      my @files = sort glob("josm/*.po");
     134      my $num = 1;
     135      while($#files >= 0)
     136      {
     137        my @f = splice(@files, 0, $count);
     138        my $file = "launchpad_upload_josm_${outdate}_$num.tar.bz2";
     139        print "Create file $file.\n";
     140        system "tar -cjf $file ".join(" ",@f);
     141        print "Upload file $file.\n";
     142        $mech->get("https://translations.launchpad.net/josm/trunk/+translations-upload");
     143        $mech->submit_form(with_fields => {"file" => $file});
     144        sleep(10);
     145        ++$num;
     146      }
     147    }
     148    system "rm -rv josm";
     149    chdir "..";
     150    approveall($mech);
    105151}
    106152
Note: See TracChangeset for help on using the changeset viewer.