Skip to content

Instantly share code, notes, and snippets.

@shaitan
shaitan / check.py
Last active March 15, 2016 10:48
Check replicas consistency
#!/usr/bin/env python
from optparse import OptionParser
import elliptics
def iterate(s, group):
route = s.routes.filter_by_group(group)[0]
it_s = s.clone()
it_s.cflags = 0
it_s.set_direct_id(route.address, route.backend_id)
@shaitan
shaitan / check.py
Last active December 25, 2015 09:07
#!/usr/bin/env python
import sys
import errno
import elliptics
def main():
address = elliptics.Address.from_host_port_family(sys.argv[1])
{
"binary_file_patterns":
[
"*.jpg",
"*.jpeg",
"*.png",
"*.gif",
"*.ttf",
"*.tga",
"*.dds",
@shaitan
shaitan / mounts.py
Last active March 23, 2017 07:36
sshfs mount
import os
local_base_dir = '/Users/user'
mount_points = {
'host' : {
'/home/user': 'volume'
}
}
@shaitan
shaitan / eblob_scan.py
Last active October 20, 2015 11:13
Script for scanning eblob blob, blob's sorted and unsorted indexes.
#!/usr/bin/python
# -*- coding: utf-8 -*-
# =============================================================================
# 2013+ Copyright (c) Kirill Smorodinnikov <shaitkir@gmail.com>
# All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
#!/usr/bin/env python
import elliptics
host='host'
port=1025
family=2
remote = elliptics.Address(host, port, family)
@shaitan
shaitan / ranges.py
Created March 4, 2014 14:01
Prints all key ranges for elliptics node
def print_address_ranges(address):
import elliptics
n = elliptics.create_node(remotes=[address])
s = elliptics.Session(n)
print s.routes.get_address_ranges(elliptics.Address.from_host_port_family(address))
print_address_range('myhost:1025:2')
@shaitan
shaitan / new_object.cpp
Created January 23, 2014 09:49
defines boost::python function which returns new object
#include <boost/python/manage_new_object.hpp>
#include <boost/python/return_value_policy.hpp>
some_object* some_function() {
return new some_object();
}
.def("some_function", some_function, boost::python::return_value_policy<boost::python::manage_new_object>(),
@shaitan
shaitan / sample.py
Last active December 26, 2015 07:39
Logger, config & node initialization.
import elliptics
log = elliptics.Logger("/dev/stderr", 31)
cfg = elliptics.Config()
cfg.cookie = "0123456789012345678901234567890123456789"
cfg.config.wait_timeout = 60
cfg.config.check_timeout = 60
n = elliptics.Node(log, cfg)