-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_xids.php
41 lines (41 loc) · 1.22 KB
/
get_xids.php
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
<?php
private function downloadFile($url, $path)
{
$newfname = $path;
$file = fopen ($url, 'rb');
if ($file) {
$newf = fopen ($newfname, 'wb');
if ($newf) {
while(!feof($file)) {
fwrite($newf, fread($file, 1024 * 8), 1024 * 8);
}
}
}
if ($file) {
fclose($file);
}
if ($newf) {
fclose($newf);
}
}
header("Content-type: text/plain; charset=utf-8");
$data = $_POST["input"];
$suffix = date(DATE_ATOM);
$in_file = "/tmp/uids_" . $suffix . ".txt";
$out_file = "/tmp/xids_" . $suffix . ".txt";
file_put_contents($in_file, $data);
$venv = "/tmp/venv_" . $suffix;
$python3 = exec("which python3");
echo $python3;
$ucca = "/cs/nlp/danielh/workspace/ucca";
echo shell_exec("python3 -m venv $venv 2>&1");
downloadFile("https://bootstrap.pypa.io/get-pip.py", "get-pip.py");
echo file_put_contents("get-pip.py");
echo shell_exec("$venv/bin/python get-pip.py 2>&1)");
echo shell_exec("$venv/bin/pip install tqdm 2>&1");
//putenv("PYTHONPATH=$ucca:" . $_ENV["PYTHONPATH"]);
//echo shell_exec("$venv/bin/python $ucca/scripts/ucca_db_download.py $in_file -nx $out_file 2>&1");
unlink($in_file);
echo file_get_contents($out_file);
unlink($out_file);
?>