Mercurial > hg
view contrib/phab-clean.py @ 45755:8ed69bd42f10 stable
demandimport: don't raise AttributeError if `exec_module` is missing
I assume this was meant to do the check gracefully. After shoveling a bunch of
modules into the ignore list in order to get keyring to work out of the box on
CentOS 8, I hit the following error accessing the password, which the change
fixes. Now the SecretStorage backend works out of the box, without any edits to
the ignore list.
** Unknown exception encountered with possibly-broken third-party extension mercurial_keyring
** which supports versions unknown of Mercurial.
** Please disable mercurial_keyring and try your action again.
** If that fixes the bug please report it to https://foss.heptapod.net/mercurial/mercurial_keyring/issues
** Python 3.6.8 (default, Apr 16 2020, 01:36:27) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]
** Mercurial Distributed SCM (version 5.5.2)
** Extensions loaded: evolve, topic, rebase, absorb, mercurial_keyring
Traceback (most recent call last):
File "/home/mharbison/hg_py3.6.8_venv/lib64/python3.6/site-packages/mercurial_keyring.py", line 230, in _read_password_from_keyring
password = keyring.get_password(KEYRING_SERVICE, pwdkey)
File "/home/mharbison/hg_py3.6.8_venv/lib64/python3.6/site-packages/keyring/core.py", line 53, in get_password
return _keyring_backend.get_password(service_name, username)
File "/home/mharbison/hg_py3.6.8_venv/lib64/python3.6/site-packages/keyring/backends/chainer.py", line 51, in get_password
password = keyring.get_password(service, username)
File "/home/mharbison/hg_py3.6.8_venv/lib64/python3.6/site-packages/keyring/backends/SecretService.py", line 79, in get_password
return item.get_secret().decode('utf-8')
File "/home/mharbison/hg_py3.6.8_venv/lib64/python3.6/site-packages/secretstorage/item.py", line 105, in get_secret
decryptor = Cipher(aes, modes.CBC(aes_iv), default_backend()).decryptor()
File "/home/mharbison/hg_py3.6.8_venv/lib64/python3.6/site-packages/cryptography/hazmat/backends/__init__.py", line 15, in default_backend
from cryptography.hazmat.backends.openssl.backend import backend
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "/home/mharbison/hg_py3.6.8_venv/lib64/python3.6/site-packages/hgdemandimport/demandimportpy3.py", line 53, in exec_module
self.loader.exec_module(module)
File "/home/mharbison/hg_py3.6.8_venv/lib64/python3.6/site-packages/cryptography/hazmat/backends/openssl/__init__.py", line 7, in <module>
from cryptography.hazmat.backends.openssl.backend import backend
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "/home/mharbison/hg_py3.6.8_venv/lib64/python3.6/site-packages/hgdemandimport/demandimportpy3.py", line 53, in exec_module
self.loader.exec_module(module)
File "/home/mharbison/hg_py3.6.8_venv/lib64/python3.6/site-packages/cryptography/hazmat/backends/openssl/backend.py", line 14, in <module>
from six.moves import range
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 951, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 894, in _find_spec
File "/home/mharbison/hg_py3.6.8_venv/lib64/python3.6/site-packages/hgdemandimport/demandimportpy3.py", line 117, in find_spec
and getattr(spec.loader, "exec_module")
AttributeError: '_SixMetaPathImporter' object has no attribute 'exec_module'
Differential Revision: https://phab.mercurial-scm.org/D9243
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Thu, 22 Oct 2020 18:38:41 -0400 |
parents | 064eb65d040f |
children | c102b704edb5 |
line wrap: on
line source
#!/usr/bin/env python # # A small script to automatically reject idle Diffs # # you need to set the PHABBOT_USER and PHABBOT_TOKEN environment variable for authentication from __future__ import absolute_import, print_function import datetime import os import sys import phabricator MESSAGE = """There seems to have been no activities on this Diff for the past 3 Months. By policy, we are automatically moving it out of the `need-review` state. Please, move it back to `need-review` without hesitation if this diff should still be discussed. :baymax:need-review-idle: """ PHAB_URL = "https://phab.mercurial-scm.org/api/" USER = os.environ.get("PHABBOT_USER", "baymax") TOKEN = os.environ.get("PHABBOT_TOKEN") NOW = datetime.datetime.now() # 3 months in seconds DELAY = 60 * 60 * 24 * 30 * 3 def get_all_diff(phab): """Fetch all the diff that the need review""" return phab.differential.query( status="status-needs-review", order="order-modified", paths=[('HG', None)], ) def filter_diffs(diffs, older_than): """filter diffs to only keep the one unmodified sin <older_than> seconds""" olds = [] for d in diffs: modified = int(d['dateModified']) modified = datetime.datetime.fromtimestamp(modified) d["idleFor"] = idle_for = NOW - modified if idle_for.total_seconds() > older_than: olds.append(d) return olds def nudge_diff(phab, diff): """Comment on the idle diff and reject it""" diff_id = int(d['id']) phab.differential.createcomment( revision_id=diff_id, message=MESSAGE, action="reject" ) if not USER: print( "not user specified please set PHABBOT_USER and PHABBOT_TOKEN", file=sys.stderr, ) elif not TOKEN: print( "not api-token specified please set PHABBOT_USER and PHABBOT_TOKEN", file=sys.stderr, ) sys.exit(1) phab = phabricator.Phabricator(USER, host=PHAB_URL, token=TOKEN) phab.connect() phab.update_interfaces() print('Hello "%s".' % phab.user.whoami()['realName']) diffs = get_all_diff(phab) print("Found %d Diffs" % len(diffs)) olds = filter_diffs(diffs, DELAY) print("Found %d old Diffs" % len(olds)) for d in olds: diff_id = d['id'] status = d['statusName'] modified = int(d['dateModified']) idle_for = d["idleFor"] msg = 'nudging D%s in "%s" state for %s' print(msg % (diff_id, status, idle_for)) # uncomment to actually affect phab nudge_diff(phab, d)