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