def main(): bitbucket_username = vault.get('bitbucket.org', 'username') github_username = vault.get('github.com', 'username') github_api_token = vault.get('github.com', github_username) for repo in bitbucket.repos(bitbucket_username): if (0 != backup(repo, bitbucket_username, github_username, github_api_token)): break
def __init__(self, server=None, auth=None): if server == None: self.server = vault.get(self.VAULT_SERVICE_NAME, 'server') else: self.server = server if auth == None: self.user = vault.get(self.VAULT_SERVICE_NAME, 'user') self.password = vault.get(self.VAULT_SERVICE_NAME, 'password') self.auth = '%s:%s' % (self.user, self.password) else: self.auth = auth self.cwd = ['/']
def prompt_for_auth(service): global _cache if service in _cache: return _cache[service] original_stdout = sys.stdout sys.stdout = sys.stderr username = vault.get(service, "username") password = vault.get(service, "password") sys.stdout = original_stdout _cache[service] = (username, password) return username, password
def vault_beat(): """ Task handler. Reads a value from Vault and confirms that the read value is the expected value. """ try: r = vault.get('secret/canary') except BaseException as e: logging.exception(e) return "VAULT FAILURE", 205 try: assert r['question'] == "What do you call a camel with 3 humps?", r assert r['answer'] == "Pregnant", r except BaseException as e: logging.exception(e) return "LOGIC FAILURE", 210 return "SUCCESS", 200
#!/usr/bin/env python """ This script backs up all public repos of a GitHub user to BitBucket. """ import tempfile import os import vault from scriptine.shell import sh import bitbucket, github github_username = vault.get('github.com', 'username') bitbucket_username = vault.get('bitbucket.org', 'username') bitbucket_password = vault.get('bitbucket.org', bitbucket_username) bitbucket_url = 'ssh://[email protected]/{0}/{1}' github_url = 'git+ssh://[email protected]/{0}/{1}.git' tmp_dir = tempfile.gettempdir() def backup(repo): print "Syncing %s from GitHub to BitBucket" % repo['name'] bitbucket.create_repo(repo, bitbucket_username, bitbucket_password) bitbucket_repo = bitbucket_url.format(bitbucket_username, repo['name']) github_repo = github_url.format(github_username, repo['name']) local_repo = os.path.join(tmp_dir, repo['name']) if os.path.exists(local_repo): sh('hg fetch {0} -R {1}'.format(github_repo, local_repo))
# Date: 15.11.2018 from __future__ import print_function from googleapiclient.discovery import build from httplib2 import Http import oauth2client from oauth2client import file, tools import imapclient import vault import json # If modifying these scopes, delete the file token.json. SCOPES = 'https://www.googleapis.com/auth/drive.metadata.readonly' # gdrive api gdrivesecret = vault.get('gdriveapi', 'secret') # get user/pass gmail = vault.get('gmailuser', 'main') pcblues = vault.get('pcbluesuser', 'main') gmailpass = vault.get('gmailpass', gmail) pcbluespass = vault.get('pcbluespass', pcblues) def drivedemo(): print('\ngdrive') """Shows basic usage of the Drive v3 API. Prints the names and ids of the first 10 files the user has access to. """ # The file token.json stores the user's access and refresh tokens, and is # created automatically when the authorization flow completes for the first
#!/usr/bin/env python """ This script backs up all public repos of a BitBucket user to GitHub. """ import tempfile import os import vault from scriptine.shell import sh import bitbucket, github bitbucket_username = vault.get("bitbucket.org", "username") github_username = vault.get("github.com", "username") github_api_token = vault.get("github.com", github_username) bitbucket_url = "http://bitbucket.org/{0}/{1}" github_url = "git+ssh://[email protected]/{0}/{1}.git" tmp_dir = tempfile.gettempdir() def backup(repo): print "Syncing " + repo + " from BitBucket to GitHub" github.create_repo(repo, github_username, github_api_token) bitbucket_repo = bitbucket_url.format(bitbucket_username, repo) github_repo = github_url.format(github_username, repo) local_repo = os.path.join(tmp_dir, repo) if os.path.exists(local_repo): sh("hg pull {0} -R {1}".format(bitbucket_repo, local_repo))