コード例 #1
0
 protected function setUp()
 {
     global $configuration;
     $this->setBrowserUrl($configuration['googleFormUrl']);
     $this->configuration = $configuration;
     // workaround to be able to see the prompt text
     ob_end_flush();
     $this->password = Cli::readInput('Please type your password to the e-mail ' . $this->configuration['email'] . ': ', [], '', true);
     Cli::writeOutput(String::newLine());
     // return to the original state
     ob_start();
 }
コード例 #2
0
ファイル: log.php プロジェクト: mobly/hour-bank
                $date = $possibleDate->format($dateMySQLFormat);
                $argvIndex++;
            }
        }
        if (!isset($data[$date][$key])) {
            $data[$date][$key] = [];
        }
        $dataTodayKey =& $data[$date][$key];
        if (isset($argv[$argvIndex])) {
            $possibleTime = DateTime::createFromFormat($timeFormat, $argv[$argvIndex]);
            if ($possibleTime instanceof DateTime) {
                $argvIndex++;
                $dataTodayKey[] = ['start' => '00h00', 'stop' => $possibleTime->format($timeFormat), 'comment' => implode(' ', array_slice($argv, $argvIndex))];
                Cli::writeOutput($key . ' added' . String::newLine(2), Cli::COLOR_GREEN_BOLD);
                break;
            }
        }
        $count = count($dataTodayKey);
        $index = $count - 1;
        if ($count > 0 && !isset($dataTodayKey[$index]['stop'])) {
            $entry =& $dataTodayKey[$index];
            $entry['stop'] = $time;
            $entry['comment'] = implode(' ', array_slice($argv, 2));
            $duration = DateTime::createFromFormat($timeFormat, $entry['start'])->diff($now)->format($intervalFormat);
            Cli::writeOutput($key . ' stopped with ' . $duration . String::newLine(2), Cli::COLOR_GREEN_BOLD);
        } else {
            $dataTodayKey[] = ['start' => $time];
            Cli::writeOutput($key . ' started' . String::newLine(2), Cli::COLOR_GREEN_BOLD);
        }
}
file_put_contents($file, json_encode($data, JSON_PRETTY_PRINT));
コード例 #3
0
ファイル: bootstrap.php プロジェクト: mobly/hour-bank
<?php

use SimpleHelpers\Cli;
use SimpleHelpers\String;
declare (ticks=1);
$basePath = realpath(dirname(__FILE__) . '/../');
require $basePath . '/src/common.php';
$os = PHP_OS == 'Darwin' ? 'mac' : 'linux';
$showSeleniumDebug = false;
if (file_exists($basePath . '/vendor/chromedriver/chromedriver-' . $os . '/chromedriver')) {
    $seleniumDebug = $showSeleniumDebug ? '' : ' 2>&1';
    Cli::writeOutput('Starting Selenium' . String::newLine(2));
    $exec = exec('java -Dwebdriver.chrome.driver=' . $basePath . '/vendor/chromedriver/chromedriver-' . $os . '/chromedriver -jar ' . $basePath . '/vendor/seleniumhq/selenium-server-standalone/selenium-server-standalone-2.48.2.jar > /dev/null ' . $seleniumDebug . ' &', $output, $return);
    sleep(2);
    $shutdown = function () {
        Cli::writeOutput('Stopping Selenium' . String::newLine(2));
        $pid = Cli::execute('ps aux | grep selenium | grep -v grep | awk \'{ print $2 }\' "$@"');
        Cli::execute('kill -9 ' . $pid['return']);
        Cli::writeOutput('Done!' . String::newLine());
        exit;
    };
    register_shutdown_function($shutdown);
    // above not working yet :(
    pcntl_signal(SIGINT, $shutdown);
    pcntl_signal(SIGTERM, $shutdown);
    pcntl_signal(SIGUSR1, $shutdown);
    pcntl_signal(SIGQUIT, $shutdown);
}
コード例 #4
0
ファイル: balance.php プロジェクト: mobly/hour-bank
        }
    }
}
$reader->close();
if (!empty($configuration['slackEndpoint']) && !empty($configuration['channel'])) {
    Cli::writeOutput('Notifying Slack team', Cli::COLOR_GREEN_DIM);
    // Instantiate with defaults, so all messages created
    // will be sent from 'Cyril' and to the #accounting channel
    // by default. Any names like @regan or #channel will also be linked.
    $client = new Client($configuration['slackEndpoint'], ['username' => 'HourBank', 'channel' => $configuration['channel'], 'icon' => ':clock4:', 'markdown_in_attachments' => ['fields']]);
    /** @var $client Message */
    !$dryRun && $client->attach(['fallback' => $teamFallback, 'color' => 'bad', 'fields' => $team])->send($headLine);
}
if ($configuration['markAsDone']) {
    $modify = new Google_Service_Gmail_ModifyMessageRequest();
    $modify->setRemoveLabelIds(['INBOX']);
    !$dryRun && $service->users_messages->modify($user, $message->getId(), $modify);
    Cli::writeOutput('Message marked as *done*', Cli::COLOR_YELLOW_DIM);
}
if ($configuration['removeMessage'] && !$dryRun) {
    !$dryRun && $service->users_messages->trash($user, $message->getId());
    Cli::writeOutput('Message moved to trash!', Cli::COLOR_YELLOW_DIM);
}
if ($headLine) {
    Cli::writeOutput(String::newLine() . $headLine . String::newLine(), Cli::COLOR_WHITE_BOLD);
}
foreach ($teamCli as $member => $data) {
    Cli::writeOutput($member . ': ' . $data['hours'] . ' ' . $data['hourDirection'], $data['hourDirection'] == 'positivas' ? Cli::COLOR_GREEN : Cli::COLOR_RED);
}
Cli::writeOutput(String::newLine());