예제 #1
0
파일: storeget.py 프로젝트: atl/thrifty-p2p
"""

import sys
sys.path.append('gen-py')

from locator.ttypes import Location
from storeserver import remote_call, parser, DEFAULTPORT, SERVICENAME
from location import find_matching_service, str2loc

usage = '''
  python %prog [options] <key>

Looks for a storage node at PEER, either as specified, or 
auto-discovered on the localhost starting from the default 
port. Sends the remote command there, which gets forwarded 
to the actual node that has it.'''

parser.set_usage(usage)
parser.remove_option('--port')

if __name__ == '__main__':
    (options, args) = parser.parse_args()
    if len(args) != 1:
        parser.error("incorrect number of arguments")
    (key,) = args
    if options.peer:
        loc = str2loc(options.peer)
    else:
        loc = find_matching_service(Location('localhost', DEFAULTPORT), SERVICENAME) or sys.exit()
    print remote_call('get', loc, key)
예제 #2
0
파일: storeput.py 프로젝트: atl/thrifty-p2p
"""

import sys
sys.path.append('gen-py')

from locator.ttypes import Location
from storeserver import remote_call, parser, DEFAULTPORT, SERVICENAME
from location import find_matching_service, str2loc

usage = '''
  python %prog [options] <key> <value>

Looks for a storage node at PEER, either as specified, or 
auto-discovered on the localhost starting from the default 
port. Sends the remote command there, which gets forwarded 
to the actual node that has it.'''

parser.set_usage(usage)
parser.remove_option('--port')

if __name__ == '__main__':
    (options, args) = parser.parse_args()
    if len(args) != 2:
        parser.error("incorrect number of arguments")
    (key, value) = args
    if options.peer:
        loc = str2loc(options.peer)
    else:
        loc = find_matching_service(Location('localhost', DEFAULTPORT), SERVICENAME) or sys.exit()
    remote_call('put', loc, key, value)
예제 #3
0
sys.path.append('gen-py')

from locator.ttypes import Location
from storeserver import remote_call, parser, DEFAULTPORT, SERVICENAME
from location import find_matching_service, str2loc

usage = '''
  python %prog

Looks for a storage node at PEER, either as specified, or 
auto-discovered on the localhost starting from the default 
port. Sends a bunch of keys for resolution.'''

parser.set_usage(usage)
parser.remove_option('--port')

KEYS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

if __name__ == '__main__':
    (options, args) = parser.parse_args()
    if options.peer:
        loc = str2loc(options.peer)
    else:
        loc = find_matching_service(Location('localhost', DEFAULTPORT), SERVICENAME) or sys.exit()
    for key in KEYS:
        value = remote_call('get', loc, key)
        if value:
            print value
        else:
            print "None received from expected %s" % remote_call('get_node', loc, key)