oio.common package


oio.common.autocontainer module

class oio.common.autocontainer.AutocontainerBuilder(offset=0, size=None, mask=18446744073692774655L, base=16, con_format='%016X', **_kwargs)[source]

Bases: oio.common.autocontainer.ContainerBuilder

Build a container name from the integer conversion of a user provided path and a clever mask.

path is expected to be something like “video/ABC/DEF/xxxxxxxxxFEDCBAxxxxxxxxxx_nomdufichier”


Verify that name is an autocontainer

class oio.common.autocontainer.ContainerBuilder(**_kwargs)[source]

Bases: object

Base class for container name builders.


Generate all alternatives for the provided content path.


Verify that name is an autocontainer

class oio.common.autocontainer.HashedContainerBuilder(offset=0, size=None, bits=15, **_kwargs)[source]

Bases: oio.common.autocontainer.ContainerBuilder

Build a container name from a SHA256 of the content path. Only the first (most significant) bits will be considered to generate the final prefix.


Verify that name is an autocontainer

exception oio.common.autocontainer.NoMatchFound[source]

Bases: exceptions.ValueError

Exception raised when none of the configured patterns match the input object name.

class oio.common.autocontainer.RegexContainerBuilder(patterns, builder=<class 'oio.common.autocontainer.ContainerBuilder'>, **kwargs)[source]

Bases: object

Build a container name from a regular expression applied on a user provided path. Use a concatenation of all matching groups as the container name if no custom builder provided.

Parameters:patterns (str or iterable of str) – regular expressions with at least one capture group

Generate all alternatives for the provided path, in case it matches several patterns.

oio.common.autocontainer.strtoll(val, base=10)[source]

Mimics libc’s strtoll function

oio.common.cache module

oio.common.cache.del_cached_container_metadata(account=None, reference=None, cid=None, cache=None, **kwargs)[source]

Delete the object metadata and location from the cache (if there is one)

oio.common.cache.del_cached_object_metadata(account=None, reference=None, path=None, cid=None, version=None, cache=None, **kwargs)[source]

Delete the object metadata and location from the cache (if there is one)

oio.common.cache.get_cached_container_metadata(account=None, reference=None, cid=None, cache=None, **kwargs)[source]

Get the container metadata from the cache (if there is one)

oio.common.cache.get_cached_object_metadata(account=None, reference=None, path=None, cid=None, version=None, properties=False, cache=None, **kwargs)[source]

Get the object metadata and location from the cache (if there is one)

oio.common.cache.set_cached_container_metadata(container_meta, account=None, reference=None, cid=None, cache=None, **kwargs)[source]

Set the object metadata and location in the cache (if there is one)

oio.common.cache.set_cached_object_metadata(content_meta, content_chunks, account=None, reference=None, path=None, cid=None, version=None, properties=False, cache=None, **kwargs)[source]

Set the object metadata and location in the cache (if there is one)

oio.common.client module

class oio.common.client.ProxyClient(conf, request_prefix='', no_ns_in_url=False, endpoint=None, request_attempts=1, logger=None, **kwargs)[source]

Bases: oio.api.base.HttpApi

Client directed towards oio-proxy, with logging facility

oio.common.configuration module

exception oio.common.configuration.InvalidServiceConfigError[source]

Bases: exceptions.ValueError

class oio.common.configuration.NamespaceConfiguration(files, *args, **kwargs)[source]

Bases: dict

Dictionary subclass that holds namespace configuration. Displays a nice message if a key is missing.

oio.common.configuration.load_namespace_conf(namespace, failsafe=False, fresh=False)[source]

Load configuration for the namespace from the local configuration files.

  • namespace – name of the namespace.
  • failsafe – in case of error, return a dummy configuration.
  • fresh – if True, reload configuration from files, do not use the cache.

a dictionary with local namespace configuration.

oio.common.configuration.read_conf(conf_path, section_name=None, defaults=None, use_yaml=False)[source]
oio.common.configuration.set_namespace_options(namespace, options, remove=None)[source]

