示例#1
0
 /**
  * Downloads the given URL to the given target
  *
  * @param [string] $url    Location of file to download
  * @param [string] $target Location to download file to
  * @return [void]
  */
 public static function download($url, $target)
 {
     try {
         $response = Request::download($url, $target);
         return $target;
     } catch (Exception $e) {
         Terminus::error($e->getMessage());
     }
 }
示例#2
0
 /**
  * Downloads the given URL to the given target
  *
  * @param [string] $url    Location of file to download
  * @param [string] $target Location to download file to
  * @return [void]
  */
 public function download($url, $target)
 {
     try {
         $response = Request::download($url, $target);
         return $target;
     } catch (Exception $e) {
         $this->log()->error($e->getMessage());
     }
 }
示例#3
0
 /**
  * Retrieves a single backup or downloads it as requested
  *
  * @params [array] $assoc_args Parameters and flags from the command line
  * @return [string] $url->url
  */
 private function getBackup($assoc_args)
 {
     $site = $this->sites->get(Input::sitename($assoc_args));
     $env = $site->environments->get(Input::env(array('args' => $assoc_args, 'site' => $site)));
     $file = Input::optional('file', $assoc_args, false);
     if ($file) {
         $backup = $env->backups->getBackupByFileName($file);
         $element = $backup->getElement();
     } else {
         $element = Input::backupElement(array('args' => $assoc_args));
         $latest = (bool) Input::optional('latest', $assoc_args, false);
         $backups = $env->backups->getFinishedBackups($element);
         if ($latest) {
             $backup = array_pop($backups);
         } else {
             $context = array('site' => $site->get('name'), 'env' => $env->get('id'));
             $backup = Input::backup(array('backups' => $backups, 'context' => $context));
         }
     }
     $url = $backup->getUrl();
     if (isset($assoc_args['to'])) {
         $target = str_replace('~', $_SERVER['HOME'], $assoc_args['to']);
         if (is_dir($target)) {
             $filename = Utils\getFilenameFromUrl($url);
             $target = sprintf('%s/%s', $target, $filename);
         }
         $this->log()->info('Downloading ... please wait ...');
         if (Request::download($url, $target)) {
             $this->log()->info('Downloaded {target}', compact('target'));
             return $target;
         } else {
             $this->failure('Could not download file');
         }
     }
     return $url;
 }