def test_env_vars_loaded(self): settings._initialize() initial_settings = settings.get()['swift'] self.assertEquals(initial_settings['username'], 'test_username') self.assertEquals(initial_settings['password'], 'test_password') self.assertEquals(initial_settings['num_retries'], 2) self.assertEquals(initial_settings['auth_url'], 'http://test_auth_url.com')
def test_initialize_w_user_file(self): expected_settings = { 'stor': {}, 's3': { 'aws_access_key_id': '', 'aws_secret_access_key': '', 'aws_session_token': '', 'profile_name': '', 'region_name': '' }, 's3:upload': { 'segment_size': 8388608, 'object_threads': 10, 'segment_threads': 10 }, 's3:download': { 'segment_size': 8388608, 'object_threads': 10, 'segment_threads': 10 }, 'swift': { 'username': '******', 'password': '******', 'auth_url': '', 'temp_url_key': '', 'num_retries': 0 }, 'swift:delete': { 'object_threads': 10 }, 'swift:download': { 'container_threads': 10, 'object_threads': 10, 'shuffle': True, 'skip_identical': True }, 'swift:upload': { 'changed': False, 'checksum': True, 'leave_segments': True, 'object_threads': 10, 'segment_size': 1073741824, 'segment_threads': 10, 'skip_identical': False, 'use_slo': True }, 'dx': { 'auth_token': 'fake_token', 'wait_on_close': 0, 'file_proxy_url': '', } } filename = os.path.join(os.path.dirname(__file__), 'file_data', 'test.cfg') with mock.patch('stor.settings.USER_CONFIG_FILE', filename): settings._initialize() self.assertEquals(settings._global_settings, expected_settings)
def test_initialize_default(self): expected_settings = { 'stor': {}, 's3': { 'aws_access_key_id': '', 'aws_secret_access_key': '', 'aws_session_token': '', 'profile_name': '', 'region_name': '' }, 's3:upload': { 'segment_size': 8388608, 'object_threads': 10, 'segment_threads': 10 }, 's3:download': { 'segment_size': 8388608, 'object_threads': 10, 'segment_threads': 10 }, 'swift': { 'username': '', 'password': '', 'auth_url': '', 'temp_url_key': '', 'num_retries': 0 }, 'swift:delete': { 'object_threads': 10 }, 'swift:download': { 'container_threads': 10, 'object_threads': 10, 'shuffle': True, 'skip_identical': True }, 'swift:upload': { 'changed': False, 'checksum': True, 'leave_segments': True, 'object_threads': 10, 'segment_size': 1073741824, 'segment_threads': 10, 'skip_identical': False, 'use_slo': True }, 'dx': { 'auth_token': '', 'wait_on_close': 0, 'file_proxy_url': '', } } settings._initialize() assert settings._global_settings == expected_settings
def main(): handler = logging.StreamHandler(sys.stdout) handler.setLevel(logging.INFO) s3_logger = logging.getLogger('stor.s3.progress') s3_logger.setLevel(logging.INFO) s3_logger.addHandler(handler) swift_logger = logging.getLogger('stor.swift.progress') swift_logger.setLevel(logging.INFO) swift_logger.addHandler(handler) settings._initialize() parser = create_parser() args = parser.parse_args() results = process_args(args) cmd = vars(args).get('cmd') if cmd in PRINT_CMDS: print_results(results)
def test_initialize_default(self): expected_settings = { 'stor': {}, 's3': {}, 's3:upload': { 'segment_size': 8388608, 'object_threads': 10, 'segment_threads': 10 }, 's3:download': { 'segment_size': 8388608, 'object_threads': 10, 'segment_threads': 10 }, 'swift': { 'username': '', 'password': '', 'auth_url': '', 'temp_url_key': '', 'num_retries': 0 }, 'swift:delete': { 'object_threads': 10 }, 'swift:download': { 'container_threads': 10, 'object_threads': 10, 'shuffle': True, 'skip_identical': True }, 'swift:upload': { 'changed': False, 'checksum': True, 'leave_segments': True, 'object_threads': 10, 'segment_size': 1073741824, 'segment_threads': 10, 'skip_identical': False, 'use_slo': True } } settings._initialize() self.assertEquals(settings._global_settings, expected_settings)
from stor.utils import is_filesystem_path from stor.utils import is_swift_path from stor.utils import NamedTemporaryDirectory from stor.base import Path from stor import settings # TODO: Compile this - costs ~700us to do this on import try: __version__ = pkg_resources.get_distribution('stor').version except pkg_resources.DistributionNotFound: # pragma: no cover # we are not pip installed in environment __version__ = None settings._initialize() def _delegate_to_path(name): def wrapper(path, *args, **kwargs): f = getattr(Path(path), name) return f(*args, **kwargs) wrapper.__doc__ = getattr(Path, name).__doc__ wrapper.__name__ = name return wrapper # extra compat! open = _delegate_to_path('open') abspath = _delegate_to_path('abspath') normcase = _delegate_to_path('normcase') normpath = _delegate_to_path('normpath')