Set options in the local namespace configuration file. Can have nasty effects, be careful, only use in test code.

  • namespace – the namespace to work with
  • options – a dictionary with options to set
  • remove – an iterable of options to remove

a dictionary with all options of the namespace


oio.common.constants module

oio.common.daemon module

class oio.common.daemon.Daemon(conf)[source]

Bases: object

run(*args, **kwargs)[source]
oio.common.daemon.run_daemon(klass, conf_file, section_name=None, **kwargs)[source]

oio.common.decorators module


Ensure the subsequent RPCs will have a request ID.


Catch oio.common.exceptions.NotFound exceptions and raise either oio.common.exceptions.NoSuchContainer or oio.common.exceptions.NoSuchObject respectively if the container is missing or the object is missing.


Patch keyword arguments with the ones passed to the class’ constructor. Compute a deadline if a timeout is provided and there is no deadline already. Requires the class to have a _global_kwargs member (dict).

oio.common.easy_value module

oio.common.easy_value.boolean_value(value, default=False)[source]
oio.common.easy_value.convert_size(size, unit='')[source]

Convert binary data to string.

For bytes arrays, return a string. For lists, call debinarize all items. For dicts, debinarize keys and values. For other types, return the item as is.

oio.common.easy_value.float_value(value, default)[source]
oio.common.easy_value.int_value(value, default)[source]
oio.common.easy_value.is_hexa(hexa, size=None)[source]

oio.common.exceptions module

exception oio.common.exceptions.BadRequest(http_status=400, status=None, message=None)[source]

Bases: oio.common.exceptions.ClientException

Request is not correct.

exception oio.common.exceptions.ChunkException[source]

Bases: oio.common.exceptions.OioException

exception oio.common.exceptions.ClientException(http_status, status=None, message=None)[source]

Bases: oio.common.exceptions.StatusMessageException

exception oio.common.exceptions.ClientPreconditionFailed(http_status=412, status=None, message=None)[source]

Bases: oio.common.exceptions.ClientException

exception oio.common.exceptions.CommandError[source]

Bases: exceptions.Exception

exception oio.common.exceptions.ConfigurationException[source]

Bases: oio.common.exceptions.OioException

exception oio.common.exceptions.Conflict(http_status=409, status=None, message=None)[source]

Bases: oio.common.exceptions.ClientException

exception oio.common.exceptions.ContainerNotEmpty[source]

Bases: oio.common.exceptions.OioException

exception oio.common.exceptions.ContentException[source]

Bases: oio.common.exceptions.OioException

exception oio.common.exceptions.ContentNotFound[source]

Bases: oio.common.exceptions.ContentException

exception oio.common.exceptions.CorruptedChunk[source]

Bases: oio.common.exceptions.ChunkException

exception oio.common.exceptions.DeadlineReached[source]

Bases: oio.common.exceptions.OioException

Special exception to be raised when a deadline is reached. This differs from the OioTimeout in that we are sure the operation won’t succeed silently in the background.

exception oio.common.exceptions.ECError[source]

Bases: exceptions.Exception

exception oio.common.exceptions.EmptyByteRange[source]

Bases: exceptions.Exception

exception oio.common.exceptions.EtagMismatch[source]

Bases: oio.common.exceptions.OioException

exception oio.common.exceptions.ExplicitBury[source]

Bases: oio.common.exceptions.OioException

exception oio.common.exceptions.FaultyChunk[source]

Bases: oio.common.exceptions.ChunkException

Raised when a chunk misses some extended attributes, or they have invalid values.

exception oio.common.exceptions.FileNotFound[source]

Bases: oio.common.exceptions.OioException

exception oio.common.exceptions.Forbidden(http_status=403, status=None, message=None)[source]

Bases: oio.common.exceptions.ClientException

Operation is forbidden.

exception oio.common.exceptions.InvalidStorageMethod[source]

Bases: oio.common.exceptions.OioException

exception oio.common.exceptions.LifecycleNotFound[source]

Bases: oio.common.exceptions.OioException

