Skip to content

Instantly share code, notes, and snippets.

@jesusbagpuss
Last active March 22, 2017 15:01
Embed
What would you like to do?
Test whether an EPrints Plugin is OK
#!/usr/bin/perl -w
######################################################################
## 1. save file as <eprints_root>/bin/local/check_plugin
## 2. make it executable
## 3. run it: <eprints_root>/bin/local/check_plugin ARCHIVEID PLUGIN
## PLUGIN should be e.g. Export::OAI_DC or Screen::FirstTool
######################################################################
use FindBin;
use lib "$FindBin::Bin/../../perl_lib";
use strict;
use EPrints;
my $repoid = $ARGV[0];
my $session = new EPrints::Session( 1, $repoid, 1 );
if( !defined $session )
{
print STDERR "Failed to load repository: $repoid\n";
exit 1;
}
my $pluginid = $ARGV[1];
if( !defined $pluginid )
{
print STDERR "Please supply a plugin id (the part after 'Plugin::' )\n";
exit 1;
}
print "Checking $pluginid\n";
my $plugin = $session->plugin( $pluginid );
if( !defined $plugin ){
print STDERR "Couldn't find $pluginid\n";
$session->terminate;
exit 1;
}
if( $plugin->broken ){
print STDERR "Plugin $pluginid could not run because:\n";
print STDERR $plugin->error_message."\n";
$session->terminate;
exit 1;
}
print "Plugin $pluginid seems to be OK...\n";
print "Plugin $pluginid is module: ", ref $plugin, ".\n";
print "Metadata prefix: ", $plugin->param( "metadataPrefix" ), ".\n";
$session->terminate;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment