view.php 6.42 KB
Newer Older
Julien Veyssier's avatar
Julien Veyssier committed
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="content-type">
<style type="text/css">
	tr { cursor: pointer; }
</style>
</head>
<body>
<?php
// param en get ID
// montrer dependencies, update.Rout
// faire un tableau jquery comme dans dnabushmeat avec les 00check.log
// colorier en rouge ceux qui ont échoué

include("config.php");

if (isset($_GET["check"])){
    echo "<table width='100%'>";

    $dir = $_GET["check"];


    $nbli = exec("ps aux | grep rtest.sh | grep -v grep | grep -v 'vi rtest.sh' | grep \"$dir\" |  wc -l");
    //$nbli = exec("ps aux | grep rtest.sh | grep $dir | wc -l");
    if ($nbli === "0"){
        echo "Process is NOT RUNNING<br/>";
    }
    else{
        echo "Process is RUNNING<br/>";
    }

    // Afficher l'isntall du package
    //echo $all_results_dir.$dir."/install_pkg.Rout";
    if (file_exists($all_results_dir.$dir."/install_pkg.Rout")){
            if (file_exists($all_results_dir.$dir."/install_pkg_ok")){
                $version = file_get_contents($all_results_dir.$dir."/pkg.version");
                $status = "ok, version $version";
                $color = "#4EE877";
            }
            else if(file_exists($all_results_dir.$dir."/install_pkg_problem")){
                $status = "problem";
                $color = "red";
            }
            else{
                $status = "running";
                $color = "yellow";
            }
        echo "<tr style='background-color:$color' class='title'><td>$package_to_test INSTALL PROCESS</td>";
        echo "<td>$status</td></tr>";
        echo "<tr class='retractable' id='update'><td colspan=3><textarea cols='240' rows='30'>".file_get_contents($all_results_dir.$dir."/install_pkg.Rout")."</textarea></td></tr>";
    }

    // Afficher l'update
    //echo $all_results_dir.$dir."/update.Rout";
    if (file_exists($all_results_dir.$dir."/update.Rout")){
            if (file_exists($all_results_dir.$dir."/update_ok")){
                $status = "ok";
                $color = "#4EE877";
            }
            else if(file_exists($all_results_dir.$dir."/update_problem")){
                $status = "problem";
                $color = "red";
            }
            else{
                $status = "running";
                $color = "yellow";
            }
        echo "<tr style='background-color:$color' class='title'><td>UPDATE PROCESS</td>";
        echo "<td>$status</td></tr>";
        echo "<tr class='retractable' id='update'><td colspan=3><textarea cols='200' rows='30'>".file_get_contents($all_results_dir.$dir."/update.Rout")."</textarea></td></tr>";
    }

    // INSTALL

    foreach(scandir($all_results_dir.$dir) as $elem){
        // si c'est un package tar
        if (strpos($elem,"_install.Rout") != False){

            $package = explode("_",$elem);
            $package_name = $package[0];

            // si CHECKOK
            if (file_exists($all_results_dir.$dir."/".$package_name."_install_ok")){
                $status = "ok";
                $color = "#4EE877";
            }
            // si CHECKPROBLEM
            else if(file_exists($all_results_dir.$dir."/".$package_name."_install_problem")){
                $status = "problem";
                $color = "red";
            }
            else{
                $status = "running";
                $color = "yellow";
            }

            $log = file_get_contents($all_results_dir.$dir."/".$package_name."_install.Rout");
            echo "<tr style='background-color:$color' class='title'><td>INSTALL $package_name</td>";
            echo "<td>$status</td></tr>";
            echo "<tr class='retractable' id='$package_name'><td colspan=3><textarea cols='200' rows='30'>$log</textarea></td></tr>";
        }
    }

    // CHECK
    foreach(scandir($all_results_dir.$dir) as $elem){
        // si c'est un package tar
        if (strpos($elem,".tar.gz") != False){

            $package = explode("_",str_replace(".tar.gz","",$elem));
            $package_name = $package[0];
            $package_version = $package[1];

            // si CHECKOK
            if (file_exists($all_results_dir.$dir."/".$package_name.".CHECKOK")){
                $status = "ok";
                $color = "#4EE877";
            }
            // si CHECKPROBLEM
            else if(file_exists($all_results_dir.$dir."/".$package_name.".CHECKPROBLEM")){
                $status = "problem";
                $color = "red";
            }
            else{
                $status = "running";
                $color = "yellow";
            }

            $log = file_get_contents($all_results_dir.$dir."/".$package_name.".Rcheck/00check.log");
            echo "<tr style='background-color:$color' class='title'><td>CHECK $package_name V $package_version</td>";
            echo "<td>$status</td></tr>";
            echo "<tr class='retractable' id='$package_name'><td colspan=3><textarea cols='200' rows='30'>$log</textarea></td></tr>";
        }
    }
    echo "</table>";
}
else{
    # on montre les tests dispos
    foreach(scandir($all_results_dir) as $elem){
        // si c'est un dossier de check
        if (strpos("a".$elem,"check_") != False){
            echo "<a href='?check=$elem'>$elem</a><br/>";
        }
    }
}
?>
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
<script>
$( document ).ready(function() {

	jQuery.fn.putCursorAtEnd = function() {

		return this.each(function() {

			$(this).focus()

				// If this function exists...
				if (this.setSelectionRange) {
					// ... then use it (Doesn't work in IE)

					// Double the length because Opera is inconsistent about whether a carriage return is one character or two. Sigh.
					var len = $(this).val().length * 2;

					this.setSelectionRange(len, len);

				} else {
					// ... otherwise replace the contents with itself
					// (Doesn't work in Google Chrome)

					$(this).val($(this).val());

				}

			// Scroll to the bottom, in case we're in a tall textarea
			// (Necessary for Firefox and Google Chrome)
			this.scrollTop = 999999;

		});

	};



    $('.retractable').each(function(){
        $(this).hide();
    });
    $('.title').each(function(){
        $(this).click(function(){
            if (! $(this).next().is(":visible")){
                $(this).next().show();
		$(this).next().find('textarea').putCursorAtEnd();
            }
            else{
                $(this).next().hide();
            }
        });
    });
    $("html, body").animate({ scrollTop: $(document).height() }, "slow");
});
</script>

</body>
</html>