Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #21325 > unrolled thread
| Started by | Shane Neeley <shane.neeley@gmail.com> |
|---|---|
| First post | 2012-03-07 08:58 -0800 |
| Last post | 2012-03-07 22:11 -0800 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
Biologist new to cgi in python Shane Neeley <shane.neeley@gmail.com> - 2012-03-07 08:58 -0800
Re: Biologist new to cgi in python Tim Roberts <timr@probo.com> - 2012-03-07 22:11 -0800
| From | Shane Neeley <shane.neeley@gmail.com> |
|---|---|
| Date | 2012-03-07 08:58 -0800 |
| Subject | Biologist new to cgi in python |
| Message-ID | <28641624.970.1331139509579.JavaMail.geo-discussion-forums@pbcgw3> |
Hi, I would greatly appreciate some help for a beginner to python programming. There is a server here that I am trying to write scripts to access: http://consurf.tau.ac.il/index_full_form_PROT.php I have been able to fill out the form simple in the url like this: Submit_seq = "http://consurf.tau.ac.il/cgi-bin/new_consurf.cgi?Run_Number=NONE&MAX_FILE_SIZE=2000 000&PDB_yes_no=no&MSA_yes_no=no&FASTA_text=%s&MSAp rogram=MAFFT&proteins_DB=UNIREF90&MAX_NUM_HOMOL=15 0&MAX_REDUNDANCY=95&MIN_IDENTITY=35&ITERATIONS=1&E _VALUE=0.0001&Homolog_search_algorithm=BLAST&ALGOR ITHM=Bayes&SUB_MATRIX=JTT&submitForm=Submit" % (text,) The %s after FASTA_text is connected to a variable of which I am looping through many files of text. The major problem I am having now is uploading a file. On that server there is an option to upload a multiple sequence alignment (MSA) when I do that and look at the HTTP headers I see this: Content-Disposition: form-data; name="MSA_yes_no" yes -----------------------------178448449274243042114807987 Content-Disposition: form-data; name="msa_FILE"; filename="MSAfromnakai.ashx.clustalw" Content-Type: application/octet-stream And then below is the text of the file I uploaded. I tried pasting that text into the url for msa_FILE= but it said the URL length was too long for the server. That probably wouldnt work anyway because it needs the file uploaded. Do you have any ideas? Here is the function I am using to insert the variable file text inside the url. Is it even possible to include the upload command in the url? def file_exporter(): path = "/Users/chimpsarehungry/Desktop/MSAtests" MSAtests = os.listdir(path) for MSA in MSAtests: file = os.path.join(path, MSA) MSAread = file Submit_seq = "http://consurf.tau.ac.il/cgi-bin/new_consurf.cgi?Run_Number=NONE&MAX_FILE_SIZE=2000 0000000&PDB_yes_no=no&MSA_yes_no=yes&msa_FILE=%s&f ilename=MSAfromnakai1&msa_SEQNAME=AAV2&Homolog_sea rch_algorithm=BLAST&ALGORITHM=Bayes&SUB_MATRIX=JTT &submitForm=Submit" % (MSAread,) Thank you much. Shane
[toc] | [next] | [standalone]
| From | Tim Roberts <timr@probo.com> |
|---|---|
| Date | 2012-03-07 22:11 -0800 |
| Message-ID | <q4jgl7lfn9a7i3ndqkj2duvi77evaua10q@4ax.com> |
| In reply to | #21325 |
Shane Neeley <shane.neeley@gmail.com> wrote: > >Here is the function I am using to insert the variable file text inside the >url. Is it even possible to include the upload command in the url? No. You are trying to simulate a "GET" request, but files can only be uploaded via a "POST" request of type multiport/form-data. There is a module called "poster" that can do the appropriate encoding for you: http://stackoverflow.com/questions/680305/using-multipartposthandler-to-post-form-data-with-python -- Tim Roberts, timr@probo.com Providenza & Boekelheide, Inc.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web