Fork me on GitHub
#babashka
<
2021-07-23
>
lispyclouds05:07:19

@alex.kelley you can use bootleg as a pod to parse html and convert it, https://github.com/retrogradeorbit/bootleg#babashka-pod-usage and https://github.com/retrogradeorbit/bootleg#data-conversion or can just simply use data.xml? https://github.com/clojure/data.xml this is supported in bb

🙏 3
lispyclouds05:07:09

if going with bootleg, you dont have to install it manually, you can follow https://github.com/babashka/pod-registry#loading-and-using-a-pod , bb should be able to download and setup bootleg for you

borkdude06:07:47

Yes, bootleg is recommended for parsing HTML, not clojure.data.xml

furiel11:07:05

Hello, I am connecting through cider-connect to a babashka nrep in emacs. Accidentally I started an infinite loop (take-while). Is it possible to stop the command execution somehow? Tried ctrl-c - ctrl-c or ctrl-c - ctrl-b (cider-interrupt), but they did not work.

borkdude11:07:59

unfortunately, due to restrictions in GraalVM native-image, Thread#stop doesn't work, this is normally what nREPL uses to kill eval

borkdude11:07:23

they chose to not support this deprecated method

furiel11:07:42

Oh I see. No problem. I am fine restarting the repl too.

borkdude15:07:13

lol yes...

😄 3
borkdude15:07:49

as this is probably the only supported value it still works as expected, but this is a mistake

dpsutton15:07:05

surprised clj-kondo didn't mention anything

borkdude15:07:25

it's not a common mistake I would say

🙌 3
dpsutton15:07:31

case on a literal should be an easy-to-recognize case maybe?

borkdude15:07:39

it surely could say something

borkdude15:07:36

I'll make an issue for it

🚀 6
nha15:07:07

would you like a PR for process.clj?

nha15:07:21

will do 🙂

nha15:07:47

Thank you! ❤️babashka

nha16:07:56

I am trying to run a command and get something like this for an API around process: I am running my tests using bb . It works great! Now I would also like to fail the tests when the output of process contains some known warnings/errors from third-party libraries. I was thinking of making a my-process function that would look like this

(let [a (atom)]
 (my-process my-cmd {:out (fn [line] (println line) (check-line a line))
                     :err (fn [line] (println line) (check-line a line))}))
However that does not seem possible at the moment? I see this https://github.com/babashka/process#processing-output which looks somewhat promising but I am not sure how to terminate the loop. I guess if I could have access to the underlying https://docs.oracle.com/javase/8/docs/api/java/lang/Process.html I could use isAlive https://docs.oracle.com/javase/8/docs/api/java/lang/Process.html but I don’t think it is currently supported.

borkdude17:07:44

@nha you have access to the underlying Process via the :proc key

👀 3
nha17:07:40

ah but I only have :proc once it is deref’ed (and therefore done) right?

nha17:07:07

hmm seeing the example

(def catp (process '[cat]))

(.isAlive (:proc catp)) ;; true
so it seems like it should work

nha17:07:31

you’re right 🙂 missed it somehow. Thanks again!

borkdude17:07:23

you can also terminate the read loops just based on the fact that the stream ended

nha17:07:16

even better :) I'll check that out

yubrshen22:07:41

How can I use math functions of abs (absolute value), PI, and cos (cosin)? I tried using org.clojure/algo.generic {:mvn/version "0.1.3"} I'm not sure if it's the right solution with Babashka. Would you please show me a working example with Babashka?