Esempio n. 1
0
    class __Translator():
        def __init__(self):
            self.dff = QTranslator()

            self.generic = QTranslator()
            self.Conf = Conf()
            self.loadLanguage()

        def loadLanguage(self):
            """ Load DFF translation + a Qt translation file

            FIXME need to check if qt4 directory exists in /usr/share or /usr/local/share
            """

            l1 = self.generic.load('/usr/share/qt4/translations/qt_' +
                                   str(self.Conf.getLanguage()).lower()[:2])
            l2 = self.dff.load(sys.modules['dff.ui.gui'].__path__[0] +
                               "/i18n/Dff_" +
                               str(self.Conf.getLanguage()).lower()[:2])

            return l1 and l2

        def getDFF(self):
            return self.dff

        def getGeneric(self):
            return self.generic
Esempio n. 2
0
File: ui.py Progetto: arxsys/dff-ui
class Usage():
   PROGRAM_USAGE = """DFF\nDigital Forensic Framework\n
Usage: """ + sys.argv[0] + """ [options]
Options:
  -v      --version                  display current version
  -g      --graphical                launch graphical interface
  -b      --batch=FILENAME	     executes batch contained in FILENAME
  -l      --language=LANG            use LANG as interface language
  -h      --help                     display this help message
  -d      --debug                    redirect IO to system console
          --verbosity=LEVEL          set verbosity level when debugging [0-3]
  -c      --config=FILEPATH          use config file from FILEPATH
"""
   VERSION = "1.3.0"

   def __init__(self, argv):
     self.argv = argv
     self.graphical = 0
     self.test = ''
     self.confPath = ''
     self.debug = False
     self.verbosity = 0
     self.batch = None
# Configuration
     self.main()
     self.conf = Conf(self.confPath)
  

   def main(self):
    """Check command line argument"""
    try:
        opts, args = getopt.getopt(self.argv, "vgdht:l:c:b:", [ "version", "graphical",  "debug", "help", "test=", "language=", "verbosity=", "config=", "batch="])
    except getopt.GetoptError:
        self.usage()
    for opt, arg in opts:
        if opt in ("-h", "--help"):
          self.usage()
        elif opt in ("-g", "--graphical"):
          self.graphical = 1
        elif opt in ("-t", "--test"):
          self.test = arg
        elif opt in ("-l", "--language"):
          self.conf.setLanguage(arg[:2])
        elif opt in ("-v", "--version"):
          print "dff version " + self.VERSION
          sys.exit(1)
        elif opt in ("-d", "--debug"):
          self.debug = True
        elif opt == "--verbosity":
          self.verbosity = int(arg)
        elif opt in ("-c", "--config"):
          self.confPath = str(arg)
	elif opt in  ("-b", "--batch"):
	  self.batch = str(arg)
    return

   def usage(self):
    """Show usage"""
    print self.PROGRAM_USAGE
    sys.exit(2)
Esempio n. 3
0
File: ui.py Progetto: kzwkt/dff
 def __init__(self, argv):
     self.argv = argv
     self.graphical = 0
     self.test = ''
     self.confPath = ''
     self.debug = False
     self.verbosity = 0
     self.batch = None
     # Configuration
     self.main()
     self.conf = Conf(self.confPath)
Esempio n. 4
0
    class __Translator():
        def __init__(self):
            self.translators = {}
            self.conf = Conf()
            if hasattr(sys, "frozen"):
                translationPath = os.path.abspath(
                    os.path.join(os.path.dirname(sys.executable),
                                 "resources/i18n"))
                self.addTranslationPath(os.path.join(translationPath, "qt_"))
                self.addTranslationPath(os.path.join(translationPath, "Dff_"))
            else:
                self.addTranslationPath(
                    os.path.join(
                        unicode(
                            QLibraryInfo.location(
                                QLibraryInfo.TranslationsPath)), "qt_"))
                self.addTranslationPath("dff/ui/gui/i18n/Dff_")
            self.loadLanguage()

        def addTranslationPath(self, path):
            translator = QTranslator()
            QCoreApplication.installTranslator(translator)
            self.translators[translator] = path

        def currentLanguage(self):
            return str(self.conf.getLanguage()).lower()[:2]

        def loadLanguage(self, language=None):
            if language == None:
                language = self.currentLanguage()

            for translator in self.translators:
                self.translators[translator] + language
                translator.load(self.translators[translator] + language)
Esempio n. 5
0
 def __init__(self):
     self.translators = {}
     self.conf = Conf()
     if hasattr(sys, "frozen"):
         translationPath = os.path.abspath(
             os.path.join(os.path.dirname(sys.executable),
                          "resources/i18n"))
         self.addTranslationPath(os.path.join(translationPath, "qt_"))
         self.addTranslationPath(os.path.join(translationPath, "Dff_"))
     else:
         self.addTranslationPath(
             os.path.join(
                 unicode(
                     QLibraryInfo.location(
                         QLibraryInfo.TranslationsPath)), "qt_"))
         self.addTranslationPath("dff/ui/gui/i18n/Dff_")
     self.loadLanguage()
Esempio n. 6
0
File: ui.py Progetto: arxsys/dff-ui
   def __init__(self, argv):
     self.argv = argv
     self.graphical = 0
     self.test = ''
     self.confPath = ''
     self.debug = False
     self.verbosity = 0
     self.batch = None
# Configuration
     self.main()
     self.conf = Conf(self.confPath)
Esempio n. 7
0
 def addHelpWidget(self):
     conf = Conf()
     path = conf.docPath
     file = QFile(path)
     if not file.exists(path):
         if path:
             dialog = QMessageBox.warning(
                 self, self.errorLoadingHelp,
                 QString(path) + ": " + self.notAnHelpFile)
         else:
             dialog = QMessageBox.warning(self, self.errorLoadingHelp,
                                          self.noSuchHelpFile)
         return
     self.addDockWidgets(Help(self, path=path), 'help')
Esempio n. 8
0
 def addHelpWidget(self):
     if hasattr(sys, "frozen"):
         path = os.path.abspath(
             os.path.join(os.path.dirname(sys.executable),
                          "resources/docs/dff_doc.qhc"))
     else:
         conf = Conf()
         path = conf.docPath
     file = QFile(path)
     if not file.exists(path):
         if path:
             dialog = QMessageBox.warning(
                 self, self.errorLoadingHelp,
                 QString(path) + ": " + self.notAnHelpFile)
         else:
             dialog = QMessageBox.warning(self, self.errorLoadingHelp,
                                          self.noSuchHelpFile)
         return
     self.addDockWidgets(Help(self, path=path), 'help')
Esempio n. 9
0
    class __Translator():
        def __init__(self):
            self.dff = QTranslator()

            self.generic = QTranslator()
            self.Conf = Conf()
            self.loadLanguage()

        def loadLanguage(self):
            """ Load DFF translation + a Qt translation file

            FIXME need to check if qt4 directory exists in /usr/share or /usr/local/share
            """
            
            l1 = self.generic.load('/usr/share/qt4/translations/qt_' + str(self.Conf.getLanguage()).lower()[:2])
            l2 = self.dff.load(sys.modules['dff.ui.gui'].__path__[0] + "/i18n/Dff_" + str(self.Conf.getLanguage()).lower()[:2])

            return l1 and l2

        def getDFF(self):
            return self.dff
        
        def getGeneric(self):
            return self.generic
Esempio n. 10
0
 def __init__(self):
     self.conf = Conf()
     self.hist = []
     self.wfile = None
     self.current = 0
     self.load()
