Esempio n. 1
0
    def GET(self, *args, **kwargs):
        cherrypy.response.headers["Content-Type"] = "application/json"

        path = '/'.join(args)
        try:
            obj = Album(os.path.join(self.rootpath, path))
        except OSError:
            raise cherrypy.HTTPError(404)
        return obj.serialize(recursive=False)
Esempio n. 2
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from ap3.core import AP3obj
from ap3.album import Album
from ap3.photo import Photo
from ap3.serializer import PrettyJsonSerializer

if __name__ == "__main__":
    import sys
    if len(sys.argv) >= 2:
        directory = sys.argv[1]
    else:
        directory = "."

    AP3obj.setRoot(directory)
    AP3obj.setSerializer(PrettyJsonSerializer)

    a = Album(directory)
    print a.serialize(extended=True)

    for p in a.listMe():
        if isinstance(p, Photo):
            pData = p.getDataMedium()
            if pData:
                print "Got p: %s dataMedium: %d" % (p, len(pData))
            pData = p.getDataSmall()
            if pData:
                print "Got p: %s dataSmall: %d" % (p, len(pData))