Revision f75f40cb snf-pithos-backend/pithos/backends/lib/hashfiler/archipelagomapper.py

b/snf-pithos-backend/pithos/backends/lib/hashfiler/archipelagomapper.py
32 32
# or implied, of GRNET S.A.
33 33

  
34 34
from binascii import hexlify
35
import os, re
35
import os
36
import re
36 37
import ctypes
37 38

  
38 39
from context_archipelago import ArchipelagoObject
......
68 69
        cfg = {}
69 70
        bcfg = open(BACKEND_ARCHIPELAGO_CONF).read()
70 71
        cfg['blockerm'] = re.search('\'blockerm_port\'\s*:\s*\d+',
71
                                        bcfg).group(0).split(':')[1]
72
                                    bcfg).group(0).split(':')[1]
72 73
        cfg['mapperd'] = re.search('\'mapper_port\'\s*:\s*\d+',
73
                                        bcfg).group(0).split(':')[1]
74
                                   bcfg).group(0).split(':')[1]
74 75
        self.ioctx_pool = ioctx_pool
75 76
        self.dst_port = int(cfg['blockerm'])
76 77
        self.mapperd_port = int(cfg['mapperd'])
......
113 114
        else:
114 115
            req.put()
115 116
            self.ioctx_pool.pool_put(ioctx)
116
            raise RuntimeError("Hashmap '%s' doesn't exists" % hexlify(maphash))
117
            raise RuntimeError("Hashmap '%s' doesn't exists" %
118
                               hexlify(maphash))
117 119
        req = Request.get_read_request(ioctx, self.dst_port,
118
                                       hexlify(maphash), size = size)
120
                                       hexlify(maphash), size=size)
119 121
        req.submit()
120 122
        req.wait()
121 123
        ret = req.success()
122 124
        if ret:
123
            data = string_at(req.get_data(),size)
125
            data = string_at(req.get_data(), size)
124 126
            req.put()
125 127
            self.ioctx_pool.pool_put(ioctx)
126
            for idx in xrange(0,len(data),namelen):
128
            for idx in xrange(0, len(data), namelen):
127 129
                hashes = hashes + (data[idx:idx+namelen],)
128 130
            hashes = list(hashes)
129 131
        else:
130 132
            req.put()
131 133
            self.ioctx_pool.pool_put(ioctx)
132
            raise RuntimeError("Hashmap '%s' doesn't exists" % hexlify(maphash))
134
            raise RuntimeError("Hashmap '%s' doesn't exists" %
135
                               hexlify(maphash))
133 136
        return hashes
134 137

  
135 138
    def map_retr_archipelago(self, maphash, size):
......
151 154
            self.ioctx_pool.pool_put(ioctx)
152 155
            raise Exception("Could not retrieve Archipelago mapfile.")
153 156
        self.ioctx_pool.pool_put(ioctx)
154
        return [string_at(segs[idx].target, segs[idx].targetlen) for idx in xrange(len(segs))]
157
        return [string_at(segs[idx].target, segs[idx].targetlen)
158
                for idx in xrange(len(segs))]
155 159

  
156 160
    def map_stor(self, maphash, hashes=(), blkoff=0, create=1):
157 161
        """Store hashes in the given hashes map."""

Also available in: Unified diff