Esempio n. 11
0
File: ui.py Progetto: kzwkt/dff
class Usage():
    PROGRAM_USAGE = """DFF\nDigital Forensic Framework\n
Usage: """ + sys.argv[0] + """ [options]
Options:
  -v      --version                  display current version
  -g      --graphical                launch graphical interface
  -b      --batch=FILENAME	     executes batch contained in FILENAME
  -l      --language=LANG            use LANG as interface language
  -h      --help                     display this help message
  -d      --debug                    redirect IO to system console
          --verbosity=LEVEL          set verbosity level when debugging [0-3]
  -c      --config=FILEPATH          use config file from FILEPATH
"""
    VERSION = "1.3.0"

    def __init__(self, argv):
        self.argv = argv
        self.graphical = 0
        self.test = ''
        self.confPath = ''
        self.debug = False
        self.verbosity = 0
        self.batch = None
        # Configuration
        self.main()
        self.conf = Conf(self.confPath)

    def main(self):
        """Check command line argument"""
        try:
            opts, args = getopt.getopt(self.argv, "vgdht:l:c:b:", [
                "version", "graphical", "debug", "help", "test=", "language=",
                "verbosity=", "config=", "batch="
            ])
        except getopt.GetoptError:
            self.usage()
        for opt, arg in opts:
            if opt in ("-h", "--help"):
                self.usage()
            elif opt in ("-g", "--graphical"):
                self.graphical = 1
            elif opt in ("-t", "--test"):
                self.test = arg
            elif opt in ("-l", "--language"):
                self.conf.setLanguage(arg[:2])
            elif opt in ("-v", "--version"):
                print "dff version " + self.VERSION
                sys.exit(1)
            elif opt in ("-d", "--debug"):
                self.debug = True
            elif opt == "--verbosity":
                self.verbosity = int(arg)
            elif opt in ("-c", "--config"):
                self.confPath = str(arg)
            elif opt in ("-b", "--batch"):
                self.batch = str(arg)
        return

    def usage(self):
        """Show usage"""
        print self.PROGRAM_USAGE
        sys.exit(2)
Esempio n. 12
0
        def __init__(self):
            self.dff = QTranslator()

            self.generic = QTranslator()
            self.Conf = Conf()
            self.loadLanguage()
Esempio n. 13
0
        def __init__(self):
            self.dff = QTranslator()

            self.generic = QTranslator()
            self.Conf = Conf()
            self.loadLanguage()
Esempio n. 14
0
    def __init__(self, parent = None):
      """ Drives preferences Dialog

      TODO
       - Valide index settings are properly handle by indexer
      """
      
      super(QDialog, self).__init__()
      
      # Set up the user interface from Qt Designer
      self.setupUi(self)
      self.translation()

      # Framework singleton classes
      self.conf = Conf()
      self.translator = Translator()

      # Temporary config, to be validated once submited
      self.tNoFootPrint = self.conf.noFootPrint
      self.tNoHistoryFile = self.conf.noHistoryFile
      self.tWorkPath = self.conf.workingDir
      self.tHistoryFileFullPath = self.conf.historyFileFullPath

      if self.conf.indexEnabled:
          self.tRootIndex = self.conf.root_index
          self.tIndexName = self.conf.index_name
          self.tIndexPath = self.conf.index_path
      else:
          idx = self.tabWidget.indexOf(self.indexTab)
          self.tabWidget.removeTab(idx)
      # Activate preferences from conf values
      self.noFootPrintCheckBox.setChecked(self.conf.noFootPrint)
      self.noHistoryCheckBox.setChecked(self.conf.noHistoryFile)
      self.footprintOrNo()

      self.workingDirPath.setText(self.conf.workingDir)
      self.historyLineEdit.setText(self.conf.historyFileFullPath)
      self.docAndHelpFullPath.setText(self.conf.docPath)
      
      # Populate languages comboBox with available languages, also set to current language
      self.langPopulate()

      # Signals handling
      self.connect(self.noFootPrintCheckBox, SIGNAL("stateChanged(int)"), self.noFootPrintChanged)
      self.connect(self.workingDirBrowse, SIGNAL("clicked()"), self.workDir)
      self.connect(self.historyToolButton, SIGNAL("clicked()"), self.historyDir)
      self.connect(self.noHistoryCheckBox, SIGNAL("stateChanged(int)"), self.historyStateChanged)
      self.connect(self.langComboBox, SIGNAL("currentIndexChanged (const QString&)"), self.langChanged)

      # Help configuration
      self.connect(self.docAndHelpBrowse, SIGNAL("clicked()"), self.helpDir)

      # Show or hide label helpers
      self.globalValid()
      self.helpValid()
      
      if parent:
          self.app = parent.app
      else:
          self.app = None

      # Catch submit to create directories if needed
      self.connect(self.buttonBox, SIGNAL("accepted()"), self.validate)
      self.connect(self.buttonBox, SIGNAL("rejected()"), self.clear)