Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
428 changes: 214 additions & 214 deletions Conteneur_Fichier.py

Large diffs are not rendered by default.

376 changes: 188 additions & 188 deletions Conteneur_OpenXML.py

Large diffs are not rendered by default.

468 changes: 234 additions & 234 deletions Conteneur_Repertoire.py

Large diffs are not rendered by default.

660 changes: 330 additions & 330 deletions Conteneur_Zip.py

Large diffs are not rendered by default.

54 changes: 24 additions & 30 deletions ExeFilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,12 @@ def init_gettext():
try:
gt = gettext.translation("ExeFilter", locale_dir, languages)
# puis on installe la fonction de traduction _():
gt.install(unicode=True)
gt.install()
except:
# en cas d'erreur, on doit quand meme definir _() comme une fonction
# "builtin" qui renvoie la chaine inchangee:
__builtins__._ = lambda text: text
import builtins
builtins._ = lambda text: text
else:
# si la langue est 'fr', on n'utilise aucune traduction:
gettext.NullTranslations().install()
Expand All @@ -192,17 +193,13 @@ def init_gettext():
import os, sys, time, socket, optparse, tempfile, os.path
import threading

# hack to change default encoding to Latin-1 instead of ASCII:
reload(sys)
sys.setdefaultencoding( "latin-1" )

# modules sp�cifiques � Windows:
if sys.platform == 'win32':
try:
import win32api , win32security
except:
raise ImportError, "the pywin32 module is not installed: "\
"see http://sourceforge.net/projects/pywin32"
raise ImportError("the pywin32 module is not installed: "
"see http://sourceforge.net/projects/pywin32")

# modules d'ExeFilter:
from commun import *
Expand Down Expand Up @@ -493,7 +490,7 @@ def init_archivage(politique, taille_src):
if taille_src > politique.parametres['taille_archives'].valeur:
msg = _(u"La taille des fichiers source est superieure a la taille du repertoire d'archivage.")
Journal.error(msg)
raise RuntimeError, msg
raise RuntimeError(msg)

# boucle pour effacer les sous-r�p les plus anciens dans le cas o� il n'y a pas assez
# d'espace disque dans le r�p archivage pour copier les fichiers source
Expand Down Expand Up @@ -523,7 +520,7 @@ def init_archivage(politique, taille_src):
# s'il n'y a plus de sous-r�p archive � effacer, on g�n�re une exception
msg = _(u"repertoire d'archivage deja vide => taille source trop grande")
Journal.error(msg)
raise RuntimeError, msg
raise RuntimeError(msg)



