def save_env(): env_default = {} for k, v in env.iteritems(): if k.startswith('_'): continue elif isinstance(v, (types.GeneratorType,)): continue env_default[k] = copy.deepcopy(v) return env_default
def list_env(key=None): """ Displays a list of environment key/value pairs. """ for k,v in sorted(env.iteritems(), key=lambda o:o[0]): if key and k != key: continue print('%s ' % (k,)) pprint(v, indent=4)
def record_manifest(): """ Called after a deployment to record any data necessary to detect changes for a future deployment. """ data = {} # Record settings. data['settings'] = dict( (k, v) for k, v in env.iteritems() if not isinstance(v, types.GeneratorType) and k.strip() and not k.startswith('_') and not callable(v)) # Record tarball hash. # Record database migrations. # Record media hash. return data
def massage_enviro_paths(env): ''' Recursively iterate through all the keys in the environment dictionary and look for any that contain the strings 'path' or 'dir' in them. For the values corresponding to the keys that do, replace any instances of the '~' character with the running user's home directory path. :type env: dictionary :param env: environment dictionary ''' for k, v in env.iteritems(): if isinstance(v, dict): massage_enviro_paths(v) elif (isinstance(k, basestring) and isinstance(v, basestring) and (k.find('path') > -1 or k.find('dir') > -1)): env[k] = replace_tilde_in_path(v)