-
Notifications
You must be signed in to change notification settings - Fork 0
/
grade.go
57 lines (44 loc) · 971 Bytes
/
grade.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package main
import (
"fmt"
"github.com/dandalf/autograde/lab/javalab"
"log"
"os"
"os/exec"
)
func init() {
}
func check(e error) {
if e != nil {
log.Fatal("Fatal Error :", e)
panic(e)
}
}
type ExtProg struct {
cmdName string
args []string
}
func main() {
if len(os.Args) != 2 {
fmt.Printf("Proper usage: %v NameLabOne.zip\n", os.Args[0])
return
}
secPolicyPath := fmt.Sprintf("secpolicy")
log.Printf("Loading java sec policy %v", secPolicyPath)
// Load the arguments
zipFileName := os.Args[1]
studentLab, err := javalab.New(zipFileName, secPolicyPath)
check(err)
// Begin processing the lab
fmt.Printf("Processing %v\n", zipFileName)
err = studentLab.Build()
check(err)
gradeReportFile, err := studentLab.RunAndReport()
// Clean up files
if err = studentLab.CleanUp(); err != nil {
check(err)
}
// Open up textmate to grade output file
textMateCmd := exec.Command("mate", gradeReportFile.Name())
textMateCmd.Run()
}