Ciao a tutti,
il problema è semplice ed è descritto nel titolo del topic.
Mi sto dedicando a imparare questo linguaggio e ho creato questo script:
codice:
#! /usr/bin/env python
# -*- coding: utf-8 -*-
#
# License: GNU General Public version 2 or any later version.
# This program comes with ABSOLUTELY NO WARRANTY; for details
# see the COPYING file or visit "http://www.gnu.org/licenses/gpl.html".
# This is free software, and you are welcome to redistribute it under
# certain conditions. See the GPL license for details.
#
# Dependence:
# ImageMagick
# python
# zenity
import os
from sys import argv, exit
from re import search
from commands import getoutput
if len(argv[1:]) == 0:
os.system('zenity --title="gruota" --error --title="Attenzione"\
--text="Seleziona almeno un file."')
exit(1)
livello = getoutput(str('zenity --scale --title="gpng2jpg" --text \
"Qualità di compressione:" --min-value=0 --max-value=100 --value=85 \
--step 1'))
if len(livello) == 0: exit(1)
count = 1
while count < len(argv):
if search(r"\.[pP][nN][gG]$", argv[count]):
imageJPG = str(argv[count].replace("png", "jpg", -1))
print imageJPG
os.system("convert -rotate '"+repr(angolo)+"' \
'"+repr(argv[count])+"' '"+argv[count]+"' \
2>>/tmp/gruota.log")
else:
os.system('echo -e "Attenzione: \''+argv[count]+\
'\' non e\' un png." >>/tmp/gpng2jpg.log')
count = count + 1
if os.path.isfile("/tmp/gpng2jpg.log") and \
os.path.getsize("/tmp/gpng2jpg.log") != 0:
os.system("cat /tmp/gpng2jpg.log | zenity \
--title=Errore - gpng2jpg --text-info")
os.remove("/tmp/gpng2jpg.log")
il comando incriminato è questo:
codice:
os.system("convert -rotate '"+repr(angolo)+"' \
'"+repr(argv[count])+"' '"+argv[count]+"' \
2>>/tmp/gruota.log")
come si può notare è anche quotato; ho usato anche la funzione escape(), ma non ottenuto nessun risultato.
Qualcuno sa darmi un aiuto.