def write_files(self, files, base_path): if os.path.isdir(base_path): shutil.rmtree(base_path) for filepath, contents in files.iteritems(): filename = os.path.join(base_path, filepath) file_dir = os.path.dirname(filename) util.mkdir_p(file_dir) util.logger.debug("Writing out file %s" % filepath) f = open(filename, 'w') f.write(contents) f.close() util.logger.info("All done writing out input data")
def __init__(self, ids_or_urls=[], options={}): util.mkdir_p(self.test_cases_path()) if not os.path.isfile(http_client.certs_path()): msg = ("You seem to have deleted the file of certificates " "that shipped with this repo. It should exist " "at %s" % http_client.certs_path()) raise error.StripeError(msg) if ids_or_urls == []: util.logger.info('No test case supplied. Randomly choosing among defaults.') ids_or_urls = [SystemRandom().choice(self.DEFAULT_TEST_CASES)] self.test_cases = map(lambda token: TestCase(self, token), ids_or_urls) self.options = options headers = { 'User-Agent': 'Stripe TestHarness/%s' % (self.VERSION,), } self.http_client = http_client.new_default_http_client(headers=headers, verify_ssl_certs=True)