exception oio.common.exceptions.Meta2Exception[source]

Bases: oio.common.exceptions.OioException

exception oio.common.exceptions.MethodNotAllowed(http_status=405, status=None, message=None)[source]

Bases: oio.common.exceptions.ClientException

Request method is not allowed. May be raised when the namespace is in WORM mode and user tries to delete.

exception oio.common.exceptions.MissingAttribute(attribute)[source]

Bases: oio.common.exceptions.OioException

exception oio.common.exceptions.MissingContentLength[source]

Bases: oio.common.exceptions.OioException

exception oio.common.exceptions.MissingData[source]

Bases: oio.common.exceptions.OioException

exception oio.common.exceptions.MissingName[source]

Bases: oio.common.exceptions.OioException

exception oio.common.exceptions.NoSuchAccount[source]

Bases: oio.common.exceptions.OioException

exception oio.common.exceptions.NoSuchContainer[source]

Bases: oio.common.exceptions.OioException

exception oio.common.exceptions.NoSuchObject[source]

Bases: oio.common.exceptions.OioException

exception oio.common.exceptions.NoSuchReference[source]

Bases: oio.common.exceptions.OioException

exception oio.common.exceptions.NotFound(http_status=404, status=None, message=None)[source]

Bases: oio.common.exceptions.ClientException

Resource was not found.

exception oio.common.exceptions.OioException[source]

Bases: exceptions.Exception

exception oio.common.exceptions.OioNetworkException[source]

Bases: oio.common.exceptions.OioException

Network related exception (connection, timeout…).

exception oio.common.exceptions.OioTimeout[source]

Bases: oio.common.exceptions.OioNetworkException

exception oio.common.exceptions.OrphanChunk[source]

Bases: oio.common.exceptions.ChunkException

exception oio.common.exceptions.PreconditionFailed[source]

Bases: oio.common.exceptions.OioException

exception oio.common.exceptions.RetryLater[source]

Bases: oio.common.exceptions.OioException

Exception raised by workers that want a task to be rescheduled later.

exception oio.common.exceptions.ServerException[source]

Bases: oio.common.exceptions.OioException

exception oio.common.exceptions.ServiceBusy(http_status=503, status=None, message=None)[source]

Bases: oio.common.exceptions.ClientException

This kind of exceptions tell that the system was “busy” and could not handle the request at the moment. The user is invited to retry after a few seconds.

exception oio.common.exceptions.ServiceUnavailable[source]

Bases: oio.common.exceptions.OioException

Exception raised when some services are temporarily not available. This does not mean data is lost.

exception oio.common.exceptions.SourceReadError[source]

Bases: oio.common.exceptions.OioException

exception oio.common.exceptions.SourceReadTimeout[source]

Bases: oio.common.exceptions.OioTimeout

Specialization of OioTimeout for the case when a timeout occurs while reading data from a client application.

exception oio.common.exceptions.SpareChunkException[source]

Bases: oio.common.exceptions.Meta2Exception

Exception raised when no spare chunk has been found, or some may have been found but they don’t match all criteria.

exception oio.common.exceptions.StatusMessageException(http_status, status=None, message=None)[source]

Bases: oio.common.exceptions.OioException

Error carrying an HTTP status, an OIO status and a message.

exception oio.common.exceptions.TooLarge(http_status=413, status=None, message=None)[source]

Bases: oio.common.exceptions.ClientException

exception oio.common.exceptions.UnfinishedUploadException(exception, chunks_already_uploaded)[source]

Bases: oio.common.exceptions.OioException

Exception raised when a number of chunks are not uploaded.


Re-raise the wrapped exception. This is intended to be called after some sort of cleanup has been done.

exception oio.common.exceptions.UnrecoverableContent[source]

Bases: oio.common.exceptions.ContentException

exception oio.common.exceptions.UnsatisfiableRange(http_status=416, status=None, message=None)[source]

Bases: oio.common.exceptions.ClientException

exception oio.common.exceptions.VolumeException[source]

Bases: oio.common.exceptions.OioException

