Re: Using a HTML to fire off a data processing script on the server (REST or SOAP)

2008-11-22 Thread Jeff Anderson
shi shaozhong wrote:
> Dear Jeff Anderson,
>
> Thank you for your email.
>
> It sounds very interesting to me.   I must confess that I am not a
> programmer, and have no experience with Django.  But I have a project
> in hand to do such a work.
>
> Have you ever tried to use feedback.py to fire off another Python
> script (external script)?  The external script may run for 2 - 3
> minutes.
>
> Perhaps you can show me how to use feedback.py to fire off a zip.py.
>   
All you really need is to use a Python thread. They are fairly easy to
use, but I don't use them enough to know without looking up how to do
it. If I needed to do it, I'd simply do a google search for "python
threads".

If you feel like this type of thing would be too difficult or time
consuming, contact me off list and I am willing to do paid freelance
work. I could get it working fairly quickly. I'm a poor college student,
so I'm happy to get extra money any way I can. :)


Thanks!

Jeff Anderson



signature.asc
Description: OpenPGP digital signature


Re: Using a HTML to fire off a data processing script on the server (REST or SOAP)

2008-11-22 Thread shi shaozhong
Dear Jeff Anderson,

Thank you for your email.

It sounds very interesting to me.   I must confess that I am not a
programmer, and have no experience with Django.  But I have a project
in hand to do such a work.

Have you ever tried to use feedback.py to fire off another Python
script (external script)?  The external script may run for 2 - 3
minutes.

Perhaps you can show me how to use feedback.py to fire off a zip.py.

Your assistance will be deeply appreciated.

Sincerely,

David

2008/11/21 Jeff Anderson <[EMAIL PROTECTED]>:
> Shao wrote:
>> Dear ALL,
>>
>> I am very much interested in using a HTML to fire off a data
>> processing script to run over the internet.
>>
>> I will be very grateful if you can advise me on passing parameters
>> from an HTML form to a script and fire the script off to carry out
>> full execution, monitor its progress and return an innerHTML with link
>> (a name string of) the file generated back to allow user to download
>> the result.
>>
>> The script run over a period of 2 to 3 minutes.
>>
> I designed a system to do something similar, but never implemented it fully.
>
> Basically, a Django view would fire off a Python thread that would run
> the script, and report its progress. I chose to use a Django model that
> the Python thread would store its progress in. The progress was
> monitored by the end user via AJAX. It queried the progress of the job
> once a second or so until it was completed. I only implemented a proof
> of concept, where the script would only count to 100. Unfortunately, I
> didn't save the code. The project I was doing it for was scrapped. The
> proof of concept code was fairly easy to implement. I think it'd fit
> your bill.
>
> If you aren't familiar with AJAX, I suggest reading a tutorial about how
> AJAX works, and then consider using an AJAX library.
>
> Hopefully this gives you a good starting point.
>
>
> Jeff Anderson
>
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---

Title: Shao Shi - call AJAX




	Sending a Form with Ajax
	
  
  

Please fill out the entire form:
Name

Email
 
Adress
 
Type of Message
 Comment
 Complain
Your Message
 hello world


	
  
		
	

		Ajax - Python Response
		
	
	


#!/usr/bin/python
import cgi, os, sys, string

def gush(data):
print "Content-type: text/html\n"
print "Thanks, %(name)s!" % vars(data)
print "Our customer's comments are always appreciated."
print "They drive our business directions, as well as"
print "help us with our karma."
print "Thanks again for the feedback!"
print "And feel free to enter more comments if you wish."
print ""+10*""+"--Joe."

def whimper(data):
print "Content-type: text/html\n"
print "Sorry, %(name)s!" % vars(data)
print "We're very sorry to read that you had a complaint"
print "regarding our product__We'll read your comments"
print "carefully and will be in touch with you."
print "Nevertheless, thanks for the feedback."
print ""+10*""+"--Joe."

def bail():
print "Content-type: text/html\n"
print "Error filling out form"
print "Please fill in all the fields in the form."
print 'http://localhost/comment.html;>'
print 'Go back to the form'
sys.exit()

class FormData:
""" A repository for information gleaned from a CGI form """
def __init__(self, form):
for fieldname in self.fieldnames:
if not form.has_key(fieldname) or form[fieldname].value == "":
bail()
else:
setattr(self, fieldname, form[fieldname].value)

class FeedbackData(FormData):
""" A FormData generated by the comment.html form. """
fieldnames = ('name', 'address', 'email', 'type', 'text')
def __repr__(self):
return "%(type)s from %(name)s on %(time)s" % vars(self)

DIRECTORY = '/home/brooks/public_html/cgi-bin/feedbackDir'

if __name__ == '__main__':
sys.stderr = sys.stdout 
form = cgi.FieldStorage()
data = FeedbackData(form)
if data.type == 'comment':
gush(data)
else:
whimper(data)
#**
# Description:
#Zips the contents of a folder.
# Parameters:
#   0 - Input folder.
#   1 - Output zip file. It is assumed that the user added the .zip 
#   extension.  
#**

# Import modules and create the geoprocessor
#
import sys, zipfile, arcgisscripting, os, traceback
gp = arcgisscripting.create()

# Function for zipping files.  If keep is true, the 

Re: Using a HTML to fire off a data processing script on the server (REST or SOAP)

2008-11-21 Thread Jeff Anderson
Shao wrote:
> Dear ALL,
>
> I am very much interested in using a HTML to fire off a data
> processing script to run over the internet.
>
> I will be very grateful if you can advise me on passing parameters
> from an HTML form to a script and fire the script off to carry out
> full execution, monitor its progress and return an innerHTML with link
> (a name string of) the file generated back to allow user to download
> the result.
>
> The script run over a period of 2 to 3 minutes.
>   
I designed a system to do something similar, but never implemented it fully.

Basically, a Django view would fire off a Python thread that would run
the script, and report its progress. I chose to use a Django model that
the Python thread would store its progress in. The progress was
monitored by the end user via AJAX. It queried the progress of the job
once a second or so until it was completed. I only implemented a proof
of concept, where the script would only count to 100. Unfortunately, I
didn't save the code. The project I was doing it for was scrapped. The
proof of concept code was fairly easy to implement. I think it'd fit
your bill.

If you aren't familiar with AJAX, I suggest reading a tutorial about how
AJAX works, and then consider using an AJAX library.

Hopefully this gives you a good starting point.


Jeff Anderson



signature.asc
Description: OpenPGP digital signature


Using a HTML to fire off a data processing script on the server (REST or SOAP)

2008-11-20 Thread Shao

Dear ALL,

I am very much interested in using a HTML to fire off a data
processing script to run over the internet.

I will be very grateful if you can advise me on passing parameters
from an HTML form to a script and fire the script off to carry out
full execution, monitor its progress and return an innerHTML with link
(a name string of) the file generated back to allow user to download
the result.

The script run over a period of 2 to 3 minutes.


Necessary are  the following steps:
* user submits data to the server from a web page using an HTML form;
server redirects the browser to a status page that says "script is
running";
* in the background, the server fires off a worker script that does
the job; the server monitors the script to see when it's done (this
monitoring can be tied to the status page: when the user reloads the
status page, the server looks at the script to check if it's done);
* user refreshes the page (or the page refreshes itself) until script
is finished, and the page says "script finished; here are the results"
* some kind of cleanup of data, either with a cron job or manually by
the user

Regards.

Shao

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---