• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.Image类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中models.Image的典型用法代码示例。如果您正苦于以下问题:Python Image类的具体用法?Python Image怎么用?Python Image使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Image类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: user_add

def user_add():
	import bcrypt
	PostForm = model_form(User)
	form = PostForm(request.form)
	if request.method == 'POST': #and form.validate():
		#the following is described in flask-uploads documentation
		filename = "" #store blank photo filename
		#initialize default user photo
		i = Image(image_path = 'default_image', is_profile=True) 
		if 'photo' in request.files:
			filename = photos.save(request.files['photo'])
			i = Image(image_path = filename, is_profile=True)
			flash("Photo saved.")
		i.save()
		#hash password stored in database so that it is not viewable by people in Romania
		hashed = bcrypt.hashpw(request.form["password"], bcrypt.gensalt())
		u = User(	email = request.form["email"], 
					first_name = request.form["first_name"], 
					last_name =request.form["last_name"], 
					password = hashed, 
					authenticated = False,
					philosophy = request.form['philosophy'],
					tags = request.form['tags'].split(','),
				)
		u.profile_picture= i
		u.save()
		return "done:" + request.form["email"] + " " + request.form["first_name"]+ " " + request.form["last_name"] + " " + '/_uploads/photos/'+i.image_path
	else:
		return render_template('add.html', form=form, cities = OccupyCity.objects.all())
开发者ID:csik,项目名称:OccuDopt,代码行数:29,代码来源:views.py


示例2: transfer_s3_structure_to_db

def transfer_s3_structure_to_db(name, path, parent_directory, is_dir=False):
    if parent_directory is not None:
        par_dir = Directory.get(Directory.key == parent_directory)
    else:
        par_dir = FakeDirectory()
        par_dir.id = None
    if is_dir:
        try:
            Directory.get(Directory.key == path)
            return False
        except DoesNotExist:
            Directory.create(
                name = name,
                key = path,
                parent_directory = par_dir.id
            )
            return True
    else:
        try:
            Image.get(Image.key == path)
            return False
        except DoesNotExist:
            Image.create(
                name = name,
                key = path,
                directory = par_dir.id
            )
            return True
开发者ID:BlaiseGratton,项目名称:DataAnalysisNgin,代码行数:28,代码来源:boto.py


示例3: receive

def receive():
    data = request.data
    data = xmltodict.parse(data)['xml']
    if data['MsgType'] == 'text':
        return send_text(data['FromUserName'], 'hi')
    if data['MsgType'] == 'image':
        token = current_access_token()
        file_url = 'https://api.weixin.qq.com/cgi-bin/media/get?access_token=%s&media_id=%s' % (token, data['MediaId'])
        file = requests.get(file_url, stream=True).raw
        i = Image()
        i.image = file
        uuid = shortuuid.ShortUUID().random(length=6)
        while Image.objects(iid=uuid):
            uuid = shortuuid.ShortUUID().random(length=6)
        i.iid = uuid
        i.title = data['MediaId']
        i.user = system_user
        i.description = ''
        i.tags = []
        i.save()
        return send_text(
            data['FromUserName'], '업로드 성공, 사진주소:%s%s' % (
                request.url_root[:-1], url_for('light-cms.image', iid=i.iid)
            )
        )
开发者ID:initNirvana,项目名称:Easyphotos,代码行数:25,代码来源:wc.py


示例4: test_create_image

 def test_create_image(self):
     i = Image(slug="broom", icon_set="fugue", path="icons/fugue/broom.png")
     i.put()
     self.assertEquals(i.slug, "broom")
     self.assertEquals(i.icon_set, "fugue")
     self.assertEquals(i.path, "icons/fugue/broom.png")
     self.assertEquals(i.absolute_url(), "/images/icons/fugue/broom.png")
开发者ID:JohnMurray,项目名称:stashboard,代码行数:7,代码来源:test_images.py


示例5: get_contents

 def get_contents(self):
     db_id = Directory.get(Directory.key == self.key).id
     directories = Directory.select().where(Directory.parent_directory == db_id)
     has_probes = False
     try:
         has_probes = Directory.get(Directory.key == directories
                             .first().key).images.first()
     except:
         pass
     if has_probes:
         directories = [DirectoryTree(d.name, d.key).get_contents() for d in directories]
         self.directories = [d.serialized for d in directories]
     else:
         self.directories = [DirectoryTree(d.name, d.key).serialized for d in directories]
     self.images = [image.serialized for image in Image.select().where(Image.directory == db_id)]
     if self.images:
         stack_title = self.key[:-1]
         try:
             stack_id = Stack.get(Stack.title == stack_title).id
         except models.DoesNotExist:
             images = Image.select().where(Image.directory == db_id)
             stack = models.Stack.create(title=stack_title)
             for image in images:
                 try:
                     models.StackImage.create(stack=stack, image = image.id)
                 except Exception as ex:
                     print ex
             stack_id = stack.id
         self.stack_id = stack_id
     return self
