SourceForge: pyqsum/pyqsum: changeset 2:72b26006b58d
pyqsum4, using combobox instead of list default tip
authorAhmed Youssef <xmonader@gmail.com>
Sun Sep 06 04:04:29 2009 +0200 (2009-09-06)
changeset 272b26006b58d
parent 1 b5212595176c
pyqsum4, using combobox instead of list
pyqsum3/hasherlib.pyc
pyqsum4/aboutdialog.ui
pyqsum4/frm.ui
pyqsum4/hasherlib.py
pyqsum4/hasherlib.pyc
pyqsum4/icons/application-exit.png
pyqsum4/icons/document-open.png
pyqsum4/icons/gtk-about.png
pyqsum4/icons/pyIcon.jpg
pyqsum4/pyqsum4.py
     1.1 Binary file pyqsum3/hasherlib.pyc has changed
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/pyqsum4/aboutdialog.ui	Sun Sep 06 04:04:29 2009 +0200
     2.3 @@ -0,0 +1,111 @@
     2.4 +<?xml version="1.0" encoding="UTF-8"?>
     2.5 +<ui version="4.0">
     2.6 + <class>dlgAbout</class>
     2.7 + <widget class="QDialog" name="dlgAbout">
     2.8 +  <property name="geometry">
     2.9 +   <rect>
    2.10 +    <x>0</x>
    2.11 +    <y>0</y>
    2.12 +    <width>381</width>
    2.13 +    <height>473</height>
    2.14 +   </rect>
    2.15 +  </property>
    2.16 +  <property name="windowTitle">
    2.17 +   <string>About</string>
    2.18 +  </property>
    2.19 +  <property name="modal">
    2.20 +   <bool>true</bool>
    2.21 +  </property>
    2.22 +  <layout class="QVBoxLayout" name="verticalLayout_2">
    2.23 +   <item>
    2.24 +    <widget class="QLabel" name="label">
    2.25 +     <property name="text">
    2.26 +      <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
    2.27 +&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
    2.28 +p, li { white-space: pre-wrap; }
    2.29 +&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
    2.30 +&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:14pt; font-weight:600;&quot;&gt;PyQSum&lt;/span&gt;&lt;/p&gt;
    2.31 +&lt;p align=&quot;center&quot; style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-weight:600;&quot;&gt;&lt;/p&gt;
    2.32 +&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;PyQSum&lt;/span&gt; is a&lt;span style=&quot; font-weight:600;&quot;&gt; &lt;/span&gt;tool for computing message digests(md5, sha1, sha224, sha256. sha384, sha512)&lt;/p&gt;
    2.33 +&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;/p&gt;
    2.34 +&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Copyright (c) 2006-2009 Ahmed Youssef &amp;lt;xmonader@gmail.com&amp;gt;&lt;/p&gt;
    2.35 +&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;a href=&quot;http://programming-fr34ks.net&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;http://programming-fr34ks.net&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
    2.36 +&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; text-decoration: underline; color:#0000ff;&quot;&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
    2.37 +     </property>
    2.38 +     <property name="wordWrap">
    2.39 +      <bool>true</bool>
    2.40 +     </property>
    2.41 +     <property name="openExternalLinks">
    2.42 +      <bool>true</bool>
    2.43 +     </property>
    2.44 +    </widget>
    2.45 +   </item>
    2.46 +   <item>
    2.47 +    <widget class="QTabWidget" name="tabWidget">
    2.48 +     <property name="currentIndex">
    2.49 +      <number>0</number>
    2.50 +     </property>
    2.51 +     <widget class="QWidget" name="tabLicense">
    2.52 +      <attribute name="title">
    2.53 +       <string>License</string>
    2.54 +      </attribute>
    2.55 +      <layout class="QVBoxLayout" name="verticalLayout">
    2.56 +       <item>
    2.57 +        <widget class="QPlainTextEdit" name="plainTextEdit">
    2.58 +         <property name="enabled">
    2.59 +          <bool>true</bool>
    2.60 +         </property>
    2.61 +         <property name="plainText">
    2.62 +          <string>This program is free software; you can redistribute it and/or modify
    2.63 +it under the terms of the GNU General Public License as published by
    2.64 +the Free Software Foundation; either version 2 of the License, or
    2.65 +(at your option) any later version.
    2.66 +
    2.67 +This program is distributed in the hope that it will be useful,
    2.68 +but WITHOUT ANY WARRANTY; without even the implied warranty of
    2.69 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    2.70 +GNU General Public License for more details.
    2.71 +
    2.72 +You should have received a copy of the GNU General Public License
    2.73 +along with this program; if not, write to the Free Software
    2.74 +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
    2.75 +MA 02110-1301, USA.</string>
    2.76 +         </property>
    2.77 +        </widget>
    2.78 +       </item>
    2.79 +      </layout>
    2.80 +     </widget>
    2.81 +    </widget>
    2.82 +   </item>
    2.83 +   <item>
    2.84 +    <widget class="QDialogButtonBox" name="buttonBox">
    2.85 +     <property name="enabled">
    2.86 +      <bool>true</bool>
    2.87 +     </property>
    2.88 +     <property name="standardButtons">
    2.89 +      <set>QDialogButtonBox::Ok</set>
    2.90 +     </property>
    2.91 +    </widget>
    2.92 +   </item>
    2.93 +  </layout>
    2.94 + </widget>
    2.95 + <resources/>
    2.96 + <connections>
    2.97 +  <connection>
    2.98 +   <sender>buttonBox</sender>
    2.99 +   <signal>accepted()</signal>
   2.100 +   <receiver>dlgAbout</receiver>
   2.101 +   <slot>accept()</slot>
   2.102 +   <hints>
   2.103 +    <hint type="sourcelabel">
   2.104 +     <x>190</x>
   2.105 +     <y>446</y>
   2.106 +    </hint>
   2.107 +    <hint type="destinationlabel">
   2.108 +     <x>190</x>
   2.109 +     <y>236</y>
   2.110 +    </hint>
   2.111 +   </hints>
   2.112 +  </connection>
   2.113 + </connections>
   2.114 +</ui>
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/pyqsum4/frm.ui	Sun Sep 06 04:04:29 2009 +0200
     3.3 @@ -0,0 +1,207 @@
     3.4 +<?xml version="1.0" encoding="UTF-8"?>
     3.5 +<ui version="4.0">
     3.6 + <class>MainWindow</class>
     3.7 + <widget class="QMainWindow" name="MainWindow">
     3.8 +  <property name="geometry">
     3.9 +   <rect>
    3.10 +    <x>0</x>
    3.11 +    <y>0</y>
    3.12 +    <width>464</width>
    3.13 +    <height>177</height>
    3.14 +   </rect>
    3.15 +  </property>
    3.16 +  <property name="windowTitle">
    3.17 +   <string>PyQSum</string>
    3.18 +  </property>
    3.19 +  <property name="windowIcon">
    3.20 +   <iconset>
    3.21 +    <normaloff>pyIcon.jpg</normaloff>pyIcon.jpg</iconset>
    3.22 +  </property>
    3.23 +  <property name="whatsThis">
    3.24 +   <string>&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
    3.25 +p, li { white-space: pre-wrap; }
    3.26 +&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
    3.27 +&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;PyQSum: Program that calculates most of known sumS&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
    3.28 +  </property>
    3.29 +  <widget class="QWidget" name="centralwidget">
    3.30 +   <layout class="QGridLayout" name="gridLayout">
    3.31 +    <item row="0" column="0">
    3.32 +     <widget class="QPushButton" name="btnBrowse">
    3.33 +      <property name="toolTip">
    3.34 +       <string>&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
    3.35 +p, li { white-space: pre-wrap; }
    3.36 +&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
    3.37 +&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;&quot;&gt;Browse for a &lt;span style=&quot; font-weight:600;&quot;&gt;file&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
    3.38 +      </property>
    3.39 +      <property name="text">
    3.40 +       <string>Browse</string>
    3.41 +      </property>
    3.42 +     </widget>
    3.43 +    </item>
    3.44 +    <item row="0" column="1">
    3.45 +     <widget class="QLineEdit" name="lineEditFilePath">
    3.46 +      <property name="toolTip">
    3.47 +       <string>&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
    3.48 +p, li { white-space: pre-wrap; }
    3.49 +&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
    3.50 +&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;&quot;&gt;File path&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
    3.51 +      </property>
    3.52 +     </widget>
    3.53 +    </item>
    3.54 +    <item row="0" column="2">
    3.55 +     <widget class="QComboBox" name="cboSums">
    3.56 +      <item>
    3.57 +       <property name="text">
    3.58 +        <string>md5</string>
    3.59 +       </property>
    3.60 +      </item>
    3.61 +      <item>
    3.62 +       <property name="text">
    3.63 +        <string>sha1</string>
    3.64 +       </property>
    3.65 +      </item>
    3.66 +      <item>
    3.67 +       <property name="text">
    3.68 +        <string>sha224</string>
    3.69 +       </property>
    3.70 +      </item>
    3.71 +      <item>
    3.72 +       <property name="text">
    3.73 +        <string>sha256</string>
    3.74 +       </property>
    3.75 +      </item>
    3.76 +      <item>
    3.77 +       <property name="text">
    3.78 +        <string>sha384</string>
    3.79 +       </property>
    3.80 +      </item>
    3.81 +      <item>
    3.82 +       <property name="text">
    3.83 +        <string>sha512</string>
    3.84 +       </property>
    3.85 +      </item>
    3.86 +     </widget>
    3.87 +    </item>
    3.88 +    <item row="0" column="3">
    3.89 +     <widget class="QSplitter" name="splitter">
    3.90 +      <property name="orientation">
    3.91 +       <enum>Qt::Horizontal</enum>
    3.92 +      </property>
    3.93 +      <widget class="QPushButton" name="btnCalculate">
    3.94 +       <property name="toolTip">
    3.95 +        <string>&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
    3.96 +p, li { white-space: pre-wrap; }
    3.97 +&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
    3.98 +&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Calculate&lt;/span&gt; the hash&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
    3.99 +       </property>
   3.100 +       <property name="text">
   3.101 +        <string>Calculate</string>
   3.102 +       </property>
   3.103 +      </widget>
   3.104 +     </widget>
   3.105 +    </item>
   3.106 +    <item row="1" column="0" colspan="4">
   3.107 +     <widget class="QTextEdit" name="txtHash">
   3.108 +      <property name="enabled">
   3.109 +       <bool>true</bool>
   3.110 +      </property>
   3.111 +      <property name="toolTip">
   3.112 +       <string>&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
   3.113 +p, li { white-space: pre-wrap; }
   3.114 +&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
   3.115 +&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Generated Hash&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
   3.116 +      </property>
   3.117 +     </widget>
   3.118 +    </item>
   3.119 +   </layout>
   3.120 +  </widget>
   3.121 +  <widget class="QMenuBar" name="menuBar">
   3.122 +   <property name="geometry">
   3.123 +    <rect>
   3.124 +     <x>0</x>
   3.125 +     <y>0</y>
   3.126 +     <width>464</width>
   3.127 +     <height>28</height>
   3.128 +    </rect>
   3.129 +   </property>
   3.130 +   <widget class="QMenu" name="menu_File">
   3.131 +    <property name="title">
   3.132 +     <string>&amp;File</string>
   3.133 +    </property>
   3.134 +    <addaction name="actionOpen"/>
   3.135 +    <addaction name="separator"/>
   3.136 +    <addaction name="actionQuit"/>
   3.137 +   </widget>
   3.138 +   <widget class="QMenu" name="menuHelp">
   3.139 +    <property name="title">
   3.140 +     <string>&amp;Help</string>
   3.141 +    </property>
   3.142 +    <addaction name="actionAbout"/>
   3.143 +   </widget>
   3.144 +   <addaction name="menu_File"/>
   3.145 +   <addaction name="menuHelp"/>
   3.146 +  </widget>
   3.147 +  <action name="actionOpen">
   3.148 +   <property name="icon">
   3.149 +    <iconset>
   3.150 +     <normaloff>icons/document-open.png</normaloff>icons/document-open.png</iconset>
   3.151 +   </property>
   3.152 +   <property name="text">
   3.153 +    <string>Open</string>
   3.154 +   </property>
   3.155 +  </action>
   3.156 +  <action name="actionQuit">
   3.157 +   <property name="icon">
   3.158 +    <iconset>
   3.159 +     <normaloff>icons/application-exit.png</normaloff>icons/application-exit.png</iconset>
   3.160 +   </property>
   3.161 +   <property name="text">
   3.162 +    <string>Quit</string>
   3.163 +   </property>
   3.164 +  </action>
   3.165 +  <action name="actionAbout">
   3.166 +   <property name="icon">
   3.167 +    <iconset>
   3.168 +     <normaloff>icons/gtk-about.png</normaloff>icons/gtk-about.png</iconset>
   3.169 +   </property>
   3.170 +   <property name="text">
   3.171 +    <string>About</string>
   3.172 +   </property>
   3.173 +  </action>
   3.174 + </widget>
   3.175 + <resources/>
   3.176 + <connections>
   3.177 +  <connection>
   3.178 +   <sender>actionQuit</sender>
   3.179 +   <signal>triggered()</signal>
   3.180 +   <receiver>MainWindow</receiver>
   3.181 +   <slot>close()</slot>
   3.182 +   <hints>
   3.183 +    <hint type="sourcelabel">
   3.184 +     <x>-1</x>
   3.185 +     <y>-1</y>
   3.186 +    </hint>
   3.187 +    <hint type="destinationlabel">
   3.188 +     <x>247</x>
   3.189 +     <y>98</y>
   3.190 +    </hint>
   3.191 +   </hints>
   3.192 +  </connection>
   3.193 +  <connection>
   3.194 +   <sender>actionOpen</sender>
   3.195 +   <signal>triggered()</signal>
   3.196 +   <receiver>btnBrowse</receiver>
   3.197 +   <slot>click()</slot>
   3.198 +   <hints>
   3.199 +    <hint type="sourcelabel">
   3.200 +     <x>-1</x>
   3.201 +     <y>-1</y>
   3.202 +    </hint>
   3.203 +    <hint type="destinationlabel">
   3.204 +     <x>51</x>
   3.205 +     <y>56</y>
   3.206 +    </hint>
   3.207 +   </hints>
   3.208 +  </connection>
   3.209 + </connections>
   3.210 +</ui>
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/pyqsum4/hasherlib.py	Sun Sep 06 04:04:29 2009 +0200
     4.3 @@ -0,0 +1,143 @@
     4.4 +#!usr/bin/env python
     4.5 +
     4.6 +#       hasherlib.py
     4.7 +#       
     4.8 +#       Copyright 2009 ahmed youssef <xmonader@gmail.com>
     4.9 +#       
    4.10 +#       This program is free software; you can redistribute it and/or modify
    4.11 +#       it under the terms of the GNU General Public License as published by
    4.12 +#       the Free Software Foundation; either version 2 of the License, or
    4.13 +#       (at your option) any later version.
    4.14 +#       
    4.15 +#       This program is distributed in the hope that it will be useful,
    4.16 +#       but WITHOUT ANY WARRANTY; without even the implied warranty of
    4.17 +#       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    4.18 +#       GNU General Public License for more details.
    4.19 +#       
    4.20 +#       You should have received a copy of the GNU General Public License
    4.21 +#       along with this program; if not, write to the Free Software
    4.22 +#       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
    4.23 +#       MA 02110-1301, USA.
    4.24 +
    4.25 +
    4.26 +#import md5
    4.27 +import hashlib as h
    4.28 +from os.path import exists, getsize
    4.29 +from sys import argv
    4.30 +from operator import truediv
    4.31 +
    4.32 +class Hasher(object):
    4.33 +
    4.34 +    def __init__(self, filename=None, bufsize=16192*2, readmode="rb"):
    4.35 +        self.filename=filename
    4.36 +        self.bufsize=bufsize
    4.37 +        self.readmode=readmode
    4.38 +        
    4.39 +    def calculate(self, algString="md5"):
    4.40 +        """Calculate(algorithm) => Returns the hash"""
    4.41 +        self.shash=None
    4.42 +        #print "Calling calculate.."
    4.43 +        if exists(self.filename):
    4.44 +            op=algString.lower()
    4.45 +            if op=="md5":
    4.46 +                self.shash=h.md5()
    4.47 +            elif op=="sha1":
    4.48 +                self.shash=h.sha1()
    4.49 +            elif op=="sha224":
    4.50 +                self.shash=h.sha224()
    4.51 +            elif op=="sha256":
    4.52 +                self.shash=h.sha256()
    4.53 +            elif op=="sha384":
    4.54 +                self.shash=h.sha384()
    4.55 +            elif op=="sha512":
    4.56 +                self.shash=h.sha512()
    4.57 +            else:
    4.58 +                raise ValueError("<%s> is Not Supported"%op)
    4.59 +                
    4.60 +            return self._do()
    4.61 +            
    4.62 +    def _do(self):
    4.63 +        f=open(self.filename, self.readmode)
    4.64 +        try:
    4.65 +            while True:
    4.66 +                data=f.read(self.bufsize)
    4.67 +                if not data:
    4.68 +                    break
    4.69 +                self.shash.update(data)
    4.70 +                yield f.tell() 
    4.71 +                    
    4.72 +        except IOError, ex:
    4.73 +            print ex
    4.74 +                
    4.75 +    def res(self):
    4.76 +        return self.shash.hexdigest() if self.shash is not None else " "
    4.77 +        
    4.78 +    def print_res(self):
    4.79 +        print "Sum: ", self.shash.hexdigest()
    4.80 +    
    4.81 +    def get_size(self):
    4.82 +        if self.filename:
    4.83 +            return getsize(self.filename)
    4.84 +        return None
    4.85 +    # 1  -> 100
    4.86 +    # 2  -> 50
    4.87 +    # 7  -> 700
    4.88 +    def get_step(self, range=100*1000*1000): #bytes
    4.89 +        raise NotImplementedError
    4.90 +        
    4.91 +    @staticmethod
    4.92 +    def get_supported():
    4.93 +        return ["md5", "sha1", "sha224", "sha256", "sha384", "sha512"]
    4.94 +                   
    4.95 +        
    4.96 +XS=0
    4.97 +def callback():
    4.98 +    global XS
    4.99 +    #print "X"
   4.100 +    
   4.101 +    XS+=1
   4.102 +    
   4.103 +def test():
   4.104 +    global XS
   4.105 +    #f="/home/ahmed/ubuntu-9.04-desktop-amd64.iso" #22560 x
   4.106 +   
   4.107 +    f="/home/ahmed/netbeans-6.7rc1-ml-linux.sh" #7621
   4.108 +    #1->100
   4.109 +    # ->700
   4.110 +    h=Hasher(filename=f)
   4.111 +    for x in h.calculate("md5"):
   4.112 +        print x
   4.113 +        callback()
   4.114 +    h.print_res() 
   4.115 +    print "Done with: ", XS
   4.116 +    
   4.117 +def usage():
   4.118 +    return "python hasherlib.py <algorithm> file1 [ file2 ... fileN]"
   4.119 +    
   4.120 +def console_main():
   4.121 +
   4.122 +    try:
   4.123 +        h=Hasher()
   4.124 +        #hasherlib.py algo 
   4.125 +        assert len(argv) > 2
   4.126 +        print argv
   4.127 +        algo=argv[1]
   4.128 +        algo=algo.lower()
   4.129 +        assert algo in Hasher.get_supported()
   4.130 +        for f in argv[2:]:
   4.131 +            print "F: ", f
   4.132 +            #if exists(f):
   4.133 +            h.filename=f
   4.134 +            for x in h.calculate(algo):
   4.135 +                pass
   4.136 +            print h.res(), "\t\t", f 
   4.137 +    except AssertionError, ae:
   4.138 +        print ae
   4.139 +        print usage()
   4.140 +        exit(-1)
   4.141 +        
   4.142 +    
   4.143 +if __name__=="__main__":
   4.144 +    #test()
   4.145 +    console_main()
   4.146 +
     5.1 Binary file pyqsum4/hasherlib.pyc has changed
     6.1 Binary file pyqsum4/icons/application-exit.png has changed
     7.1 Binary file pyqsum4/icons/document-open.png has changed
     8.1 Binary file pyqsum4/icons/gtk-about.png has changed
     9.1 Binary file pyqsum4/icons/pyIcon.jpg has changed
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/pyqsum4/pyqsum4.py	Sun Sep 06 04:04:29 2009 +0200
    10.3 @@ -0,0 +1,94 @@
    10.4 +#!bin/python
    10.5 +
    10.6 +#       pyqsum3.py
    10.7 +#       
    10.8 +#       Copyright 2009 ahmed youssef <xmonader@gmail.com>
    10.9 +#       
   10.10 +#       This program is free software; you can redistribute it and/or modify
   10.11 +#       it under the terms of the GNU General Public License as published by
   10.12 +#       the Free Software Foundation; either version 2 of the License, or
   10.13 +#       (at your option) any later version.
   10.14 +#       
   10.15 +#       This program is distributed in the hope that it will be useful,
   10.16 +#       but WITHOUT ANY WARRANTY; without even the implied warranty of
   10.17 +#       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   10.18 +#       GNU General Public License for more details.
   10.19 +#       
   10.20 +#       You should have received a copy of the GNU General Public License
   10.21 +#       along with this program; if not, write to the Free Software
   10.22 +#       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
   10.23 +#       MA 02110-1301, USA.
   10.24 +
   10.25 +
   10.26 +import sys
   10.27 +from hasherlib import Hasher
   10.28 +from PyQt4 import QtCore, QtGui, uic
   10.29 +
   10.30 +class AboutDialog(QtGui.QDialog):
   10.31 +    
   10.32 +    def __init__(self, *args):
   10.33 +        QtGui.QDialog.__init__(self, *args)
   10.34 +        uic.loadUi("aboutdialog.ui", self)
   10.35 +        
   10.36 +class PyQSumWindow(QtGui.QMainWindow):#, Ui_MainWindow):
   10.37 +    
   10.38 +    def __init__(self):
   10.39 +        QtGui.QMainWindow.__init__(self)
   10.40 +        uic.loadUi("frm.ui", self)
   10.41 +        
   10.42 +        #self.setupUi(self)
   10.43 +        self.filename=None
   10.44 +        self.option=None
   10.45 +        self.hasher=Hasher()
   10.46 +        self.connect(self.btnBrowse, QtCore.SIGNAL('clicked()'), self.__setFileName)
   10.47 +        #self.connect(self.listSums, QtCore.SIGNAL('currentTextChanged(QString)'), self.__setOption) 
   10.48 +        self.connect(self.btnCalculate, QtCore.SIGNAL('clicked()'), self._calculate) 
   10.49 +        self.connect(self.actionAbout, QtCore.SIGNAL('triggered()'), self.__onAbout)
   10.50 +        
   10.51 +    def __onAbout(self):
   10.52 +        aboutdlg=AboutDialog()
   10.53 +        aboutdlg.exec_()
   10.54 +            
   10.55 +    #def __setOption(self):
   10.56 +    #    self.option=str(self.listSums.currentItem().text())
   10.57 +
   10.58 +    def __setFileName(self):
   10.59 +        if sys.platform == 'win32':
   10.60 +            start="C:\\"
   10.61 +        else:
   10.62 +            start=r"/home"
   10.63 +            
   10.64 +        fileName = QtGui.QFileDialog.getOpenFileName(self,
   10.65 +                                         self.tr("File: "),
   10.66 +                                         start,
   10.67 +                                         self.tr("All Files (*);;Text Files (*.txt)"))
   10.68 +        if not fileName.isEmpty():
   10.69 +            self.filename=fileName
   10.70 +            self.lineEditFilePath.setText(self.filename)
   10.71 +            self.lineEditFilePath.setEnabled(False)
   10.72 +            self.hasher.filename=fileName
   10.73 +        
   10.74 +    def _calculate(self):
   10.75 +        self.option=str(self.cboSums.currentText())
   10.76 +        if self.hasher.filename and self.option:
   10.77 +            pd=QtGui.QProgressDialog("Calculating...", "Cancel", 0, 100, self)
   10.78 +            pd.setMinimum(0)
   10.79 +            pd.setMaximum(self.hasher.get_size())
   10.80 +            for x in self.hasher.calculate(self.option):
   10.81 +                QtGui.qApp.processEvents()
   10.82 +                if pd.wasCanceled():
   10.83 +                    return
   10.84 +                pd.setValue(x) #f.tell
   10.85 +                
   10.86 +            self.txtHash.setText(self.hasher.res())
   10.87 +        
   10.88 +    
   10.89 +if __name__=="__main__":       
   10.90 +    app=QtGui.QApplication(sys.argv)
   10.91 +    app.setStyle("Plastique")
   10.92 +
   10.93 +    form=PyQSumWindow()
   10.94 +    form.show()
   10.95 +
   10.96 +    sys.exit(app.exec_())
   10.97 +