Commit 796f2a68 authored by Vincent Mazenod's avatar Vincent Mazenod
Browse files

tweat app import force commands

parent 93c5f4bd
Juniperus Salix Alnus Betula Pinus Corylus Quercus Ulmus Tilia Fraxinus Abies Fagus Olea Carpinus Juglans Castanea Picea Poaceae Cerealia-type Secale-type
0 0 1.08 3.77 6.47 21.29 27.22 8.36 17.52 5.66 0.27 0.81 0 0 0 0 0 2.96 0 0
0 0.32 2.54 2.54 6.98 23.17 30.48 6.98 14.92 2.54 0 0.63 0.32 0 0 0 0 1.59 0 0
0.59 0 2.35 2.35 7.04 29.91 27.57 5.87 12.02 4.99 0 1.17 0 0 0 0 0 1.17 0 0
0.49 0.25 1.23 6.67 4.94 33.09 19.75 3.95 11.36 5.68 0 1.98 0.25 0 0 0 0 2.96 0 0
0.29 0 0.86 4.61 8.07 27.09 23.05 4.61 9.22 7.2 0 5.19 0 0 0 0 0 1.73 0 0
0.76 0.25 2.78 3.29 9.87 28.86 20.76 3.54 11.65 7.59 0 3.04 0 0 0 0 0 2.78 0 0
0.48 0 2.16 2.88 7.91 25.9 28.06 4.56 7.19 6.24 0 6.47 0 0 0 0 0 2.4 0 0
0.2 0.61 1.64 2.45 13.29 20.65 22.7 3.89 3.89 3.68 0.41 15.34 0 0 0 0 0 3.68 0 0
0.21 0.42 1.48 4.64 9.07 19.62 20.89 3.38 3.8 4.64 0.21 19.41 0 0 0 0 0 4.43 0 0
0 1.47 2.95 4.72 5.9 16.22 21.24 4.13 7.96 2.36 0 22.42 0 0 0 0 0 3.54 0 0
0 0.3 1.22 2.74 6.38 17.02 19.76 0.91 3.65 2.13 0.3 31 0 0 0 0 0 3.95 0.3 0
0 0.56 2.23 3.34 6.41 21.17 19.5 2.79 6.13 1.95 0.56 22.01 0 0 0 0 0 6.13 0.28 0
0 0.61 2.86 4.08 10 20.82 18.16 0.82 2.04 1.84 0.61 19.18 0 0 0 0 0 8.78 0.2 0
0 0 1.7 4.26 21.88 9.09 22.73 0.85 2.56 1.99 0 31.25 0 0 0 0 0 1.14 0 0
0 0.62 3.08 5.34 26.69 10.47 18.28 1.03 2.46 1.85 0.21 24.23 0 0 0 0 0 2.05 0 0
0.25 0.49 2.95 2.21 14.5 8.85 25.55 1.23 2.21 2.7 0.74 28.99 0 0 0 0 0 2.46 0.25 0
0 0.23 2.33 3.26 5.36 6.53 25.87 0.93 3.03 3.03 0.7 40.79 0.23 0 0 0 0 3.03 0 0
0 1.12 2.91 2.24 2.68 9.17 16.55 1.34 2.01 0.89 1.12 50.34 0 0 0 0 0 2.91 0 0
0 0 1.23 1.97 2.22 6.65 18.72 1.72 1.48 3.94 0.25 56.9 0.25 0 0 0 0 1.72 0 0
0 0.58 2.59 1.44 3.17 7.78 17.87 2.02 1.44 2.02 1.44 52.74 0 0 0 0 0 1.73 0 0
......@@ -6,6 +6,7 @@ use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Doctrine\ORM\EntityManagerInterface;
......@@ -16,15 +17,21 @@ class ForceSchemaCommand extends Command
protected $testServer = "mobipaleo.test.local.isima.fr";
protected $prodServer = "mobipaleo.cri.local.isima.fr";
protected $remoteSshUserKeyPath = "~/.ssh/stack/limosadm";
protected $remoteDatasheetsDirPath = "/var/www/mobipaleo/current/public/uploads/datasheets";
protected $remoteSshUser = "limosadm";
protected $remoteSshPath = "/var/www/my/current";
protected $localDbUser = "admin";
private $em;
private $params;
public function __construct(EntityManagerInterface $entityManager)
public function __construct(
EntityManagerInterface $entityManager,
ParameterBagInterface $params
)
{
$this->em = $entityManager;
$this->params = $params;
parent::__construct();
}
......@@ -53,6 +60,10 @@ class ForceSchemaCommand extends Command
else
$server = $this->prodServer;
# import csv
shell_exec('rm -rf '.$this->remoteDatasheetsDirPath.'/*.csv');
shell_exec('scp -i '.$this->params->get('datasheets_dir').'/*.csv '.$this->remoteSshUserKeyPath.' '.$this->remoteSshUser.'@'.$server.':'.$this->remoteDatasheetsDirPath.'/');
# force schema
shell_exec("mysqldump -u '.$this->localDbUser.' '.$database.' > /tmp/'.$database.'.sql");
shell_exec('ssh -i '.$this->remoteSshUserKeyPath.' '.$this->remoteSshUser.'@'.$server.' "cd '.$this->remoteSshPath.' && php bin/console doctrine:database:drop --force"');
shell_exec('ssh -i '.$this->remoteSshUserKeyPath.' '.$this->remoteSshUser.'@'.$server.' "cd '.$this->remoteSshPath.' && php bin/console doctrine:database:create"');
......
......@@ -7,25 +7,33 @@ use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Doctrine\ORM\EntityManagerInterface;
class ImportSchemaCommand extends Command
class ImportCommand extends Command
{
// the name of the command (the part after "bin/console")
protected static $defaultName = 'app:import';
protected $testServer = "mobipaleo.test.local.isima.fr";
protected $prodServer = "mobipaleo.cri.local.isima.fr";
protected $remoteSshUserKeyPath = "~/.ssh/stack/limosadm";
protected $remoteDatasheetsDirPath = "/var/www/mobipaleo/current/public/uploads/datasheets";
protected $remoteSshUser = "limosadm";
protected $localDbUser = "admin";
private $em;
private $params;
public function __construct(EntityManagerInterface $entityManager)
public function __construct(
EntityManagerInterface $entityManager,
ParameterBagInterface $params
)
{
$this->em = $entityManager;
$this->params = $params;
parent::__construct();
}
......@@ -54,8 +62,11 @@ class ImportSchemaCommand extends Command
else
$server = $this->prodServer;
# import csv
shell_exec('rm -rf '.$this->params->get('datasheets_dir').'/*.csv');
shell_exec('scp -i '.$this->remoteSshUserKeyPath.' '.$this->remoteSshUser.'@'.$server.':'.$this->remoteDatasheetsDirPath.'/*.csv '.$this->params->get('datasheets_dir').'/');
# import schema
shell_exec('ssh -i '.$this->remoteSshUserKeyPath.' '.$this->remoteSshUser.'@'.$server.' "mysqldump '.$database.'" > /tmp/'.$database.'.sql');
$dropCmd = $this->getApplication()->find('doctrine:database:drop');
$dropCmd->run(new ArrayInput([ '--force' => true ]), $output);
$createCmd = $this->getApplication()->find('doctrine:database:create');
......@@ -64,7 +75,7 @@ class ImportSchemaCommand extends Command
$createCmd->run(new ArrayInput([]), $output);
shell_exec('mysql -u '.$this->localDbUser.' '.$database.' < /tmp/'.$database.'.sql');
//shell_exec('rm /tmp/'.$database.'.sql');
shell_exec('rm /tmp/'.$database.'.sql');
$output->writeln("<fg=cyan>app imported</>");
......
......@@ -93,7 +93,7 @@ class MiningCommand extends Command {
$output->writeln(" * memory usage: ".$this->convertBytes2($memory, 'K')." KB");
$output->writeln(" * time: ".$time/pow(10,9). " seconds");
$output->writeln(" * output: ./public/datasheets/".$job->getOutputDatasheet());
$output->writeln(" * output: ./public/uploads/datasheets/".$job->getOutputDatasheet());
}
// https://isabelcastillo.com/php-convert-bytes
......
......@@ -145,7 +145,8 @@ class JobController extends AbstractController
}
return $this->render('job/show.html.twig', [
'job' => $job
'job' => $job,
'constraintMiningChoices' => array_flip(ConstraintMining::$constraintMiningChoices)
]);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment