blob: 790209ce85dbde9b1a90a399efee668646e1afd0 [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
26import cgi, cgitb, os, sys
27cgitb.enable()
28
29# import libs
Rushabh Mehtaa9209432012-05-07 18:00:57 +053030sys.path.append('..')
Rushabh Mehtac8abe5b2012-04-15 22:31:32 +053031
32import conf
33
Rushabh Mehtaa9209432012-05-07 18:00:57 +053034sys.path.append('../lib/py')
Rushabh Mehtac8abe5b2012-04-15 22:31:32 +053035sys.path.append(conf.modules_path)
Rushabh Mehta66ac2b02011-09-05 18:43:09 +053036
37import webnotes
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053038import webnotes.handler
39import webnotes.auth
Rushabh Mehta66ac2b02011-09-05 18:43:09 +053040
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053041def 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 Mehta66ac2b02011-09-05 18:43:09 +053046
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053047 # init request
Rushabh Mehta4167e2f2012-02-06 10:58:48 +010048 try:
49 webnotes.http_request = webnotes.auth.HTTPRequest()
Rushabh Mehtada27db42012-02-28 12:17:08 +010050 return True
Rushabh Mehtaafaac602012-02-14 11:44:13 +053051 except webnotes.AuthenticationError, e:
Rushabh Mehtaa38bbe22012-02-29 10:55:43 +053052 return True
Anand Doshi1ed4ef12012-04-27 15:30:23 +053053 #except webnotes.UnknownDomainError, e:
54 # print "Location: " + (conf.redirect_404)
Rushabh Mehtada27db42012-02-28 12:17:08 +010055 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 Mehta66ac2b02011-09-05 18:43:09 +053069
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053070def respond():
71 import webnotes
72 if 'cmd' in webnotes.form_dict:
73 webnotes.handler.handle()
74 else:
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053075 print "Content-Type: text/html"
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053076 print
Rushabh Mehtaa9209432012-05-07 18:00:57 +053077 print "<html><head><script>window.location.href='index.html';</script></head></html>"
Rushabh Mehta5ede3e82011-09-08 14:16:34 +053078
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053079if __name__=="__main__":
Rushabh Mehtada27db42012-02-28 12:17:08 +010080 if init():
81 respond()