1 # -*- coding: utf-8 -*-
3 # ------------------------------------------------------------
4 # directly start the browsing
6 # Autor: Oliver Maurhart, <oliver.maurhart@ait.ac.at>
7 # Mihai Bartha, <mihai.bartha@ait.ac.at>
9 # Copyright 2013-2014 X-Net and AIT Austrian Institute of Technology
16 # https://www.x-net.at
18 # AIT Austrian Institute of Technology
19 # Donau City Strasse 1
22 # http://www.ait.ac.at
25 # Licensed under the Apache License, Version 2.0 (the "License");
26 # you may not use this file except in compliance with the License.
27 # You may obtain a copy of the License at
29 # http://www.apache.org/licenses/LICENSE-2.0
31 # Unless required by applicable law or agreed to in writing, software
32 # distributed under the License is distributed on an "AS IS" BASIS,
33 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
34 # See the License for the specific language governing permissions and
35 # limitations under the License.
36 # ------------------------------------------------------------
39 # ------------------------------------------------------------
46 from PyQt4 import QtCore
47 from PyQt4 import QtGui
50 import __init__ as opensecurity
53 if sys.platform == 'win32' or sys.platform == 'cygwin':
54 from cygwin import Cygwin
57 # ------------------------------------------------------------
62 if __name__ == "__main__":
64 if not (sys.platform == 'win32' or sys.platform == 'cygwin'):
65 QtGui.QMessageBox.critical(None, 'OpenSecurity Error', 'This action is not supported on this platform.\nSorry.')
70 # get a proper browsing VM
73 proxy_support = urllib2.ProxyHandler({})
74 opener = urllib2.build_opener(proxy_support)
75 urllib2.install_opener(opener)
78 proxy = proxy_getter.getProxySettings()
80 req_data = '?' + urllib.urlencode(proxy)
81 req = 'http://127.0.0.1:8080/browsing'+ req_data
82 browsing_vm = urllib2.urlopen(req).readline()
83 print('Called '+ req + ' got: ' + str(browsing_vm))
87 QtGui.QApplication.instance().processEvents()
88 QtGui.QMessageBox.critical(None, 'Failed to invoke Safe Internet Browsing', 'OpenSecurity Error')