开发者ID:BlaiseGratton,项目名称:DataAnalysisNgin,代码行数:30,代码来源:directory.py


示例6: upload

def upload():
    with open('data.csv') as f:
        reader = csv.DictReader(f)
        for row in reader:
            try:
                s = Store()
                
                print row['name'], row['images'], row['types']
                if re.search("\[.*\]", row['reference']):
                    row['place_id'] = row['scope']
                    row['scope'] = row['latlng']
                    row['latlng'] = row['address']
                    row['address'] = row['photos']
                    row['photos'] = row['reference']

            

                print row['name'], row['images'], row['types']
                s.tags = json.loads(row['types'])
                s.point = db.GeoPt(*eval(row['latlng']))
                s.reference = row['reference'] and row['reference'][0] or ""
                s.address = row['address']
                s.name = row['name']

                
                for img in eval(row['images']):
                    image = Image()
                    image.image = img
                    image.put()
                    s.imgs.append(image)
            except Exception as e:
                pass
            finally:
                s.put()
开发者ID:georgefs,项目名称:ezselector,代码行数:34,代码来源:scripts.py


示例7: upload

def upload():
    form = UploadForm()
    if form.validate_on_submit():
        try:
            name = form.name.data
            filename = images.save(form.image.data, folder=unicode(g.user.id))

            #Checks if Image is new or exists before commit changes
            image = Image.query.filter_by(name = form.name.data).first()
	    if image is None:
                image = Image(name = name, filename = filename, uid=g.user.id)
                message = "%r image uploaded." % name
            else:
                old_file = image.filename
                image.filename = filename
                message = "%r image changed." % name

            db.session.add(image)
            db.session.commit()

            flash(message)
            return redirect(url_for('index'))
        except UploadNotAllowed:
            flash("Not allowed to upload image")
    else:
        filename = None

    return render_template('upload.html',
        form = form,
        filename = filename)
开发者ID:antoniofcano,项目名称:gi_test,代码行数:30,代码来源:index.py


示例8: create_tables

def create_tables():
    from models import Image, Imageuri, ImageFragment, Metadata, Annotation
    Image.create_table()
    Imageuri.create_table()
    ImageFragment.create_table()
    Metadata.create_table()
    Annotation.create_table()
开发者ID:annebaui,项目名称:srimato,代码行数:7,代码来源:app.py


示例9: upload_image_for_match

def upload_image_for_match(request):
    if request.method == 'POST':
        form = UploadFileForm(request.POST, request.FILES)
        if form.is_valid():
            #title
            tit = request.REQUEST.get("title", None)
            
            #Sensor
            lon = request.REQUEST.get('longitude', None)
            lat = request.REQUEST.get('latitude', None)
            azi = request.REQUEST.get("azimuth", None)
            pit = request.REQUEST.get("pitch", None)
            rol = request.REQUEST.get("roll", None)
            
            #Image
            image = Image(image_path = request.FILES['file'],
                          azimuth = azi,
                          pitch = pit,
                          roll = rol,
                          longitude = lon,
                          latitude = lat,
                          title = tit)
            image.save()
            
            '''match the image against the database'''
            name = image.match()
            obj = Object.objects.get(object_name = name)
            
            #wrap object_url and object_name as json and return
            return responseJson({'object_url':obj.img_path.name, 'object':obj.object_name})
            
        else:
            return fail()
    else:
        return fail()
开发者ID:Amos-zq,项目名称:PhoneARtServer,代码行数:35,代码来源:views.py


示例10: get

    def get(self, hash, extension=None):
        q = Album.all().filter('hash =', hash)
        album = q.get()
        if album:
            if extension:
                return self.error(404)
            
            q = Image.all().filter('album =', album)
            return self.response.out.write(render_template('album.html', {
                'name': album.name,
                'images': q,
            }))

        q = Image.all().filter('hash =', hash)
        image = q.get()
        if image:
            if not extension:
                return self.response.out.write(render_template('image.html',
                    { 'image': image }))
            elif image.extension == extension:
                return write_image(self, image.image_data, extension)
            else:
                return self.error(404)
        
        return self.error(404)
开发者ID:chosak,项目名称:restful-gallery,代码行数:25,代码来源:app.py


示例11: post

 def post(self):
     if not setup_occurred():
         Status.load_defaults()
         Image.load_defaults()
         api.invalidate_cache()
         finish_setup()
     self.redirect("/admin")
开发者ID:Homefinder,项目名称:stashboard,代码行数:7,代码来源:admin.py


