The curl
manpage isn't super clear on this, but to read from stdin
you need to prepend the dash with a @
.
json_producer | curl -d @- -H 'Content-Type: application/json' http://example.com/json_consumer
The curl
manpage isn't super clear on this, but to read from stdin
you need to prepend the dash with a @
.
json_producer | curl -d @- -H 'Content-Type: application/json' http://example.com/json_consumer
You should always use the logging
module instead of just littering print
statements all over your code. You will very quickly thank yourself for taking a bit of extra time.
Having said that, setting up logging is a bit of a pain so here's the pattern I use 90% of the time.
Uploading to Minio (or S3) in a script is a bit tricky.
Update: now on GitHub with some Python versions.
#!/bin/bash
# usage: ./minio-upload my-bucket my-file.zip
bucket=$1
file=$2
host=minio.example.com
s3_key='secret key'
s3_secret='secret token'
resource="/${bucket}/${file}"
content_type="application/octet-stream"
date=`date -R`
_signature="PUT\n\n${content_type}\n${date}\n${resource}"
signature=`echo -en ${_signature} | openssl sha1 -hmac ${s3_secret} -binary | base64`
curl -v -X PUT -T "${file}" \
-H "Host: $host" \
-H "Date: ${date}" \
-H "Content-Type: ${content_type}" \
-H "Authorization: AWS ${s3_key}:${signature}" \
https://$host${resource}
I highly doubt I've invented something new, but I did independently invent it, so I have that going for me, which is nice. Plus I'm stitching together lots of great open source pieces which we all have going for us.
Anyhow, this is kind of difficult to explain. And complicated… with lots of moving parts… but is super useful once you get it to work.
As high level as possible, when I do a git push
, another machine
reloads new configuration files. And notifies me. All within a second.
Alkali v0.5.5 has now escaped.
Code at github.com and docs at readthedocs.org.
Major features are:
You can now nicely render markdown in your console/terminal with ConsoleMD in glorious color.
Note the subtlety changing hues of the subtopics, the brilliance of auto-incrementing list counters, the dulcet notes of the embedded python, the elegant italics of the block quote. ConsoleMD has it all! At least with regards to my small test files.
Code is on github.com
Alkali v0.5.4 has now escaped.
Code at github.com and docs at readthedocs.org.
Major features are:
I had a hell of a time trying to make a nice help
command while using click.
I wanted the ability to have a help
sub-command for each real command.
mycommand --help
mycommand help
mycommand foo --help
mycommand help foo
It's actually fairly easy (once you know how).
CTX_SETTINGS=dict(help_option_names=['-h','--help'])
@click.group(context_settings=CTX_SETTINGS)
@click.pass_context
def cli(ctx, **kw):
...
@cli.command()
@click.pass_context
def foo(ctx):
...
@cli.command()
@click.argument('topic', default=None, required=False, nargs=1 )
@click.pass_context
def help(ctx, topic, **kw):
if topic is None:
print ctx.parent.get_help()
else:
print cli.commands[topic].get_help(ctx)
So it turns out I hadn't updated my Fedora installation for over two years (protip: don't run Fedora on a server kids) so I did a quick series of upgrades and went from Fedora 21 to Fedora 25.
Unfortunately that means that my PostgreSQL database was at version 9.3 but the installed software was version 9.5.
So can you upgrade from 9.3 to 9.5? No. But it's not impossible either.