forked from evansde77/cirrus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/3.0.0' into new-master
- Loading branch information
Showing
60 changed files
with
493 additions
and
504 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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}" | ||
|
||
|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.