[web2py] Re: Question with saving the thumbnail name on linux disk

2019-08-25 Thread Dave S


On Sunday, August 25, 2019 at 5:27:34 AM UTC-7, Rahul wrote:
>
> Hi All,
> I have an issue with the following code which I ain't able to 
> trace. The code is for uploading images, generating the thumbnails 
> ,watermarking the image and saving the watermarked thumbnail to a path on 
> the system. While this is working fine on windows system, it *fails 
> *miserably 
> on linux system. On debian system it does not save the file name as the 
> record name and it saves it with an incremental valued name.
>
> For example if the thumbnail should be 114.thumbnail.jpg on  the system it 
> saves as 91.thumbnail.jpg or such name. Note that there is a gap in naming 
> for example there are a few files with names 88.thumbnail.jpg then 
> 90.thumbnail.jpg  .. and then 112.thumbnail.jpg. Basically the records ID 
> value appended with .thumbnail.jpg. When a new image is uploaded it should 
> ideally start from 115.thumbnail.jpg as that is the value that is generated 
> and saved in the database. but it takes other value instead when saving the 
> file on the disk may be (if 90.thumnail.. exists already) it will save it 
> as 91.thumbnail.jpg
>
> CODE BELOW - 
>
>
> if form.accepts(request.vars,session): 
> recordsID= form.vars.id  
> import platform
> is_windows=(platform.system().lower().find("win") > -1)
> is_linux=(platform.system().lower().find("lin") > -1)
> is_mac=(platform.system().lower().find("mac") > -1)
>
> if (is_windows == True):
> #print "is windows"
>
> foto_path = (request.folder + "static\\user_uploads\\" + 
> upload_pic)
> infile = foto_path
> thumbnail_filename = ("%s" % recordsID + ".thumbnail.jpg")
> outfile = (request.folder + "static\\thumbs\\" + 
> thumbnail_filename )
> thumbpath = os.path.join(request.folder, 'static', 'thumbs\\') 
> + thumbnail_filename
> 
> elif (is_linux == True):
> #print "is linux"
>
> foto_path = (request.folder + "static/user_uploads/" + 
> upload_pic)
> infile = foto_path   
> thumbnail_filename = ("%s" % recordsID + ".thumbnail.jpg")   
> 
> #outfile = (request.folder + "static/thumbs/" + 
> thumbnail_filename )  
> thumbpath = os.path.join(request.folder, 'static', 'thumbs/') 
> + thumbnail_filename
> outfile = (thumbpath)  ## Changed on AUG 25
>  
> db(db.fotoz.id==recordsID).update(imgthumb=thumbnail_filename, 
> imgthumbpath=thumbpath)  ##outfile
> if infile != outfile:
> try:  
> im = Image.open(infile)
> im.thumbnail(size) 
> #Check for image format
> image_format = (im.format)
> #print ("Image format: ", image_format)
>
> ###  Watermark stuff 
> ==
> 
> width, height = im.size
> draw = ImageDraw.Draw(im)   
> 
> watermark_text = "WATERMARK"
> watermark_font = ImageFont.truetype('arial.ttf', 20)
> textwidth, textheight = draw.textsize(watermark_text, 
> watermark_font)
> # calculate the x,y coordinates of the text
> margin = 5
> x = width - textwidth - margin
> y = height - textheight - margin
>
> # draw watermark in the bottom right corner
> ## Specify this to fill font with red color , 
> fill=(128,0,0,128))  OR  #, fill=shadowcolor) OR  fill="red" or 
> fill="#ff" -- work
> draw.text((x, y), watermark_text, font=watermark_font, 
> opacity=0.25)
> 
> ##  --- Watermark text ends ---   
> 
> #Process various image formats for making thumbnails. 
> Currently supporting JPG/JPEG, GIF and PNG
> if (image_format == "JPEG"):
> im.save(outfile, "JPEG")
> if (image_format == "GIF"):
> im.save(outfile, "GIF")
> if (image_format == "PNG"):
> im.save(outfile, "PNG")
> except IOError:
> print("Cannot create thumbnail (un-recognized format) for 
> ", infile)
> pass
>
> If any one has any idea please suggest - 
>
> Regards,
>
> Rahul
>

At the moment, I think I need to read through it a couple more times, but 
it seems rather perverse to be using os.path.join() and then using 
os-specific filename separators, when the whole point of os.path.join() is 
to not have to do that. (And then you do string cats for foto_path, instead 
of using os.path.join() there.)

Where is upload_pic defined?  Why does o

[web2py] Re: Question with saving the thumbnail name on linux disk

2019-08-27 Thread Rahul
Hey Dave,
  I was facing issues with path storage in a db field so I started 
using this method. I dont need outfiles curly braces will revisit the code 
today if possible and get back with the details. This is my modified code, 
previous one was straight forward and streamlined code and was using simple 
code.Thanks for the questions I’ll try getting in details.

Regards,

Rahul

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/584d42e5-ba11-4d8c-b289-f5cc4ea3d462%40googlegroups.com.


[web2py] Re: Question with saving the thumbnail name on linux disk

2019-08-28 Thread Rahul
Hi Dave,
 
upload_pic is the form variable that user specifies for uploading the file 
from local disk. Basically it is the filename. I removed the braces for
outfile = (thumbpath)
but this is still not working. Any more suggestions ? 


Regards
Rahul

On Tuesday, August 27, 2019 at 2:21:45 PM UTC+5:30, Rahul wrote:
>
> Hey Dave, 
>   I was facing issues with path storage in a db field so I started 
> using this method. I dont need outfiles curly braces will revisit the code 
> today if possible and get back with the details. This is my modified code, 
> previous one was straight forward and streamlined code and was using simple 
> code.Thanks for the questions I’ll try getting in details. 
>
> Regards, 
>
> Rahul

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/1c2717cb-6b94-4025-9b82-844f4938bea1%40googlegroups.com.


[web2py] Re: Question with saving the thumbnail name on linux disk

2019-08-28 Thread Val K
It is no need to use different code for win/linux, since it is Python!
There is os.path.normpath(your_path) that does all stuff with slashes, I 
have app that works on both platforms just fine (without platform checking 
at all)
My way - always use '/'  in path, and at the end of all manipulations 
performs normalisation:  path = os.path.normpath(path) 
And keep in mind that os.path.join() also works with filenames, so you can 
just os.path.join('foo', 'bar', 'baz.thumbnail.jpg')

  

On Wednesday, August 28, 2019 at 9:05:11 PM UTC+3, Rahul wrote:
>
> Hi Dave,
>  
> upload_pic is the form variable that user specifies for uploading the file 
> from local disk. Basically it is the filename. I removed the braces for
> outfile = (thumbpath)
> but this is still not working. Any more suggestions ? 
>
>
> Regards
> Rahul
>
> On Tuesday, August 27, 2019 at 2:21:45 PM UTC+5:30, Rahul wrote:
>>
>> Hey Dave, 
>>   I was facing issues with path storage in a db field so I 
>> started using this method. I dont need outfiles curly braces will revisit 
>> the code today if possible and get back with the details. This is my 
>> modified code, previous one was straight forward and streamlined code and 
>> was using simple code.Thanks for the questions I’ll try getting in details. 
>>
>> Regards, 
>>
>> Rahul
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/52d6b81a-a04a-4ef7-b2e4-9bf08b5ac325%40googlegroups.com.


[web2py] Re: Question with saving the thumbnail name on linux disk

2019-08-28 Thread Dave S


On Wednesday, August 28, 2019 at 11:05:11 AM UTC-7, Rahul wrote:
>
> Hi Dave,
>  
> upload_pic is the form variable that user specifies for uploading the file 
> from local disk. Basically it is the filename. I removed the braces for
> outfile = (thumbpath)
> but this is still not working. Any more suggestions ? 
>
>
> Regards
> Rahul
>
>
Your code looks overly complicated, and mixes methods (string 
concatenation, os-specific separators, and os.path.join()).

I'd try what I think is clearer, simpler, and should work on both Windows 
and Linux.


foto_path = os.path.join(request.folder,
 "static", 
 "user_uploads",
 upload_pic)
thumbnail_filename = "%s.thumbnail.jpg" % recordsID  
thumbpath = outfile = os.path.join(request.folder, 
   'static', 
   'thumbs',
   thumbnail_filename)


and the only reason I have both thumbpath and outfile is because you use 
both later on (in the db update and in the thumbing process, 
respectively).  Ditto foto_path and infile.  Also, infile and outfile can 
never be the same even with your constuctions, because "thumbs" != 
"user_uploads".

Note:  I have made plenty of use of os.path.join() on Linux and on Windows 
(different apps),  and have never had problems with random changes in the 
filenames.

/dps

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/68d588ef-0074-4678-aedf-1398f4722a16%40googlegroups.com.


[web2py] Re: Question with saving the thumbnail name on linux disk

2019-08-29 Thread Rahul
Hi Val and Dave,

Have a look at the code below - the line foto_path=... below works but it 
uploads the photos to"web2py\applications\artpicstatic\user_uploads" 
folder instead of web2py\applications\artpic\static\user_uploads folder. It 
also generates the thumbnail file.  Now  if I use  *foto_path = 
os.path.join(request.folder + "static/user_uploads/" + upload_pic)* it 
shows the right path after normalization but does not upload the photo at 
all. And since it does not upload the photo the rest of the code fails  to 
generate thumbnails etc and throws this error . m using windows 10 with 
python 2.7.13

-   [Errno 2] No such file or directory: 
'E:\\web2py_src\\web2py\\applications\\artpic\\static\\user_uploads\\fotoz.upload_photo.82bfeee5a1affabd.3033372e4a5047.JPG'

CODE:
---
#foto_path = (request.folder + "static/user_uploads/" + upload_pic)
print ("")
foto_path = (request.folder + "static/user_uploads/" + upload_pic)
print "Foto Path: ", foto_path

normal_foto_path = os.path.normpath(foto_path)
print "Normal Foto Path: ", normal_foto_path

infile = normal_foto_path
print "infile: " , infile

thumbnail_filename = ("%s" % recordsID + ".thumbnail.jpg")
print "thumbnail_filename :", thumbnail_filename

outfile_path = os.path.join(request.folder, "static/thumbs/" + 
thumbnail_filename)
print "outfile_path: ", outfile_path

normal_outfile_path = os.path.normpath(outfile_path)
print "normal_outfile_path ", normal_outfile_path

outfile = normal_outfile_path
print "outfile: ", outfile
---
OUTPUT ITERATIONS: 

[1]

Foto Path:  
E:\web2py_src\web2py\applications\artpicstatic/user_uploads/fotoz.upload_photo.8c9837615e4fa932.3035382e4a5047.JPG
Normal Foto Path:  
E:\web2py_src\web2py\applications\artpicstatic\user_uploads\fotoz.upload_photo.8c9837615e4fa932.3035382e4a5047.JPG
infile:  
E:\web2py_src\web2py\applications\artpicstatic\user_uploads\fotoz.upload_photo.8c9837615e4fa932.3035382e4a5047.JPG
thumbnail_filename : 64.thumbnail.jpg
outfile:  
E:\web2py_src\web2py\applications\artpic\static\thumbs\64.thumbnail.jpg

[2]

Foto Path:  
E:\web2py_src\web2py\applications\artpicstatic/user_uploads/fotoz.upload_photo.838dbfb13f66470d.3030312e4a5047.JPG
Normal Foto Path:  
E:\web2py_src\web2py\applications\artpicstatic\user_uploads\fotoz.upload_photo.838dbfb13f66470d.3030312e4a5047.JPG
infile:  
E:\web2py_src\web2py\applications\artpicstatic\user_uploads\fotoz.upload_photo.838dbfb13f66470d.3030312e4a5047.JPG
thumbnail_filename : 65.thumbnail.jpg
outfile_path:  
E:\web2py_src\web2py\applications\artpic\static/thumbs/65.thumbnail.jpg
normal_outfile_path  
E:\web2py_src\web2py\applications\artpic\static\thumbs\65.thumbnail.jpg
outfile:  
E:\web2py_src\web2py\applications\artpic\static\thumbs\65.thumbnail.jpg


[3]

infile:  
E:\web2py_src\web2py\applications\artpicstatic\user_uploads\fotoz.upload_photo.862f9808c7622ca7.3033372e4a5047.JPG
thumbnail_filename:  79.thumbnail.jpg
outfile:  
E:\web2py_src\web2py\applications\artpic\static\thumbs\79.thumbnail.jpg
thumbpath:  
E:\web2py_src\web2py\applications\artpic\static\thumbs\79.thumbnail.jpg
Cannot create thumbnail (un-recognized format) for:  
E:\web2py_src\web2py\applications\artpicstatic\user_uploads\fotoz.upload_photo.862f9808c7622ca7.3033372e4a5047.JPG


SCREENSHOT




CODELISTING IS ATTACHED

Looks like a simple answer  but feels like my code is badly written... 

Regards,

Rahul 









On Thursday, August 29, 2019 at 2:17:49 AM UTC+5:30, Val K wrote:
>
> It is no need to use different code for win/linux, since it is Python!
> There is os.path.normpath(your_path) that does all stuff with slashes, I 
> have app that works on both platforms just fine (without platform checking 
> at all)
> My way - always use '/'  in path, and at the end of all manipulations 
> performs normalisation:  path = os.path.normpath(path) 
> And keep in mind that os.path.join() also works with filenames, so you can 
> just os.path.join('foo', 'bar', 'baz.thumbnail.jpg')
> 
>   
>
> On Wednesday, August 28, 2019 at 9:05:11 PM UTC+3, Rahul wrote:
>>
>> Hi Dave,
>>  
>> upload_pic is the form variable that user specifies for uploading the 
>> file from local disk. Basically it is the filename. I removed the braces for
>> outfile = (thumbpath)
>> but this is still not working. Any more suggestions ? 
>>
>>
>> Regards
>> Rahul
>>
>> On Tuesday, August 27, 2019 at 2:21:45 PM UTC+5:30, Rahul wrote:
>>>
>>> Hey Dave, 
>>>   I was facing issues with path storage in a db field so I 
>>> started using this method. I dont need outfiles curly braces will revisit 
>>> the code today if possible and get back with the details. This is my 
>>> modified code, previous one was straight forward and streamlined code and 
>>> was usi

[web2py] Re: Question with saving the thumbnail name on linux disk

2019-08-29 Thread Rahul
And apparently this is what is causing the issue on Linux the wrong path 
and the folder that does not have the permission. If the above path problem 
is corrected and if the file is properly saved and thumbnail created then I 
guess the Linux disk issue might be resolved too. 

Please suggest 

Regards,

Rahul

On Friday, August 30, 2019 at 12:51:41 AM UTC+5:30, Rahul wrote:
>
> Hi Val and Dave,
>
> Have a look at the code below - the line foto_path=... below works but it 
> uploads the photos to"web2py\applications\artpicstatic\user_uploads" 
> folder instead of web2py\applications\artpic\static\user_uploads folder. It 
> also generates the thumbnail file.  Now  if I use  *foto_path = 
> os.path.join(request.folder + "static/user_uploads/" + upload_pic)* it 
> shows the right path after normalization but does not upload the photo at 
> all. And since it does not upload the photo the rest of the code fails  to 
> generate thumbnails etc and throws this error . m using windows 10 with 
> python 2.7.13
>
> -   [Errno 2] No such file or directory: 
> 'E:\\web2py_src\\web2py\\applications\\artpic\\static\\user_uploads\\fotoz.upload_photo.82bfeee5a1affabd.3033372e4a5047.JPG'
>
> CODE:
> ---
> #foto_path = (request.folder + "static/user_uploads/" + upload_pic)
> print ("")
> foto_path = (request.folder + "static/user_uploads/" + upload_pic)
> print "Foto Path: ", foto_path
> 
> normal_foto_path = os.path.normpath(foto_path)
> print "Normal Foto Path: ", normal_foto_path
> 
> infile = normal_foto_path
> print "infile: " , infile
> 
> thumbnail_filename = ("%s" % recordsID + ".thumbnail.jpg")
> print "thumbnail_filename :", thumbnail_filename
> 
> outfile_path = os.path.join(request.folder, "static/thumbs/" + 
> thumbnail_filename)
> print "outfile_path: ", outfile_path
> 
> normal_outfile_path = os.path.normpath(outfile_path)
> print "normal_outfile_path ", normal_outfile_path
> 
> outfile = normal_outfile_path
> print "outfile: ", outfile
> ---
> OUTPUT ITERATIONS: 
>
> [1]
>
> Foto Path:  
> E:\web2py_src\web2py\applications\artpicstatic/user_uploads/fotoz.upload_photo.8c9837615e4fa932.3035382e4a5047.JPG
> Normal Foto Path:  
> E:\web2py_src\web2py\applications\artpicstatic\user_uploads\fotoz.upload_photo.8c9837615e4fa932.3035382e4a5047.JPG
> infile:  
> E:\web2py_src\web2py\applications\artpicstatic\user_uploads\fotoz.upload_photo.8c9837615e4fa932.3035382e4a5047.JPG
> thumbnail_filename : 64.thumbnail.jpg
> outfile:  
> E:\web2py_src\web2py\applications\artpic\static\thumbs\64.thumbnail.jpg
> 
> [2]
>
> Foto Path:  
> E:\web2py_src\web2py\applications\artpicstatic/user_uploads/fotoz.upload_photo.838dbfb13f66470d.3030312e4a5047.JPG
> Normal Foto Path:  
> E:\web2py_src\web2py\applications\artpicstatic\user_uploads\fotoz.upload_photo.838dbfb13f66470d.3030312e4a5047.JPG
> infile:  
> E:\web2py_src\web2py\applications\artpicstatic\user_uploads\fotoz.upload_photo.838dbfb13f66470d.3030312e4a5047.JPG
> thumbnail_filename : 65.thumbnail.jpg
> outfile_path:  
> E:\web2py_src\web2py\applications\artpic\static/thumbs/65.thumbnail.jpg
> normal_outfile_path  
> E:\web2py_src\web2py\applications\artpic\static\thumbs\65.thumbnail.jpg
> outfile:  
> E:\web2py_src\web2py\applications\artpic\static\thumbs\65.thumbnail.jpg
>
> 
> [3]
>
> infile:  
> E:\web2py_src\web2py\applications\artpicstatic\user_uploads\fotoz.upload_photo.862f9808c7622ca7.3033372e4a5047.JPG
> thumbnail_filename:  79.thumbnail.jpg
> outfile:  
> E:\web2py_src\web2py\applications\artpic\static\thumbs\79.thumbnail.jpg
> thumbpath:  
> E:\web2py_src\web2py\applications\artpic\static\thumbs\79.thumbnail.jpg
> Cannot create thumbnail (un-recognized format) for:  
> E:\web2py_src\web2py\applications\artpicstatic\user_uploads\fotoz.upload_photo.862f9808c7622ca7.3033372e4a5047.JPG
>
>
> SCREENSHOT
>
>
>
>
> CODELISTING IS ATTACHED
>
> Looks like a simple answer  but feels like my code is badly written... 
>
> Regards,
>
> Rahul 
>
>
>
>
>
>
>
>
>
> On Thursday, August 29, 2019 at 2:17:49 AM UTC+5:30, Val K wrote:
>>
>> It is no need to use different code for win/linux, since it is Python!
>> There is os.path.normpath(your_path) that does all stuff with slashes, I 
>> have app that works on both platforms just fine (without platform checking 
>> at all)
>> My way - always use '/'  in path, and at the end of all manipulations 
>> performs normalisation:  path = os.path.normpath(path) 
>> And keep in mind that os.path.join() also works with filenames, so you 
>> can just os.path.join('foo', 'bar', 'baz.thumbnail.jpg')
>> 
>>   
>>
>> On Wednesday, August 28, 2019 at 9:05:11 PM UTC+3, Rahul wrote:
>>>
>>> Hi Dave,
>>>  
>>> upload_pic is the form variable that user specifies for uploading the 
>>> file fro

[web2py] Re: Question with saving the thumbnail name on linux disk

2019-08-29 Thread Dave S


On Thursday, August 29, 2019 at 12:21:41 PM UTC-7, Rahul wrote:
>
> Hi Val and Dave,
>
> Have a look at the code below - the line foto_path=... below works but it 
> uploads the photos to"web2py\applications\artpicstatic\user_uploads" 
> folder instead of web2py\applications\artpic\static\user_uploads folder. It 
> also generates the thumbnail file.  Now  if I use  *foto_path = 
> os.path.join(request.folder + "static/user_uploads/" + upload_pic)* it 
> shows the right path after normalization but does not upload the photo at 
> all. And since it does not upload the photo the rest of the code fails  to 
> generate thumbnails etc and throws this error . m using windows 10 with 
> python 2.7.13
>
> -   [Errno 2] No such file or directory: 
> 'E:\\web2py_src\\web2py\\applications\\artpic\\static\\user_uploads\\fotoz.upload_photo.82bfeee5a1affabd.3033372e4a5047.JPG'
>
> CODE:
> ---
> #foto_path = (request.folder + "static/user_uploads/" + upload_pic)
> print ("")
> foto_path = (request.folder + "static/user_uploads/" + upload_pic)
>

Bzzt.   Concantenating different parts of the path is tetchy.  I'd use 
os.path.join() ALWAYS, and let it provide the separators.  You missed one, 
it seems.

/dps


print "Foto Path: ", foto_path
> 
> normal_foto_path = os.path.normpath(foto_path)
> print "Normal Foto Path: ", normal_foto_path
> 
> infile = normal_foto_path
> print "infile: " , infile
> 
> thumbnail_filename = ("%s" % recordsID + ".thumbnail.jpg")
> print "thumbnail_filename :", thumbnail_filename
> 
> outfile_path = os.path.join(request.folder, "static/thumbs/" + 
> thumbnail_filename)
> print "outfile_path: ", outfile_path
> 
> normal_outfile_path = os.path.normpath(outfile_path)
> print "normal_outfile_path ", normal_outfile_path
> 
> outfile = normal_outfile_path
> print "outfile: ", outfile
> ---
> OUTPUT ITERATIONS: 
>
> [1]
>
> Foto Path:  
> E:\web2py_src\web2py\applications\artpicstatic/user_uploads/fotoz.upload_photo.8c9837615e4fa932.3035382e4a5047.JPG
> Normal Foto Path:  
> E:\web2py_src\web2py\applications\artpicstatic\user_uploads\fotoz.upload_photo.8c9837615e4fa932.3035382e4a5047.JPG
> infile:  
> E:\web2py_src\web2py\applications\artpicstatic\user_uploads\fotoz.upload_photo.8c9837615e4fa932.3035382e4a5047.JPG
> thumbnail_filename : 64.thumbnail.jpg
> outfile:  
> E:\web2py_src\web2py\applications\artpic\static\thumbs\64.thumbnail.jpg
> 
> [2]
>
> Foto Path:  
> E:\web2py_src\web2py\applications\artpicstatic/user_uploads/fotoz.upload_photo.838dbfb13f66470d.3030312e4a5047.JPG
> Normal Foto Path:  
> E:\web2py_src\web2py\applications\artpicstatic\user_uploads\fotoz.upload_photo.838dbfb13f66470d.3030312e4a5047.JPG
> infile:  
> E:\web2py_src\web2py\applications\artpicstatic\user_uploads\fotoz.upload_photo.838dbfb13f66470d.3030312e4a5047.JPG
> thumbnail_filename : 65.thumbnail.jpg
> outfile_path:  
> E:\web2py_src\web2py\applications\artpic\static/thumbs/65.thumbnail.jpg
> normal_outfile_path  
> E:\web2py_src\web2py\applications\artpic\static\thumbs\65.thumbnail.jpg
> outfile:  
> E:\web2py_src\web2py\applications\artpic\static\thumbs\65.thumbnail.jpg
>
> 
> [3]
>
> infile:  
> E:\web2py_src\web2py\applications\artpicstatic\user_uploads\fotoz.upload_photo.862f9808c7622ca7.3033372e4a5047.JPG
> thumbnail_filename:  79.thumbnail.jpg
> outfile:  
> E:\web2py_src\web2py\applications\artpic\static\thumbs\79.thumbnail.jpg
> thumbpath:  
> E:\web2py_src\web2py\applications\artpic\static\thumbs\79.thumbnail.jpg
> Cannot create thumbnail (un-recognized format) for:  
> E:\web2py_src\web2py\applications\artpicstatic\user_uploads\fotoz.upload_photo.862f9808c7622ca7.3033372e4a5047.JPG
>
>
> SCREENSHOT
>
>
>
>
> CODELISTING IS ATTACHED
>
> Looks like a simple answer  but feels like my code is badly written... 
>
> Regards,
>
> Rahul 
>
>
>
>
>
>
>
>
>
> On Thursday, August 29, 2019 at 2:17:49 AM UTC+5:30, Val K wrote:
>>
>> It is no need to use different code for win/linux, since it is Python!
>> There is os.path.normpath(your_path) that does all stuff with slashes, I 
>> have app that works on both platforms just fine (without platform checking 
>> at all)
>> My way - always use '/'  in path, and at the end of all manipulations 
>> performs normalisation:  path = os.path.normpath(path) 
>> And keep in mind that os.path.join() also works with filenames, so you 
>> can just os.path.join('foo', 'bar', 'baz.thumbnail.jpg')
>> 
>>   
>>
>> On Wednesday, August 28, 2019 at 9:05:11 PM UTC+3, Rahul wrote:
>>>
>>> Hi Dave,
>>>  
>>> upload_pic is the form variable that user specifies for uploading the 
>>> file from local disk. Basically it is the filename. I removed the braces for
>>> outfile = (thumbpath)
>>> but this is still not working. Any more sug

[web2py] Re: Question with saving the thumbnail name on linux disk

2019-08-30 Thread Rahul

Hi Dave and Everyone,
I followed your advice --  Thanks for the code cleanup - However 
the issues still exist

*ISSUE*#1 - The photo is still being saved in 
[E:\web2py_src\web2py\applications\*artpicstatic*\user_uploads] 
Correct path where it should be saved is [infile:  
E:\web2py_src\web2py\applications\artpic\static\user_uploads\]
I simply do not understand why the application is saving the file in above 
path and not in the correct path in green. We have removed the problem 
causing code [foto_path = (request.folder + "static/user_uploads/" + 
upload_pic) ] from this method so where is it pulling it from and saving 
the files to this location only. Where is this magic happening from? Is it 
web2py


*ISSUE*#2 - As the application cannot find the file in the correct path 
mentioned above it fails to create a thumbnail for it



UPDATED CODE listing


 form = SOLIDFORM(db.fotoz , fields=fields, submit_button='Upload Foto')
#if form.accepts(request.vars, session):
if form.process().accepted:
upload_pic = form.vars.upload_photo
recordsID= form.vars.id
#Thumbnail code
print ("")   
infile = os.path.join(request.folder, "static", "user_uploads", 
upload_pic)
print "infile: " , infile

thumbnail_filename = "%s.thumbnail.jpg" % recordsID
print "thumbnail_filename: ", thumbnail_filename

thumbpath = outfile = os.path.join(request.folder, "static", 
"thumbs" , thumbnail_filename)  
print "thumbpath and outfile: ", outfile

#Insert thumbnail and thumbnail path in db  imgthumb field.
db(db.fotoz.id==recordsID).update(imgthumb=thumbnail_filename, 
imgthumbpath=thumbpath)  ##outfile
if infile != outfile:
try:

im = Image.open(infile)
im.thumbnail(size) 
#Check for image format
image_format = (im.format)
#print ("Image format: ", image_format)


###  Watermark stuff ==
   
## Watermark Text --
width, height = im.size
draw = ImageDraw.Draw(im)


watermark_text = "WATER"
watermark_font = ImageFont.truetype('arial.ttf', 20)
textwidth, textheight = draw.textsize(watermark_text, 
watermark_font)
# calculate the x,y coordinates of the text
margin = 5
x = width - textwidth - margin
y = height - textheight - margin

# draw watermark in the bottom right corner
## Specify this to fill font with red color , 
fill=(128,0,0,128))  OR  #, fill=shadowcolor) OR  fill="red" or 
fill="#ff" -- work
draw.text((x, y), watermark_text, font=watermark_font, 
opacity=0.25)

