Tuesday, October 23, 2018

pycharm debug detecting

I use pycharm. I have a program that works through tasks in parallel. When I'm debugging, however, I want to work though tasks in series. So I have this check to know if I'm running in debug:

    IS_DEBUG = True if __loader__.path.endswith('pydev/pydevd.py') else False

or, you can just use:

 __debug__


Wednesday, July 25, 2018

parse clj

if you've got a lob of Clojure data in a clj file, this gubbins will allow you to ingest it into python using the pyparsing library

            lkey = Suppress(Literal(":")) + Word(printables)
            lvalue = Forward()
            lvalue << (QuotedString(quoteChar='"', escChar='\\')
                       ^ Suppress('[') + Group(OneOrMore(QuotedString('"', escChar='\\'))) + Suppress(']')
                       ^ Suppress('{') + Dict(delimitedList(Group(lkey + lvalue), delim=',')) + Suppress('}'))
            row = Suppress("{") + Dict(delimitedList(Group(lkey + lvalue), delim=',')) + Suppress("}")

you call it with: cljdict = row.parseString(row_of_clj data)

Thursday, March 8, 2018

dockerfile for get_iplayer on Alpine linux

as subject:

FROM alpine:latest

RUN apk update
RUN apk add perl curl git perl-utils perl-dev musl-dev make gcc wget perl-net-ssleay libxml2-dev
RUN curl -L http://cpanmin.us | perl - App::cpanminus
RUN cpanm HTML::Entities JSON::PP LWP LWP::Protocol::https Mojolicious XML::LibXML CGI
RUN git clone https://github.com/get-iplayer/get_iplayer.git
CMD ["/get_iplayer/get_iplayer.cgi", "--getiplayer=/get_iplayer/get_iplayer", "--listen=0.0.0.0", "--port=8080"]