Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] ValueError when using --test-differ #79

Closed
Markus00000 opened this issue Apr 23, 2024 · 2 comments
Closed

[BUG] ValueError when using --test-differ #79

Markus00000 opened this issue Apr 23, 2024 · 2 comments

Comments

@Markus00000
Copy link

Describe the bug.
Using --test-differ as documented online and in webchanges -h results in a ValueError.

$ webchanges -v --test-differ 4
2024-04-23 16:04:03,558 cli[126289157486400] INFO: webchanges: 3.21 Copyright 2020- Mike Borsetti
2024-04-23 16:04:03,558 cli[126289157486400] INFO: CPython: 3.11.8 ('main', 'Feb 12 2024 14:50:05') GCC 13.2.1 20230801
2024-04-23 16:04:03,558 cli[126289157486400] INFO: System: Linux-6.8.7-arch1-1-x86_64-with-glibc2.39
2024-04-23 16:04:03,840 storage[126289157486400] INFO: The configuration file /home/m/.config/webchanges/config.yaml is missing directive(s); the following default values are being used:
database:
  engine: sqlite3
  max_snapshots: 4
display:
  empty-diff: true
  error: true
  new: true
  unchanged: false
footnote: null
report:
  browser:
    enabled: false
  discord:
    colored: true
    embed: true
    enabled: false
    max_message_length: null
    subject: '[webchanges] {count} changes{jobs_files}: {jobs}'
    webhook_url: ''
  email:
    enabled: false
    from: ''
    html: true
    method: smtp
    sendmail:
      path: sendmail
    smtp:
      auth: true
      host: localhost
      insecure_password: ''
      port: 25
      starttls: true
      user: ''
    subject: '[webchanges] {count} changes{jobs_files}: {jobs}'
    to: ''
  html:
    diff: unified
    footer: true
    separate: false
    title: '[webchanges] {count} changes{jobs_files}: {jobs}'
  ifttt:
    enabled: false
    event: ''
    key: ''
  mailgun:
    api_key: ''
    domain: ''
    enabled: false
    from_mail: ''
    from_name: ''
    region: us
    subject: '[webchanges] {count} changes{jobs_files}: {jobs}'
    to: ''
  markdown:
    details: true
    footer: true
    minimal: false
    separate: false
  matrix:
    access_token: ''
    enabled: false
    homeserver: ''
    room_id: ''
  prowl:
    api_key: ''
    application: ''
    enabled: false
    priority: 0
    subject: '[webchanges] {count} changes{jobs_files}: {jobs}'
  pushbullet:
    api_key: ''
    enabled: false
  pushover:
    app: ''
    device: null
    enabled: false
    priority: normal
    sound: spacealarm
    user: ''
  run_command:
    command: ''
    enabled: false
  stdout:
    color: true
    enabled: true
  telegram:
    bot_token: ''
    chat_id: ''
    enabled: false
    silent: false
  text:
    details: true
    footer: true
    line_length: 75
    minimal: false
    separate: false
  tz: null
  webhook:
    enabled: false
    markdown: false
    max_message_length: null
    rich_text: null
    webhook_url: ''
  xmpp:
    enabled: false
    insecure_password: ''
    recipient: ''
    sender: ''
See documentation at https://webchanges.readthedocs.io/en/stable/configuration.html
2024-04-23 16:04:03,840 storage[126289157486400] INFO: Loaded configuration from /home/m/.config/webchanges/config.yaml
2024-04-23 16:04:03,841 storage[126289157486400] INFO: Using sqlite3 3.45.3 database at /home/m/.cache/webchanges/cache.db
2024-04-23 16:04:03,861 storage[126289157486400] INFO: Loaded 67 jobs from [PosixPath('/home/m/.config/webchanges/jobs.yaml')]
Traceback (most recent call last):
  File "/usr/bin/webchanges", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/lib/python3.11/site-packages/webchanges/cli.py", line 392, in main
    urlwatch_command.run()
  File "/usr/lib/python3.11/site-packages/webchanges/command.py", line 1097, in run
    self.handle_actions()
  File "/usr/lib/python3.11/site-packages/webchanges/command.py", line 1034, in handle_actions
    self._exit(self.test_differ(self.urlwatch_config.test_differ))
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/webchanges/command.py", line 478, in test_differ
    job_id, max_diffs_str = arg_test_differ
    ^^^^^^^^^^^^^^^^^^^^^
ValueError: not enough values to unpack (expected 2, got 1)

Supplying the second argument works:

$ webchanges -v --test-differ 4 1

Expected behavior.
Document the second argument. If no second argument is given, diff snapshots 0 and -1. Currently the second argument is [JOB ...]. I expected --test-differ JOB [NUM_DIFFS].

Related: When more diffs are requested than are available, the output is IndexError: list index out of range. Maybe consider catching the exception and output something like No more snapshots found or No more diffs available.

Version info.

$ webchanges --detailed-versions
Software:
• webchanges: 3.21
• CPython: 3.11.8 ('main', 'Feb 12 2024 14:50:05') GCC 13.2.1 20230801
• SQLite: 3.45.3

System:
• Platform: Linux-6.8.7-arch1-1-x86_64-with-glibc2.39, x86_64
• Processor: 
• CPUs (logical): 12
• Free memory: 7.6G physical plus 15.2G swap.
• Free disk '/': 16.3G (23.8%)

Installed PyPi dependencies:
• beautifulsoup4: 4.12.3
• colorama: 0.4.6
• cryptography: 42.0.5
  - cffi: 1.16.0
  - mypy: 1.9.0
  - click: 8.1.7
  - build: 0.10.0
  - bcrypt: 4.1.2
  - certifi: 2024.2.2
• cssselect: 1.2.0
• html2text: 2020.1.16
• html5lib: 1.1
  - webencodings: 0.5.1
• httpx: 0.26.0
  - anyio: 4.3.0
  - certifi: 2024.2.2
  - idna: 3.6
  - sniffio: 1.3.1
• keyring: 25.0.0
  - jaraco.classes: 3.3.1
  - jaraco.functools: 3.7.0
  - jaraco.context: 4.3.0
  - importlib-metadata: 5.1.0
  - SecretStorage: 3.3.3
  - jeepney: 0.8.0
  - shtab: 1.6.5
• lxml: 5.1.0
• markdown2: 2.4.12
• msgpack: 1.0.5
• pdftotext: 2.2.2
• Pillow: 10.3.0
  - coverage: 7.4.1
  - markdown2: 2.4.12
  - packaging: 23.2
  - typing-extensions: 4.10.0
• platformdirs: 4.2.0
• playwright: 1.43.0
  - greenlet: 3.0.3
  - pyee: 11.0.1
• psutil: 5.9.8
• pyyaml: 6.0.1
• requests: 2.31.0
  - charset-normalizer: 3.3.2
  - idna: 3.6
  - urllib3: 1.26.18
  - chardet: 5.2.0
• tzdata: 2024.1
• vobject: 0.9.7
  - python-dateutil: 2.9.0
playwright._impl._errors.Error: BrowserType.launch: Chromium distribution 'chrome' is not found at /opt/google/chrome/chrome
Run "playwright install chrome"
@mborsetti
Copy link
Owner

Thanks for the report, and will fix in the next few hours.

@mborsetti
Copy link
Owner

Fixed in 3.22, just released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants