Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Python for Unix and Linux System Administration
A Note Regarding Supplemental Files
Foreword
Preface
Conventions Used in This Book
Using Code Examples
Safari® Books Online
How to Contact Us
Acknowledgments
Noah’s Acknowledgments
Jeremy’s Acknowledgments
1. Introduction
Why Python?
Motivation
The Basics
Executing Statements in Python
Summary
Using Functions in Python
Reusing Code with the Import Statement
2. IPython
Installing IPython
Basic Concepts
Interacting with IPython
Tab Completion
Magic Edit
Configuring IPython
Help with Magic Functions
Unix Shell
alias
Shell Execute
rehash
rehashx
cd
bookmark
dhist
pwd
Variable Expansion
String Processing
sh Profile
Information Gathering
page
pdef
pdoc
pfile
pinfo
psource
psearch
who
who_ls
whos
History
Readline support
hist command
History results
Automation and Shortcuts
alias
macro
store
reset
run
save
rep
Summary
3. Text
Python Built-ins and Modules
str
Creating strings
Built-in methods for str data extraction
Unicode strings
re
Apache Config File Hacking
Working with Files
Creating files
Reading files
Writing files
Additional resources
Standard Input and Output
StringIO
urllib
Log Parsing
ElementTree
Summary
4. Documentation and Reporting
Automated Information Gathering
Receiving Email
Manual Information Gathering
Information Formatting
Graphical Images
PDFs
Information Distribution
Sending Email
Sending basic messages
Using SMTP authentication
Sending attachments with Python
Trac
Summary
5. Networking
Network Clients
socket
httplib
ftplib
urllib
urllib2
Remote Procedure Call Facilities
XML-RPC
Pyro
SSH
Twisted
Scapy
Creating Scripts with Scapy
6. Data
Introduction
Using the OS Module to Interact with Data
Copying, Moving, Renaming, and Deleting Data
Working with Paths, Directories, and Files
Comparing Data
Using the filecmp Module
Using os.list
Merging Data
MD5 Checksum Comparisons
Pattern Matching Files and Directories
Wrapping Up rsync
Metadata: Data About Data
Archiving, Compressing, Imaging, and Restoring
Using tarfile Module to Create TAR Archives
Using a tarfile Module to Examine the Contents of TAR Files
7. SNMP
Introduction
Brief Introduction to SNMP
SNMP Overview
SNMP Installation and Configuration
IPython and Net-SNMP
Discovering a Data Center
Retrieving Multiple-Values with Net-SNMP
Finding Memory
Creating Hybrid SNMP Tools
Extending Net-SNMP
SNMP Device Control
Enterprise SNMP Integration with Zenoss
Zenoss API
Using Zendmd
Device API
8. OS Soup
Introduction
Cross-Platform Unix Programming in Python
Using SSH Keys, NFS-Mounted Source Directory, and Cross-Platform Python to Manage Systems
Creating a Cross-Platform, Systems Management Tool
Creating a Cross-Platform Build Network
PyInotify
OS X
Scripting DSCL or Directory Services Utility
OS X Scripting APIs
Automatically Re-Imaging Machines
Managing Plist Files from Python
Red Hat Linux Systems Administration
Ubuntu Administration
Solaris Systems Administration
Virtualization
VMware
Cloud Computing
Amazon Web Services with Boto
Google App Engine
Building a sample Google App Engine application
Using Zenoss to Manage Windows Servers from Linux
9. Package Management
Introduction
Setuptools and Python Eggs
Using easy_install
easy_install Advanced Features
Search for Packages on a Web Page
Install Source Distribution from URL
Install Egg Located on Local or Network Filesystem
Upgrading Packages
Install an Unpacked Source Distribution in Current Working Directory
Extract Source Distribution to Specified Directory
Change Active Version of Package
Changing Standalone .py File into egg
Authenticating to a Password Protected Site
Using Configuration Files
Easy Install Advanced Features Summary
Creating Eggs
Entry Points and Console Scripts
Registering a Package with the Python Package Index
Where Can I Learn More About …
Distutils
Buildout
Using Buildout
Developing with Buildout
virtualenv
Creating a Custom Bootstrapped Virtual Environment
EPM Package Manager
EPM Package Manager Requirements and Installation
Creating a Hello World Command-Line Tool to Distribute
Creating Platform-Specific Packages with EPM
Making the Package
EPM Summary: It Really Is That Easy
10. Processes and Concurrency
Introduction
Subprocess
Using Return Codes with Subprocess
Using Supervisor to Manage Processes
Using Screen to Manage Processes
Threads in Python
Timed Delay of Threads with threading.Timer
Threaded Event Handler
Processes
Processing Module
Scheduling Python Processes
daemonizer
Summary
11. Building GUIs
GUI Building Theory
Building a Simple PyGTK App
Building an Apache Log Viewer Using PyGTK
Building an Apache Log Viewer Using Curses
Web Applications
Django
Apache Log Viewer Application
Simple Database Application
Conclusion
12. Data Persistence
Simple Serialization
Pickle
cPickle
shelve
YAML
ZODB
Relational Serialization
SQLite
Storm ORM
SQLAlchemy ORM
Summary
13. Command Line
Introduction
Basic Standard Input Usage
Introduction to Optparse
Simple Optparse Usage Patterns
No Options Usage Pattern
True/False Usage Pattern
Counting Options Usage Pattern
Choices Usage Pattern
Option with Multiple Arguments Usage Pattern
Unix Mashups: Integrating Shell Commands into Python Command-Line Tools
Kudzu Usage Pattern: Wrapping a Tool in Python
Hybrid Kudzu Design Pattern: Wrapping a Tool in Python, and Then Changing the Behavior
Hybrid Kudzu Design Pattern: Wrapping a Unix Tool in Python to Spawn Processes
Integrating Configuration Files
Summary
14. Pragmatic Examples
Managing DNS with Python
Using LDAP with OpenLDAP, Active Directory, and More with Python
Importing an LDIF File
Apache Log Reporting
FTP Mirror
A. Callbacks
Index
About the Authors
Colophon
← Prev
Back
Next →
← Prev
Back
Next →