Category: Python

  • Using procmail with custom python script

    If you want to execute some special commands, log or make an API call when you’re receiving an email onto your server, you can easily set up this by using procmail. Procmail is designed to filter and sort emails but can make any call you want. Here, as an example, we will set up a…

  • DNS queries from a file/list to CSV

    It’s not easy to perform bulk DNS resolution when you have many DNS/IPs to control. Here is a simple script allowing you to perform DNS resolution over a list of DNS entries or IPs. Here is a list of DNS (names and IPs) that we put in a file called listDNS.txt www.python.org www.pyython.org 208.67.220.220 www.bing.com Let’s…

  • openssl/pyOpenSSL – “SSL23_GET_SERVER_HELLO:tlsv1 alert internal error”

    You’re getting this annoying error message again and again when trying to fetch certificate and/or establish a connection to your website using openssl: 139647967614624:error:14077438:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert internal error:s23_clnt.c:769: This issue is well known in several openssl versions, and a bug has been addressed for Ubuntu repositories: https://bugs.launchpad.net/ubuntu/+source/openssl/+bug/1475228 For now, there’s a simple workaround that works…

  • Generate SHA-512 hash on command-line with Python

    Need to generate the hash for a password? No need to use an online generator, totally insecure for your passwords … This simple command will ask you which string you want to hash and will return you the result after pressing “Enter” key! python -c “import crypt, getpass, pwd; print crypt.crypt(raw_input(), ‘\$6\ Besoin de générer…

  • AWS – Update massively metadata using boto (python) on multiple S3 objects

    A simple script that allows you to update massively Content-Type for files on an S3 bucket. This script is able to: Browse recursively a bucket Perform action only on files matching specific prefix Auto-detect type of file depending on its extension Obviously, you can add any extension you want to the function update_md to handle…

  • Python – Browse directory and push on S3 (with regex)

    A simple script that can browse a directory, and upload to S3 some files matching a regex. The file will be uploaded by respecting the path you have in local. #!/usr/bin/env python # -*- coding: utf-8 -*- import os, re import boto from boto.s3.connection import S3Connection from boto.s3.key import Key # Variables AWS_ACCESS_KEY_ID = ‘YOUR_AWS_ACCESS_KEY_ID’…

  • Create an interactive command-line menu using Python

    It can be necessary to create a simple interactive menu on CLI (Command-Line Interface) using Python to allow users to make some choices while executing a script/program. As there is no standard library for this in Python, you will have to adapt it by yourself. Here is a very simple example of how to do…

  • Use FTPS (SSL/TLS) with Python 2.6

    By default, Python 2.6 does not permit to open an FTPS connection (using SSL/TLS) and restricts the use of non secure protocol FTP. However, it’s possible to get around this lack by using the FTP library available since version 2.7, which is fully compatible and supported with 2.6. You can get the library directly from…

  • Unserialize web2py requests and allow concurrent access

    With a default configuration for your web2py application, you will notice that when you are launching an action, if this one is quite long to execute, you won’t be able to open a new tab to run another request on the same application. This can be explained because when you are launching an action, your…

  • Web2py framework

    Do you like web development and Python ? You’re looking for a framework free, complete and in a constant evolution (features, security, …) ? So Web2py is for you ! web2py is a free, open-source web framework for agile development of secure database-driven web applications; it is written in Python and programmable in Python. web2py is a…