Beispiel #1
0
 /**
  * @param Cache $imagesCache in Falle eines FileCaches wird vor diesen kein "images" angehängt (als cache key)
  */
 public function __construct($imageEntityName = 'BasicImage', EntityManager $em, Dir $imagesDirectory, Cache $imagesCache)
 {
     $this->entityName = $imageEntityName;
     $this->em = $em;
     $this->imageRep = $this->em->getRepository($this->entityName);
     $this->directory = $imagesDirectory->create();
     $this->cache = $imagesCache;
     $this->imagine = new Imagine();
     $this->images = new ArrayCollection();
 }
Beispiel #2
0
 public function commitSinglePath(WebforgeDir $repositoryDir, $path, $contents, $commitMessage = NULL)
 {
     // wir müssen das repository auschecken (geht leider nicht anders)
     // wir checken das rep leer aus und machen update für den path
     $repoFile = $repositoryDir->getFile($path);
     $directoryUrl = clone $repoFile->getDirectory();
     $directoryUrl->wrapWith('file');
     $wc = Dir::createTemporary();
     $this->executeCommand('svn co ' . $directoryUrl . ' ' . $wc->getQuotedString(Dir::WITHOUT_TRAILINGSLASH));
     $wcFile = $wc->getFile($repoFile->getName());
     // wir haben ja das verzeichnis direkt ausgecheckt, deshalb brauchen wir hier nur den dateinamen
     $wcFile->writeContents($contents);
     $this->executeCommand('svn commit' . ($commitMessage ? ' -m' . escapeshellarg($commitMessage) : '') . ' ' . $wcFile->getQuotedString());
     $wc->delete();
 }
Beispiel #3
0
 /**
  * @param const $p  eine PSC::PATH_* Klassenkostante (jedoch ohne die PSC_CMS Dinger
  * @return Webforge\Common\System\Dir
  */
 public function getPath($p)
 {
     if (!array_key_exists($p, $this->dirs)) {
         if (!array_key_exists($p, $this->paths)) {
             throw new \Psc\Exception('Pfad: ' . Code::varInfo($p) . ' ist unbekannt. Pfade vorhanden: ' . implode(',', array_keys($this->paths)));
         }
         $this->dirs[$p] = $this->root->expand($this->paths[$p]);
     }
     return clone $this->dirs[$p];
 }
Beispiel #4
0
 protected function expandDestination($destination)
 {
     if (is_string($destination)) {
         if (S::endsWith($destination, '/')) {
             $destination = $this->targetProject->getRoot()->sub($destination);
         } else {
             $destination = Dir::createFromURL($destination, $this->targetProject->getRoot());
         }
     }
     return $destination;
 }
Beispiel #5
0
 /**
  * Gibt das Verzeichnis eines Namespaces in einem Verzeichnis zurück
  *
  * dies nimmt einfach den Namespace
  * @return Dir absolute im angebenen $classPath oder relatives Verzeichnis
  */
 public static function namespaceToPath($namespace, Dir $classPath = NULL)
 {
     // end und anfangs backslashs weg
     $namespace = trim($namespace, '\\');
     if (!isset($classPath)) {
         $classPath = new Dir('.' . DIRECTORY_SEPARATOR);
     }
     return $classPath->sub(str_replace('\\', '/', $namespace) . '/');
 }
