2 # -*- coding: utf-8 -*-
4 # ------------------------------------------------------------
7 # an opensecurity dialog
9 # Autor: Oliver Maurhart, <oliver.maurhart@ait.ac.at>
11 # Copyright (C) 2013 AIT Austrian Institute of Technology
12 # AIT Austrian Institute of Technology GmbH
13 # Donau-City-Strasse 1 | 1220 Vienna | Austria
14 # http://www.ait.ac.at
16 # This program is free software; you can redistribute it and/or
17 # modify it under the terms of the GNU General Public License
18 # as published by the Free Software Foundation version 2.
20 # This program is distributed in the hope that it will be useful,
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 # GNU General Public License for more details.
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write to the Free Software
27 # Foundation, Inc., 51 Franklin Street, Fifth Floor,
28 # Boston, MA 02110-1301, USA.
29 # ------------------------------------------------------------
32 # ------------------------------------------------------------
39 from PyQt4 import QtCore
40 from PyQt4 import QtGui
43 from credentials import Credentials
44 from environment import Environment
45 from password import Password
48 # ------------------------------------------------------------
55 parser = argparse.ArgumentParser(description = 'OpenSecurity Dialog.')
56 parser.add_argument('mode', metavar='MODE', help='dialog mode: \'password\' or \'credentials\'')
57 parser.add_argument('text', metavar='TEXT', help='text to show')
58 args = parser.parse_args()
60 app = QtGui.QApplication(sys.argv)
62 # prebuild the pixmap cache: fetch all jpg, png and jpeg images and load them
63 data_path = Environment("OpenSecurity").data_path
64 image_path = os.path.join(data_path, '..', 'gfx')
65 for file in os.listdir(image_path):
66 if file.lower().rpartition('.')[2] in ('jpg', 'png', 'jpeg'):
67 QtGui.QPixmapCache.insert(file.lower().rpartition('.')[0], QtGui.QPixmap(os.path.join(image_path, file)))
69 # we should have now our application icon
70 app.setWindowIcon(QtGui.QIcon(QtGui.QPixmapCache.find('opensecurity_icon_64')))
72 if args.mode == 'password':
73 dlg = Password(args.text)
75 if args.mode == 'credentials':
76 dlg = Credentials(args.text)
82 # give proper result code
83 if dlg.result() == QtGui.QDialog.Accepted:
91 if __name__ == "__main__":