Expand Down Expand Up @@ -621,7 +618,7 @@ def _transfert_not_threadsafe(liste_source, destination, type_transfert="entree"
if pol != None:
if isinstance(pol, Politique.Politique):
p = pol
elif isinstance (pol, [file, str, unicode, list]):
elif isinstance(pol, (str, bytes, list)):
p = Politique.Politique(pol)
# obsolete, to be removed?
elif type_transfert in ("entree", "sortie"):
Expand All @@ -639,7 +636,7 @@ def _transfert_not_threadsafe(liste_source, destination, type_transfert="entree"

# nom des fichiers log = nom de la machine + date et heure du transfert
if logfile == 'auto':
print 'logfile=auto'
print('logfile=auto')
# generate log filename automatically (one per session):
nom_journal_secu = nom_commun + ".log"
# set full path in logs folder:
Expand All @@ -649,7 +646,7 @@ def _transfert_not_threadsafe(liste_source, destination, type_transfert="entree"
logs_folder.makedirs()
path_logfile = (logs_folder / nom_journal_secu).abspath()
elif logfile:
print 'logfile=%s' % logfile
print('logfile=%s' % logfile)
# use provided log filename:
nom_journal_secu = logfile
# set full path directly:
Expand Down Expand Up @@ -743,7 +740,7 @@ def _transfert_not_threadsafe(liste_source, destination, type_transfert="entree"
if taille_src > p.parametres['taille_temp'].valeur:
msg = "La taille des fichiers source est superieure a la taille du repertoire temporaire."
Journal.error(msg)
raise RuntimeError, msg
raise RuntimeError(msg)

# initialisation de l'archivage:
if parametres['archive_after'].valeur:
Expand Down Expand Up @@ -797,7 +794,7 @@ def _transfert_not_threadsafe(liste_source, destination, type_transfert="entree"
elif (blocked>0) and (clean+cleaned == 0):
exitcode = p.parametres['exitcode_blocked'].valeur
else:
raise ValueError, 'Summary values look wrong...'
raise ValueError('Summary values look wrong...')
Journal.debug('Exit code: %d' % exitcode)

Journal.fermer_journal()
Expand Down Expand Up @@ -919,12 +916,12 @@ def scan_string(data, filename=None, content_type=None, policy=None, logfile=Non
elif content_type is not None:
if content_type not in CT_to_ext:
#TODO: here we should return a "blocked" result rather than an exception
raise ValueError, 'Content-type not allowed: "%s"' % content_type
raise ValueError('Content-type not allowed: "%s"' % content_type)
ext = CT_to_ext[content_type]
# use a temporary filename = temp.ext
fname = 'temp'+ext
else:
raise RuntimeError, 'Either filename or content-type is required'
raise RuntimeError('Either filename or content-type is required')
# create a new temporary dir to store the file with its original filename
tempdir = tempfilemgr.newTempDir()
fpath = os.path.join(tempdir, fname)
Expand Down Expand Up @@ -963,12 +960,12 @@ def clean_string(data, filename=None, content_type=None, policy=None, logfile=No
elif content_type is not None:
if content_type not in CT_to_ext:
#TODO: here we should return a "blocked" result rather than an exception
raise ValueError, 'Content-type not allowed: "%s"' % content_type
raise ValueError('Content-type not allowed: "%s"' % content_type)
ext = CT_to_ext[content_type]
# use a temporary filename = temp.ext
fname = 'temp'+ext
else:
raise RuntimeError, 'Either filename or content-type is required'
raise RuntimeError('Either filename or content-type is required')
# create a new temporary dir to store the file with its original filename
tempdir = tempfilemgr.newTempDir()
fpath = os.path.join(tempdir, fname)
Expand Down Expand Up @@ -999,14 +996,11 @@ def clean_string(data, filename=None, content_type=None, policy=None, logfile=No
if __name__ == '__main__':
# si compilation py2exe, il faut fixer ici le codec par d�faut, car il n'y
# a pas de sitecustomize.py:
if hasattr(sys,"setdefaultencoding"):
sys.setdefaultencoding("iso-8859-1")

# Banniere
print "-"*79
print "ExeFilter v%s - %s" % (XF_VERSION, XF_DATE)
print "-"*79
print ""
print("-"*79)
print("ExeFilter v%s - %s" % (XF_VERSION, XF_DATE))
print("-"*79)
print("")

# on cr�e un objet optparse.OptionParser pour analyser la ligne de commande:
op = optparse.OptionParser(usage =
Expand Down Expand Up @@ -1043,8 +1037,8 @@ def clean_string(data, filename=None, content_type=None, policy=None, logfile=No
and options.export_html==''\
and options.nouv_politique=='':
op.print_help()
print ""
print 'Please specify files to be analyzed, and an optional destination.'
print("")
print('Please specify files to be analyzed, and an optional destination.')
## print _("Il faut indiquer les fichiers/repertoires a nettoyer, ainsi qu'une destination.")
sys.exit(parametres['exitcode_error'].valeur)

Expand All @@ -1068,13 +1062,13 @@ def clean_string(data, filename=None, content_type=None, policy=None, logfile=No
# fichier INI:
if options.nouv_politique != '':
pol.ecrire_fichier(options.nouv_politique)
print _('Politique sauvee dans le fichier %s') % options.nouv_politique
print(_('Politique sauvee dans le fichier %s') % options.nouv_politique)
sys.exit()

# si l'option export est active on exporte la politique dans un fichier HTML:
if options.export_html != '':
pol.ecrire_html(options.export_html)
print _('Politique exportee dans le fichier %s') % options.export_html
print(_('Politique exportee dans le fichier %s') % options.export_html)
sys.exit()

# check force_extension option (-f):
Expand Down
Loading