def test_resolve_config_location_relative_path(self): os.makedirs('folder') location = '.' + os.path.sep + 'folder/myfile.cfg.yml' fileoperations.write_to_data_file(location, self.data) result = saved_configs.resolve_config_location(location) self.assertEqual(result, os.path.abspath(location))
def test_resolve_config_location_full_path(self): location = os.path.expanduser(os.getcwd() + os.path.sep + 'myfile.cfg.yml') fileoperations.write_to_data_file(location, self.data) result = saved_configs.resolve_config_location(location) self.assertEqual(result, location)
def test_resolve_config_location_relative_without_slash(self): cfg_name = 'myfile.cfg.yml' location = fileoperations.get_project_file_full_location(cfg_name) fileoperations.write_to_data_file(location, self.data) result = saved_configs.resolve_config_location(cfg_name) self.assertEqual(result, location)
def test_update_config_resolve_path(self, mock_upload): cfg_name = self.cfg_name location = fileoperations.get_project_file_full_location(cfg_name) fileoperations.write_to_data_file(location, self.data) saved_configs.update_config('app', './{0}'.format(self.cfg_name)) mock_upload.assert_called_with('app', 'myfile', location)
def download_application_version(url, zip_file_location): """ Method downloads the application version from the URL, 'url', and writes them at the location specified by `zip_file_location` :param url: the URL of the application version. :param zip_file_location: path on the user's system to write the application version ZIP file to. :return: None """ data = utils.get_data_from_url(url, timeout=30) fileoperations.write_to_data_file(zip_file_location, data)
def download_source_bundle(app_name, env_name): env = elasticbeanstalk.get_environment(app_name=app_name, env_name=env_name) if env.version_label and env.version_label != 'Sample Application': app_version = elasticbeanstalk.get_application_versions( app_name, version_labels=[env.version_label])['ApplicationVersions'][0] source_bundle = app_version['SourceBundle'] bucket_name = source_bundle['S3Bucket'] key_name = source_bundle['S3Key'] io.echo('Downloading application version...') data = s3.get_object(bucket_name, key_name) filename = get_filename(key_name) else: # sample app template = cloudformation.get_template('awseb-' + env.id + '-stack') try: url = template['TemplateBody']['Parameters']['AppSource'][ 'Default'] except KeyError: raise NotFoundError('Can not find app source for environment') utils.get_data_from_url(url) io.echo('Downloading application version...') data = utils.get_data_from_url(url, timeout=30) filename = 'sample.zip' fileoperations.make_eb_dir('downloads/') location = fileoperations.get_eb_file_full_location('downloads/' + filename) fileoperations.write_to_data_file(location, data) io.echo('Application version downloaded to:', location) cwd = os.getcwd() try: fileoperations._traverse_to_project_root() if heuristics.directory_is_empty(): # If we dont have any project code, unzip as current project io.echo('Unzipping application version as project files.') fileoperations.unzip_folder(location, os.getcwd()) io.echo('Done.') finally: os.chdir(cwd)
def dumps(self, path): fileoperations.write_to_data_file(data=cPickle.dumps(self, protocol=2), location=path)