607a96d4 |
1 | pload TOPTEST |
2 | pload DCAF |
3 | |
4 | cpulimit 300 |
5 | |
6 | set ValidatorCheck 0 |
7 | |
8 | if { [info exists env(CSF_ValidatorPath)] != 0 } { |
9 | if {[file exists $env(CSF_ValidatorPath)]} { |
10 | set ValidatorCheck 1 |
11 | set Validator $env(CSF_ValidatorPath) |
12 | } |
13 | } |
14 | |
15 | if { [info exists imagedir] == 0 } { |
16 | set imagedir . |
17 | } |
18 | |
19 | if { [info exists test_image ] == 0 } { |
20 | set test_image photo |
21 | } |
22 | |
23 | set WorkDirectory $imagedir |
24 | |
37d6975c |
25 | set env(os_type) $tcl_platform(platform) |
26 | if { [regexp "indows" $env(os_type)] } { |
607a96d4 |
27 | if {[regexp -nocase {jdk} $env(PATH)] || [regexp -nocase {java} $env(PATH)]} { |
28 | set Java "java" |
29 | } else { |
30 | puts "Warning: environment variable PATH doesn't contain path to Java" |
31 | } |
32 | } else { |
33 | catch {set Java $env(JAVAHOME)/bin/java} |
607a96d4 |
34 | } |
35 | |
36 | set SchemaFile "" |
37 | |
38 | proc SaveToFile { aD aFile } { |
39 | upvar $aD D |
40 | global FileSuffix ValidatorCheck |
41 | catch {[file delete ${aFile}]} |
191082ac |
42 | SaveAs D $aFile |
607a96d4 |
43 | if { [file exists $aFile] } { |
44 | if { $FileSuffix == "xml" && $ValidatorCheck} { |
45 | ValidateXml $aFile |
46 | } else { |
47 | puts "Validation of XML file by XSD schema is not provided." |
48 | } |
49 | } else { |
50 | puts "Error : There is no ${aFile} file" |
51 | } |
52 | catch {[file attributes ${aFile} -permissions 0777]} |
53 | } |
54 | |
55 | proc ValidateXml { aFile } { |
56 | global Validator Java SchemaFile |
57 | if { ![info exists Java] } { |
58 | puts "Error : Java is not exists" |
59 | return |
60 | } |
61 | set isValidInfo "" |
62 | set ValCommand "exec $Java -jar $Validator $SchemaFile ${aFile}" |
63 | set isValid [catch {set isValidInfo [eval $ValCommand]}] |
64 | puts $isValidInfo |
65 | if { ![regexp "the document is valid" ${isValidInfo}] } { |
66 | puts "Error : File is not valid" |
67 | } |
68 | } |