I hereby claim:
- I am murarisumit on github.
- I am murarisumit (https://keybase.io/murarisumit) on keybase.
- I have a public key whose fingerprint is 1FDF CF05 7A84 D426 E99E F8C8 D921 BB76 883B A21F
To claim this, I am signing this object:
find ./ -type f -exec sed -i -e 's/search/replace/g' {} \; |
grep search-term file_name | awk '/filter1/ && !/filter2/ && $3!="filter3" { print $1 }' |
I hereby claim:
To claim this, I am signing this object:
#!/bin/bin/env python | |
import subprocess | |
#Exeternal Command with args | |
DPKG = ['dpkg', '-l'] | |
# Execute the command | |
dpkg_process = subprocess.Popen(DPKG, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
# Pipe output of dpkg to grep | |
grep_process = subprocess.Popen(['grep', 'lsof'], stdin=dpkg_process.stdout, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
#!/bin/bin/env python | |
import subprocess | |
#Exeternal Command with args | |
DPKG = ['dpkg', '-l'] | |
# Execute the command | |
dpkg_process = subprocess.Popen(DPKG, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
# Wait till process to exit | |
out, error = dpkg_process.communicate() |
import sys | |
import logging | |
# We don't need to use print statement, using logger removes many python compatibilit | |
# and need to modify code later, we can just configure logger and rest code remains as it is. # | |
# logging.basicConfig(stream=sys.stdout, level=logging.INFO) | |
logger = logging.getLogger("LOGGER_NAME") | |
logger.setLevel(logging.DEBUG) | |
ch = logging.StreamHandler(sys.stdout) |
# `ref: https://fangpenlin.com/posts/2012/08/26/good-logging-practice-in-python/ | |
import logging | |
logger = logging.getLogger(__name__) | |
logger.setLevel(logging.INFO) | |
# create a file handler | |
handler = logging.FileHandler('hello.log') |
A Python module is simply a Python source file, which can expose classes, functions and global variables.
When imported from another Python source file, the file name is treated as a namespace.
namespace.Globalvar
A Python package is simply a directory of Python module(s).
# definations.py | |
import os | |
import configparser | |
# Environment defination variable, this environment variable will use used to pick config file | |
ENV = os.environ["ENVIRONMENT"] | |
# settings | |
settings = configparser.ConfigParser() | |
BASEDIR = os.path.dirname(os.path.realpath(__file__)) |
#!/bin/bash | |
## | |
# the handle_argument function receives all the non-option argument or non-flag argument | |
## | |
handle_argument() { | |
# the first argumeent without any flag | |
echo " Argument is : $1 " | |
} |