##  --- Watermark text ends ---   

#Process various image formats for making thumbnails. 
Currently supporting JPG/JPEG, GIF and PNG
if (image_format == "JPEG"):
im.save(outfile, "JPEG")
if (image_format == "JPG"):
im.save(outfile, "JPG")
if (image_format == "GIF"):
im.save(outfile, "GIF")
if (image_format == "PNG"):
im.save(outfile, "PNG")
except IOError:
print "Cannot create thumbnail (un-recognized format) for: "
, infile
#pass

response.flash='Photo uploaded'




*OUTPUT *- Path output for above code --* NOTE The infile must be saved in 
the path mentioned below but it does not exist there. *

infile:  
E:\web2py_src\web2py\applications\artpic\static\user_uploads\fotoz.upload_photo.bf976468faa81f30.3030372e4a5047.JPG
thumbnail_filename:  99.thumbnail.jpg
thumbpath and outfile:  
E:\web2py_src\web2py\applications\artpic\static\thumbs\99.thumbnail.jpg
Cannot create thumbnail (un-recognized format) for:  
E:\web2py_src\web2py\applications\artpic\static\user_uploads\fotoz.upload_photo.bf976468faa81f30.3030372e4a5047.JPG

Regards,

Rahul





On Friday, August 30, 2019 at 1:42:44 AM UTC+5:30, Dave S wrote:
>
>
>
> On Thursday, August 29, 2019 at 12:21:41 PM UTC-7, Rahul wrote:
>>
>> Hi Val and Dave,
>>
>> Have a look at the code below - the line foto_path=... below works but it 
>> uploads the photos to"web2py\applications\artpicstatic\user_uploads" 
>> folder instead of web2py\applications\artpic\static\user_uploads folder. It 
>> also generates the thumbnail file.  Now  if I use  *foto_path = 
>> os.path.join(request.folder + "static/user_uploads/" + upload_pic)* it 
>> shows the right path after normalization but does not upload the photo at 
>> all. And 

