Git Product home page Git Product logo

playcli's Issues

CLI.pipe lock issue with `convert`

Example: CLI.pipe("convert - png:-")

Bug: the command is never terminated. stdin is written, but nothing is read from the command which is not responding.

It is not possible to grep tail command

Tail as an enumerator keeps waiting and does not go through grep. Below is a sample code to reproduce the issue.

val file = args(0)
val pattern = args(1)

val tail = CLI.enumerate(Seq("tail", "-f", file))
val grep = CLI.pipe(Seq("grep", pattern))
val printlnIteratee = Iteratee.foreach[Array[Byte]](s => print(new String(s)))

tail &> grep |>>> printlnIteratee

CLI.pipe not working with Enumerator.generateM

  import collection.immutable.StringOps
  import play.api.libs.concurrent.Promise.timeout
  import concurrent.{Await}
  import concurrent.duration.Duration
  val maxDuration = Duration.Inf
  val stringToBytes = (str: StringOps) => str.map(_.toByte).toArray
  val bytesJoinConsumer = Iteratee.fold[Array[Byte], Array[Byte]](Array[Byte]())((a, b) => a++b)
  val nbOfLines = 3
  val line = stringToBytes("hello\n")
  val enum = Enumerator.generateM[Array[Byte]] {
    timeout(Some(line), 5)
  }
  val pipe = CLI.pipe(Seq("head", "-n", nbOfLines.toString), 10)

  val result: Array[Byte] = Await.result(enum &> pipe |>>> bytesJoinConsumer, maxDuration)
  println(result.map(_.toChar).mkString)

Handle CLI errors (command not found kind)

I've started to implement it like this:

(pipe example)

  runProcess(command) map { case (process, stdin, stdout, stderr) =>
     ...
  } getOrElse(Future.successful(Error("CLI failed", Input.Empty)))

But it's maybe not the good way.

CLI.pipe issues

CLI.pipe current implementation seems to lock in some case (command are not closed and nothing is streamed anymore).

  1. when chaining multiple CLI.pipe.
  2. when triggering a lot of pipe (with the ffmpeg example and opening multiple connections).
  3. during some time (~ 2min in the webradio example)

Example for (1):

import concurrent.ExecutionContext.Implicits.global
import concurrent.{Future, Await}
import concurrent.duration.Duration
import play.api.libs.iteratee._
import cli.CLI

val enum = Enumerator("test".map(_.toByte).toArray)
val cat = CLI.pipe("cat")
val all = enum &> cat &> cat &> cat |>>> Iteratee.consume[Array[Byte]]()
concurrent.Await.result(all, Duration("2 s")).map(_.toChar).mkString

Make broadcast working

Exemple:

val addEchoToOgg = CLI.pipe("sox -t ogg - -t ogg - echo 0.5 0.7 60 1")
val radioStream = proxyBroadcast("http://radio.hbr1.com:19800/ambient.ogg")
val (radioStreamWithEcho, _) = Concurrent.broadcast(radioStream &> addEchoToOgg)

def radio = Action(Ok.stream(radioStreamWithEcho).withHeaders(CONTENT_TYPE -> "audio/ogg"))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.