Skip to content

Commit

Permalink
Merge branch 'release/3.0.0' into new-master
Browse files Browse the repository at this point in the history
  • Loading branch information
shudgston committed May 6, 2019
2 parents 25ed89e + 7c93528 commit 43733e1
Show file tree
Hide file tree
Showing 60 changed files with 493 additions and 504 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: python

python:
- "2.7"
- "3.5"

install: "pip install -r requirements.txt"
# command to run tests
Expand Down
4 changes: 2 additions & 2 deletions cirrus.conf
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[package]
name = cirrus-cli
version = 2.0.2
version = 3.0.0
description = cirrus development and build git extensions
organization = cloudant
version_file = src/cirrus/__init__.py
python_versions = 2
python_versions = 3

[gitflow]
develop_branch = new-development
Expand Down
7 changes: 3 additions & 4 deletions installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
# installs git alias commands
# gets token for github access & updates .gitconfig

: ${CIRRUS_PYPI_URL?"is not set! Hint: https://[email protected]:[email protected]/artifactory/api/pypi/wcp-sapi-pypi-virtual/simple)"}

CIRRUS_PACKAGE="cirrus-cli==2.0.2"
CIRRUS_INSTALL_DIR="${HOME}/.cirrus"
CIRRUS_DEFAULT_USER="${USER}"

Expand Down Expand Up @@ -40,7 +37,9 @@ cd ${LOCATION}
virtualenv venv
. venv/bin/activate

pip install --index-url=${CIRRUS_PYPI_URL} ${CIRRUS_PACKAGE} 1>> ${LOCATION}/install.log
# This depends on a properly configured pip.conf file.
# See https://github.com/cloudant/service_engineering/wiki/Using-JFrog-Artifactory
pip install cirrus-cli${CIRRUS_INSTALL_VERSION} 1>> ${LOCATION}/install.log

export CIRRUS_HOME=${LOCATION}
export VIRTUALENV_HOME=${LOCATION}/venv
Expand Down
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
argparse==1.2.1
arrow==0.4.2
Fabric==1.11.1
Fabric==2.4.0
GitPython==2.1.9
mock==1.0.1
nose==1.3.0
pep8==1.5.7
pylint==1.3.0
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
Setup script for cirrus.
"""
import ConfigParser
import configparser
import setuptools

#
# read the cirrus conf for this package
#
config = ConfigParser.RawConfigParser()
config = configparser.RawConfigParser()
config.read("cirrus.conf")

#
Expand Down
2 changes: 1 addition & 1 deletion src/cirrus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
See the License for the specific language governing permissions and
limitations under the License.
"""
__version__="2.0.2"
__version__="3.0.0"

12 changes: 6 additions & 6 deletions src/cirrus/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from cirrus.configuration import load_configuration, get_pypi_auth
from cirrus.pypirc import PypircFile
from cirrus.logger import get_logger
from fabric.operations import local
from invoke import run

LOGGER = get_logger()

Expand Down Expand Up @@ -117,12 +117,12 @@ def execute_build(opts):
if opts.clean and os.path.exists(venv_path):
cmd = "rm -rf {0}".format(venv_path)
LOGGER.info("Removing existing virtualenv: {0}".format(venv_path))
local(cmd)
run(cmd)

if not os.path.exists(venv_bin_path):
cmd = "{0} {1}".format(venv_command, venv_path)
LOGGER.info("Bootstrapping virtualenv: {0}".format(venv_path))
local(cmd)
run(cmd)

# custom pypi server
pypi_server = config.pypi_url()
Expand Down Expand Up @@ -170,7 +170,7 @@ def execute_build(opts):
cmd += " {} ".format(pip_options)

