Пример #1
0
def upload2_receive():
    file_obj = flask.request.files['file']

    data = file_obj.read(int(1e9))
    image.add_image(data, "image_name", "image description")

    return flask.render_template('upload2_received.html')
Пример #2
0
def upload_receive():
    the_file = request.files["file"]
    print dir(the_file)
    print 'received file with name:', the_file.filename
    data = the_file.read(int(1e9))
    add_image(data)

    return redirect("/")
Пример #3
0
def upload_receive():

    file_obj = flask.request.files['file']
    name = flask.request.form['image_name']
    description = flask.request.form["image_description"]
    mimetype =  file_obj.mimetype

    data = file_obj.read(int(1e9))
    image.add_image(data, name, description, mimetype)

    return flask.redirect(flask.url_for('index'))
Пример #4
0
	def setUnits(self, coord, turn):
		units = {}
		if not coord:
			return
		
		self.tree.DeleteAllItems()
		image_list = wx.ImageList(40, 40)
		self.tree.AssignImageList(image_list)
		img_list_data = {}
		root = self.tree.AddRoot('Fleets')
		for user in db.users():
			user_id = user['id']
			tree_user = None
			for fleet in db.fleets(turn, util.filter_coord(coord) + ['owner_id=%s'%(user_id,)]):
				if not tree_user:
					tree_user = self.tree.AppendItem(root, user['name'])
				tree_fleet = self.tree.AppendItem(tree_user, fleet['name'])
				for unit in db.units(turn, ['fleet_id=%s'%(fleet['id'],)]):					
					proto = db.get_prototype(unit['class'], ('carapace', 'color', 'name'))
					obj_carp = int(unit['class']), int(proto['carapace']), int(proto['color'])
					img_item = None
					if obj_carp in img_list_data:
						img_item = img_list_data[obj_carp]
					else:
						img_item = image.add_image(image_list, obj_carp)
						img_list_data[obj_carp] = img_item
					name = proto['name']
					if not name:
						name = get_unit_name(int(proto['carapace']))
					self.tree.AppendItem(tree_fleet, name, image=img_item)
					
		for user in db.alien_players(turn):
			user_id = int(user['player_id'])
			tree_user = None
			for fleet in db.fleets(turn, util.filter_coord(coord) + ['owner_id=%s'%(user_id,)]):
				if not tree_user:
					tree_user = self.tree.AppendItem(root, user['name'])
				tree_fleet = self.tree.AppendItem(tree_user, fleet['name'])

				for unit in db.alienUnits(turn, ['fleet_id=%s'%(fleet['id'],)]):
					print 'get alient unit %s'%(unit,)
					obj_carp = unit['class'], int(unit['carapace']), int(unit['color'])
					img_item = None
					if obj_carp in img_list_data:
						img_item = img_list_data[obj_carp]
					else:
						img_item = image.add_image(image_list, obj_carp)
						img_list_data[obj_carp] = img_item

					self.tree.AppendItem(tree_fleet, get_unit_name(int(unit['carapace'])), image=img_item)
				
					
		self.tree.ExpandAll()
Пример #5
0
 def PUT(self):
     auth_token = web.ctx.get('environ').get('HTTP_X_AUTH_TOKEN', None)
     auth_tenant_id = web.ctx.get('environ').get('HTTP_X_AUTH_TENANT_ID', None)
     
     image_data = web.data()
     image_meta={}
     """
     Image parameters
     """
     image_meta['id'] = web.ctx.env.get('HTTP_X_IMAGE_META_ID', None)
     image_meta['name'] = web.ctx.env.get('HTTP_X_IMAGE_META_NAME', None)
     image_meta['status'] = web.ctx.env.get('HTTP_X_IMAGE_META_STATUS', None)
     image_meta['checksum'] = web.ctx.env.get('HTTP_X_IMAGE_META_CHECKSUM', None)
     image_meta['created_at'] = web.ctx.env.get('HTTP_X_IMAGE_META_CREATED_AT', None)
     image_meta['disk_format'] = web.ctx.env.get('HTTP_X_IMAGE_META_DISK_FORMAT', None)
     image_meta['updated_at'] = web.ctx.env.get('HTTP_X_IMAGE_META_UPDATED_AT', None)
     image_meta['owner'] = web.ctx.env.get('HTTP_X_IMAGE_META_OWNER', None)
     image_meta['min_ram'] = web.ctx.env.get('HTTP_X_IMAGE_META_MIN_RAM', None)
     image_meta['container_format'] = web.ctx.env.get('HTTP_X_IMAGE_META_CONTAINER_FORMAT', None)
     image_meta['min_disk'] = web.ctx.env.get('HTTP_X_IMAGE_META_MIN_DISK', None)
     image_meta['size'] = web.ctx.env.get('HTTP_X_IMAGE_META_SIZE', None)
     image_meta['properties'] = web.ctx.env.get('HTTP_X_IMAGE_META_PROPERTIES', None)
     """
     Boolean image parameters
     """
     image_meta['deleted'] = web.ctx.env.get('HTTP_X_IMAGE_META_DELETED', 'false')
     image_meta['protected'] = web.ctx.env.get('HTTP_X_IMAGE_META_PROTECTED', 'false')
     image_meta['is_public'] = web.ctx.env.get('HTTP_X_IMAGE_META_IS_PUBLIC', 'false')
         
     new_image_id = image.add_image(auth_token, image_meta, image_data, features=None)
     
     return json.dumps(new_image_id, indent=4)
Пример #6
0
def setup():                            # stuff that should be run once.
    html.init_templates()

    if (not os.path.isfile('images.sqlite')):
        db = sqlite3.connect('images.sqlite')
        db.execute('CREATE TABLE image_store (i INTEGER PRIMARY KEY, \
                                              image BLOB,            \
                                              title TEXT,            \
                                              description TEXT)')    
        db.commit()
        db.text_factory = bytes
        some_data = open('imageapp/dice.png', 'rb').read()
        image.add_image(some_data, 'Dice', 'Four six sided dice')
        print 'here'
        db.commit()
        db.close()
Пример #7
0
@app.route("/upload")
def upload():
    return render_template("upload.html")

@app.route("/upload_receive", methods=['GET', 'POST'])
def upload_receive():
    the_file = request.files["file"]
    print dir(the_file)
    print 'received file with name:', the_file.filename
    data = the_file.read(int(1e9))
    add_image(data)

    return redirect("/")

@app.route("/image")
def image():
    return render_template("image.html")

@app.route("/image_raw")
def image_raw():
    img = get_latest_image()
    return img

if __name__ == "__main__":
    app.debug = True
    # Initiate with tux.png
    tux = open("tux.png")
    add_image(tux.read())
    tux.close()
    app.run()
Пример #8
0
 def test_1add_image(self):
     data = image.add_image(token, image_meta={'id': random_image_id, 'name': 'test1', 'image_format': 'qcow2', 'container_format': 'ovf'})
     print "\nImage ID:", data
     self.assertIsNotNone(data, 'No data')