This file contains hidden or 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
# Convert all flac files in all subdirs to mp3 with ffmpeg | |
find . -type f -name "*.flac" -print0 | while read -d $'\0' a; do | |
< /dev/null ffmpeg -i "$a" -qscale:a 0 "${a[@]/%flac/mp3}" | |
done |
This file contains hidden or 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
#! /usr/bin/env bash | |
# Only tested on Mac OSX 10.10 | |
if [ -d ~/.chef_pp ]; then | |
echo "Changing to Pre-Production Chef Environment." | |
mv ~/.chef ~/.chef_sandbox | |
mv ~/.berkshelf ~/.berkshelf_sandbox | |
mv ~/.chef_pp ~/.chef | |
mv ~/.berkshelf_pp ~/.berkshelf |
This file contains hidden or 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
from requests.adapters import HTTPAdapter | |
from requests.packages.urllib3.poolmanager import PoolManager | |
class SSLAdapter(HTTPAdapter): | |
"""A HTTPS Transport Adapter that uses an arbitrary SSL version.""" | |
def __init__(self, ssl_version=None, **kwargs): | |
self.ssl_version = ssl_version | |
super(SSLAdapter, self).__init__(**kwargs) |
This file contains hidden or 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
def create_build_info(self, build_name, build_number, dependencies, build_dependencies): | |
""" | |
Returns a build info dictionary which is formated to correctly deploy | |
a new build to artifactory. | |
Make a put request with this build info to api/build | |
""" | |
build_info = {'version': '1.0.1', | |
'name': build_name, | |
'number': str(build_number), | |
'type': 'GENERIC', |
This file contains hidden or 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
import jsonschema | |
import json | |
import nose.tools | |
def test_schema_generator(): | |
test_setup_data = [ | |
{"schema": "../schema/1.0/build-manifest.json", "tests": "build-manifest-validtests.json", "assert_function": nose.tools.assert_true}, | |
{"schema": "../schema/1.0/build-manifest.json", "tests": "build-manifest-invalidtests.json", "assert_function": nose.tools.assert_false}] | |
for test_setup in test_setup_data: |
This file contains hidden or 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
import json | |
import jsonschema | |
import requests | |
def get_valid_json(self, data, json_schema_url): | |
""" | |
Validates a json artifact against a published schema. | |
""" | |
s = requests.get(url=json_schema_url) | |
schema = s.json() |
This file contains hidden or 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
import requests | |
import json | |
class AbstractDataProvider(): | |
"""A list of methods that data providers should implement or extend.""" | |
def __init__(self, base_url, username=None, password=None): | |
self.base_url = base_url.rstrip('/') | |
self.username = username | |
self.password = password |
This file contains hidden or 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
class APIWrapper: | |
#snippet... | |
def poll_api(self, tries, initial_delay, delay, backoff, success_list, apifunction, *args): | |
time.sleep(initial_delay) | |
for n in range(tries): | |
try: | |
status = self.get_status() | |
if status not in success_list: |
This file contains hidden or 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
import socket | |
import inject_exception2 | |
import requests | |
from mock import patch | |
import nose.tools | |
# ...snippet | |
def test_api_call(): | |
with patch.object(requests, "get") as get_mock: |
This file contains hidden or 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
import socket | |
# ...snippet | |
class ExceededRetries(StopIteration): | |
pass | |
def call_api(url): | |
try: | |
requests.get(url="url") |