Exception raised when someone is trying to contact a rdir service, but there is none assigned to the specified rawx.

oio.common.exceptions.from_response(resp, body=None)[source]
oio.common.exceptions.from_status(status, reason='n/a')[source]
oio.common.exceptions.reraise(exc_type, exc_value, extra_message=None)[source]

Raise an exception of type exc_type with arguments of exc_value plus maybe extra_message at the beginning.

oio.common.fullpath module


Decode a “fullpath” string, extract its 5 parts.

Raises:ValueError if the string has invalid format.
Returns:account, container, path, version and content ID.
oio.common.fullpath.encode_fullpath(account, container, path, version, content_id)[source]
oio.common.fullpath.encode_old_fullpath(account, container, path, version)[source]

oio.common.green module

exception oio.common.green.ChunkReadTimeout(seconds=None, exception=None)[source]

Bases: oio.common.green.OioTimeout

msg_prefix = 'Chunk read '
exception oio.common.green.ChunkWriteTimeout(seconds=None, exception=None)[source]

Bases: oio.common.green.OioTimeout

msg_prefix = 'Chunk write '
exception oio.common.green.ConnectionTimeout(seconds=None, exception=None)[source]

Bases: oio.common.green.OioTimeout

msg_prefix = 'Connection '
class oio.common.green.ContextPool(size=1000)[source]

Bases: eventlet.greenpool.GreenPool

exception oio.common.green.OioTimeout(seconds=None, exception=None)[source]

Bases: eventlet.timeout.Timeout

Wrapper over eventlet.Timeout with better __str__.

msg_prefix = ''
exception oio.common.green.SourceReadTimeout(seconds=None, exception=None)[source]

Bases: oio.common.green.OioTimeout

msg_prefix = 'Source read '

Swith to another eventlet coroutine.

oio.common.green.ratelimit(run_time, max_rate, increment=1, rate_buffer=5, time_time=None)[source]

Given a policy, return a customized wrapper around ratelimit for a time aware rate limiter. :param policy: An array representing a rate limiting policy as described

by ratelimit_validate_policy.
Returns:A callable function similar in signature to ratelimit but that ignores all parameters other than the first one.
oio.common.green.ratelimit_function_curr_rate(curr_date, policy)[source]

Given a validated policy and a datetime, return the applicable max_rate

Parameters:curr_date – The current date

:type curr_date datetime :param policy: An array representing a validated policy :return: The applicable max_rate (elements per second)

oio.common.green.ratelimit_function_next_rate(curr_date, policy)[source]

Given a current date and a policy, calculate the date at which the next rate change is scheduled.

(Could be useful if the rate limited operation is fast, and as such we would want to cache the next rate date so that instead of selecting the rate each op, we’d just compare to a timestamp and return a cached value, which in the current implementation would make it go from a for loop with several comparisons to about a single comparison)

  • curr_date (datetime) – The current datetime
  • policy – A list representing a validated policy.

the next scheduled rate and the datetime object for the next scheduled rate change.

Return type:list of 2-tuples with a datetime.timedelta and an integer.

Validate a policy. The following rules are checked: - Each partition has a positive max_rate. - The start date of each partition is 0 or positive. - The start date of each partition is lower than 24h.