[web2py] Re: Question with saving the thumbnail name on linux disk

2019-08-30 Thread Dave S


On Friday, August 30, 2019 at 11:42:37 AM UTC-7, Rahul wrote:
>
>
> Hi Dave and Everyone,
> I followed your advice --  Thanks for the code cleanup - However 
> the issues still exist
>
> *ISSUE*#1 - The photo is still being saved in 
> [E:\web2py_src\web2py\applications\*artpicstatic*\user_uploads] 
> Correct path where it should be saved is [infile:  
> E:\web2py_src\web2py\applications\artpic\static\user_uploads\]
> I simply do not understand why the application is saving the file in above 
> path and not in the correct path in green. We have removed the problem 
> causing code [foto_path = (request.folder + "static/user_uploads/" + 
> upload_pic) ] from this method so where is it pulling it from and saving 
> the files to this location only. Where is this magic happening from? Is it 
> web2py
>


I think it is time to see the declaration of db.fotoz.

/dps
 

> *ISSUE*#2 - As the application cannot find the file in the correct path 
> mentioned above it fails to create a thumbnail for it
>
>
>
> UPDATED CODE listing
>
>
>  form = SOLIDFORM(db.fotoz , fields=fields, submit_button='Upload Foto') 
>
> #if form.accepts(request.vars, session):
> if form.process().accepted:
> upload_pic = form.vars.upload_photo
> recordsID= form.vars.id
> #Thumbnail code
> print ("")   
> infile = os.path.join(request.folder, "static", "user_uploads", 
> upload_pic)
> print "infile: " , infile
> 
> thumbnail_filename = "%s.thumbnail.jpg" % recordsID
> print "thumbnail_filename: ", thumbnail_filename
> 
> thumbpath = outfile = os.path.join(request.folder, "static", 
> "thumbs" , thumbnail_filename)  
> print "thumbpath and outfile: ", outfile
>
> #Insert thumbnail and thumbnail path in db  imgthumb field.
> db(db.fotoz.id==recordsID).update(imgthumb=thumbnail_filename, 
> imgthumbpath=thumbpath)  ##outfile
> if infile != outfile:
> try:
> 
> im = Image.open(infile)
> im.thumbnail(size) 
> #Check for image format
> image_format = (im.format)
> #print ("Image format: ", image_format)
>
>
> ###  Watermark stuff 
> ==
>
> ## Watermark Text --
> width, height = im.size
> draw = ImageDraw.Draw(im)
> 
> 
> watermark_text = "WATER"
> watermark_font = ImageFont.truetype('arial.ttf', 20)
> textwidth, textheight = draw.textsize(watermark_text, 
> watermark_font)
> # calculate the x,y coordinates of the text
> margin = 5
> x = width - textwidth - margin
> y = height - textheight - margin
>
> # draw watermark in the bottom right corner
> ## Specify this to fill font with red color , 
> fill=(128,0,0,128))  OR  #, fill=shadowcolor) OR  fill="red" or 
> fill="#ff" -- work
> draw.text((x, y), watermark_text, font=watermark_font, 
> opacity=0.25)
> 
> ##  --- Watermark text ends ---   
> 
> #Process various image formats for making thumbnails. 
> Currently supporting JPG/JPEG, GIF and PNG
> if (image_format == "JPEG"):
> im.save(outfile, "JPEG")
> if (image_format == "JPG"):
> im.save(outfile, "JPG")
> if (image_format == "GIF"):
> im.save(outfile, "GIF")
> if (image_format == "PNG"):
> im.save(outfile, "PNG")
> except IOError:
> print "Cannot create thumbnail (un-recognized format) 
> for: ", infile
> #pass
> 
> response.flash='Photo uploaded'
>
>
>
>
> *OUTPUT *- Path output for above code --* NOTE The infile must be saved 
> in the path mentioned below but it does not exist there. *
> 
> infile:  
> E:\web2py_src\web2py\applications\artpic\static\user_uploads\fotoz.upload_photo.bf976468faa81f30.3030372e4a5047.JPG
> thumbnail_filename:  99.thumbnail.jpg
> thumbpath and outfile:  
> E:\web2py_src\web2py\applications\artpic\static\thumbs\99.thumbnail.jpg
> Cannot create thumbnail (un-recognized format) for:  
> E:\web2py_src\web2py\applications\artpic\static\user_uploads\fotoz.upload_photo.bf976468faa81f30.3030372e4a5047.JPG
>
> Regards,
>
> Rahul
>
>
>
>
>
> On Friday, August 30, 2019 at 1:42:44 AM UTC+5:30, Dave S wrote:
>>
>>
>>
>> On Thursday, August 29, 2019 at 12:21:41 PM UTC-7, Rahul wrote:
>>>
>>> Hi Val and Dave,
>>>
>>> Have a look at the code below - the line foto_path=... below works but 
>>> it uploads the photos to   

