Skip to content
This repository
Browse code

Use Parrot LWP::UserAgent instead of system wget. benabik++ for pir help

  • Loading branch information...
commit 02eb2a879b90834d3dbbd758a70560bf025467ba 1 parent b37c702
Tadeusz Sośnierz authored

Showing 1 changed file with 32 additions and 1 deletion. Show diff stats Hide diff stats

  1. +32 1 lib/Panda/Ecosystem.pm
33 lib/Panda/Ecosystem.pm
@@ -8,6 +8,36 @@ class Panda::Ecosystem does Pies::Ecosystem {
8 8 has %!projects;
9 9 has %!states;
10 10
  11 + sub getfile($src, $dest) {
  12 + pir::load_bytecode__vs('LWP/UserAgent.pir');
  13 + my $res = Q:PIR {
  14 + .local string what, where
  15 + .local pmc ua, response, outfile
  16 + $P0 = find_lex '$src'
  17 + what = repr_unbox_str $P0
  18 + $P0 = find_lex '$dest'
  19 + where = repr_unbox_str $P0
  20 + ua = new ['LWP';'UserAgent']
  21 + response = ua.'get'(what)
  22 + $I0 = response.'code'()
  23 + if $I0 == 200 goto success
  24 + $I0 = 1
  25 + goto end
  26 + success:
  27 + outfile = new ['FileHandle']
  28 + outfile.'open'(where, 'w')
  29 + $S0 = response.'content'()
  30 + outfile.'print'($S0)
  31 + $S0 = "\n"
  32 + outfile.'print'($S0)
  33 + outfile.'close'()
  34 + $I0 = 0
  35 + end:
  36 + %r = perl6_box_int $I0
  37 + };
  38 + $res and die "Unable to fetch $src";
  39 + }
  40 +
11 41 method flush-states {
12 42 my $fh = open($!statefile, :w);
13 43 for %!states.kv -> $key, $val {
@@ -47,7 +77,8 @@ class Panda::Ecosystem does Pies::Ecosystem {
47 77
48 78 method update {
49 79 try unlink $!projectsfile;
50   - shell qq[wget "feather.perl6.nl:3000/list" -O "$!projectsfile"];
  80 + getfile 'http://feather.perl6.nl:3000/projects.json',
  81 + $!projectsfile
51 82 }
52 83
53 84 # Pies::Ecosystem methods

0 comments on commit 02eb2a8

Please sign in to comment.
Something went wrong with that request. Please try again.