<commit_before><?php	

namespace LaPoiz\WindBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Config\Definition\Exception\Exception;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

//use LaPoiz\WindBundle\Entity\DataWindPrev;
use LaPoiz\WindBundle\core\websiteDataManage\WebsiteGetData;
use LaPoiz\WindBundle\core\maree\MareeGetData;


class GetDataCommand extends ContainerAwareCommand  {

 	protected function configure()
    {
        $this
            ->setName('lapoiz:getData')
            ->setDescription('Get Data from web site')
        ;
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
		// get list of URL 
    	$em = $this->getContainer()->get('doctrine.orm.entity_manager');
    	$dataWindPrevList = $em->getRepository('LaPoizWindBundle:DataWindPrev')->findAll();
    	
    	foreach ($dataWindPrevList as $dataWindPrev) {
            try {
                GetDataCommand::getDataFromDataWindPrev($dataWindPrev, $output, $em);
            } catch (Exception $e) {
                $output->writeln('<error>'.$e->getMessage().'</error>');
            }
    	}

        // Get Marée
        $spotList = $em->getRepository('LaPoizWindBundle:Spot')->findAll();

        $output->writeln('<info>************** GET MAREE ****************</info>');
        foreach ($spotList as $spot) {
            if ($spot->getMareeURL()!=null) {
                //$prevMaree = MareeGetData::getMaree($spot->getMareeURL());
                $prevMaree = MareeGetData::getMareeForXDays($spot->getMareeURL(),10);
                MareeGetData::saveMaree($spot, $prevMaree, $em, $output);
            }
        }
    }

    public static function getDataFromDataWindPrev($dataWindPrev, $output, $em) {
        $output->write('<info>Spot '.$dataWindPrev->getSpot()->getNom().' - </info>');

        // get each web site
        $output->writeln('<info>site '.$dataWindPrev->getWebSite()->getNom().' -> '.$dataWindPrev->getUrl().'</info>');

        // save data<commit_msg>pb d exception dans la commande resolu<commit_after><?php	

namespace LaPoiz\WindBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Config\Definition\Exception\Exception;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

//use LaPoiz\WindBundle\Entity\DataWindPrev;
use LaPoiz\WindBundle\core\websiteDataManage\WebsiteGetData;
use LaPoiz\WindBundle\core\maree\MareeGetData;


class GetDataCommand extends ContainerAwareCommand  {

 	protected function configure()
    {
        $this
            ->setName('lapoiz:getData')
            ->setDescription('Get Data from web site')
        ;
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
		// get list of URL 
    	$em = $this->getContainer()->get('doctrine.orm.entity_manager');
    	$dataWindPrevList = $em->getRepository('LaPoizWindBundle:DataWindPrev')->findAll();
    	
    	foreach ($dataWindPrevList as $dataWindPrev) {
            try {
                GetDataCommand::getDataFromDataWindPrev($dataWindPrev, $output, $em);
            } catch (\Exception $e) {
                $output->writeln('<error>'.$e->getMessage().'</error>');
            }
    	}

        // Get Marée
        $spotList = $em->getRepository('LaPoizWindBundle:Spot')->findAll();

        $output->writeln('<info>************** GET MAREE ****************</info>');
        foreach ($spotList as $spot) {
            if ($spot->getMareeURL()!=null) {
                //$prevMaree = MareeGetData::getMaree($spot->getMareeURL());
                $prevMaree = MareeGetData::getMareeForXDays($spot->getMareeURL(),10);
                MareeGetData::saveMaree($spot, $prevMaree, $em, $output);
            }
        }
    }

    public static function getDataFromDataWindPrev($dataWindPrev, $output, $em) {
        $output->write('<info>Spot '.$dataWindPrev->getSpot()->getNom().' - </info>');

        // get each web site
        $output->writeln('<info>site '.$dataWindPrev->getWebSite()->getNom().' -> '.$dataWindPrev->getUrl().'</info>');

        // save data
{'fraction_non_alphanumeric': 0.15807174887892378, 'fraction_numerical': 0.0008968609865470852, 'mean_word_length': 3.1305555555555555, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 63, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5929221', 'n_tokens_mistral': 1413, 'n_tokens_neox': 1336, 'n_words': 207}