An example of a simple policy would be: [

(datetime.timedelta(0), 3),


Which would be a policy to have a constant max_rate of 3. A more complex policy would be: [

(datetime.timedelta(0, 1800), 10), # 0h30 to 6h45 (datetime.timedelta(0, 24300), 2), # 6h45 to 9h45 (datetime.timedelta(0, 35100), 5), # 9h45 to 15h30 (datetime.timedelta(0, 55800), 3), # 15h30 to 20h00 (datetime.timedelta(0, 72000), 8), # 20h00 to 0h30


Parameters:policy (list) – A list containing the policy that follows the aforementioned description.
Raises:ValueError if one of the rules is not respected.

oio.common.http module

class oio.common.http.CustomHttpConnection(*args, **kwargs)[source]

Bases: oio.common.http_eventlet.CustomHttpConnection

class oio.common.http.HeadersDict(headers, **kwargs)[source]

Bases: dict

get(k[, d]) → D[k] if k in D, else d. d defaults to None.[source]
pop(k[, d]) → v, remove specified key and return the corresponding value.[source]

If key is not found, d is returned if given, otherwise KeyError is raised

update([E, ]**F) → None. Update D from dict/iterable E and F.[source]

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

oio.common.http.get_addr(host, port)[source]

Generate the address for host (IPv4 or IPv6) and port


Generate chunk PUT request headers from object metadata.


oio.common.http_eventlet module

class oio.common.http_eventlet.CustomHTTPResponse(sock, debuglevel=0, strict=0, method=None, url=None)[source]

Bases: httplib.HTTPResponse

class oio.common.http_eventlet.CustomHttpConnection(host, port=None, strict=None, timeout=<object object>, source_address=None)[source]

Bases: httplib.HTTPConnection

putrequest(method, url, skip_host=0, skip_accept_encoding=0)[source]

alias of CustomHTTPResponse


Enable or disable TCP_CORK on the underlying socket.


Enable or disable TCP_NODELAY on the underlying socket.

class oio.common.http_eventlet.CustomHttpsConnection(host, port=None, key_file=None, cert_file=None, strict=None, timeout=<object object>, source_address=None, context=None, check_hostname=None)[source]

Bases: httplib.HTTPSConnection

putrequest(method, url, skip_host=0, skip_accept_encoding=0)[source]

alias of CustomHTTPResponse


Enable or disable TCP_CORK on the underlying socket.

oio.common.http_eventlet.http_connect(host, method, path, headers=None, query_string=None, scheme='http')[source]

oio.common.http_urllib3 module

class oio.common.http_urllib3.SafePoolManager(num_pools=10, headers=None, **connection_pool_kw)[source]

Bases: urllib3.poolmanager.PoolManager

urllib3.PoolManager wrapper that filters out keyword arguments not recognized by urllib3.

request(*args, **kwargs)[source]

Filter out arguments that are not recognized by urllib3, then call urllib3.PoolManager.request.

oio.common.http_urllib3.get_pool_manager(pool_connections=32, pool_maxsize=32, max_retries=0, backoff_factor=0, **kwargs)[source]

Get urllib3.PoolManager to manage pools of connections

  • pool_connections (int) – number of connection pools (see “num_pools”).
  • pool_maxsize (int) – number of connections per connection pool
  • max_retries (int) – number of retries per request
  • backoff_factor (float) – backoff factor to apply between attempts after second try
oio.common.http_urllib3.oio_exception_from_httperror(exc, reqid=None, url=None)[source]

Convert an HTTPError from urllib3 to an OioException, and re-raise it.

oio.common.json module

oio.common.logger module

class oio.common.logger.StreamToLogger(logger, log_type='STDOUT')[source]

Bases: object

oio.common.logger.get_logger(conf, name=None, verbose=False, fmt='%(process)d %(thread)X %(name)s %(levelname)s %(message)s')[source]

Close stdio, redirect stdout and stderr.


oio.common.redis_conn module

class oio.common.redis_conn.RedisConnection(host=None, sentinel_hosts=None, sentinel_name=None, **kwargs)[source]

Bases: object

URL_QUERY_ARGUMENT_PARSERS = {'health_check_interval': <type 'int'>, 'max_connections': <type 'int'>, 'retry_on_timeout': <function true_value at 0x7fdf932391b8>, 'socket_connect_timeout': <type 'float'>, 'socket_keepalive': <function true_value at 0x7fdf932391b8>, 'socket_timeout': <type 'float'>}
acquire_lock_with_timeout(lockname, acquire_timeout=10, lock_timeout=10)[source]

Acquire a lock :lockname:


Retrieve Redis connection (normal or sentinel)


Retrieve Redis connection (normal or sentinel)


Register a LUA script and return Script object.

release_lock(lockname, identifier)[source]

Release a previously acquired Lock


Catch errors attributable to the Redis service and raise ServiceBusy instead.

Raises:ServiceBusy – in case of a Redis service error

oio.common.storage_functions module

oio.common.storage_functions.fetch_stream(*args, **kwargs)[source]
oio.common.storage_functions.fetch_stream_ec(*args, **kwargs)[source]
oio.common.storage_functions.get_meta_ranges(ranges, chunks)[source]

Convert object ranges to metachunks ranges.

Returns:a list of dictionaries indexed by metachunk positions
oio.common.storage_functions.obj_range_to_meta_chunk_range(obj_start, obj_end, meta_sizes)[source]

Convert a requested object range into a list of meta_chunk ranges.

Parameters:meta_sizes (iterable, sorted in ascendant metachunk order.) – size of all object metachunks. Must be sorted!
Returns:a dict of tuples (meta_chunk_start, meta_chunk_end) with metachunk positions as keys.
  • meta_chunk_start is the first byte of the meta chunk, or None if this is a suffix byte range
  • meta_chunk_end is the last byte of the meta_chunk, or None if this is a prefix byte range

Choose an element from the scores sequence and return its index

oio.common.storage_method module

class oio.common.storage_method.BackblazeStorageMethod(name, account_id, bucket_name)[source]

Bases: oio.common.storage_method.StorageMethod

classmethod build(params)[source]
class oio.common.storage_method.ECStorageMethod(name, ec_segment_size, ec_type, ec_nb_data, ec_nb_parity)[source]

Bases: oio.common.storage_method.StorageMethod

classmethod build(params)[source]
class oio.common.storage_method.ReplicatedStorageMethod(name, nb_copy)[source]

Bases: oio.common.storage_method.StorageMethod

classmethod build(params)[source]
class oio.common.storage_method.StorageMethod(name, ec=False, backblaze=False)[source]

Bases: object

class oio.common.storage_method.StorageMethodLoad[source]

Bases: object

class oio.common.storage_method.StorageMethods(methods)[source]

Bases: object

load(chunk_method, **kwargs)[source]

oio.common.timestamp module

class oio.common.timestamp.Timestamp(timestamp=None)[source]

Bases: object

oio.common.timestamp.cmp(x, y)[source]

oio.common.tool module

class oio.common.tool.Tool(conf, beanstalkd_addr=None, logger=None)[source]

Bases: object

Process all found items.

For the task_res variable, the following format must be respected: (item, info, error).

create_worker(queue_workers, queue_reply)[source]

Create worker to process the items.

exit_gracefully(signum, frame)[source]

Fetch items with beanstalkd reply (useful if the task is distributed).


Check if there are any errors.

static items_from_task_event(task_event)[source]

Convert the task event into a list (generator) of items.

log_report(status, force=False)[source]

Log a report with a fixed interval.


The tool will dispatch the tasks on the platform.


The tool will dispatch the tasks locally.

static res_event_from_task_res(task_res)[source]

Convert the task result into a result event.


Start processing all found items.

static string_from_item(item)[source]

Convert the item into a string.

static task_event_from_item(item)[source]

Convert the item into a task event.

static tasks_res_from_res_event(res_event)[source]

Convert the result event into a list (generator) of tasks result.


Update all counters of the tool.

class oio.common.tool.ToolWorker(tool, queue_workers, queue_reply)[source]

Bases: object

Process all items given by the tool.


Starting processing all items given by the tool.

oio.common.tool.locate_tube(services, tube)[source]

Get a list of beanstalkd services hosting the specified tube.

  • services (iterable of dictionaries) – known beanstalkd services.
  • tube – the tube to locate.

a list of beanstalkd services hosting the the specified tube.

Return type:

list of dict

oio.common.utils module

class oio.common.utils.CacheDict(size=262144)[source]

Bases: collections.OrderedDict

OrderedDict subclass which holds a limited number of items.

class oio.common.utils.GeneratorIO(gen, sub_generator=True, iter_size=8192)[source]

Bases: io.RawIOBase

Make a file-like object from a generator. gen is the generator to read. sub_generator is a boolean telling that the generator yields sequences of bytes instead of bytes.


Return whether object was opened for reading.

If False, read() will raise IOError.

class oio.common.utils.RingBuffer(size=1)[source]

Bases: list


L.append(object) – append object to end


Get the size of the ring buffer

oio.common.utils.cid_from_name(account, ref)[source]

Compute a container ID from an account and a reference name.

oio.common.utils.compute_perfdata_stats(perfdata, prefix='upload.')[source]

Compute extra statistics from a dictionary of performance data.

oio.common.utils.deadline_to_timeout(deadline, check=False)[source]

Convert a deadline (float seconds) to a timeout (float seconds)

oio.common.utils.depaginate(func, item_key=None, listing_key=None, marker_key=None, truncated_key=None, attempts=1, *args, **kwargs)[source]

Yield items from the lists returned by the repetitive calls to func(*args, **kwargs). For each call (except the first), the marker is taken from the last element returned by the previous call (unless marker_key is provided). The listing stops after an empty listing is returned (unless truncated_key is provided).

  • item_key – an accessor to the actual item that should be yielded, applied on each element of the listing
  • listing_key – an accessor to the actual listing, applied on the result of func(*args, **kwargs)
  • marker_key – an accessor to the next marker from the previous listing, applied on the result of func(*args, **kwargs)
  • truncated_key – an accessor telling if the listing is truncated, applied on the result of func(*args, **kwargs)
oio.common.utils.encode(input, codec='utf-8')[source]

Recursively encode a list of dictionnaries

oio.common.utils.fix_ranges(ranges, length)[source]
oio.common.utils.getrandbits(k) → x. Generates a long int with k random bits.

Group errors in a dictionary of lists. The keys are errors, the values are lists of chunk IDs.


Convert all dict keys to lower case.


Get the monotonic time as float seconds


Yield paths of all regular files under volume_path.

oio.common.utils.quote(value, safe='/')[source]

Build a 128-bit request id string.

Parameters:prefix – optional prefix to the request id.
oio.common.utils.set_deadline_from_read_timeout(kwargs, force=False)[source]

Compute a deadline from a read timeout, and set it in a keyword argument dictionary if there is none (or force is set).

Parameters:volume – path to the mount point to get stats from.
Returns:the free space ratio.
Return type:float
oio.common.utils.timeout_to_deadline(timeout, now=None)[source]

Convert a timeout (float seconds) to a deadline (float seconds).

oio.common.wsgi module

class oio.common.wsgi.Application(app, conf, logger_class=None)[source]

Bases: gunicorn.app.base.BaseApplication

access_log_fmt = '%(bind0)s %(h)s:%({remote}p)s %(m)s %(s)s %(D)s %(B)s %(l)s %({x-oio-req-id}i)s %(U)s?%(q)s'

This method is used to load the configuration from one or several input(s). Custom Command line, configuration file. You have to override this method in your class.

class oio.common.wsgi.ServiceLogger(cfg)[source]

Bases: gunicorn.glogging.Logger

access(resp, req, environ, request_time)[source]

See http://httpd.apache.org/docs/2.0/logs.html#combined for format details

atoms(resp, req, environ, request_time)[source]

Gets atoms for log formating.

class oio.common.wsgi.WerkzeugApp(url_map=None, logger=None)[source]

Bases: object

wsgi_app(environ, start_response)[source]
oio.common.wsgi.init_request_processor(conf_file, app_name, app_factory, *args, **kwargs)[source]

oio.common.xattr module

oio.common.xattr.set_fullpath_xattr(fd, new_fullpaths, remove_old_xattr=False, xattr_to_remove=None)[source]

Insert new fullpath extended attributes, remove deprecated ones.

  • new_fullpaths – dictionary of “fullpath” extended attributes that should be set on file. The key is the chunk ID (required to generate the attribute key), the value is the “fullpath”.
  • remove_old_xattr (bool) – remove legacy attributes from file
  • xattr_to_remove – list of extra extended attributes that should be removed from file

Module contents