Closed ecolina closed 10 years ago
Your SiriAPI installation is located in the directory /home/Siri-API, right? Does exist the file proxy.pac there? Normally it is downloaded when you clone the repo.
Yes the proxy.pac file is there.I even tried again as root but no success.
What happens when you try to open the file (using an editor such as nano, vi or gedit)?
I am able to open it.I think I made a mistake when writing the directory on the sever.py.but I don't know how I should write it
I managed to get passed that error now when I call Google Siri terminal returns this:
proxy.pac 192.168.0.103 - - [06/Aug/2014 05:57:07] "GET /proxy.pac HTTP/1.1" 400 -
I am able to open it.I think I made a mistake when writing the directory on the sever.py.but I don't know how I should write it
Which directory do you mean? Normally you don't have to change any directory in the server.py
Thanks I realized that I made a mistake.I restored the orginal sever.py but when I run it get this:
pi@raspberrypi ~ $ sudo python3 /home/Siri-API/server.py File "/home/Siri-API/server.py", line 24 def do_HEAD(self): ^ SyntaxError: invalid character in identifier
That's strange. Can you post the content of server.py in code tags please. You can find the instructions for using code tags here: https://help.github.com/articles/github-flavored-markdown
Which Python version do you use? I remember issues with a python 3 subversion in an earlier issue. Maybe it is again something like in incompatibility error.
Sorry for the delay I had to re install raspbian.Therfore I reinstaled Siri API.Now the server.py runs smothly. Here is the server.py:
import http.server
import socketserver
import threading
import time
import os
from commands import commands
from search import search
######################
# Configuration area #
######################
squid_hostname = "192.168.0.11" # Hostname or IP address of the server which is running squid proxy
squid_port = 3128 # Port of squid (change only if you changed it in squid configuration)
google_domain = ".google.com" # Domain of "the" Google which is opened from your language. Consult readme for more information
keyword = "Siri" # By default this is siri. You can change this to any other (well recognized) keyword, CASE SENSITIVE!!!
######################
os.chdir(os.path.dirname(os.path.abspath(__file__))) # Set working directory to path of server.py
class Handler(http.server.SimpleHTTPRequestHandler):
def do_HEAD(self):
self.send_response(200)
self.send_header("Content-type", "text/html")
self.end_headers()
def do_GET(self):
global squid_hostname
global squid_port
global google_domain
global keyword
parts = self.path.split("?") #Extract requested file and get parameters from path
path = parts[0]
#Extract variables from get parameters
try:
arguments = {}
arguments["q"] = None #Variable for search request. Default None to prevent errors if no search request was started
if (len(parts) > 1):
raw_arguments = parts[1].split("&")
for raw_argument in raw_arguments[:]:
argument = raw_argument.split("=", 1)
arguments[argument[0]] = argument[1]
except:
print ("No get parameters")
print (path)
#Decide wether a search or the style.css was requested
if (path == "/style.css"):
self.document = open('style.css', 'r').read()
self.send_response(200)
self.send_header('Content-type', 'text/html')
self.end_headers()
self.wfile.write(bytes(self.document, "utf-8"))
elif (path == "/proxy.pac"):
self.document = open('proxy.pac', 'r').read()
self.document = self.document.replace('<keyword>', keyword.lower(), 1)
self.document = self.document.replace('<google_domain>', google_domain, 1)
self.document = self.document.replace('<squid_host>', squid_hostname, 1)
self.document = self.document.replace('<squid_port>', str(squid_port), 1)
self.send_response(200)
self.send_header('Content-type', 'x-ns-proxy-autoconfig')
self.end_headers()
self.wfile.write(bytes(self.document, "utf-8"))
elif (arguments["q"] != None):
arguments["q"] = arguments["q"].replace(keyword + '+', '', 1)
arguments["q"] = arguments["q"].replace('+', ' ')
command = commands(self)
search(command).search(arguments["q"])
else:
self.send_response(404)
self.send_header('Content-type', 'text/html')
self.end_headers()
self.wfile.write(bytes('Not found. Please visit <a href="https://github.com/HcDevel/Siri-API/wiki/_pages">https://github.com/HcDevel/Siri-API/wiki/_pages</a>', "utf-8"))
return
port = 3030
print ("Starting Server...")
exception = True
while (exception == True): #Solves trouble in autostart mode (when network isn't ready)
try:
#(Try) to start webserver
httpd = socketserver.TCPServer(('', port), Handler)
threading.Thread(target=httpd.serve_forever).start()
print('Server listening on port ' + str(port) + '...')
exception = False
except:
print ("Error: Webserver can't be started")
time.sleep (1)
input ("Press enter to exit")
print ("Shutting down server ...")
httpd.shutdown()
httpd.server_close()
And terminal shows up this:
pi@raspberrypi /home/Siri-API $ sudo python3 server.py
Starting Server...
Server listening on port 3030...
Press enter to exit/
192.168.0.15 - - [11/Aug/2014 04:45:49] "GET / HTTP/1.1" 404 -
/proxy.pac
192.168.0.15 - - [11/Aug/2014 04:45:51] "GET /proxy.pac HTTP/1.1" 200 -
It`s just like before except that when I try to run Squid I get this:
pi@raspberrypi /home/Siri-API $ sudo /usr/local/squid/sbin/squid -NCd9
2014/08/11 04:56:48| SECURITY NOTICE: auto-converting deprecated "ssl_bump allow <acl>" to "ssl_bump client-first <acl>" which is usually inferior to the newer server-first bumping mode. Update your ssl_bump rules.
2014/08/11 04:56:48| WARNING: auto-converting deprecated "ssl_bump deny <acl>" to "ssl_bump none <acl>". Update your ssl_bump rules.
Thanks for your help
Squid only shows the message because of its configuration. This is no problem but I should upgrade the configuration to prevent future problems
Hi I can start the server but terminal returns this