[web2py] Re: Question with saving the thumbnail name on linux disk

2019-08-31 Thread Dave S


On Saturday, August 31, 2019 at 6:40:26 AM UTC-7, Rahul wrote:
>
> Hi Dave,
> I finally found the issue where the magic was with default folder 
> path specified in db.py. I rectified it in code where-ever I had defined 
> for other upload types aswell and it works properly. Now the files do get 
> saved to the desired path.
>

Yay!

 

> *but the THUMBNAIL file saving issue still persists on linux.* Again this 
> works properly in Windows.
> [...]
>
 

> [Sat Aug 31 18:00:20.813518 2019] [wsgi:error] [pid 3806] [client 
> 42.108.232.228:38975] Cannot create thumbnail (un-recognized format) 
> for:  /home/www-data/web2py/applications/artpic/stati$
>

Hmmm  

>
> [Sat Aug 31 18:02:09.456898 2019] [wsgi:error] [pid 3810] [client 
> 95.163.255.151:41074] WARNING:root:Unable to write to file 
> /home/www-data/web2py/applications/artpic/languages/ru.py
> [Sat Aug 31 18:02:09.685699 2019] [wsgi:error] [pid 3810] [client 
> 95.163.255.151:41074] WARNING:root:Unable to write to file 
> /home/www-data/web2py/applications/artpic/languages/ru.py
> [Sat Aug 31 18:02:10.900764 2019] [wsgi:error] [pid 3810] [client 
> 95.163.255.151:41074] WARNING:root:Unable to write to file 
> /home/www-data/web2py/applications/artpic/languages/ru.py
> [Sat Aug 31 18:02:10.901023 2019] [wsgi:error] [pid 3810] [client 
> 95.163.255.151:41074 
> ]
>  
> WARNING:root:Unable to write to file 
> /home/www-data/web2py/applications/artpic/languages/ru.py
>

