Beispiel #1
0
 def get(self):
     collector = CloudFetch.CloudFetch()     
     urllist = collector.getUrlList()
     #url = 'http://www.technobuffalo.com/wp-content/uploads/2012/12/Google-Apps.jpeg'
     #urllist = urllist.append(url)
     images = Images.all()
     for url in urllist:
         bf = urllib.urlopen(url).read()
         #bf=self.request.get("file")
         if not bf:
             return self.redirect('/')
         #name=self.request.body_file.vars['file'].filename
         #mime = self.request.body_file.vars['file'].headers['content-type']
         #if mime.find('image')==-1:
         #     return self.redirect('/admin/upload/')
         #description=self.request.get("description")
         mime = 'image'
         description = 'Fetched From Cloud'
         name = url.split('/')[len(url.split('/'))-1]
         #DETECT DUPLICATE
         flag = False;
         for i in images:
             if(i.name == name):
                 flag = True
                 break
         if(flag == True):
             continue
         image=methods.addImage( mime, description, bf, name)
     self.redirect('/')
Beispiel #2
0
    def post(self):
        bf=self.request.get("file")
        if not bf:
            return self.redirect('/admin/upload/')
#        name=self.request.body_file.vars['file'].filename
        mime = self.request.body_file.vars['file'].headers['content-type']
        if mime.find('image')==-1:
             return self.redirect('/admin/upload/')
        description=self.request.get("description")
        image=methods.addImage( mime, description, bf)
        
        self.redirect('/show/%s/' %image.id)
Beispiel #3
0
    def post(self):
        bf = self.request.get("file")
        if not bf:
            return self.redirect('/admin/upload/')
        name = self.request.body_file.vars['file'].filename
        mime = self.request.body_file.vars['file'].headers['content-type']
        if mime.find('image') == -1:
            return self.redirect('/admin/upload/')
        description = self.request.get("description")
        image = methods.addImage(mime, description, bf, name)

        self.redirect('/show/%s/' % image.id)
Beispiel #4
0
 def post(self):
     PixelCompare(im1, im2, mode = "pct", alpha = .01):
     bf=self.request.get("file")
     if not bf:
         return self.redirect('/admin/find/')
     name=self.request.body_file.vars['file'].filename
     mime = self.request.body_file.vars['file'].headers['content-type']
     if mime.find('image')==-1:
          return self.redirect('/admin/find/')
     description=self.request.get("description")
     image=methods.addImage( mime, description, bf, name)
     
     self.redirect('/gshow/%s/' %image.id)
Beispiel #5
0
    def post(self):
        bf = self.request.get("image")
        if not bf:
            return self.redirect('/admin/upload/')
        o = urllib2.build_opener()
        f = o.open(bf).read()

        title = self.request.get("title")
        referer = self.request.get("referer")
        xhrLocation = self.request.get("xhrLocation")
        image = methods.addImage(title, f, referer)

        self.render('views/posted.html', {
            "msg": "success",
            "xhrLocation": xhrLocation
        })
Beispiel #6
0
    def get(self):

        f = urllib2.urlopen(
            'http://img1.cache.netease.com/cnews/2011/5/6/20110506083751ebe4c.jpg'
        )
        image = methods.addImage("11111", f.read(), "http://1111")

        config = auth.Authenticator.load_config("config/dropbox.ini")
        dba = auth.Authenticator(config)
        #access_token = dba.obtain_trusted_access_token(config['testing_user'], config['testing_password'])
        access_token = oauth.OAuthToken.from_string(
            "oauth_token_secret=f16we6l2pn4mkx5&oauth_token=299vslb2j8xg8ns")
        db_client = client.DropboxClient(config['server'],
                                         config['content_server'],
                                         config['port'], dba, access_token)
        root = config['root']

        image.name = "20110506083751ebe4c.jpg"

        resp = db_client.put_file(root, "/", image)
        print resp
Beispiel #7
0
    def post(self):
        bf = self.request.get("file")
        if not bf:
            return self.redirect('/admin/find/')
        name = self.request.body_file.vars['file'].filename
        mime = self.request.body_file.vars['file'].headers['content-type']
        if mime.find('image') == -1:
            return self.redirect('/admin/find/')

        description = descriptor.dhash(bf)

        images = Images.all().order('-created_at').fetch(30, 0)
        max = -1
        git = None
        for image in images:
            if descriptor.compare_hash(image.description, description) > max:
                max = descriptor.compare_hash(image.description, description)
                gid = image

        image = methods.addImage(mime, description, bf, name)
        template_value = {"git": gid, "simil": max, "image": image}
        self.render('views/gausshow.html', template_value)