Error al compilar py en phyton
Estoy tratando de compilar un plugins para Tucan escrito en phyton, pero al compilar me da un error y no sé como solucionarlo
Este es el código: y este es el error que obtengo-.
l@ldebian:~/Desktop/p$ python -O ~/Desktop/p/anonymous_download.py
File "/home/lml/Desktop/p/anonymous_download.py", line 104
Show details Hide details###############################################################################
## Tucan Project
##
## Copyright (C) 2008-2010 Fran Lupion crak@tucaneando.com
## Elie Melois eliemelois@gmail.com
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
###############################################################################
import urllib
import cookielib
import logging
logger = logging.getLogger(__name__)
from core.download_plugin import DownloadPlugin
from core.recaptcha import Recaptcha
from core.url_open import URLOpen
BASE_URL = "http://fileserve.com"
class AnonymousDownload(DownloadPlugin):
""""""
def link_parser(self, url, wait_func, xrange=None):
""""""
try:
file_id = url.split("/")[-1].strip("/")
cookie = cookielib.CookieJar()
opener = URLOpen(cookie)
it = iter(opener.open(url).readlines())
for line in it:
if 'reCAPTCHA_publickey=' in line:
tmp = line.split("'")[1].split("'")[0]
recaptcha_link = "http://www.google.com/recaptcha/api/challenge?k=%s" % tmp
if not wait_func():
return
c = Recaptcha(BASE_URL, recaptcha_link)
for retry in range(3):
challenge, response = c.solve_captcha()
if response:
if not wait_func():
return
#Submit the input to the recaptcha system
form = urllib.urlencode([("recaptcha_challenge_field", challenge), ("recaptcha_response_field", response), ("recaptcha_shortencode_field",file_id)])
url = "%s/checkReCaptcha.php" % BASE_URL
#Captcha is good
if "success" in opener.open(url,form).read():
form = urllib.urlencode([("downloadLink", "wait")])
url = "%s/file/%s" % (BASE_URL,file_id)
wait = int(opener.open(url,form).read())
if not wait_func(wait):
return
form = urllib.urlencode([("downloadLink", "show")])
opener.open(url,form).read()
form = urllib.urlencode([("download", "normal")])
handle = opener.open(url,form)
if not handle.info().getheader("Content-Type") == "text/html":
#Allowed to download
return handle
else:
set_limit_exceeded()
except Exception, e:
logger.exception("%s: %s" % (url, e))
def check_links(self, url):
""""""
name = None
size = -1
unit = None
try:
it = iter(URLOpen().open(url).readlines())
for line in it:
if '"panel file_download"' in line:
it.next()
name = it.next().split(">")[1].split("<")[0]
it.next()
tmp = it.next().split("<strong>")[1].split("<")[0]
unit = tmp[-2:]
size = int(round(float(tmp[:-2])))
if size > 1024:
if unit == "KB":
size = size / 1024
unit = "MB"
break
except Exception, e:
logger.exception("%s :%s" % (url, e))
return name, size, unit
Show details Hide details
Change log
r205 by eliemelois on Oct 30, 2010 Diff
Fileserve port
Go to:
Sign in to write a code review
Older revisions
All revisions of this file
File info
Size: 3484 bytes, 102 lines
View raw file
- Inicie sesión o regístrese para enviar comentarios
- 478 lecturas


como puedes ver al final del archivo
Size: 3484 bytes, 102 lineseste solo tiene 102 lineas, las otras no forman parte del codigo, borra desde la linea 103, o comentalas con '#'.