How to use the storage.Storage function in storage

To help you get started, we’ve selected a few storage examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github apache / thrift / contrib / zeromq / test-client.py View on Github external
def main(args):
    endpoint = "tcp://127.0.0.1:9090"
    socktype = zmq.REQ
    incr = 0
    if len(args) > 1:
        incr = int(args[1])
        if incr:
            socktype = zmq.DOWNSTREAM
            endpoint = "tcp://127.0.0.1:9091"

    ctx = zmq.Context()
    transport = TZmqClient.TZmqClient(ctx, endpoint, socktype)
    protocol = thrift.protocol.TBinaryProtocol.TBinaryProtocolAccelerated(transport)
    client = storage.Storage.Client(protocol)
    transport.open()

    if incr:
        client.incr(incr)
        time.sleep(0.05)
    else:
        value = client.get()
        print value
github robotology / yarp / extern / thrift / thrift / contrib / zeromq / test-server.py View on Github external
def main():
    handler = StorageHandler()
    processor = storage.Storage.Processor(handler)

    ctx = zmq.Context()
    reqrep_server = TZmqServer.TZmqServer(processor, ctx, "tcp://0.0.0.0:9090", zmq.REP)
    oneway_server = TZmqServer.TZmqServer(processor, ctx, "tcp://0.0.0.0:9091", zmq.PULL)
    multiserver = TZmqServer.TZmqMultiServer()
    multiserver.servers.append(reqrep_server)
    multiserver.servers.append(oneway_server)
    multiserver.serveForever()
github spiffytech / MobileBlur / gluon / sqlhtml.py View on Github external
if record and isinstance(record, (int, long, str, unicode)):
            if not str(record).isdigit():
                raise HTTP(404, "Object not found")
            record = table._db(table._id == record).select().first()
            if not record:
                raise HTTP(404, "Object not found")
        self.record = record

        self.record_id = record_id
        if keyed:
            self.record_id = dict([(k,record and str(record[k]) or None) \
                                       for k in table._primarykey])
        self.field_parent = {}
        xfields = []
        self.fields = fields
        self.custom = Storage()
        self.custom.dspval = Storage()
        self.custom.inpval = Storage()
        self.custom.label = Storage()
        self.custom.comment = Storage()
        self.custom.widget = Storage()
        self.custom.linkto = Storage()

        # default id field name
        self.id_field_name = table._id.name

        sep = separator or ''

        for fieldname in self.fields:
            if fieldname.find('.') >= 0:
                continue
github jniltinho / smb4manager / gluon / serializers.py View on Github external
def xml_rec(value, key, quote=True):
    if hasattr(value, 'custom_xml') and callable(value.custom_xml):
        return value.custom_xml()
    elif isinstance(value, (dict, Storage)):
        return TAG[key](*[TAG[k](xml_rec(v, '', quote))
                          for k, v in value.items()])
    elif isinstance(value, list):
        return TAG[key](*[TAG.item(xml_rec(item, '', quote)) for item in value])
    elif hasattr(value, 'as_list') and callable(value.as_list):
        return str(xml_rec(value.as_list(), '', quote))
    elif hasattr(value, 'as_dict') and callable(value.as_dict):
        return str(xml_rec(value.as_dict(), '', quote))
    else:
        return xmlescape(value, quote)
github openpathsampling / openpathsampling / opentis / xyz_files / xyztranslator.py View on Github external
def init_storage(self, fname):
        '''
        Initializes a storage object with appropriate information.

        Only used if we're converting from xyz to nc: requires that
        self.trajfile be loaded before calling.

        Parameters
        ----------
        fname : str
            filename for the netCDF output
        '''
        topol = self.trajfile_topology(self.trajfile)
        system = AtomCounter(self.trajfile.frames[0].natoms)
        self.simulation = SimulationDuckPunch(topol, system)
        self.storage = Storage( topology_file=topol,
                                          filename=fname, 
                                          mode=None)
        snapshot.Snapshot.simulator = self
        self.storage.simulator = self
github nocproject / noc / main / stomp / daemon.py View on Github external
def __init__(self):
        super(STOMPDaemon, self).__init__()
        logging.info("Running noc-stomp")
        self.factory = SocketFactory(controller=self, write_delay=False)
        self.subscriptions = {}  # socket, id -> Subscription
        self.destinations = {}  # name -> destination
        self.storage = Storage()
github realpython / book2-exercises / py2manager / gluon / fileutils.py View on Github external
def get_session(request, other_application='admin'):
    """Checks that user is authorized to access other_application"""
    if request.application == other_application:
        raise KeyError
    try:
        session_id = request.cookies['session_id_' + other_application].value
        session_filename = os.path.join(
            up(request.folder), other_application, 'sessions', session_id)
        if not os.path.exists(session_filename):
            session_filename = generate(session_filename)
        osession = storage.load_storage(session_filename)
    except Exception, e:
        osession = storage.Storage()
    return osession
github opensvc / opensvc / lib / nodemgr_parser.py View on Github external
"""
nodemgr command line actions and options
"""
import node
from storage import Storage
from rcOptParser import OptParser
from optparse import Option

PROG = "nodemgr"

OPT = Storage({
    "api": Option(
        "--api", default=None, action="store", dest="api",
        help="Specify a collector api url different from the "
             "one set in node.conf."),
    "access": Option(
        "--access", default="rwo", action="store", dest="access",
        help="The access mode of the volume. rwo, roo, rwx, rox."),
    "add": Option(
        "--add", default=None,
        action="store",
        help="A list member to add to the value pointed by :opt:``--param``. "
             "If :opt:``--index`` is set, insert the new element at the "
             "specified position in the list."),
    "app": Option(
        "--app", default=None, action="store", dest="app",
        help="Optional with the register command. Register the "
github realpython / book2-exercises / web2py-rest / gluon / fileutils.py View on Github external
def get_session(request, other_application='admin'):
    """Checks that user is authorized to access other_application"""
    if request.application == other_application:
        raise KeyError
    try:
        session_id = request.cookies['session_id_' + other_application].value
        session_filename = os.path.join(
            up(request.folder), other_application, 'sessions', session_id)
        if not os.path.exists(session_filename):
            session_filename = generate(session_filename)
        osession = storage.load_storage(session_filename)
    except Exception, e:
        osession = storage.Storage()
    return osession
github spiffytech / MobileBlur / gluon / rewrite.py View on Github external
def _router_default():
    "return new copy of default base router"
    router = Storage(
        default_application = 'init',
            applications = 'ALL',
        default_controller = 'default',
            controllers = 'DEFAULT',
        default_function = 'index',
            functions = dict(),
        default_language = None,
            languages = None,
        root_static = ['favicon.ico', 'robots.txt'],
        domains = None,
        exclusive_domain = False,
        map_hyphen = False,
        acfe_match = r'\w+$',              # legal app/ctlr/fcn/ext
        file_match = r'(\w+[-=./]?)+$',    # legal file (path) name
        args_match = r'([\w@ -]+[=.]?)*$', # legal arg in args
    )