cmd_block_till
Run a command and wait until a condition evaluates to True.
+cd
+ A context manager that temporarily changes the current working directory
+
The logging functions either use the format capability or play
the simple role of providing shorter names.
import time
import types
import uuid
+from contextlib import contextmanager
import logging
llog = logging.getLogger('pyi2ncommon.sysmisc')
# HELPERS
###############################################################################
+@contextmanager
+def cd(path):
+ """
+ A context manager which changes the working directory.
+
+ Changes current working directory to the given path, and then changes it
+ back to its previous value on exit.
+
+ Taken from comment for python recipe by Greg Warner at
+ http://code.activestate.com/recipes/576620-changedirectory-context-manager/
+ (MIT license)
+ """
+ orig_wd = os.getcwd()
+ os.chdir(path)
+ try:
+ yield
+ finally:
+ os.chdir(orig_wd)
+
+
def run_cmd_with_pipe(argv, inp=None):
"""
Read from a process pipe.