Skip to content

Instantly share code, notes, and snippets.

View bmacauley's full-sized avatar

Brian Macauley bmacauley

View GitHub Profile
@bmacauley
bmacauley / fabric local bug
Last active July 15, 2016 14:07
fabric...local() bug?
# not working
def svn_commit():
"""commit any changes to svn"""
mod = local('svn st -q',capture=True)
if mod != '':
print "Modified:"
print mod
#working
@bmacauley
bmacauley / skel_module2.py
Last active December 15, 2015 12:49
module skeleton, long version
#!/usr/bin/env python
# -*- coding: ascii -*-
"""
Module Docstring
Docstrings: http://www.python.org/dev/peps/pep-0257/
"""
__author__ = 'Joe Author (joe.author@website.org)'
__copyright__ = 'Copyright (c) 2009-2010 Joe Author'
@bmacauley
bmacauley / skel_module1.py
Last active December 15, 2015 12:49
module skeleton, short version
#!/usr/bin/env python
"""
Module Docstring
"""
#
## Code goes here.
#
@bmacauley
bmacauley / skel_module3.py
Last active December 15, 2015 12:49
module skeleton, long version alternate
#!/usr/bin/env python
# -*- coding: ascii -*-
"""
package.module
~~~~~~~~~~~~~
A description which can be long and explain the complete
functionality of this module even with indented code examples.
Class/Function however should not be documented here.
@bmacauley
bmacauley / skel_module4.py
Last active December 15, 2015 12:49
module skeleton
#!/usr/bin/env python
# coding: utf-8
"""
package.module
~~~~~~~~~~~~~
A description which can be long and explain the complete
functionality of this module even with indented code examples.
Class/Function however should not be documented here.
@bmacauley
bmacauley / skel_module4.py
Created March 28, 2013 13:19
module skeleton
#!/usr/bin/env python
# coding: utf-8
"""
package.module
~~~~~~~~~~~~~
A description which can be long and explain the complete
functionality of this module even with indented code examples.
Class/Function however should not be documented here.
#!/usr/bin/env python
"""
SYNOPSIS
TODO helloworld [-h,--help] [-v,--verbose] [--version]
DESCRIPTION
TODO This describes how to use this script. This docstring
will be printed by the script if there is an error or
@bmacauley
bmacauley / skel_setup.py
Created March 28, 2013 13:25
setup.py skeleton
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
config = {
'description': 'My Project',
'author': 'My Name',
'url': 'URL to get it at.',
'download_url': 'Where to download it.',
@bmacauley
bmacauley / logging.py
Created March 28, 2013 13:37
logging
#set up logging
logger = logging.getLogger('main')
logger.setLevel(logging.DEBUG)
# Use file output for production logging:
filename, fileextension = os.path.splitext(sys.argv[0])
# log file name <script name>.log
log_file = '{0}.log'.format(filename)
filelog = logging.FileHandler(log_file, 'a')
filelog.setLevel(logging.INFO)
import logging
logger = logging.getLogger('myapp')
hdlr = logging.FileHandler('/var/tmp/myapp.log')
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
hdlr.setFormatter(formatter)
logger.addHandler(hdlr)
logger.setLevel(logging.WARNING)