示例12: post

    def post(self, user, account, group_id):
        group = get_image_group_or_404(self, group_id)

        # FIXME: admins!
        if group.owner.key() != account.key():
            return render_json_response(self, {"error": "access-denied"})

        file_name = self.request.headers["X-File-Name"]
        data = self.request.body

        mime_type = mimetypes.guess_type(file_name)[0]
        if not mime_type.startswith("image/"):
            return render_json_response(self, {"error": "wrong-file-type"})

        img = images.Image(data)

        imgdata = ImageData(data=data)
        imgdata.put()

        image = Image(
            file_name=file_name,
            width=img.width,
            height=img.height,
            mime_type=mime_type,
            group=group,
            data=imgdata,
            digest=hashlib.sha1(data).hexdigest(),
        )
        image.put()

        memcache.delete(group.memcache_key())

        return render_json_response(self, {"name": image.file_name})
开发者ID:andreyvit,项目名称:mockko,代码行数:33,代码来源:handlers.py


示例13: setUp

 def setUp(self):
     super(StatusInstanceTest, self).setUp()
     image = Image(icon_set="fugue", slug="cross-circle",
                   path="fugue/cross-circle.png")
     image.put()
     self.status = Status(name="Foo", slug="foo", description="bar", 
         image="cross-circle")
     self.status.put()
开发者ID:2do,项目名称:stashboard,代码行数:8,代码来源:test_rest_status.py


示例14: test_add

    def test_add(self):
        from models import Image
        Image.add(name="Hallo.img")

        img = Image.by_id(1)
        self.assertEqual(1, img.id)
        self.assertEqual("Hallo.img", img.name)
        self.assertEqual("hallo.img", img.route)
开发者ID:daymien,项目名称:pymyblog,代码行数:8,代码来源:test_models.py


示例15: gallery

def gallery(id=None):
    # Get gallery images associated with feed #id
    if id is None:
        images = Image.select()
    else:
        images = Image.select().where(Feed.id == id).paginate(1, 50)

    return render_template("gallery.html",
                           images=images)
开发者ID:KyubiSystems,项目名称:Wisewolf,代码行数:9,代码来源:views.py


示例16: execute

    def execute(self):
        image = Image()
        image.image_key = self.image_key
        image.put()

        invite = Invite.get_by_unique_id(self.unique_id)
        invite.poster_picture = image.key
        invite.put()
        return invite.poster_picture.urlsafe()
开发者ID:xplot,项目名称:imeet,代码行数:9,代码来源:UpdateInviteCoverImageCommand.py


示例17: post

    def post(self):
        album_key = ndb.Key(urlsafe=self.request.get('key'))
        upload_files = self.get_uploads()  # 'file' is file upload field in the form
        blob_info = upload_files[0]
        photo = Image(parent=album_key, image_blob=blob_info.key(), index=1)
        photo.populate(serving_url=images.get_serving_url(blob_info.key()))
        photo.put()

        self.redirect('/add-album?key=%s' % album_key.urlsafe())
开发者ID:IanChilds,项目名称:ButtonsAndLace,代码行数:9,代码来源:add_photo.py


示例18: create_image

 def create_image(self,request):
     u = self.current_user(request)
     if 'description' in request.POST:
         image = list(Image.objects.filter(user=u))[-1:][0]
         descr = request.POST['description']
         image.description = descr
         image.save()
         return response('Description added to image successfully')
     i = Image(link=self.upload_image(request),user=u)
     i.save()
     return response('Image created successfully')
开发者ID:fabricadeideias,项目名称:lab,代码行数:11,代码来源:app.py


示例19: post

    def post(self):
        " Post to blobstore, create Image object and redirect to info URL. "
        upload_files = self.get_uploads("file")
        blob_info = upload_files[0]

        img = Image(title=self.request.POST.get("title", ""), image=blob_info)
        img.put()

        upload_url = urllib.quote(blobstore.create_upload_url("/%s/upload" % IMAGE_APP_PATH))
        self.response.set_status(303)
        self.redirect("/%s/upload?key=%s&newurl=%s" % (IMAGE_APP_PATH, urllib.quote(str(img.key())), upload_url))
开发者ID:mentat,项目名称:imageapp,代码行数:11,代码来源:views.py


示例20: put_image

 def put_image(self, submitter, url, tags):
     DEBUG('put_image: %s (%s)' % (url, tags))
     exists = self.get_image_by_url(url)
     ltags = [tag.lower() for tag in tags]
     if exists:
         DEBUG('found existing %s' % img)
         for image in exists:
             image.tags.extend([tag for tag in ltags if tag not in image.tags])
             image.put()
     else:
         image = Image(url=url, tags=ltags, submitter=submitter)
         image.put()
开发者ID:dforsyth,项目名称:gif-wrappy,代码行数:12,代码来源:wrappy.py



注:本文中的models.Image类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.Images类代码示例发布时间:2022-05-27
下一篇:
Python models.History类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap