OpenSecurity/bin/start_browsing.pyw
changeset 199 26b9a95b0da1
child 238 d33edf5c2717
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/OpenSecurity/bin/start_browsing.pyw	Wed Jun 25 19:21:04 2014 +0200
     1.3 @@ -0,0 +1,70 @@
     1.4 +# -*- coding: utf-8 -*-
     1.5 +
     1.6 +# ------------------------------------------------------------
     1.7 +# directly start the browsing
     1.8 +# 
     1.9 +# Autor: Oliver Maurhart, <oliver.maurhart@ait.ac.at>
    1.10 +#
    1.11 +# Copyright (C) 2013 AIT Austrian Institute of Technology
    1.12 +# AIT Austrian Institute of Technology GmbH
    1.13 +# Donau-City-Strasse 1 | 1220 Vienna | Austria
    1.14 +# http://www.ait.ac.at
    1.15 +#
    1.16 +# This program is free software; you can redistribute it and/or
    1.17 +# modify it under the terms of the GNU General Public License
    1.18 +# as published by the Free Software Foundation version 2.
    1.19 +# 
    1.20 +# This program is distributed in the hope that it will be useful,
    1.21 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.22 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.23 +# GNU General Public License for more details.
    1.24 +# 
    1.25 +# You should have received a copy of the GNU General Public License
    1.26 +# along with this program; if not, write to the Free Software
    1.27 +# Foundation, Inc., 51 Franklin Street, Fifth Floor, 
    1.28 +# Boston, MA  02110-1301, USA.
    1.29 +# ------------------------------------------------------------
    1.30 +
    1.31 +
    1.32 +# ------------------------------------------------------------
    1.33 +# imports
    1.34 +
    1.35 +import sys
    1.36 +import urllib
    1.37 +import urllib2
    1.38 +
    1.39 +from PyQt4 import QtCore
    1.40 +from PyQt4 import QtGui
    1.41 +
    1.42 +# local
    1.43 +import __init__ as opensecurity
    1.44 +
    1.45 +if sys.platform == 'win32' or sys.platform == 'cygwin':
    1.46 +    from cygwin import Cygwin
    1.47 +
    1.48 +
    1.49 +# ------------------------------------------------------------
    1.50 +# code
    1.51 +
    1.52 +
    1.53 +# start
    1.54 +if __name__ == "__main__":
    1.55 +
    1.56 +    if not (sys.platform == 'win32' or sys.platform == 'cygwin'):
    1.57 +        QtGui.QMessageBox.critical(self.parent(), 'OpenSecurity Error', 'This action is not supported on this platform.\nSorry.')
    1.58 +        sys.exit(1)
    1.59 +   
    1.60 +    try:
    1.61 +    
    1.62 +        # get a proper browsing VM
    1.63 +        Cygwin.start_X11()
    1.64 +
    1.65 +        # TODO: HARDCODED ADDRESS OF OPENSECURITYD
    1.66 +        browsing_vm = urllib2.urlopen('http://127.0.0.1:8080/browsing').readline()
    1.67 +        print('Called http://127.0.0.1:8080/browsing got: ' + str(browsing_vm))
    1.68 +        
    1.69 +    except:
    1.70 +        
    1.71 +        QtGui.QApplication.instance().processEvents()
    1.72 +        QtGui.QMessageBox.critical(None, 'Failed to invoke Safe Internet Browsing', 'OpenSecurity Error')
    1.73 +