Rushabh Mehta | 03e8787 | 2012-04-14 15:02:17 +0530 | [diff] [blame] | 1 | #!/usr/bin/env python |
Rushabh Mehta | 3966f1d | 2012-02-23 12:35:32 +0530 | [diff] [blame] | 2 | |
Rushabh Mehta | 03e8787 | 2012-04-14 15:02:17 +0530 | [diff] [blame] | 3 | # Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com) |
Rushabh Mehta | 3966f1d | 2012-02-23 12:35:32 +0530 | [diff] [blame] | 4 | # |
Rushabh Mehta | 03e8787 | 2012-04-14 15:02:17 +0530 | [diff] [blame] | 5 | # MIT License (MIT) |
Rushabh Mehta | 3966f1d | 2012-02-23 12:35:32 +0530 | [diff] [blame] | 6 | # |
Rushabh Mehta | 03e8787 | 2012-04-14 15:02:17 +0530 | [diff] [blame] | 7 | # Permission is hereby granted, free of charge, to any person obtaining a |
| 8 | # copy of this software and associated documentation files (the "Software"), |
| 9 | # to deal in the Software without restriction, including without limitation |
| 10 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 11 | # and/or sell copies of the Software, and to permit persons to whom the |
| 12 | # Software is furnished to do so, subject to the following conditions: |
Rushabh Mehta | 3966f1d | 2012-02-23 12:35:32 +0530 | [diff] [blame] | 13 | # |
Rushabh Mehta | 03e8787 | 2012-04-14 15:02:17 +0530 | [diff] [blame] | 14 | # The above copyright notice and this permission notice shall be included in |
| 15 | # all copies or substantial portions of the Software. |
| 16 | # |
| 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, |
| 18 | # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A |
| 19 | # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
| 20 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF |
| 21 | # CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE |
| 22 | # OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 23 | # |
Rushabh Mehta | 3966f1d | 2012-02-23 12:35:32 +0530 | [diff] [blame] | 24 | |
Rushabh Mehta | 66ac2b0 | 2011-09-05 18:43:09 +0530 | [diff] [blame] | 25 | |
| 26 | import cgi, cgitb, os, sys |
| 27 | cgitb.enable() |
| 28 | |
| 29 | # import libs |
Rushabh Mehta | a920943 | 2012-05-07 18:00:57 +0530 | [diff] [blame^] | 30 | sys.path.append('..') |
Rushabh Mehta | c8abe5b | 2012-04-15 22:31:32 +0530 | [diff] [blame] | 31 | |
| 32 | import conf |
| 33 | |
Rushabh Mehta | a920943 | 2012-05-07 18:00:57 +0530 | [diff] [blame^] | 34 | sys.path.append('../lib/py') |
Rushabh Mehta | c8abe5b | 2012-04-15 22:31:32 +0530 | [diff] [blame] | 35 | sys.path.append(conf.modules_path) |
Rushabh Mehta | 66ac2b0 | 2011-09-05 18:43:09 +0530 | [diff] [blame] | 36 | |
| 37 | import webnotes |
Rushabh Mehta | 9ef63f9 | 2012-02-01 14:47:29 +0530 | [diff] [blame] | 38 | import webnotes.handler |
| 39 | import webnotes.auth |
Rushabh Mehta | 66ac2b0 | 2011-09-05 18:43:09 +0530 | [diff] [blame] | 40 | |
Rushabh Mehta | 9ef63f9 | 2012-02-01 14:47:29 +0530 | [diff] [blame] | 41 | def init(): |
| 42 | # make the form_dict |
| 43 | webnotes.form = cgi.FieldStorage(keep_blank_values=True) |
| 44 | for key in webnotes.form.keys(): |
| 45 | webnotes.form_dict[key] = webnotes.form.getvalue(key) |
Rushabh Mehta | 66ac2b0 | 2011-09-05 18:43:09 +0530 | [diff] [blame] | 46 | |
Rushabh Mehta | 9ef63f9 | 2012-02-01 14:47:29 +0530 | [diff] [blame] | 47 | # init request |
Rushabh Mehta | 4167e2f | 2012-02-06 10:58:48 +0100 | [diff] [blame] | 48 | try: |
| 49 | webnotes.http_request = webnotes.auth.HTTPRequest() |
Rushabh Mehta | da27db4 | 2012-02-28 12:17:08 +0100 | [diff] [blame] | 50 | return True |
Rushabh Mehta | afaac60 | 2012-02-14 11:44:13 +0530 | [diff] [blame] | 51 | except webnotes.AuthenticationError, e: |
Rushabh Mehta | a38bbe2 | 2012-02-29 10:55:43 +0530 | [diff] [blame] | 52 | return True |
Anand Doshi | 1ed4ef1 | 2012-04-27 15:30:23 +0530 | [diff] [blame] | 53 | #except webnotes.UnknownDomainError, e: |
| 54 | # print "Location: " + (conf.redirect_404) |
Rushabh Mehta | da27db4 | 2012-02-28 12:17:08 +0100 | [diff] [blame] | 55 | except webnotes.SessionStopped, e: |
| 56 | if 'cmd' in webnotes.form_dict: |
| 57 | webnotes.handler.print_json() |
| 58 | else: |
| 59 | print "Content-Type: text/html" |
| 60 | print |
| 61 | print """<html> |
| 62 | <body style="background-color: #EEE;"> |
| 63 | <h3 style="width: 900px; background-color: #FFF; border: 2px solid #AAA; padding: 20px; font-family: Arial; margin: 20px auto"> |
| 64 | Updating. |
| 65 | We will be back in a few moments... |
| 66 | </h3> |
| 67 | </body> |
| 68 | </html>""" |
Rushabh Mehta | 66ac2b0 | 2011-09-05 18:43:09 +0530 | [diff] [blame] | 69 | |
Rushabh Mehta | 9ef63f9 | 2012-02-01 14:47:29 +0530 | [diff] [blame] | 70 | def respond(): |
| 71 | import webnotes |
| 72 | if 'cmd' in webnotes.form_dict: |
| 73 | webnotes.handler.handle() |
| 74 | else: |
Rushabh Mehta | 9ef63f9 | 2012-02-01 14:47:29 +0530 | [diff] [blame] | 75 | print "Content-Type: text/html" |
Rushabh Mehta | 9ef63f9 | 2012-02-01 14:47:29 +0530 | [diff] [blame] | 76 | print |
Rushabh Mehta | a920943 | 2012-05-07 18:00:57 +0530 | [diff] [blame^] | 77 | print "<html><head><script>window.location.href='index.html';</script></head></html>" |
Rushabh Mehta | 5ede3e8 | 2011-09-08 14:16:34 +0530 | [diff] [blame] | 78 | |
Rushabh Mehta | 9ef63f9 | 2012-02-01 14:47:29 +0530 | [diff] [blame] | 79 | if __name__=="__main__": |
Rushabh Mehta | da27db4 | 2012-02-28 12:17:08 +0100 | [diff] [blame] | 80 | if init(): |
| 81 | respond() |