Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/turtleart.py
diff options
context:
space:
mode:
authorJames Boisture <jboisture@jboisture-laptop.(none)>2010-08-03 19:55:24 (GMT)
committer James Boisture <jboisture@jboisture-laptop.(none)>2010-08-03 19:55:24 (GMT)
commit9bee2c4a9d6f761faaa9f6a2af6dbaf9b7c6e0e1 (patch)
tree2b881cf75e29f51c663cff532a024ec10e3628d1 /turtleart.py
parent6f6694a42b104241c93c5aefb6e152f0e0701261 (diff)
added to the upload code so that it now checks if the file is to big to be uploaded. if it is it resizes the image until it is not too big.
Diffstat (limited to 'turtleart.py')
-rwxr-xr-xturtleart.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/turtleart.py b/turtleart.py
index 57c34df..ee17366 100755
--- a/turtleart.py
+++ b/turtleart.py
@@ -477,7 +477,7 @@ class TurtleMain():
self.pop_up = gtk.Window()
self.pop_up.set_default_size(600, 400)
self.pop_up.connect('delete_event', self._stop_uploading)
- table = gtk.Table(False, 1, 8)
+ table = gtk.Table( 1, 8,False)
self.pop_up.add(table)
login_label = gtk.Label(_('You must have an account at \
http://turtleartsite.sugarlabs.org to upload your project.'))
@@ -553,7 +553,12 @@ http://turtleartsite.sugarlabs.org to upload your project.'))
description = self.description_entry.get_buffer().get_text(
*self.description_entry.get_buffer().get_bounds())
tafile, imagefile = self.tw.save_for_upload(title)
-
+ if int(os.path.getsize(imagefile))> 950000:
+ import Image
+ while int(os.path.getsize(imagefile))>950000:
+ im = Image.open(imagefile)
+ out = im.resize((int(.9*im.size[0]),int(.9*im.size[1])),Image.ANTIALIAS)
+ out.save(imagefile,quatlity = 100)
c = pycurl.Curl()
c.setopt(c.POST, 1)
c.setopt(c.FOLLOWLOCATION, 1)
@@ -565,18 +570,18 @@ http://turtleartsite.sugarlabs.org to upload your project.'))
('title', title),
('description', description),
('upload_key',key), ('_formname',
- 'image_create')])
+ 'image_create')])
c.perform()
error_code = c.getinfo(c.HTTP_CODE)
c.close
os.remove(imagefile)
os.remove(tafile)
if error_code == 400:
- self.login_message.set_text(_('Failed to upload!'))
+ self.login_message.set_text(_('Failed to upload!'))
else:
- self.pop_up.hide()
- self.uploading = False
-
+ self.pop_up.hide()
+ self.uploading = False
+
if __name__ == "__main__":
TurtleMain()