/[A3C]/bin/import-strix.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /bin/import-strix.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 139 by dpavlin, Fri May 30 21:16:08 2008 UTC revision 147 by dpavlin, Tue Jun 3 10:22:49 2008 UTC
# Line 10  use Data::Dump qw/dump/; Line 10  use Data::Dump qw/dump/;
10  use File::Find;  use File::Find;
11  use A3C::PHP;  use A3C::PHP;
12    
13    my $debug = 0;
14    
15  BEGIN { Jifty->new; };  BEGIN { Jifty->new; };
16  Jifty->web->request(Jifty::Request->new);  Jifty->web->request(Jifty::Request->new);
17  Jifty->web->response(Jifty::Response->new);  Jifty->web->response(Jifty::Response->new);
# Line 23  my $total = 0; Line 25  my $total = 0;
25  find({ no_chdir => 1, wanted => sub {  find({ no_chdir => 1, wanted => sub {
26          my $path = $File::Find::name;          my $path = $File::Find::name;
27          return unless -f $_;          return unless -f $_;
28          warn "? $path\n";          warn "? $path\n" if $debug;
29          return unless m/conf\.php$/;          return unless m/conf\.php$/;
30    
31          $path =~ m{/etc/([^/]+)/conf\.php$} or die "can't find site name in $path";          $path =~ m{/etc/([^/]+)/conf\.php$} or die "can't find site name in $path";
# Line 31  find({ no_chdir => 1, wanted => sub { Line 33  find({ no_chdir => 1, wanted => sub {
33    
34          my $data = A3C::PHP->parse_file( $path );          my $data = A3C::PHP->parse_file( $path );
35    
36          warn "# PHP = ", dump( $data );          warn "# PHP = ", dump( $data ) if $debug;
37          $data->{site} = $site;          $data->{site} = $site;
38    
39          my ($id,$msg) = $model->load_or_create( %$data );          my ($ok,$msg) = $model->load_or_create( %$data );
40          warn "$id $site ", $msg || 'ADDED', "\n";          if ( $ok ) {
41          $total++ if $id;                  Jifty->log->info("$ok $site ", $msg || 'ADDED');
42                    $total++;
43            } else {
44                    Jifty->log->error("can't parse $path");
45            }
46    
47  }}, $config->{dir} );  }}, $config->{dir} );
48    

Legend:
Removed from v.139  
changed lines
  Added in v.147

  ViewVC Help
Powered by ViewVC 1.1.26