This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'''Makes a directory; no exception if directory already exists, make parent directories as needed''' | |
def mkdir_p(path, mode = 0777): | |
try: | |
os.makedirs(path, mode) | |
except OSError as exc: # Python >2.5 | |
if exc.errno == errno.EEXIST and os.path.isdir(path): | |
print("%s already exists.", path) | |
else: | |
raise |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'''A simple function to create a backup of a file with a date stamp and backup extension''' | |
import datetime | |
import shutil | |
import os | |
def create_backup_file(file_name, backup_extension=".bak", date=str(datetime.date.today())): | |
'''Create a backup of a file using the given backup extension''' | |
backup_file_name = os.path.join(file_name, backup_extension) | |
try: | |
shutil.copyfile(file_name, backup_file_name) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'''Requires psutil package that's available from pip''' | |
import psutil | |
def find_processes_by_user(user_name): | |
user_processes = [proc for proc in psutil.process_iter(attrs=['pid', 'name', 'username']) if proc.info["username"] == user_name] | |
return user_processes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo | |
sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key | |
sudo yum install jenkins |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Start by making sure your system is up-to-date: | |
yum update | |
# Compilers and related tools: | |
yum groupinstall -y "development tools" | |
# Libraries needed during compilation to enable all features of Python: | |
yum install -y zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel expat-devel | |
# If you are on a clean "minimal" install of CentOS you also need the wget tool: | |
yum install -y wget | |
NewerOlder