Page MenuHomePhabricator

imageharvest: on line 78 (urllib.basejoin), basejoin attribute don't exists
Closed, DuplicatePublic

Description

Hello,

I just installed piwikibot (latest stable version), and can't use the imageharvest, with python 3.6.

On the line 78: links.append(urllib.basejoin(url, link)) I get the error on urllib.basejoin saying that basejoin attribute don't exists.

I tried to add (on a userscript):
from six.moves.urllib.parse import urljoin as basejoin

same error

Any idea ?

Thanks

Event Timeline

Restricted Application added subscribers: pywikibot-bugs-list, Aklapper. · View Herald Transcript

Please give the full traceback, the version.py result and your command line which invokes the bot. This could be important for investigation

This bug has been solved already with rPWBCf562036a8c22c6, see T167726. But this isn't part of the stable release yet. I'll submit it soon.

commands

python3 pwb.py scripts imageharvest http://jenny.gb.free.fr/imgupload
then python3 pwb.py scripts/userscripts/imageharvest http://jenny.gb.free.fr/imgupload

Python 3.6.9 on ubuntu 18.04.4 LTS

Note: I added, on top of several files #!/usr/bin/python3.6 (for ex in pwb.py or imageharvest.py)

Is that what you call a full traceback ?

~/bin/core$ **python3 pwb.py imageharvest http://jenny.gb.free.fr/imgupload**

WARNING: /usr/lib/python3.6/importlib/_bootstrap.py:219: ImportWarning: can't resolve package from spec or package, falling back on name and path return f(*args, **kwds)

Python 3.6.9 (default, Apr 18 2020, 01:56:04)
[GCC 8.4.0]

What text should be added at the end of the description of each image from this url?

Traceback (most recent call last):

File "pwb.py", line 390, in <module>
  if not main():
File "pwb.py", line 385, in main
  file_package)
File "pwb.py", line 101, in run_python_file
  main_mod.__dict__)
File "./scripts/userscripts/imageharvest.py", line 160, in <module>
  main()
File "./scripts/userscripts/imageharvest.py", line 154, in main
  run_bot(url, image_url, desc)
File "./scripts/userscripts/imageharvest.py", line 104, in run_bot
  ilinks = get_imagelinks(url)
File "./scripts/userscripts/imageharvest.py", line 78, in get_imagelinks
  links.append(urllib.basejoin(url, link))

AttributeError: module 'urllib' has no attribute 'basejoin'
Found 1 ryzomcommon:en processes running, including this one.
Dropped throttle(s).
Closing network session.
CRITICAL: Exiting due to uncaught exception <class 'AttributeError'>
Network session closed.

python3 pwb.py imageharvest http://jenny.gb.free.fr/imgupload

WARNING: /usr/lib/python3.6/importlib/_bootstrap.py:219: ImportWarning: can't resolve package from spec or package, falling back on name and path return f(*args, **kwds)

Python 3.6.9 (default, Apr 18 2020, 01:56:04)
[GCC 8.4.0]
What text should be added at the end of the description of each image from this url? Rendor on Silan, April 2020
Http response doesn't contain a charset.
Include image http://jenny.gb.free.fr/craftj%20et%20rendor%202020-04-16.png?
([y]es, [N]o, [q]uit): y
Give the description of this image: Craftjenn with Rendors [[category:Lucios Craftjenn]]
Specify a category (or press enter to end adding categories):

WARNING: url as string is deprecated. Use an iterable instead. Found 1 ryzomcommon:en processes running, including this one. The filename on the target wiki will default to: craftj%20et%20rendor%202020-04-16.png Enter a better name, or press enter to accept: The suggested description is: Craftjenn with Rendors [[category:Lucios Craftjenn]]

Rendor on Silan, April 2020

Do you want to change this description? ([y]es, [N]o, [q]uit): n
Uploading file to ryzomcommon:en...
Reading file http://jenny.gb.free.fr/craftj%20et%20rendor%202020-04-16.png

WARNING: /home/jenny/bin/core/pywikibot/specialbots.py:427: DeprecationWarning: URLopener style of invoking requests is deprecated. Use newer urlopen functions/methods file_url = self.read_file_content(file_url)

1 pages read
0 pages written
0 pages skipped
Script terminated by exception:

ERROR: <HTTPError 404: 'Not Found'>: HTTP Error 404: Not Found
Traceback (most recent call last):

File "pwb.py", line 390, in <module>
  if not main():
File "pwb.py", line 385, in main
  file_package)
File "pwb.py", line 101, in run_python_file
  main_mod.__dict__)
File "./scripts/userscripts/imageharvest.py", line 160, in <module>
  main()
File "./scripts/userscripts/imageharvest.py", line 154, in main
  run_bot(url, image_url, desc)
File "./scripts/userscripts/imageharvest.py", line 127, in run_bot
  UploadRobot(image, description=desc).run()
File "/home/jenny/bin/core/pywikibot/specialbots.py", line 473, in run
  return self.upload_file(self.url)
File "/home/jenny/bin/core/pywikibot/tools/__init__.py", line 1790, in wrapper
  return obj(*__args, **__kw)
File "/home/jenny/bin/core/pywikibot/specialbots.py", line 427, in upload_file
  file_url = self.read_file_content(file_url)
File "/home/jenny/bin/core/pywikibot/specialbots.py", line 146, in read_file_content
  infile = uo.open(file_url)
File "/usr/lib/python3.6/urllib/request.py", line 1764, in open
  return getattr(self, name)(url)
File "/usr/lib/python3.6/urllib/request.py", line 1943, in open_http
  return self._open_generic_http(http.client.HTTPConnection, url, data)
File "/usr/lib/python3.6/urllib/request.py", line 1939, in _open_generic_http
  response.status, response.reason, response.msg, data)
File "/usr/lib/python3.6/urllib/request.py", line 1959, in http_error
  return self.http_error_default(url, fp, errcode, errmsg, headers)
File "/usr/lib/python3.6/urllib/request.py", line 1964, in http_error_default
  raise HTTPError(url, errcode, errmsg, headers, None)

urllib.error.HTTPError: HTTP Error 404: Not Found
Dropped throttle(s).
Closing network session.
CRITICAL: Exiting due to uncaught exception <class 'urllib.error.HTTPError'>
Network session closed.

With an other of my website, and without in the command the URL, it's ok !

Thanks a lot D

I have deployed a new stable release. Please update your bot to it. I think this bug is solved with it.

Xqt changed the task status from Open to Stalled.May 8 2020, 4:45 PM