What's trying to write to this file?

 

> [...] 
>
[Sat Aug 31 18:27:17.451565 2019] [wsgi:error] [pid 5696] [client 
> 42.108.232.228:34651] , referer: 
> http://artpic.in/upload-fotoz
> [Sat Aug 31 18:27:17.451647 2019] [wsgi:error] [pid 5696] [client 
> 42.108.232.228:34651] infile:  
> /home/www-data/web2py/applications/artpic/static/user_uploads/fotoz.upload_photo.b404a9b372$
> [Sat Aug 31 18:27:17.451668 2019] [wsgi:error] [pid 5696] [client 
> 42.108.232.228:34651] thumbnail_filename:  133.thumbnail.jpg, referer: 
> http://artpic.in/upload-fotoz
> [Sat Aug 31 18:27:17.451690 2019] [wsgi:error] [pid 5696] [client 
> 42.108.232.228:34651] thumbpath and outfile:  
> /home/www-data/web2py/applications/artpic/static/thumbs/133.thumbnail.jpg, 
> r$
> [Sat Aug 31 18:27:19.289744 2019] [wsgi:error] [pid 5696] [client 
> 42.108.232.228:34651] Cannot create thumbnail (un-recognized format) 
> for:  /home/www-data/web2py/applications/artpic/stati$
>
> *CODE - FOR THUMBNAIL*
> [...] 
>
except IOError:
> print "Cannot create thumbnail (un-recognized format) 
> for: ", infile
>
>
>  * Please suggest on how to get the thumbnail to save in debian box - 
> I'll try it again after removing the try and catch blocks and get*
>  
>
*raw ticket if any tomorrow*
>

