The latest version is available from https://bitbucket.org/techtonik/trac-bootstrap-script
This file contains 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
def get_svn_path_revision(path): | |
"""return latest modification revision of a path inside svn | |
:raise: EnvironmentError if SVN working copy format is unknown | |
:return: int | |
""" | |
from os.path import basename, dirname, join, isdir | |
if isdir(path): | |
entries_path = join(path, ".svn", "entries") |
This file contains 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
def get_hg_repo_revision(path): | |
"""return current revision of a repository at path | |
:raise: EnvironmentError if `hg` isn't found or path invalid | |
:return: string like 'num:hash' | |
""" | |
from subprocess import Popen, PIPE | |
if os.path.isfile(path): | |
path = os.path.dirname(path) | |
try: |
This file contains 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
def get_hg_path_revision(path): | |
"""return latest modification revision of a path inside hg | |
:raise: EnvironmentError if `hg` isn't found or path invalid | |
:return: string like 'num:hash' | |
""" | |
from subprocess import Popen, PIPE | |
try: | |
hgprocess = Popen( | |
'hg log -l 1 --template "{node|short} {rev}" --cwd "%s" "%s"' |
This file contains 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
import inspect | |
import logging | |
def log(level, msg, depth=1): | |
"""Logging function that detects name of appropriate logger for calling | |
function in 'module.class' format. `depth` allows to specify a higher | |
frame in a call stack if you want to wrap this function. | |
""" | |
name = None | |
try: |
Updated version of this Gist is available from https://bitbucket.org/techtonik/xtrace
This file contains 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
""" https://gist.github.com/1978810 | |
shutil.runret() and shutil.runout() functions | |
runret(command) - run command through shell, return ret code | |
runout(command) - run command through shell, return output | |
Public Domain, i.e. free for copy/paste | |
https://groups.google.com/d/topic/python-ideas/u42aZZnrs8A/discussion | |
https://bitbucket.org/techtonik/shellrun |
This file contains 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
import socket | |
if __name__ == '__main__': | |
# socket read/write testing - client and server in one thread | |
# (techtonik): the stuff below is placed into public domain | |
print "-- Testing standard Python socket interface --" | |
address = ("127.0.0.1", 9999) | |
This file contains 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
# Public Domain, i.e. feel free to copy/paste | |
# Considered a hack in Python 2 | |
import inspect | |
def caller_name(skip=2): | |
"""Get a name of a caller in the format module.class.method | |
`skip` specifies how many levels of stack to skip while getting caller | |
name. skip=1 means "who calls me", skip=2 "who calls my caller" etc. |
This file contains 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
"""Reset admin password in Chef Server WebUI by removing admin user from DB""" | |
# based on http://lists.opscode.com/sympa/arc/chef/2011-08/msg00151.html | |
import urllib2 | |
import json | |
COUCHSERV = 'localhost:5984' | |
COUCHDB = 'http://' + COUCHSERV + '/chef/' |
OlderNewer