Archived
1
0
Fork 0
This repository has been archived on 2021-10-08. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
ACU/process/files/moulette_get.pl
2013-09-20 03:35:53 +02:00

91 lines
1.7 KiB
Perl

#! /usr/bin/env perl
use v5.10.1;
use strict;
use warnings;
use Pod::Usage;
use File::Temp;
use ACU::Log;
use ACU::Process;
my %actions = (
"tar" => \&receive_tar,
"git" => \&receive_tar, # \&receive_git
"tests" => \&create_testsuite,
"moulette" => \&moulette,
);
sub receive_tar
{
my $project_id = $args->{param}{id};
my $year = $args->{param}{year};
my $rendu = $args->{param}{rendu};
my $file = $args->{param}{file};
if (!exists $args->{files}{$file}) {
return "No file named '$file' given".
}
($fh, $filename) = tempfile(SUFFIX => $file);
binmode($fh);
print $fh $args->{files}{$file};
close $fh;
# TODO: Call Fact for create .ff
return "Ok"
}
sub create_testsuite
{
my $project_id = $args->{param}{id};
my $year = $args->{param}{year};
my $rendu = $args->{param}{rendu};
my $file = $args->{param}{file};
($fh, $filename) = tempfile();
if (!exists $args->{files}{$file}) {
return "No file named '$file' given".
}
($fh, $filename) = tempfile(SUFFIX => $file);
binmode($fh);
print $fh $args->{files}{$file};
close $fh;
# TODO: Call Fact to create testsuite
return "Ok"
}
sub moulette
{
my $project_id = $args->{param}{id};
my $year = $args->{param}{year};
my $rendu = $args->{param}{rendu};
my $login = $args->{param}{login};
# TODO: Call Fact to launch student tarball
return "Ok"
}
sub process_get
{
my ($given_args, $args) = @_;
my $type = $args->{param}{type};
if (! exists $actions{$type}) {
log WARN, "Unknown type '$type'";
return "Unknown type '$type'.";
}
return $actions{$type}($args);
}
Process::register("moulette_get", \&process_get);