I want to setup a proxy for openlayers to use so I followed these steps:
Downloaded the proxy.cgi file from the OpenLayers web site:
http://trac.osgeo.org/openlayers/browser/trunk/openlayers/examples/proxy.cgi
Modify the proxy.cgi file to include my domain in the allowedHosts list:
allowedHosts = ['localhost:6901']
Copy the proxy.cgi file to the following folder:
$TOMCAT_PATH$/webapps/yourApp/WEB-INF/cgi/
Modify the file web.xml of your web app by adding the sections below. You find the file at
$TOMCAT_PATH$/webapps/yourApp/WEB-INF/web.xml
Comment: In case the web.xml file doesn’t exist for your webapp, just create it yourself or copy it from another webapp and modify it. (created!)
Comment: the “param-value” for the “executable” parameter has to contain the path to your Python installation. (it does!)
<servlet>
<servlet-name>cgi</servlet-name>
<servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>cgiPathPrefix</param-name>
<param-value>WEB-INF/cgi</param-value>
</init-param>
<init-param>
<param-name>executable</param-name>
<param-value>c:\python25\python.exe</param-value>
</init-param>
<init-param>
<param-name>passShellEnvironment</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>5</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>cgi</servlet-name>
<url-pattern>/cgi-bin/*</url-pattern>
</servlet-mapping>
Modify the file context.xml of your web app by adding the element below. You find the file at $TOMCAT_PATH$/webapps/yourApp/META-INF/context.xml
Restart Tomcat
To use the proxy with OpenLayers, just include this single line into your code:
OpenLayers.ProxyHost = "/yourWebApp/cgi-bin/proxy.cgi?url=";
But when I try to use it like:
/webappname/cgi-bin/proxy.cgi?url=labs.metacarta.com
I get this error:
Some unexpected error occurred. Error text was: list index out of range
I think its related with os.environ["REQUEST_METHOD"] but I dont know how its related ..
You're asking for an environment variable that isn't defined.
You need to either catch and handle the exception or use os.environ.get:
try:
methodq = os.environ["REQUEST_METHOD"]
except KeyError:
methodq = "default value"
Or:
methodq = os.environ.get("REQUEST_METHOD", "default value")
You're submitting :
/webappname/cgi-bin/proxy.cgi?url=labs.metacarta.com
But the proxy.cgi script is trying to do this:
host = url.split("/")[2]
Try http://labs.metacarta.com for your url so proxy.cgi has some slashes to split on, or modify it to parse the url a little smarter.
The answer is: You don't install or use cgi proxy on Tomcat.
cgi is for apache server or IIS that are used as a front-end server. Tomcat may sit behind it. The configuration of Apache is detailed in: http://tomcat.apache.org/tomcat-6.0-doc/proxy-howto.html
Be warned that OpenLayers warns that its proxy.cgi is only an example and may not have good enough check to stop it from being exploited, i.e. it may run some malicious script.
If you are serving your OpenLayers client page on Tomcat alone and it contains layers from other GeoServer or Mapserver, you can use proxy servlet and specify it as:
OpenLayers.ProxyHost = "sevlet URL on the server that served this page";
http://wiki.apache.org/tomcat/ServletProxy
https://svn.openxdata.org/Experimental/openXmapper/trunk/gwt-openlayers-server/src/main/java/org/gwtopenmaps/openlayers/server/GwtOpenLayersProxyServlet.java
There are reverse proxy or rewrite sevlet solutions to it, too. Please Google on these.
Related
I want to parse the following entries in config file:
[Domain1]
DOMAIN_NAME=my_domain1
NM_HOST=myhost1.com
ADMIN_URL=t3://myhost1.com:9001
DOMAIN_DIR=/nasn/app/oracle/admin/domains/mydomain_1/bin
WLS_DIR=/nasampn/app/oracle/product/fmw_api12c
ADMIN_USER=/software/wlst/secure/UPE/mydomain_1/AdminConfig.secure
ADMIN_PASS=/software/wlst/secure/UPE/mydomain_1/AdminKey.secure
NM_PORT=5556
NM_TYPE=SSL
OS_USER=oraamp
[Domain2]
DOMAIN_NAME=mydomain_2
NM_HOST=myhost1.com
ADMIN_URL=t3://myhost1.com:7001
DOMAIN_DIR=/nasn/app/oracle/admin/domains/mydomain_1/bin
WLS_DIR=/nasn/app/oracle/product/fmw_api12c
ADMIN_USER=/software/wlst/secure/UPE/mydomain_2/AdminConfig.secure
ADMIN_PASS=/software/wlst/secure/UPE/mydomain_2/AdminKey.secure
NM_PORT=5556
NM_TYPE=SSL
OS_USER=oraamp
[Domain3]
[Domain4,5,6,7]
for example and for each domain, I need to pass the values to connect to the admin server and stop and start the domain.
How can I parse the values so that I can provide the info for the connect and serverStart arguments
I am new python member and wanted to see why parser I can use to get this info
https://www.ebicus.com/en/blog/how-to-restart-managed-servers-simultaneously-with-wlst/
All you have to do is to install the configparser module in python. You can do that simply by opening the (command promp) on Windows or (terminal) on Linux, then write pip install configparser and your code should work perfectly!!
I'm fairly new to Flask, GAE and the use of API. I'm trying to build a basic Web App that can connect to one of Google's API.
My folder structure looks like this (I've kept it to the main files):
app-webemotions:
-app.yaml
-main.py
-lib
--sentimentanalysis.py
-static
--credential.json
Everything is working but providing the json file for the credentials. My understanding is that there's a couple of ways to do it:
1) Setting up the GOOGLE_APPLICATION_CREDENTIALS environment variable to the destination of my file in app.yaml
2) Requesting the file through my script (sentimentanalysis.py)
Unfortunately, I haven't been able to make any of those work.
Option 1):
In app.yaml I have the line:
env_variables:
GOOGLE_APPLICATION_CREDENTIALS: static/key/credentials.json
I then run my code through dev_appserver.py . and get the following error:
ApplicationDefaultCredentialsError: File static/key/credentials.json (pointed by GOOGLE_APPLICATION_CREDENTIALS environment variable) does not exist!
Option 2):
I have a line of code in my script sentimentanalysis.py:
scope = ['https://www.googleapis.com/auth/cloud-platform']
credentials = ServiceAccountCredentials.from_json_keyfile_name('/static/credentials.json', scope)
And when running the code I get the following error:
raise IOError(errno.EACCES, 'file not accessible', filename)
IOError: [Errno 13] file not accessible: '/static/credentials.json'
INFO 2016-08-06 04:10:51,678 module.py:788] default: "POST /Sentiment-analysis HTTP/1.1" 500 -
Question:
So it looks like regardless of the method I'm using, I'm not able to provide the right path to the JSON file
My question is to know first if any of the above options is the right option and if yes, what am I doing wrong? If they are not the right options, what would you recommend?
Apologies if this has already been asked, I've tried to find an answer for a few hours now and haven't been able to crack it...
Thank you!
If you are running on Google App Engine, then your code automatically has the credentials it needs. Do not set GOOGLE_APPLICATION_CREDENTIALS and do not call .from_json_keyfile_name. Instead, call:
credentials = GoogleCredentials.get_application_default()
As shown here:
https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/bigquery/api/getting_started.py
set GOOGLE_APPLICATION_CREDENTIALS=credentials.json
use this command if you are using cmd
I'm trying to get an .onion website's content to python, a little research showed that 'stem'
and as i am running this tutorial script, or more specifically, when i'm trying to use stem.process.launch_tor_with_config, i get this error:
'tor' isn't available on your system. Maybe it's not in your PATH?
I supposed to have some sort of tor process installed, I got the tor browser bundle and put the /Tor library (with the tor.exe) in it in my path, and it's not helping...
Obviously I'm missing something VERY BASIC, please advise....
Many thanks...
I had the same issue on my Mac. Try specifying exactly where the tor file is located to the tor_cmd parameter:
tor_process = stem.process.launch_tor_with_config(
tor_cmd = '/Applications/TorBrowser.app/Tor/tor.real',
config = { SocksPort': str(SOCKS_PORT),
'ExitNodes': '{ru}',},
init_msg_handler = print_bootstrap_lines,
)
I'm following the Diazo Quickstart instructions . I start the proxy and issue a request, I get a response but I'm not sure the response is what I'm meant to be getting.
The Quickstart reads :
The idea is to run a local webserver that applies the Diazo theme to a
response coming from an existing website, either locally or somewhere
on the internet
... only that seems inconsistent with this part of the proxy.ini contained in the Quickstart guide ...
# Proxy http://diazo.org as the content
[app:content]
use = egg:Paste#proxy
address = http://diazo.org/
suppress_http_headers = accept-encoding
... after seeing that I thought what was going to happen was that the content from diazo.org would be embedded within the theme.html and with the theme.css applied to that content .
What actually happens (as far as I can tell) is that if I request ...
http://localhost:8000
... I receive an unaltered copy of the content at http://diazo.org.
On the other hand if I amend proxy.ini so that the app:content reads as follows ...
# Proxy http://diazo.org as the content
[app:content]
use = egg:Paste#proxy
address = http://python.org/
suppress_http_headers = accept-encoding
I don't get the content of python.org sent to the browser, I get the content of the theme.html file !
The proxy.ini is identical to the once shown in the QuickStart guide except I'm using port 8000 and as mentioned above I've changed the address within the app:content section for the purposes of testing.
So my question is what am I meant to see if I complete the steps in the QuickStart document ? And if it's meant to be a slightly altered version of the diazo.org content (as I suspect) why don't I see the same alterations when I change the target for the proxy ?
modify u rules.xml
<replace css:theme-children="#content" css:content-children=".container" />
I am using pyramid web framework to build a website. I keep getting this warning in chrome console:
Resource interpreted as Font but transferred with MIME type application/octet-stream: "http:static/images/fonts/font.woff".
How do I get rid of this warning message?
I have configured static files to be served using add_static_view
I can think of a way to do this by adding a subscriber function for responses that checks if the path ends in .woff and setting the response header to application/x-font-woff. But it does not look like a clean solution. Is there a way to tell Pyramid to do it through some setting.
Pyramid uses the standard mimetypes module to guess the mimetype based on the extension. It calls:
mimetypes.guess_type(path, strict=False)
The module looks in the Windows registry if on that platform, and in the following locations for mimetype lists:
knownfiles = [
"/etc/mime.types",
"/etc/httpd/mime.types", # Mac OS X
"/etc/httpd/conf/mime.types", # Apache
"/etc/apache/mime.types", # Apache 1
"/etc/apache2/mime.types", # Apache 2
"/usr/local/etc/httpd/conf/mime.types",
"/usr/local/lib/netscape/mime.types",
"/usr/local/etc/httpd/conf/mime.types", # Apache 1.2
"/usr/local/etc/mime.types", # Apache 1.3
]
You can either extend one of those files, or create your own file and add it to the module using the .init() function.
The file format is simple, just list the mimetype, then some whitespace, then a space-separated list of extensions:
application/x-font-woff woff
Simply add this following code where your Pyramid web app gets initialized.
import mimetypes
mimetypes.add_type('application/x-font-woff', '.woff')
For instance, I have added it in my webapp.py file, which gets called the first time the server gets hit with a request.