Your except is not printing the exception itself, and what it does print is 
misleading (un-recognized format for an IOError?) and the filename printed 
may not be the one with the IOError.   First check ... make sure the thumbs 
directory exists and is writable. Is the ', r' appended to the line just an 
artifact of your logging tool? (I see "referer: 
hsttp://artpic.ini/upload-fotoz" on some other lines).

You're definitely getting closer!

/dps

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/b6bf42c1-6d57-4b53-ae8e-c963d116bdfc%40googlegroups.com.


Re: [web2py] Re: Question with saving the thumbnail name on linux disk

2019-08-31 Thread Rahul Dhakate
Yes the thumbs directory exists and I have given all the rights to it.
Strange enough it did write a few files to this directory before. As I
mentioned before, the previous problem was that thumbnail file name was not
properly named, now it does not write to it at all. Also after the patch I
did yesterday I executed this command *chmod *... to give appropriate write
permissions to it again. I will remove the try catch block today to check
it gives me the raw error.

Thanks and regards

Rahul

On Sun, Sep 1, 2019 at 5:15 AM Dave S  wrote:

>
>
> On Saturday, August 31, 2019 at 6:40:26 AM UTC-7, Rahul wrote:
>>
>> Hi Dave,
>> I finally found the issue where the magic was with default folder
>> path specified in db.py. I rectified it in code where-ever I had defined
>> for other upload types aswell and it works properly. Now the files do get
>> saved to the desired path.
>>
>
> Yay!
>
>
>
>> *but the THUMBNAIL file saving issue still persists on linux.* Again
>> this works properly in Windows.
>> [...]
>>
>
>
>> [Sat Aug 31 18:00:20.813518 2019] [wsgi:error] [pid 3806] [client
>> 42.108.232.228:38975] Cannot create thumbnail (un-recognized format)
>> for:  /home/www-data/web2py/applications/artpic/stati$
>>
>
> Hmmm 
>
>>
>> [Sat Aug 31 18:02:09.456898 2019] [wsgi:error] [pid 3810] [client
>> 95.163.255.151:41074] WARNING:root:Unable to write to file
>> /home/www-data/web2py/applications/artpic/languages/ru.py
>> [Sat Aug 31 18:02:09.685699 2019] [wsgi:error] [pid 3810] [client
>> 95.163.255.151:41074] WARNING:root:Unable to write to file
>> /home/www-data/web2py/applications/artpic/languages/ru.py
>> [Sat Aug 31 18:02:10.900764 2019] [wsgi:error] [pid 3810] [client
>> 95.163.255.151:41074] WARNING:root:Unable to write to file
>> /home/www-data/web2py/applications/artpic/languages/ru.py
>> [Sat Aug 31 18:02:10.901023 2019] [wsgi:error] [pid 3810] [client
>> 95.163.255.151:41074
>> ]
>> WARNING:root:Unable to write to file
>> /home/www-data/web2py/applications/artpic/languages/ru.py
>>
>
> What's trying to write to this file?
>
>
>
>> [...]
>>
> [Sat Aug 31 18:27:17.451565 2019] [wsgi:error] [pid 5696] [client
>> 42.108.232.228:34651] , referer:
>> http://artpic.in/upload-fotoz
>> [Sat Aug 31 18:27:17.451647 2019] [wsgi:error] [pid 5696] [client
>> 42.108.232.228:34651] infile:
>> /home/www-data/web2py/applications/artpic/static/user_uploads/fotoz.upload_photo.b404a9b372$
>> [Sat Aug 31 18:27:17.451668 2019] [wsgi:error] [pid 5696] [client
>> 42.108.232.228:34651] thumbnail_filename:  133.thumbnail.jpg, referer:
>> http://artpic.in/upload-fotoz
>> [Sat Aug 31 18:27:17.451690 2019] [wsgi:error] [pid 5696] [client
>> 42.108.232.228:34651] thumbpath and outfile:
>> /home/www-data/web2py/applications/artpic/static/thumbs/133.thumbnail.jpg,
>> r$
>> [Sat Aug 31 18:27:19.289744 2019] [wsgi:error] [pid 5696] [client
>> 42.108.232.228:34651] Cannot create thumbnail (un-recognized format)
>> for:  /home/www-data/web2py/applications/artpic/stati$
>>
>> *CODE - FOR THUMBNAIL*
>> [...]
>>
> except IOError:
>> print "Cannot create thumbnail (un-recognized format)
>> for: ", infile
>>
>>
>>  * Please suggest on how to get the thumbnail to save in debian box -
>> I'll try it again after removing the try and catch blocks and get*
>>
>>
> *raw ticket if any tomorrow*
>>
>
> Your except is not printing the exception itself, and what it does print
> is misleading (un-recognized format for an IOError?) and the filename
> printed may not be the one with the IOError.   First check ... make sure
> the thumbs directory exists and is writable. Is the ', r' appended to the
> line just an artifact of your logging tool? (I see "referer:
> hsttp://artpic.ini/upload-fotoz" on some other lines).
>
> You're definitely getting closer!
>
> /dps
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/Gn-cqZjDURk/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/web2py/b6bf42c1-6d57-4b53-ae8e-c963d116bdfc%40googlegroups.com
> 
> .
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you a

Re: [web2py] Re: Question with saving the thumbnail name on linux disk

2019-08-31 Thread Rahul Dhakate
To Add -

[Sat Aug 31 18:02:10.901023 2019] [wsgi:error] [pid 3810] [client
> 95.163.255.151:41074
> ]
> WARNING:root:Unable to write to file
> /home/www-data/web2py/applications/artpic/languages/ru.py
>

What's trying to write to this file?
[Rahul] This is not me. I am not trying to write anything to this file as I
dont use it - I donk know about it. I gave the write permissions to
language folder to resolve the issue. It got resolved and it is not showing
that error in the logs

I am not sure about the r artifact - I did not put anything like that.

Rahul


On Sun, Sep 1, 2019 at 5:15 AM Dave S  wrote:

>
>
> On Saturday, August 31, 2019 at 6:40:26 AM UTC-7, Rahul wrote:
>>
>> Hi Dave,
>> I finally found the issue where the magic was with default folder
>> path specified in db.py. I rectified it in code where-ever I had defined
>> for other upload types aswell and it works properly. Now the files do get
>> saved to the desired path.
>>
>
> Yay!
>
>
>
>> *but the THUMBNAIL file saving issue still persists on linux.* Again
>> this works properly in Windows.
>> [...]
>>
>
>
>> [Sat Aug 31 18:00:20.813518 2019] [wsgi:error] [pid 3806] [client
>> 42.108.232.228:38975] Cannot create thumbnail (un-recognized format)
>> for:  /home/www-data/web2py/applications/artpic/stati$
>>
>
> Hmmm 
>
>>
>> [Sat Aug 31 18:02:09.456898 2019] [wsgi:error] [pid 3810] [client
>> 95.163.255.151:41074] WARNING:root:Unable to write to file
>> /home/www-data/web2py/applications/artpic/languages/ru.py
>> [Sat Aug 31 18:02:09.685699 2019] [wsgi:error] [pid 3810] [client
>> 95.163.255.151:41074] WARNING:root:Unable to write to file
>> /home/www-data/web2py/applications/artpic/languages/ru.py
>> [Sat Aug 31 18:02:10.900764 2019] [wsgi:error] [pid 3810] [client
>> 95.163.255.151:41074] WARNING:root:Unable to write to file
>> /home/www-data/web2py/applications/artpic/languages/ru.py
>> [Sat Aug 31 18:02:10.901023 2019] [wsgi:error] [pid 3810] [client
>> 95.163.255.151:41074
>> ]
>> WARNING:root:Unable to write to file
>> /home/www-data/web2py/applications/artpic/languages/ru.py
>>
>
> What's trying to write to this file?
>
>
>
>> [...]
>>
> [Sat Aug 31 18:27:17.451565 2019] [wsgi:error] [pid 5696] [client
>> 42.108.232.228:34651] , referer:
>> http://artpic.in/upload-fotoz
>> [Sat Aug 31 18:27:17.451647 2019] [wsgi:error] [pid 5696] [client
>> 42.108.232.228:34651] infile:
>> /home/www-data/web2py/applications/artpic/static/user_uploads/fotoz.upload_photo.b404a9b372$
>> [Sat Aug 31 18:27:17.451668 2019] [wsgi:error] [pid 5696] [client
>> 42.108.232.228:34651] thumbnail_filename:  133.thumbnail.jpg, referer:
>> http://artpic.in/upload-fotoz
>> [Sat Aug 31 18:27:17.451690 2019] [wsgi:error] [pid 5696] [client
>> 42.108.232.228:34651] thumbpath and outfile:
>> /home/www-data/web2py/applications/artpic/static/thumbs/133.thumbnail.jpg,
>> r$
>> [Sat Aug 31 18:27:19.289744 2019] [wsgi:error] [pid 5696] [client
>> 42.108.232.228:34651] Cannot create thumbnail (un-recognized format)
>> for:  /home/www-data/web2py/applications/artpic/stati$
>>
>> *CODE - FOR THUMBNAIL*
>> [...]
>>
> except IOError:
>> print "Cannot create thumbnail (un-recognized format)
>> for: ", infile
>>
>>
>>  * Please suggest on how to get the thumbnail to save in debian box -
>> I'll try it again after removing the try and catch blocks and get*
>>
>>
> *raw ticket if any tomorrow*
>>
>
> Your except is not printing the exception itself, and what it does print
> is misleading (un-recognized format for an IOError?) and the filename
> printed may not be the one with the IOError.   First check ... make sure
> the thumbs directory exists and is writable. Is the ', r' appended to the
> line just an artifact of your logging tool? (I see "referer:
> hsttp://artpic.ini/upload-fotoz" on some other lines).
>
> You're definitely getting closer!
>
> /dps
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/Gn-cqZjDURk/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/web2py/b6bf42c1-6d57-4b53-ae8e-c963d116bdfc%40googlegroups.com
> 
> .
>

-- 
Resources:
- http://web2py.com
- http://web

Re: [web2py] Re: Question with saving the thumbnail name on linux disk

2019-09-03 Thread Dave S
 

On Saturday, August 31, 2019 at 6:54:21 PM UTC-7, Rahul wrote:
>
> To Add - 
>
> [Sat Aug 31 18:02:10.901023 2019] [wsgi:error] [pid 3810] [client 
>> 95.163.255.151:41074 
>> ]
>>  
>> WARNING:root:Unable to write to file 
>> /home/www-data/web2py/applications/artpic/languages/ru.py
>>
>
> What's trying to write to this file?
> [Rahul] This is not me. I am not trying to write anything to this file as 
> I dont use it - I donk know about it. I gave the write permissions to 
> language folder to resolve the issue. It got resolved and it is not showing 
> that error in the logs
>
>
That may be a web2py thing.  I see that some of my languages/*.py don't 
have the same date; most show 2015-12-26, but zh-cn is 2019-08-06.

(and a couple of them have the +x permission).
 

> I am not sure about the r artifact - I did not put anything like that. 
>
>
I suspect your logging tool, but keep an eye on it.

Aside from that, I'm missing whatever is wrong.  Let's know when you have 
the traceback from the exception.


Rahul
>
>
>
/dps
 

> On Sun, Sep 1, 2019 at 5:15 AM Dave S > 
> wrote:
>
>>
>>
>> On Saturday, August 31, 2019 at 6:40:26 AM UTC-7, Rahul wrote:
>>>
>>> Hi Dave,
>>> I finally found the issue where the magic was with default 
>>> folder path specified in db.py. I rectified it in code where-ever I had 
>>> defined for other upload types aswell and it works properly. Now the files 
>>> do get saved to the desired path.
>>>
>>
>> Yay!
>>
>>  
>>
>>> *but the THUMBNAIL file saving issue still persists on linux.* Again 
>>> this works properly in Windows.
>>> [...]
>>>
>>  
>>
>>> [Sat Aug 31 18:00:20.813518 2019] [wsgi:error] [pid 3806] [client 
>>> 42.108.232.228:38975] Cannot create thumbnail (un-recognized format) 
>>> for:  /home/www-data/web2py/applications/artpic/stati$
>>>
>>
>> Hmmm  
>>
>>>
>>> [Sat Aug 31 18:02:09.456898 2019] [wsgi:error] [pid 3810] [client 
>>> 95.163.255.151:41074] WARNING:root:Unable to write to file 
>>> /home/www-data/web2py/applications/artpic/languages/ru.py
>>> [Sat Aug 31 18:02:09.685699 2019] [wsgi:error] [pid 3810] [client 
>>> 95.163.255.151:41074] WARNING:root:Unable to write to file 
>>> /home/www-data/web2py/applications/artpic/languages/ru.py
>>> [Sat Aug 31 18:02:10.900764 2019] [wsgi:error] [pid 3810] [client 
>>> 95.163.255.151:41074] WARNING:root:Unable to write to file 
>>> /home/www-data/web2py/applications/artpic/languages/ru.py
>>> [Sat Aug 31 18:02:10.901023 2019] [wsgi:error] [pid 3810] [client 
>>> 95.163.255.151:41074 
>>> ]
>>>  
>>> WARNING:root:Unable to write to file 
>>> /home/www-data/web2py/applications/artpic/languages/ru.py
>>>
>>
>> What's trying to write to this file?
>>
>>  
>>
>>> [...] 
>>>
>> [Sat Aug 31 18:27:17.451565 2019] [wsgi:error] [pid 5696] [client 
>>> 42.108.232.228:34651] , referer: 
>>> http://artpic.in/upload-fotoz
>>> [Sat Aug 31 18:27:17.451647 2019] [wsgi:error] [pid 5696] [client 
>>> 42.108.232.228:34651] infile:  
>>> /home/www-data/web2py/applications/artpic/static/user_uploads/fotoz.upload_photo.b404a9b372$
>>> [Sat Aug 31 18:27:17.451668 2019] [wsgi:error] [pid 5696] [client 
>>> 42.108.232.228:34651] thumbnail_filename:  133.thumbnail.jpg, referer: 
>>> http://artpic.in/upload-fotoz
>>> [Sat Aug 31 18:27:17.451690 2019] [wsgi:error] [pid 5696] [client 
>>> 42.108.232.228:34651] thumbpath and outfile:  
>>> /home/www-data/web2py/applications/artpic/static/thumbs/133.thumbnail.jpg, 
>>> r$
>>> [Sat Aug 31 18:27:19.289744 2019] [wsgi:error] [pid 5696] [client 
>>> 42.108.232.228:34651] Cannot create thumbnail (un-recognized format) 
>>> for:  /home/www-data/web2py/applications/artpic/stati$
>>>
>>> *CODE - FOR THUMBNAIL*
>>> [...] 
>>>
>> except IOError:
>>> print "Cannot create thumbnail (un-recognized format) 
>>> for: ", infile
>>>
>>>
>>>  * Please suggest on how to get the thumbnail to save in debian box - 
>>> I'll try it again after removing the try and catch blocks and get*
>>>  
>>>
>> *raw ticket if any tomorrow*
>>>
>>
>> Your except is not printing the exception itself, and what it does print 
>> is misleading (un-recognized format for an IOError?) and the filename 
>> printed may not be the one with the IOError.   First check ... make sure 
>> the thumbs directory exists and is writable. Is the ', r' appended to the 
>> line just an artifact of your logging tool? (I see "referer: 
>> hsttp://artpic.ini/upload-fotoz" on some other lines).
>>
>> You're definitely getting closer!
>>
>> /dps
>>
>> -- 
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> --- 
>> You received this 

Re: [web2py] Re: Question with saving the thumbnail name on linux disk

2019-09-04 Thread Rahul
Hi Dave,

   Sorry for the delay - I got busy but - Thanks for pushing me I 
worked on it today and now it is finally *RESOLVED!! Yay!! *

There were two errors - 

1] (cannot open resource) 
2] NameError: global name 'watermark_font' is not defined

These were because the system could not find the *font *I specified in the 
code. As usual it worked flawlessly on windows but failed on Linux - I 
applied the previous os checks and specified default fonts from the system 
and then it worked. I re-instated my try-except blocks back and tested it. 
It is working properly now.  One major error resolved. 

THANK YOU FOR ALL THE SUGGESTIONS AND GUIDANCE :-)

Regards,

*Rahul *

On Wednesday, September 4, 2019 at 1:54:48 AM UTC+5:30, Dave S wrote:
>
>  
>
> On Saturday, August 31, 2019 at 6:54:21 PM UTC-7, Rahul wrote:
>>
>> To Add - 
>>
>> [Sat Aug 31 18:02:10.901023 2019] [wsgi:error] [pid 3810] [client 
>>> 95.163.255.151:41074 
>>> ]
>>>  
>>> WARNING:root:Unable to write to file 
>>> /home/www-data/web2py/applications/artpic/languages/ru.py
>>>
>>
>> What's trying to write to this file?
>> [Rahul] This is not me. I am not trying to write anything to this file as 
>> I dont use it - I donk know about it. I gave the write permissions to 
>> language folder to resolve the issue. It got resolved and it is not showing 
>> that error in the logs
>>
>>
> That may be a web2py thing.  I see that some of my languages/*.py don't 
> have the same date; most show 2015-12-26, but zh-cn is 2019-08-06.
>
> (and a couple of them have the +x permission).
>  
>
>> I am not sure about the r artifact - I did not put anything like that. 
>>
>>
> I suspect your logging tool, but keep an eye on it.
>
> Aside from that, I'm missing whatever is wrong.  Let's know when you have 
> the traceback from the exception.
>
>
> Rahul
>>
>>
>>
> /dps
>  
>
>> On Sun, Sep 1, 2019 at 5:15 AM Dave S  wrote:
>>
>>>
>>>
>>> On Saturday, August 31, 2019 at 6:40:26 AM UTC-7, Rahul wrote:

 Hi Dave,
 I finally found the issue where the magic was with default 
 folder path specified in db.py. I rectified it in code where-ever I had 
 defined for other upload types aswell and it works properly. Now the files 
 do get saved to the desired path.

>>>
>>> Yay!
>>>
>>>  
>>>
 *but the THUMBNAIL file saving issue still persists on linux.* Again 
 this works properly in Windows.
 [...]

>>>  
>>>
 [Sat Aug 31 18:00:20.813518 2019] [wsgi:error] [pid 3806] [client 
 42.108.232.228:38975] Cannot create thumbnail (un-recognized format) 
 for:  /home/www-data/web2py/applications/artpic/stati$

>>>
>>> Hmmm  
>>>

 [Sat Aug 31 18:02:09.456898 2019] [wsgi:error] [pid 3810] [client 
 95.163.255.151:41074] WARNING:root:Unable to write to file 
 /home/www-data/web2py/applications/artpic/languages/ru.py
 [Sat Aug 31 18:02:09.685699 2019] [wsgi:error] [pid 3810] [client 
 95.163.255.151:41074] WARNING:root:Unable to write to file 
 /home/www-data/web2py/applications/artpic/languages/ru.py
 [Sat Aug 31 18:02:10.900764 2019] [wsgi:error] [pid 3810] [client 
 95.163.255.151:41074] WARNING:root:Unable to write to file 
 /home/www-data/web2py/applications/artpic/languages/ru.py
 [Sat Aug 31 18:02:10.901023 2019] [wsgi:error] [pid 3810] [client 
 95.163.255.151:41074 
 ]
  
 WARNING:root:Unable to write to file 
 /home/www-data/web2py/applications/artpic/languages/ru.py

>>>
>>> What's trying to write to this file?
>>>
>>>  
>>>
 [...] 

>>> [Sat Aug 31 18:27:17.451565 2019] [wsgi:error] [pid 5696] [client 
 42.108.232.228:34651] , referer: 
 http://artpic.in/upload-fotoz
 [Sat Aug 31 18:27:17.451647 2019] [wsgi:error] [pid 5696] [client 
 42.108.232.228:34651] infile:  
 /home/www-data/web2py/applications/artpic/static/user_uploads/fotoz.upload_photo.b404a9b372$
 [Sat Aug 31 18:27:17.451668 2019] [wsgi:error] [pid 5696] [client 
 42.108.232.228:34651] thumbnail_filename:  133.thumbnail.jpg, referer: 
 http://artpic.in/upload-fotoz
 [Sat Aug 31 18:27:17.451690 2019] [wsgi:error] [pid 5696] [client 
 42.108.232.228:34651] thumbpath and outfile:  
 /home/www-data/web2py/applications/artpic/static/thumbs/133.thumbnail.jpg, 
 r$
 [Sat Aug 31 18:27:19.289744 2019] [wsgi:error] [pid 5696] [client 
 42.108.232.228:34651] Cannot create thumbnail (un-recognized format) 
 for:  /home/www-data/web2py/applications/artpic/stati$

 *CODE - FOR THUMBNAIL*
 [...] 

>>> except IOError:
 print "Cannot create thumbnail (un-recognized format) 
 for: ", infile


  * Please suggest

Re: [web2py] Re: Question with saving the thumbnail name on linux disk

2019-09-04 Thread Dave S


On Wednesday, September 4, 2019 at 11:09:06 AM UTC-7, Rahul wrote:
>
> Hi Dave,
>
>Sorry for the delay - I got busy but - Thanks for pushing me I 
> worked on it today and now it is finally *RESOLVED!! Yay!! *
>
> There were two errors - 
>
> 1] (cannot open resource) 
> 2] NameError: global name 'watermark_font' is not defined
>
> These were because the system could not find the *font *I specified in 
> the code. As usual it worked flawlessly on windows but failed on Linux - I 
> applied the previous os checks and specified default fonts from the system 
> and then it worked. I re-instated my try-except blocks back and tested it. 
> It is working properly now.  One major error resolved. 
>
> THANK YOU FOR ALL THE SUGGESTIONS AND GUIDANCE :-)
>
> Regards,
>
> *Rahul *
>

Congratulations!  

/dps
 

>
>
> On Wednesday, September 4, 2019 at 1:54:48 AM UTC+5:30, Dave S wrote:
>>
>>  
>>
>> On Saturday, August 31, 2019 at 6:54:21 PM UTC-7, Rahul wrote:
>>>
>>> To Add - 
>>>
>>> [Sat Aug 31 18:02:10.901023 2019] [wsgi:error] [pid 3810] [client 
 95.163.255.151:41074 
 ]
  
 WARNING:root:Unable to write to file 
 /home/www-data/web2py/applications/artpic/languages/ru.py

>>>
>>> What's trying to write to this file?
>>> [Rahul] This is not me. I am not trying to write anything to this file 
>>> as I dont use it - I donk know about it. I gave the write permissions to 
>>> language folder to resolve the issue. It got resolved and it is not showing 
>>> that error in the logs
>>>
>>>
>> That may be a web2py thing.  I see that some of my languages/*.py don't 
>> have the same date; most show 2015-12-26, but zh-cn is 2019-08-06.
>>
>> (and a couple of them have the +x permission).
>>  
>>
>>> I am not sure about the r artifact - I did not put anything like that. 
>>>
>>>
>> I suspect your logging tool, but keep an eye on it.
>>
>> Aside from that, I'm missing whatever is wrong.  Let's know when you have 
>> the traceback from the exception.
>>
>>
>> Rahul
>>>
>>>
>>>
>> /dps
>>  
>>
>>> On Sun, Sep 1, 2019 at 5:15 AM Dave S  wrote:
>>>


 On Saturday, August 31, 2019 at 6:40:26 AM UTC-7, Rahul wrote:
>
> Hi Dave,
> I finally found the issue where the magic was with default 
> folder path specified in db.py. I rectified it in code where-ever I had 
> defined for other upload types aswell and it works properly. Now the 
> files 
> do get saved to the desired path.
>

 Yay!

  

> *but the THUMBNAIL file saving issue still persists on linux.* Again 
> this works properly in Windows.
> [...]
>
  

> [Sat Aug 31 18:00:20.813518 2019] [wsgi:error] [pid 3806] [client 
> 42.108.232.228:38975] Cannot create thumbnail (un-recognized format) 
> for:  /home/www-data/web2py/applications/artpic/stati$
>

 Hmmm  

>
> [Sat Aug 31 18:02:09.456898 2019] [wsgi:error] [pid 3810] [client 
> 95.163.255.151:41074] WARNING:root:Unable to write to file 
> /home/www-data/web2py/applications/artpic/languages/ru.py
> [Sat Aug 31 18:02:09.685699 2019] [wsgi:error] [pid 3810] [client 
> 95.163.255.151:41074] WARNING:root:Unable to write to file 
> /home/www-data/web2py/applications/artpic/languages/ru.py
> [Sat Aug 31 18:02:10.900764 2019] [wsgi:error] [pid 3810] [client 
> 95.163.255.151:41074] WARNING:root:Unable to write to file 
> /home/www-data/web2py/applications/artpic/languages/ru.py
> [Sat Aug 31 18:02:10.901023 2019] [wsgi:error] [pid 3810] [client 
> 95.163.255.151:41074 
> ]
>  
> WARNING:root:Unable to write to file 
> /home/www-data/web2py/applications/artpic/languages/ru.py
>

 What's trying to write to this file?

  

> [...] 
>
 [Sat Aug 31 18:27:17.451565 2019] [wsgi:error] [pid 5696] [client 
> 42.108.232.228:34651] , referer: 
> http://artpic.in/upload-fotoz
> [Sat Aug 31 18:27:17.451647 2019] [wsgi:error] [pid 5696] [client 
> 42.108.232.228:34651] infile:  
> /home/www-data/web2py/applications/artpic/static/user_uploads/fotoz.upload_photo.b404a9b372$
> [Sat Aug 31 18:27:17.451668 2019] [wsgi:error] [pid 5696] [client 
> 42.108.232.228:34651] thumbnail_filename:  133.thumbnail.jpg, 
> referer: http://artpic.in/upload-fotoz
> [Sat Aug 31 18:27:17.451690 2019] [wsgi:error] [pid 5696] [client 
> 42.108.232.228:34651] thumbpath and outfile:  
> /home/www-data/web2py/applications/artpic/static/thumbs/133.thumbnail.jpg,
>  
> r$
> [Sat Aug 31 18:27:19.289744 2019] [wsgi:error] [pid 5696] [client 
> 42.108.232.228:34651] Cannot create thumbnail (un-recognized format) 
>