Mercurial > eagle-eye
comparison Ikariam.pm @ 367:d9d3cdff27c6
handling field not found error
author | "Rex Tsai <chihchun@kalug.linux.org.tw>" |
---|---|
date | Sun, 01 Mar 2009 22:14:05 +0800 |
parents | 4bea7db828eb |
children | ba1643654e6d |
comparison
equal
deleted
inserted
replaced
366:2cfa03edc22e | 367:d9d3cdff27c6 |
---|---|
636 my @forms = $self->{mech}->forms(); | 636 my @forms = $self->{mech}->forms(); |
637 if($#forms < 1) { | 637 if($#forms < 1) { |
638 my $city = Ikariam::Cities->retrieve($cityId); | 638 my $city = Ikariam::Cities->retrieve($cityId); |
639 $city->delete; | 639 $city->delete; |
640 } else { | 640 } else { |
641 $self->{mech}->submit_form( | 641 $self->{mech}->form_number(1); |
642 form_number => 1, | 642 |
643 fields => $fields); | 643 foreach my $k (keys(%{$fields})) { |
644 eval{ | |
645 $self->{mech}->field($k, $fields->{$k}) | |
646 }; | |
647 warn $@ if($@); | |
648 } | |
649 $self->{mech}->submit(); | |
650 # $self->{mech}->submit_form( | |
651 # form_number => 1, | |
652 # fields => $fields); | |
644 } | 653 } |
645 } else { | 654 } else { |
646 # put the id in the friends.txt file. | 655 # put the id in the friends.txt file. |
647 Ikariam::Cities->has_a(user => 'Ikariam::User'); | 656 Ikariam::Cities->has_a(user => 'Ikariam::User'); |
648 my $city = Ikariam::Cities->retrieve($cityId); | 657 my $city = Ikariam::Cities->retrieve($cityId); |
1260 my $res = $self->{mech}->post(sprintf("http://%s/index.php?action=loginAvatar&function=login", $self->{server}), [ | 1269 my $res = $self->{mech}->post(sprintf("http://%s/index.php?action=loginAvatar&function=login", $self->{server}), [ |
1261 name => $self->{user}, | 1270 name => $self->{user}, |
1262 password => $self->{pass}, | 1271 password => $self->{pass}, |
1263 ]); | 1272 ]); |
1264 | 1273 |
1265 my @cities = Ikariam::Extractor->new(content => $res->content)->find('//option[@class="avatarCities coords"]/@value'); | 1274 while (1) { |
1266 | 1275 my @cities = Ikariam::Extractor->new(content => $res->content)->find('//option[@class="avatarCities coords"]/@value'); |
1267 if($#cities<0) { | 1276 |
1268 die ("login failed\n"); | 1277 if($#cities<0) { |
1269 } | 1278 warn ("login failed\n"); |
1270 foreach (@cities) { | 1279 next; |
1271 $self->{'cities'}->{$_} = {}; | 1280 } |
1272 $self->{'cities'}->{$_}->{id} = $_; | 1281 foreach (@cities) { |
1273 if(-f "city-$_-dump.yaml") { | 1282 $self->{'cities'}->{$_} = {}; |
1274 $self->{'cities'}->{$_} = LoadFile("city-$_-dump.yaml"); | 1283 $self->{'cities'}->{$_}->{id} = $_; |
1275 } | 1284 if(-f "city-$_-dump.yaml") { |
1285 $self->{'cities'}->{$_} = LoadFile("city-$_-dump.yaml"); | |
1286 } | |
1287 } | |
1288 last; | |
1276 } | 1289 } |
1277 } | 1290 } |
1278 | 1291 |
1279 | 1292 |
1280 1; | 1293 1; |