/[A3C]/bin/import-strix-config.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

Annotation of /bin/import-strix-config.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 146 - (hide annotations)
Tue Jun 3 10:10:20 2008 UTC (12 years, 11 months ago) by dpavlin
Original Path: bin/import-strix.pl
File MIME type: text/plain
File size: 1000 byte(s)
split errors only with debug flag and log errors as, well errors...
1 dpavlin 139 #!/usr/bin/perl
2    
3     use warnings;
4     use strict;
5    
6     use lib 'lib';
7    
8     use Jifty;
9     use Data::Dump qw/dump/;
10     use File::Find;
11     use A3C::PHP;
12    
13 dpavlin 146 my $debug = 0;
14    
15 dpavlin 139 BEGIN { Jifty->new; };
16     Jifty->web->request(Jifty::Request->new);
17     Jifty->web->response(Jifty::Response->new);
18    
19     my $config = Jifty->config->app('strix') or die "need strix config";
20    
21     my $model = A3C::Model::StrixSite->new;
22    
23     my $total = 0;
24    
25     find({ no_chdir => 1, wanted => sub {
26     my $path = $File::Find::name;
27     return unless -f $_;
28 dpavlin 146 warn "? $path\n" if $debug;
29 dpavlin 139 return unless m/conf\.php$/;
30    
31     $path =~ m{/etc/([^/]+)/conf\.php$} or die "can't find site name in $path";
32     my $site = $1;
33    
34     my $data = A3C::PHP->parse_file( $path );
35    
36 dpavlin 146 warn "# PHP = ", dump( $data ) if $debug;
37 dpavlin 139 $data->{site} = $site;
38    
39     my ($id,$msg) = $model->load_or_create( %$data );
40 dpavlin 146 Jifty->log->info("$id $site ", $msg || 'ADDED');
41     if ( $id ) {
42     $total++;
43     } else {
44     Jifty->log->error("can't parse $path: $msg");
45     }
46 dpavlin 139
47     }}, $config->{dir} );
48    
49     Jifty->log->info( "$total Strix sites imported" );

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26