OpenSecurity/bin/start_browsing.pyw
author Oliver Maurhart <oliver.maurhart@ait.ac.at>
Wed, 25 Jun 2014 19:21:04 +0200
changeset 199 26b9a95b0da1
child 238 d33edf5c2717
permissions -rw-r--r--
explorer button in configuration working
     1 # -*- coding: utf-8 -*-
     2 
     3 # ------------------------------------------------------------
     4 # directly start the browsing
     5 # 
     6 # Autor: Oliver Maurhart, <oliver.maurhart@ait.ac.at>
     7 #
     8 # Copyright (C) 2013 AIT Austrian Institute of Technology
     9 # AIT Austrian Institute of Technology GmbH
    10 # Donau-City-Strasse 1 | 1220 Vienna | Austria
    11 # http://www.ait.ac.at
    12 #
    13 # This program is free software; you can redistribute it and/or
    14 # modify it under the terms of the GNU General Public License
    15 # as published by the Free Software Foundation version 2.
    16 # 
    17 # This program is distributed in the hope that it will be useful,
    18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    20 # GNU General Public License for more details.
    21 # 
    22 # You should have received a copy of the GNU General Public License
    23 # along with this program; if not, write to the Free Software
    24 # Foundation, Inc., 51 Franklin Street, Fifth Floor, 
    25 # Boston, MA  02110-1301, USA.
    26 # ------------------------------------------------------------
    27 
    28 
    29 # ------------------------------------------------------------
    30 # imports
    31 
    32 import sys
    33 import urllib
    34 import urllib2
    35 
    36 from PyQt4 import QtCore
    37 from PyQt4 import QtGui
    38 
    39 # local
    40 import __init__ as opensecurity
    41 
    42 if sys.platform == 'win32' or sys.platform == 'cygwin':
    43     from cygwin import Cygwin
    44 
    45 
    46 # ------------------------------------------------------------
    47 # code
    48 
    49 
    50 # start
    51 if __name__ == "__main__":
    52 
    53     if not (sys.platform == 'win32' or sys.platform == 'cygwin'):
    54         QtGui.QMessageBox.critical(self.parent(), 'OpenSecurity Error', 'This action is not supported on this platform.\nSorry.')
    55         sys.exit(1)
    56    
    57     try:
    58     
    59         # get a proper browsing VM
    60         Cygwin.start_X11()
    61 
    62         # TODO: HARDCODED ADDRESS OF OPENSECURITYD
    63         browsing_vm = urllib2.urlopen('http://127.0.0.1:8080/browsing').readline()
    64         print('Called http://127.0.0.1:8080/browsing got: ' + str(browsing_vm))
    65         
    66     except:
    67         
    68         QtGui.QApplication.instance().processEvents()
    69         QtGui.QMessageBox.critical(None, 'Failed to invoke Safe Internet Browsing', 'OpenSecurity Error')
    70