Beispiel #6
0
        }
    }
    // das nimmt vielleicht zu viele, weis nicht, alternativ würds auch ne statische methode zur extension tun
    foreach ($extension->getProperties() as $property) {
        $fields[] = $property->getName();
    }
    $json = array();
    foreach (array_unique($fields) as $field) {
        $json[$field] = '%(ask:' . $field . ')';
    }
    $command->comment(sprintf('Komodo-Command für %s:', $extension->getClassName()));
    $output->writeln(\Psc\TPL\TPL::miniTemplate('cli.bat compile:generic %F inFile %extension% %json%', array('extension' => $extension->getClassName(), 'json' => json_encode((object) $json))));
});
$createCommand('git:pre-push-hook', array($arg('someFile'), $arg('someFile2'), $arg('workingTree')), function ($input, $output, $command) {
    $workingTree = Dir::factoryTS($input->getArgument('workingTree'));
    $dir = new Dir(__DIR__ . DIRECTORY_SEPARATOR);
    $root = $dir->up();
    if ($workingTree->equals($root)) {
        $dist = $root->getFile('dist/psc-cms.phar.gz');
        $lastMessage = exec('git log -n 1 --format=%s');
        $updateComposer = 'composer update --prefer-dist --dev';
        $buildPhar = $root->getFile('bin/cli') . ' build-phar';
        $cd = 'cd ' . $root;
        $ammend = 'git commit -m"' . $lastMessage . '" --amend -o ' . $dist . ' composer.lock ';
        system($cd . ' && ' . $updateComposer . ' && ' . $buildPhar . ' && ' . $ammend);
        return 0;
    }
    throw new Exception($workingTree . ' is not registered as hook script');
});
$createCommand('composer:update', array(), function ($input, $output, $command) {
    system('cd ' . $command->getProject()->getSrc() . ' &&php ' . \Psc\PSC::getRoot()->getFile('composer.phar') . ' update');
 /**
  * Nimmt alle verfügbaren Subtitles der Staffel und speichert sie nach Format gruppiert in Unterverzeichnissen
  * nach der Episodennummer im verzeichnis $root
  */
 public function downloadSubs(array $subs, Dir $root)
 {
     $this->Logger->writeln('downloade Subs');
     foreach ($subs as $episodeNum => $languages) {
         $episodeDir = $root->clone_()->append($episodeNum . '/');
         $episodeDir->make(Dir::ASSERT_EXISTS | Dir::PARENT);
         foreach ($languages as $lang => $formats) {
             foreach ($formats as $format => $attachment) {
                 $srt = new File($episodeDir, $format . '.' . $lang . '.srt');
                 if (!$srt->exists()) {
                     $req = new URLRequest('http://www.subcentral.de/' . $attachment, $this->cookieJar);
                     $archiveContents = $req->init()->process();
                     $res = $req->getResponse();
                     try {
                         $type = $res->getContentType() === 'application/x-rar-compressed' || File::factory($res->getAttachmentFilename())->getExtension() == 'rar' ? 'rar' : 'zip';
                     } catch (\Exception $e) {
                         $type = 'rar';
                     }
                     $destination = new File($episodeDir, $format . '.' . $lang . '.' . $type);
                     $destination->writeContents($archiveContents);
                     $destination = $this->tryUnpack($destination);
                     $this->logger->writeln('Schreibe Datei: ' . $destination);
                 } else {
                     $this->logger->writeln('Sub (srt) existiert schon. Überspringe Download.');
                 }
             }
         }
     }
 }
 protected function runOrganizer()
 {
     $this->downloadsDir = Dir::createTemporary();
     $this->targetDir = Dir::createTemporary();
     $this->jdownloaderRPC = $this->jd->build();
     $this->organizer = new DownloadsOrganizer($this->downloadsDir, $this->targetDir, $this->client, $this->jdownloaderRPC, $subsManager = NULL, $this->logger = new BufferLogger());
     $this->organizer->setHosterPrio($this->hosterPrio);
     $this->organizer->organize();
 }
Beispiel #9
0
 public function getProjectClassPath($name, Dir $root, $mode = self::MODE_SRC)
 {
     $paths = $this->getProjectPaths($name, $mode);
     return $root->expand($paths[PSC::PATH_CLASS]);
 }
Beispiel #10
0
 public function validateFile($path, $flags = self::MUST_EXIST)
 {
     $errorDetail = NULL;
     if (!empty($path)) {
         $file = File::factory($path);
         // workaround file
         if (self::RESOLVE_RELATIVE && !Dir::isAbsolutePath((string) $file->getDirectory()) && !$file->isRelative()) {
             $file->setDirectory(new Dir('.' . DIRECTORY_SEPARATOR . $file->getDirectory()));
         }
         $file->resolvePath();
         if (!($flags & self::MUST_EXIST) || $file->exists()) {
             return $file;
         } else {
             $errorDetail = ' It must exist!';
         }
     }
     throw $this->exitException(sprintf("File from path: '%s' cannot be found.%s", $path, $errorDetail));
 }
 public function cleanup(Dir $dir)
 {
     // @todo checks ob wir nicht doch was cooles löschen
     // @todo vielleicht hier auch aus dem JDownloader rausnehmen?
     $dir->delete();
 }
 public function doCompileCSWidgetsDir(Dir $specifcationsDir)
 {
     $converter = new JSONConverter();
     $compiled = array();
     foreach ($specifcationsDir->getFiles('json') as $file) {
         $compiled[] = $this->doCompileCSWidgetFile($file, $converter)->getWrittenFile();
     }
     return $compiled;
 }
Beispiel #13
0
if (!$conf['downloadDir'] || !$conf['targetDir']) {
    print 'Bitte unbedingt die Variablen downloadDir und targetDir in ' . $configFile . ' anpassen!';
    exit;
}
$reload = isset($_GET['reload']);
$update = isset($_GET['update']);
$scan = isset($_GET['scan']);
$client = new Client($conf['serienLoaderURL']);
$log = NULL;
$episodes = array();
if ($reload) {
    $organizer = new DownloadsOrganizer(new Dir($conf['downloadDir']), new Dir($conf['targetDir']), $client, new JDownloaderRPC($conf['jdownloader']['host'], $conf['jdownloader']['port']), $subtitlesManager = NULL, $log = new BufferLogger());
    $organizer->setHosterPrio($conf['hosterPrio']);
    $episodes = $organizer->organize();
} elseif ($update) {
    $root = Dir::factoryTS(__DIR__)->sub('../../../../')->resolvePath();
    $finder = new \Symfony\Component\Process\ExecutableFinder();
    $process = \Psc\System\Console\Process::build($finder->find('composer'))->addOption('working-dir', mb_substr($root, 0, -1))->addOption('prefer-dist')->addOption('v')->addArgument('update')->end();
    $process->run();
    $log = "Running self-update. \n";
    $log .= "run: " . $process->getCommandline() . "\n";
    $log .= $process->getOutput() . "\n";
    $log .= $process->getErrorOutput() . "\n";
} elseif ($scan) {
    $xbmc = new XBMC($conf['xbmc']['username'], $conf['xbmc']['password'], $conf['xbmc']['port']);
    $log = 'Forcing XBMC to scan. Response: ';
    $log .= $xbmc->scan();
} else {
    $episodes = $client->getEpisodes();
    $log = 'nothing was updated. Hit reload';
}