blob: 2b5e2389b6a0b508f73eb579c9a08c96c75eafff [file] [log] [blame]
Rushabh Mehta03e87872012-04-14 15:02:17 +05301#!/usr/bin/env python
Rushabh Mehta3966f1d2012-02-23 12:35:32 +05302
Rushabh Mehta03e87872012-04-14 15:02:17 +05303# Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com)
Rushabh Mehta3966f1d2012-02-23 12:35:32 +05304#
Rushabh Mehta03e87872012-04-14 15:02:17 +05305# MIT License (MIT)
Rushabh Mehta3966f1d2012-02-23 12:35:32 +05306#
Rushabh Mehta03e87872012-04-14 15:02:17 +05307# 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 Mehta3966f1d2012-02-23 12:35:32 +053013#
Rushabh Mehta03e87872012-04-14 15:02:17 +053014# 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 Mehta3966f1d2012-02-23 12:35:32 +053024
Rushabh Mehta66ac2b02011-09-05 18:43:09 +053025
Anand Doshi486f9df2012-07-19 13:40:31 +053026from __future__ import unicode_literals
Rushabh Mehta66ac2b02011-09-05 18:43:09 +053027import cgi, cgitb, os, sys
28cgitb.enable()
29
30# import libs
Rushabh Mehtaa9209432012-05-07 18:00:57 +053031sys.path.append('..')
Rushabh Mehtac8abe5b2012-04-15 22:31:32 +053032
33import conf
34
Rushabh Mehtaa9209432012-05-07 18:00:57 +053035sys.path.append('../lib/py')
Rushabh Mehtac8abe5b2012-04-15 22:31:32 +053036sys.path.append(conf.modules_path)
Rushabh Mehta66ac2b02011-09-05 18:43:09 +053037
38import webnotes
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053039import webnotes.handler
40import webnotes.auth
Rushabh Mehta66ac2b02011-09-05 18:43:09 +053041
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053042def init():
43 # make the form_dict
44 webnotes.form = cgi.FieldStorage(keep_blank_values=True)
45 for key in webnotes.form.keys():
46 webnotes.form_dict[key] = webnotes.form.getvalue(key)
Rushabh Mehta66ac2b02011-09-05 18:43:09 +053047
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053048 # init request
Rushabh Mehta4167e2f2012-02-06 10:58:48 +010049 try:
50 webnotes.http_request = webnotes.auth.HTTPRequest()
Rushabh Mehtada27db42012-02-28 12:17:08 +010051 return True
Rushabh Mehtaafaac602012-02-14 11:44:13 +053052 except webnotes.AuthenticationError, e:
Rushabh Mehtaa38bbe22012-02-29 10:55:43 +053053 return True
Anand Doshi1ed4ef12012-04-27 15:30:23 +053054 #except webnotes.UnknownDomainError, e:
55 # print "Location: " + (conf.redirect_404)
Rushabh Mehtada27db42012-02-28 12:17:08 +010056 except webnotes.SessionStopped, e:
57 if 'cmd' in webnotes.form_dict:
58 webnotes.handler.print_json()
59 else:
60 print "Content-Type: text/html"
61 print
62 print """<html>
63 <body style="background-color: #EEE;">
64 <h3 style="width: 900px; background-color: #FFF; border: 2px solid #AAA; padding: 20px; font-family: Arial; margin: 20px auto">
65 Updating.
66 We will be back in a few moments...
67 </h3>
68 </body>
69 </html>"""
Rushabh Mehta66ac2b02011-09-05 18:43:09 +053070
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053071def respond():
72 import webnotes
73 if 'cmd' in webnotes.form_dict:
74 webnotes.handler.handle()
75 else:
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053076 print "Content-Type: text/html"
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053077 print
Rushabh Mehtaa9209432012-05-07 18:00:57 +053078 print "<html><head><script>window.location.href='index.html';</script></head></html>"
Rushabh Mehta5ede3e82011-09-08 14:16:34 +053079
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053080if __name__=="__main__":
Rushabh Mehtada27db42012-02-28 12:17:08 +010081 if init():
82 respond()