This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-09-10
Channels
- # announcements (8)
- # aws-lambda (4)
- # babashka (60)
- # beginners (65)
- # braveandtrue (5)
- # chlorine-clover (3)
- # cider (10)
- # clj-kondo (2)
- # cljdoc (2)
- # cljfx (32)
- # cljsrn (5)
- # clojure (198)
- # clojure-berlin (10)
- # clojure-europe (22)
- # clojure-france (1)
- # clojure-losangeles (33)
- # clojure-nl (3)
- # clojure-norway (22)
- # clojure-uk (35)
- # clojurescript (12)
- # code-reviews (14)
- # core-typed (1)
- # cursive (56)
- # datomic (13)
- # depstar (7)
- # emacs (1)
- # events (1)
- # figwheel-main (3)
- # fulcro (30)
- # graphql (15)
- # helix (1)
- # jobs (5)
- # juxt (6)
- # kaocha (14)
- # klipse (2)
- # malli (12)
- # off-topic (88)
- # portal (4)
- # re-frame (3)
- # reagent (5)
- # shadow-cljs (6)
- # specter (6)
- # sql (73)
- # tools-deps (15)
- # windows (4)
struggling a bit to get the output of a ProcessBuilder
workflow (my Java is weak)
(defn find-files! []
(let [proc (-> (ProcessBuilder. ["find" "./some-dir"])
(.redirectOutput ProcessBuilder$Redirect/INHERIT)
(.redirectError ProcessBuilder$Redirect/INHERIT)
(.start))
proc-input (.getOutputStream proc)]
(into [] ????)))
(ripped off from https://github.com/borkdude/babashka/blob/master/examples/process_builder.clj)
@goomba Not sure where you're going with that example: you want to feed input to the process?
It's probably safe to assume that I'm totally misunderstanding ProcessBuilder and the output streams. My goal here is to capture the output of a long running process, like a large "git clone", and capture the output into a string or a vector of strings.
In some previous work I tried using shell/sh
, but it doesn't seem suitable for long running tasks
I tried looking into the Java API for how to work with the redirects of the ProcessBuilder but I got lost in the sauce
(require '[ :as io])
(defn find-files [path]
(let [proc (-> (ProcessBuilder. ["find" path])
(.start))
output (.getInputStream proc)]
(future
(run! prn (line-seq (io/reader output))))))
@(find-files (first *command-line-args*))
$ bb /tmp/foo.clj /tmp/version-clj
"/tmp/version-clj"
"/tmp/version-clj/test"
"/tmp/version-clj/test/cljx"
"/tmp/version-clj/test/cljx/version_clj"
...
Confusingly, you get the output of the process using .getInputStream
because it returns an inputstream
sweet! thank you
This is an in progress library which should make all of this easier: https://github.com/babashka/babashka.process
You can also take a look at https://github.com/babashka/babashka.process
Any thoughts on this discussion? https://github.com/http-kit/http-kit/issues/442#issuecomment-690040016. If you have, consider posting your thoughts there.
I've added a simple example of using Babashka to rewrite an existing bash script into Clojure to perform spotifyd notifications on Linux: https://github.com/dharrigan/spotifyd-notification
Cool! Feel free to add to https://github.com/borkdude/babashka/blob/master/doc/libraries.md which also features projects
Curious about techniques for Babashka applications-as-scripts.
For instance, I created two files, config.clj
and core.clj
(which requries config.clj
with a deps.edn
and the traditional project structure. However from a non-root directory when I tried bb -f ../path/to/src/core.clj
, I got the cannot find my-project.config.clj
error message
If I wanted to have a more complex setup but still use it as a script, would I be looking at making an Uberjar?
root dir?
that has the deps?
I gotta tell you @borkdude this damn project is so much damn fun hahaha
Good to hear :)
So if your sources are in <project>/src
then classpath should be src
, but you then go into ..
then your classpath should become <project>/src
but maybe using absolute paths for that is the least confusing
understood. So regardless of what location I'm in, if I set the -cp
to the src
of the project (relatively or absolutely, as long as it is correct). Does that mean then that if I have src/project_name/*.clj
files, and the namespaces are (ns project-name.something)
, it should still be src
?
to be more specific:
$ tree
.
├── deps.edn
├── Makefile
└── src
└── react_deployment
├── config.clj
└── core.clj
so still point to src
with the classpath?
you can also make the classpath the current directory and have no src dir for example
perfect
yep that did it
I can't wait to try out some crazy socket/async stuff
Hey,
I have been writing a bit of babashka lately (it’s absolutely amazing btw) I was wondering what was the best way to interact with AWS with babashka. I have been doing some stuff with generating and running commands with clojure.java.shell
but I was wondering if there was a way to either use the java sdk or if a library to integrate with the AWS api or something (couldn’t find something here https://github.com/borkdude/babashka/blob/master/doc/libraries.md)
@thomas.ormezzano It's been asked a couple of times before. I think you could maybe wrap the aws using clojure.java.shell or maybe create a pod around the Python AWS SDK.
This is an example of a pod in Python: https://github.com/babashka/babashka.pods/blob/master/examples/pod-lispyclouds-sqlite/pod-lispyclouds-sqlite.py
very interesting idea to write an AWS pod in another language, maybe Go would be a good candidate too
Yes, Go would also be a good candidate, since it also compiles to native and should have very good startup
I'm not using AWS myself that much, so I'm leaving this one up to the babashka community :)
This is v. relevant to something I'll be working on soon, no promises but I might tackle this
I did some hack with lambda, attaching babashka and awscli layers, shelling to aws cli worked nicely, although awscli is a python thing so not that stand-alone, compared to go
@lukaszkorecki The pod could live under the babashka org when it's more or less done, if you wanted to. Also ok to keep it under your company org, etc.
@borkdude I'm still at the gathering requirements stage, so it's not been fully decided if we're going to go with Clojure (jvm) or BB. But if we go with BB, it's def going to be open source
Could be both. If you're going with the JVM library and make it GraalVM compatible, it could also be wrapped in a pod
Have you guys seen this? I am using it for some minor stuff but it's got the entire set of services for AWS. https://github.com/cognitect-labs/aws-api