def _create_target_userspace_directories(target_userspace): api.current_logger().debug('Creating target userspace directories.') try: utils.makedirs(target_userspace) api.current_logger().debug('Done creating target userspace directories.') except OSError: api.current_logger().error( 'Failed to create temporary target userspace directories %s', target_userspace, exc_info=True) # This is an attempt for giving the user a chance to resolve it on their own raise StopActorExecutionError( message='Failed to prepare environment for package download while creating directories.', details={ 'hint': 'Please ensure that {directory} is empty and modifiable.'.format(directory=target_userspace) } )
def apply_python3_workaround(): py3_leapp = os.path.join(LEAPP_HOME, 'leapp3') makedirs(LEAPP_HOME) leapp_lib_symlink_path = os.path.join(LEAPP_HOME, 'leapp') if not os.path.exists(leapp_lib_symlink_path): os.symlink(_get_orig_leapp_path(), leapp_lib_symlink_path) with open(py3_leapp, 'w') as f: f_content = [ '#!/usr/bin/python3', 'import sys', 'sys.path.append(\'{}\')'.format(LEAPP_HOME), '', 'import leapp.cli', 'sys.exit(leapp.cli.main())', ] f.write('{}\n\n'.format('\n'.join(f_content))) os.chmod(py3_leapp, 0o770)
def _create_mounts_dir(scratch_dir, mounts_dir): """ Prepares directories for mounts """ api.current_logger().debug('Creating mount directories.') try: utils.makedirs(mounts_dir) api.current_logger().debug('Done creating mount directories.') except OSError: api.current_logger().error('Failed to create mounting directories %s', mounts_dir, exc_info=True) # This is an attempt for giving the user a chance to resolve it on their own raise StopActorExecutionError( message= 'Failed to prepare environment for package download while creating directories.', details={ 'hint': 'Please ensure that {scratch_dir} is empty and modifiable.'. format(scratch_dir=scratch_dir) })
def impl(source, target): source_path = str(basedir.join(*source.lstrip('/').split('/'))) makedirs(source_path) symlink(source_path, target)