def do_add(args): ret, _, _ = utils.run_command( [ 'git', 'clone', args.url, ], cwd=config.get('template_repos'), ) if ret: raise RuntimeError('Failed to clone the repository')
def do_update(args): repos_dir = config.get('template_repos') ret, out, _ = utils.run_command( ['find', repos_dir, '-type', 'd', '-name', '.git'], ) for line in [l.strip() for l in out.split('\n') if len(l)]: repo_path = os.path.dirname(line) print 'Updating %s' % repo_path for command in [ ['git', 'fetch'], ['git', 'reset', '--hard'], ['git', 'checkout', 'origin/master'], ]: ret, _, _ = utils.run_command(command, cwd=repo_path) if ret: raise RuntimeError('Error running: %s' % (' '.join(command)))
def do_update(args): repos_dir = config.get('template_repos') ret, out, _ = utils.run_command( [ 'find', repos_dir, '-type', 'd', '-name', '.git' ], ) for line in [l.strip() for l in out.split('\n') if len(l)]: repo_path = os.path.dirname(line) print 'Updating %s' % repo_path for command in [ ['git', 'fetch'], ['git', 'reset', '--hard'], ['git', 'checkout', 'origin/master'], ]: ret, _, _ = utils.run_command(command, cwd=repo_path) if ret: raise RuntimeError('Error running: %s' % (' '.join(command)))
def test_get_from_env(): nt.assert_equals(config.get('env_var_1'), 'env_val_1', )
def test_nonexistent_default(): nt.assert_equals(config.get('i_dont_exist', 'foo'), 'foo', )
def test_get_from_env(): assert config.get('env_var_1') == 'env_val_1'
def test_get_from_system(): nt.assert_equals(config.get('system_var_1'), 'system_val_1', ) nt.assert_equals(config.get('system_var_2'), 'system_val_2', )
def test_nonexistent_throws(): with nt.assert_raises(KeyError): config.get('i_dont_exist')
def test_get_from_user(): nt.assert_equals(config.get('user_var_2'), 'user_val_2', )
def test_user_shadows_system(): nt.assert_equals(config.get('system_var_3'), 'user_val_3', )
def test_env_shadows_user(): assert config.get('user_var_1') == 'env_val_2'
def test_env_shadows_user(): nt.assert_equals(config.get('user_var_1'), 'env_val_2', )
def test_nonexistent_default(): assert config.get('i_dont_exist', 'foo') == 'foo'
def test_nonexistent_throws(): with pytest.raises(KeyError): config.get('i_dont_exist')
def test_get_from_system(): assert config.get('system_var_1') == 'system_val_1' assert config.get('system_var_2') == 'system_val_2'
def test_user_shadows_system(): assert config.get('system_var_3') == 'user_val_3'
def test_get_from_user(): assert config.get('user_var_2') == 'user_val_2'