Beispiel #1
0
 def save_container(self, uid, name, content):
     path = '%s/%s/' % ( self.poiDataPath, uid )
     if os.path.exists(path):
         meta = None
         ts = int(time())
         with open('%s/meta.json' % path) as metafile:
             meta = json.loads(metafile.read())
         if meta:
             with io.open('%s/meta.json' % path, 'w') as metafile:
                 metafile.write(unicode(json.dumps({ 
                     'name': name,
                     'created_at': meta['created_at'],
                     'updated_at': ts,
                     'deleted': meta['deleted']
                     })))
             with io.open('%s/poi.ov2' % path, 'wb') as stream:
                 ov2.save_pois_to_stream(stream, content)
             return
         raise Exception('Malformed meta.json file at [%s]' % uid)
     raise Exception('Unknown UID')
Beispiel #2
0
 def save_container(self, uid, name, content):
     path = '%s/%s/' % ( self.poiDataPath, uid )
     if os.path.exists(path):
         meta = None
         ts = int(time())
         with open('%s/meta.json' % path) as metafile:
             meta = json.loads(metafile.read())
         if meta:
             with io.open('%s/meta.json' % path, 'w') as metafile:
                 metafile.write(unicode(json.dumps({ 
                     'name': name,
                     'created_at': meta['created_at'],
                     'updated_at': ts,
                     'deleted': meta['deleted']
                     })))
             with io.open('%s/poi.ov2' % path, 'wb') as stream:
                 ov2.save_pois_to_stream(stream, content)
             return
         raise Exception('Malformed meta.json file at [%s]' % uid)
     raise Exception('Unknown UID')
Beispiel #3
0
 def create_container(self, name = "Nuevo mapa", pois = [], poi_bin_string = None):
     uid = uuid4().hex
     container = POIContainer(name)
     container.id = uid
     path = '%s/%s/' % ( self.poiDataPath, uid )
     os.mkdir(path)
     ts = int(time())
     with io.open('%s/meta.json' % path, 'w') as metafile:
         metafile.write(unicode(json.dumps({
             'name': name,
             'created_at': ts,
             'updated_at': ts,
             'deleted': False
             })))
     if len(pois) > 0:
         with io.open('%s/poi.ov2' % path, 'wb') as stream:
             ov2.save_pois_to_stream(stream, pois)
     if poi_bin_string:
         with io.open('%s/poi.ov2' % path, 'wb') as stream:
             stream.write(poi_bin_string)
         with io.open('%s/poi.ov2' % path, 'rb') as stream:
             container.content = ov2.get_pois_from_stream(stream)
     return container
Beispiel #4
0
 def create_container(self, name = "Nuevo mapa", pois = [], poi_bin_string = None):
     uid = uuid4().hex
     container = POIContainer(name)
     container.id = uid
     path = '%s/%s/' % ( self.poiDataPath, uid )
     os.mkdir(path)
     ts = int(time())
     with io.open('%s/meta.json' % path, 'w') as metafile:
         metafile.write(unicode(json.dumps({
             'name': name,
             'created_at': ts,
             'updated_at': ts,
             'deleted': False
             })))
     if len(pois) > 0:
         with io.open('%s/poi.ov2' % path, 'wb') as stream:
             ov2.save_pois_to_stream(stream, pois)
     if poi_bin_string:
         with io.open('%s/poi.ov2' % path, 'wb') as stream:
             stream.write(poi_bin_string)
         with io.open('%s/poi.ov2' % path, 'rb') as stream:
             container.content = ov2.get_pois_from_stream(stream)
     return container