Tag Info

Hot answers tagged

4

There are two principal ways: Parameter expansion by enabling PROMPT_SUBST The psvar array 1. Parameter expansion in prompt If PROMPT_SUBST is enabled setopt PROMPT_SUBST the prompt is subjected to parameter expansion, command substitution and arithmetic expansion before it is evaluated. That way, the output of a script can be included via command ...


3

Given just this file, you can do something like: <testfile jq -r '.data | map(.displayName), map(.value) | join(", ")' The . operator selects a field from an object/hash. Thus, we start with .data, which returns the array with the data in it. We then map over the array twice, first selecting the displayName, then selecting the value, giving us two ...


3

Use tee to grab the output Tee Manual tee reads from Standard INPUT/OUTPUT to write files. I have a Python script which supports one of my requirements, and simple ">" redirection fails. Tee is the way to grab output. Your line should be: 10 04 * * * user /usr/bin/python2.7 /home/user/script.py -f someFlag | tee -a ~/cronout.log 2>&1 Try this: ...


2

A script can check its Python version and, if that's Python 3, re-start itself using Python 2. Add the following near the head of the script: if sys.version > '3': python2 = os.popen('which python2 2> /dev/null').read().rstrip() if python2: args = sys.argv[:] args.insert(0,python2) os.execv(python2,args) else: sys.exit("%s ...


2

You can do this by setting up a precmd hook which will take the output of the command and format it as you want, and then make it available to your PROMPT. Minimally, you need: autoload -U add-zsh-hook add-zsh-hook precmd my_precmd_hook_function Define my_precmd_hook_function to call your python script and capture its output in a variable. You can then ...


2

Have you looked at the code module? You probably want to subclass code.InteractiveConsole and override its write method to write into your out FIFO, and have an outer loop that reads lines from the in FIFO and calls the push method with each line. I haven't tested this but even if it doesn't work exactly like I've suggested your solution will no doubt ...


2

By default, cron runs all jobs in the home directory of the user who owns the job. Make sure that your python script uses absolute paths when writing the output files, or it'll put them in the current user's home directory.


2

If I understand correctly, you're looking for something like this (in bash): #!/usr/bin/env bash ## avoid errors if a directory has no *tex files shopt -s nullglob directories=("Cardiology" "Rheumatology" "Surgery"); ## Change this to set whichever options you want. printf "%s\n%s\n" "\documentclass{YOURCLASS}" "\begin{document}" for directory in ...


2

The closest thing I can see is Capistrano. With fabric: from fabric.api import run def uptime(): run('uptime') then: fab -H localhost uptime With Capistrano: task :uptime, :hosts => "localhost" do run "uptime" end then: cap uptime


1

I've found jq hard to wrap my head around. Here's some Ruby: ruby -rjson -rcsv -e ' data = JSON.parse(File.read "file.json") data["data"].collect {|item| [item["displayName"], item["value"]]} .transpose .each {|row| puts row.to_csv} ' First Name,Last Name,Position,Company Name,Country VALUE,VALUE,VALUE,VALUE,VALUE The ...


1

Solved. I had export LD_LIBRARY_PATH="/usr/lib/plexmediaserver" in my .bashrc. /usr/lib/plexmediaserver had lots of dynamic libs, including libssl.so.1.0.0 and libexpat.so.1. So they were loaded instead of ones from /usr/lib and were causing problems. This problem has nothing to do with python actually, it would equally cause problems for any other program ...


1

One fast and easy way could be to use alien, it convert .tar to .deb: tar czf pkg-name.tgz usr/ fakeroot alien -d pkg-name.tgz Else use the old way, I use a Makefile like that: all: deb deb: mkdir -p tmp/usr/bin tmp/DEBIAN tmp/etc tmp/usr/share/man/man5 find tmp -type d | xargs chmod 755 cp some.conf tmp/etc/ cp man/some.5 ...


1

If checkinstall failed probably the package isn't installed, no need to remove, eventually try sudo dpkg -r <package-name>, and you can safely remove with rm intermediate files left in the directory. The version is important for dpkg/apt so you must use one, even a fake, if tomorrow a package with the same name enter the distro, the one with the newer ...


1

I think this is exactly what I wanted, PyWO. Only depends on python-xlib and claims to work with any EWMH compatable manager (openbox included!). Have not tested yet, but these are the features I wanted (drop in extension as opposed to a clobber everything replacement). Pure py WMs seem cool, but I dont want to manage everything, only those few windowing ...


1

Too long for a comment. Depending on how much effort you want to put into it, looking at PLWM or Qtile might be worthwhile. Then there is also PyWM, which seems to be "stable" at this moment. Last but not least, looking around on the internet doesn't seem to be that hopeless: for example this blog looks as possibly useful. If you are not insisting on ...


1

The python-gdata on Ubuntu 12.04 is 2.0.14-2, this is outdated. Download latest python-gdata deb from http://mirrors.kernel.org/ubuntu/pool/universe/p/python-gdata/python-gdata_2.0.18+dfsg-1_all.deb and then run dpkg -i python-gdata_2.0.18+dfsg-1_all.deb



Only top voted, non community-wiki answers of a minimum length are eligible