try:
local(cmd)
run(cmd)
except OSError as ex:
msg = (
"Error running pip install command during build\n"
Expand Down Expand Up @@ -198,7 +198,7 @@ def execute_build(opts):
for cmd in commands:
LOGGER.info("Installing extra requirements... {}".format(cmd))
try:
local(cmd)
run(cmd)
except OSError as ex:
msg = (
"Error running pip install command extra "
Expand All @@ -213,7 +213,7 @@ def execute_build(opts):
LOGGER.info(msg)
else:
LOGGER.info('running python setup.py develop...')
local(
run(
'. ./{0}/bin/activate && python setup.py develop'.format(
config.venv_name()
)
Expand Down
6 changes: 3 additions & 3 deletions src/cirrus/chef_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def edit_chef_environment(server_url, cert, username, environment, attributes):
env = chef.Environment(environment)
overrides = env.override_attributes
LOGGER.info("Editing Chef Server Environment: {} as {}".format(environment, username))
for attr, new_value in attributes.iteritems():
for attr, new_value in attributes.items():
LOGGER.info(" => Setting {}={}".format(attr, new_value))
set_dotted(overrides, attr, new_value)
env.save()
Expand All @@ -104,7 +104,7 @@ def edit_chef_role(server_url, cert, username, rolename, attributes):
role = chef.Role(rolename)
LOGGER.info("Editing Chef Server Role: {} as {}".format(rolename, username))
overrides = role.override_attributes
for attr, new_value in attributes.iteritems():
for attr, new_value in attributes.items():
LOGGER.info(" => Setting {}={}".format(attr, new_value))
set_dotted(overrides, attr, new_value)
role.save()
Expand Down Expand Up @@ -191,7 +191,7 @@ def update_chef_environment(server_url, cert, username, environment, attributes,
with r.feature_branch(feature_name, push=kwargs.get('push', False)):
with r.edit_environment(environment, branch=r.current_branch_name) as env:
LOGGER.info("Updating Chef Environment: {}".format(environment))
for x, y in attributes.iteritems():
for x, y in attributes.items():
LOGGER.info(" => Setting {}={}".format(x, y))
set_dotted(env['override_attributes'], x, y)

Expand Down
2 changes: 1 addition & 1 deletion src/cirrus/cirrus_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def ask_question(question, default=None, valid=None):
to_ask += " [{0}]: ".format(default)
else:
to_ask += ": "
result = raw_input(to_ask)
result = input(to_ask)
if result.strip() == '':
if default is not None:
result = default
Expand Down
6 changes: 3 additions & 3 deletions src/cirrus/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from cirrus.gitconfig import load_gitconfig
from cirrus.environment import repo_directory
import subprocess
import ConfigParser
import configparser
import pluggage.registry


Expand Down Expand Up @@ -52,7 +52,7 @@ def load(self):
Reread the cirrus config file
"""
self.parser = ConfigParser.RawConfigParser()
self.parser = configparser.RawConfigParser()
self.parser.read(self.config_file)
for section in self.parser.sections():
self.setdefault(section, {})
Expand Down Expand Up @@ -103,7 +103,7 @@ def has_gitconfig_param(
return validator(self.gitconfig.get_param(section, param))

def list_gitconfig_params(self, section='cirrus'):
return self.gitconfig[section].keys()
return list(self.gitconfig[section].keys())

def has_section(self, section):
return section in self
Expand Down
2 changes: 1 addition & 1 deletion src/cirrus/creds_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,4 @@ def credential_map(self):

if __name__ == '__main__':
p = CredsPlugin()
print p.credential_map()
print(p.credential_map())
6 changes: 3 additions & 3 deletions src/cirrus/delegate.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ def main():
args = sys.argv[1:]
if len(args) == 0 or args[0] == '-h':
# missing command or help
print format_help(commands)
print(format_help(commands))
exit_code = 0
else:
command_path = "{0}/bin/{1}".format(home, args[0])
if not os.path.exists(command_path):
msg = "Unknown command: {}".format(args[0])
print msg
print format_help(commands)
print(msg)
print(format_help(commands))
exit_code = 127
else:
exit_code = run_command([command_path, ] + args[1:])
Expand Down
4 changes: 2 additions & 2 deletions src/cirrus/documentation_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import sys
import tarfile

from fabric.operations import local
from invoke import run
import pluggage.registry

from cirrus.configuration import load_configuration
Expand Down Expand Up @@ -81,7 +81,7 @@ def build_docs(make_opts=None):
# additional args were passed after --docs. Pass these to make
cmd = 'cd {} && make {}'.format(docs_root, ' '.join(make_opts))

local('. ./{}/bin/activate && {}'.format(config.venv_name(), cmd))
run('. ./{}/bin/activate && {}'.format(config.venv_name(), cmd))
LOGGER.info('Build command was "{}"'.format(cmd))


Expand Down
2 changes: 1 addition & 1 deletion src/cirrus/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def repo_directory():
outp, err = process.communicate()
if process.returncode:
return None
return outp.strip()
return outp.strip().decode('utf-8')


def cirrus_home():
Expand Down
58 changes: 21 additions & 37 deletions src/cirrus/fabric_helpers.py
Original file line number Diff line number Diff line change
@@ -1,52 +1,36 @@
#!/usr/bin/env python
"""
_fabric_helpers_
Utils/helpers for fabric api
"""
import copy
from fabric.api import env
from fabric.config import Config
from fabric.connection import Connection


class FabricHelper(object):
class FabricHelper(Connection):
"""
_FabricHelper_
Context helper to set and clear fabric env
to run a command on a given host
Simplified fabric Connection
Example usage;
with FabricHelper('pypi.cloudant.com', 'evansde77', '/Users/david/.ssh/id_rsa'):
run('/bin/date')
with FabricHelper('pypi.cloudant.com', 'evansde77', '/Users/david/.ssh/id_rsa') as fh:
fh.run('/bin/date')
Will run the date command on pypi.cloudant.com as evansde77 using the key file
specified
"""
def __init__(self, hostname, username, ssh_key):
self.hostname = hostname
self.username = username
self.ssh_key = ssh_key
# save settings
self.hostname_cache = None
self.username_cache = None
self.ssh_key_cache = None

def __enter__(self):
self.hostname_cache = copy.copy(env.host_string)
self.username_cache = copy.copy(env.user)
self.ssh_key_cache = copy.copy(env.key_filename)

env.host_string = self.hostname
env.user = self.username
env.key_filename = self.ssh_key
return self

def __exit__(self, *args):
env.host_string = self.hostname_cache
env.user = self.username_cache
env.key_filename = self.ssh_key_cache



config = Config(key_filename=ssh_key)
super().__init__(hostname, user=username, config=config)

def put(self, local, remote, use_sudo=False):
"""
Adds sudo implementation that was removed in fabric2
:param bool use_sudo: if True, file is first moved to user's home
directory and then moved to the remote location
"""
if use_sudo:
super().put(local)
self.sudo('mv {} {}'.format(local, remote))
else:
super().put(local, remote)
4 changes: 2 additions & 2 deletions src/cirrus/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ def list_feature_branches(opts):
list unmerged feature branches
"""
repo_dir = os.getcwd()
print "unmerged feature branches:"
print("unmerged feature branches:")
with GitHubContext(repo_dir) as ghc:
for x in ghc.iter_git_feature_branches(merged=False):
print x
print(x)


def main():
Expand Down
8 changes: 4 additions & 4 deletions src/cirrus/git_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def push(repo_dir):
# Check to make sure that we haven't errored out.
for r in ret:
if r.flags >= r.ERROR:
raise RuntimeError(unicode(r.summary))
raise RuntimeError(str(r.summary))
return ret


Expand Down Expand Up @@ -329,17 +329,17 @@ def format_commit_messages(rows):
--- DATETIME: COMMIT MESSAGE
"""
result = [u" - Commit History:"]
result = [" - Commit History:"]

for author, commits in itertools.groupby(rows, lambda x: x['committer']):
result.append(u" -- Author: {0}".format(author))
result.append(" -- Author: {0}".format(author))
sorted_commits = sorted(
[ c for c in commits ],
key=lambda x: x['date'],
reverse=True
)
result.extend(
u' --- {0}: {1}'.format(commit['date'],commit['message'])
' --- {0}: {1}'.format(commit['date'],commit['message'])
for commit in sorted_commits
)

Expand Down
Loading

0 comments on commit 43733e1

Please sign in to comment.