def dump(): """ Dumps the config dict to the user's configuration file ~/.baboonrc. If the file already exists, it's copied to ~/.baboonrc.old and the original file is overwritten. """ # Don't dump the config if the --nosave arg is present. if config['parser'].get('nosave', False): return baboonrc_path = os.path.expanduser('~/.baboonrc') # Override the default baboonrc_path if the --config arg is present. if config['parser'].get('configpath'): baboonrc_path = config['parser']['configpath'] try: # Dump the config file. with open(baboonrc_path, 'w') as fd: print >>fd, get_dumped_user() print >>fd, get_dumped_server() print >>fd, get_dumped_projects() print >>fd, get_dumped_example_project() csuccess("The new configuration file is written in %s\n" % baboonrc_path) except EnvironmentError as err: cerr("Cannot dump the configuration. Cause:\n%s" % err)
def dump(): """ Dumps the config dict to the user's configuration file ~/.baboonrc. If the file already exists, it's copied to ~/.baboonrc.old and the original file is overwritten. """ # Don't dump the config if the --nosave arg is present. if config['parser'].get('nosave', False): return baboonrc_path = os.path.expanduser('~/.baboonrc') # Override the default baboonrc_path if the --config arg is present. if config['parser'].get('configpath'): baboonrc_path = config['parser']['configpath'] try: # Dump the config file. with open(baboonrc_path, 'w') as fd: print >> fd, get_dumped_user() print >> fd, get_dumped_server() print >> fd, get_dumped_projects() print >> fd, get_dumped_example_project() csuccess("The new configuration file is written in %s\n" % baboonrc_path) except EnvironmentError as err: cerr("Cannot dump the configuration. Cause:\n%s" % err)
def _on_action_finished(ret_status, msg, fatal=False): if ret_status >= 200 and ret_status < 300: csuccess(msg) return True else: # Print the error message. cerr(msg) return False