This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git

commit dc4d0a248a682bd40b783d9e141efa5742d13ec9
Author: Dillon Walls <[email protected]>
AuthorDate: Thu Jan 26 20:14:13 2023 +0000

    [#8495] fix DeprecationWarning 'log.warn' - 'log.warning'
---
 Allura/allura/command/taskd.py                       |  2 +-
 Allura/allura/controllers/base.py                    |  2 +-
 Allura/allura/controllers/site_admin.py              |  2 +-
 Allura/allura/lib/app_globals.py                     |  4 ++--
 Allura/allura/lib/macro.py                           |  2 +-
 Allura/allura/lib/repository.py                      |  2 +-
 Allura/allura/lib/solr.py                            |  2 +-
 Allura/allura/model/auth.py                          |  4 ++--
 Allura/allura/model/index.py                         |  4 ++--
 Allura/allura/model/notification.py                  |  2 +-
 Allura/allura/model/project.py                       |  2 +-
 Allura/allura/scripts/delete_projects.py             |  4 ++--
 Allura/allura/tasks/repo_tasks.py                    |  2 +-
 Allura/allura/tests/test_webhooks.py                 |  2 +-
 Allura/allura/webhooks.py                            |  2 +-
 ForgeBlog/forgeblog/command/rssfeeds.py              |  2 +-
 ForgeBlog/forgeblog/main.py                          |  4 ++--
 ForgeGit/forgegit/model/git_repo.py                  |  2 +-
 ForgeImporters/forgeimporters/github/__init__.py     |  4 ++--
 .../forgeimporters/tests/github/test_extractor.py    |  8 ++++----
 ForgeTracker/forgetracker/tracker_main.py            |  2 +-
 ForgeWiki/forgewiki/wiki_main.py                     |  2 +-
 scripts/teamforge-import.py                          | 20 ++++++++++----------
 23 files changed, 41 insertions(+), 41 deletions(-)

diff --git a/Allura/allura/command/taskd.py b/Allura/allura/command/taskd.py
index 6d5bfe861..dc2b173c6 100644
--- a/Allura/allura/command/taskd.py
+++ b/Allura/allura/command/taskd.py
@@ -111,7 +111,7 @@ class TaskdCommand(base.Command):
 
         def start_response(status, headers, exc_info=None):
             if status != '200 OK':
-                log.warn(
+                log.warning(
                     'Unexpected http response from taskd request: %s.  
Headers: %s',
                     status, headers)
 
diff --git a/Allura/allura/controllers/base.py 
b/Allura/allura/controllers/base.py
index 2e859c0bb..68902ab3a 100644
--- a/Allura/allura/controllers/base.py
+++ b/Allura/allura/controllers/base.py
@@ -38,7 +38,7 @@ class BaseController:
     def rate_limit(self, artifact_class, message, redir='..'):
         if artifact_class.is_limit_exceeded(c.app.config, user=c.user):
             msg = f'{message} rate limit exceeded. '
-            log.warn(msg + c.app.config.url())
+            log.warning(msg + c.app.config.url())
             flash(msg + 'Please try again later.', 'error')
             redirect(redir or '/')
 
diff --git a/Allura/allura/controllers/site_admin.py 
b/Allura/allura/controllers/site_admin.py
index 8aa80f246..b9a8f93e8 100644
--- a/Allura/allura/controllers/site_admin.py
+++ b/Allura/allura/controllers/site_admin.py
@@ -161,7 +161,7 @@ class SiteAdminController:
             try:
                 ok = self.subscribe_artifact(url, user)
             except Exception:
-                log.warn("Can't subscribe to artifact", exc_info=True)
+                log.warning("Can't subscribe to artifact", exc_info=True)
                 ok = False
 
             if ok:
diff --git a/Allura/allura/lib/app_globals.py b/Allura/allura/lib/app_globals.py
index 7fe9ffb16..05e1c1920 100644
--- a/Allura/allura/lib/app_globals.py
+++ b/Allura/allura/lib/app_globals.py
@@ -109,7 +109,7 @@ class ForgeMarkdown(markdown.Markdown):
         cache_field_name = field_name + '_cache'
         cache = getattr(artifact, cache_field_name, None)
         if not cache:
-            log.warn(
+            log.warning(
                 'Skipping Markdown caching - Missing cache field "%s" on class 
%s',
                 field_name, artifact.__class__.__name__)
             return self.convert(source_text)
@@ -132,7 +132,7 @@ class ForgeMarkdown(markdown.Markdown):
             threshold = float(threshold) if threshold else None
         except ValueError:
             threshold = None
-            log.warn('Skipping Markdown caching - The value for config param '
+            log.warning('Skipping Markdown caching - The value for config 
param '
                      '"markdown_cache_threshold" must be a float.')
 
         # Check if contains macro and never cache
diff --git a/Allura/allura/lib/macro.py b/Allura/allura/lib/macro.py
index 669d91eff..a4e5b9bc5 100644
--- a/Allura/allura/lib/macro.py
+++ b/Allura/allura/lib/macro.py
@@ -102,7 +102,7 @@ class parse:
             response = macro(**h.encode_keys(args))
             return response
         except (ValueError, TypeError) as ex:
-            log.warn('macro error.  Upwards stack is %s',
+            log.warning('macro error.  Upwards stack is %s',
                      ''.join(traceback.format_stack()),
                      exc_info=True)
             msg = html.escape(f'[[{s}]] ({repr(ex)})')
diff --git a/Allura/allura/lib/repository.py b/Allura/allura/lib/repository.py
index 4617eaef2..494c46772 100644
--- a/Allura/allura/lib/repository.py
+++ b/Allura/allura/lib/repository.py
@@ -155,7 +155,7 @@ class RepositoryApp(Application):
             try:
                 self.repo.push_upstream_context()
             except Exception:
-                log.warn('Could not get upstream repo (perhaps it is gone) 
for: %s %s',
+                log.warning('Could not get upstream repo (perhaps it is gone) 
for: %s %s',
                          self.repo, self.repo.upstream_repo.name, 
exc_info=True)
             else:
                 has_upstream_repo = True
diff --git a/Allura/allura/lib/solr.py b/Allura/allura/lib/solr.py
index 69445c956..79c7f61c5 100644
--- a/Allura/allura/lib/solr.py
+++ b/Allura/allura/lib/solr.py
@@ -163,7 +163,7 @@ class MockSOLR:
             if part in ('&&', 'AND'):
                 continue
             if part in ('||', 'OR'):
-                log.warn(f"MockSOLR doesn't implement OR yet; treating as AND. 
q={q} fq={fq}")
+                log.warning(f"MockSOLR doesn't implement OR yet; treating as 
AND. q={q} fq={fq}")
                 continue
             if ':' in part:
                 field, value = part.split(':', 1)
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index 5b46b49cd..4e3f50e1a 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -637,7 +637,7 @@ class User(MappedClass, ActivityNode, ActivityObject, 
SearchIndexable):
         try:
             private_project = self.private_project()
         except Exception:
-            log.warn('Error getting/creating user-project for %s',
+            log.warning('Error getting/creating user-project for %s',
                      self.username, exc_info=True)
             private_project = None
         icon_source = None
@@ -681,7 +681,7 @@ class User(MappedClass, ActivityNode, ActivityObject, 
SearchIndexable):
         users = [ea.claimed_by_user(not only_confirmed) for ea in addrs]
         users = [u for u in users if u is not None]
         if len(users) > 1:
-            log.warn('Multiple active users matching confirmed email: %s %s. '
+            log.warning('Multiple active users matching confirmed email: %s 
%s. '
                      'Using first one', [u.username for u in users], addr)
         return users[0] if len(users) > 0 else None
 
diff --git a/Allura/allura/model/index.py b/Allura/allura/model/index.py
index 34bf0c015..f3b1852e5 100644
--- a/Allura/allura/model/index.py
+++ b/Allura/allura/model/index.py
@@ -228,9 +228,9 @@ class Shortlink(MappedClass):
 
     @classmethod
     def log_ambiguous_link(cls, msg, matches, *args):
-        log.warn(msg, *args)
+        log.warning(msg, *args)
         for m in matches:
-            log.warn('... %r', m)
+            log.warning('... %r', m)
 
     @classmethod
     def _parse_link(cls, s):
diff --git a/Allura/allura/model/notification.py 
b/Allura/allura/model/notification.py
index f866d490e..d97f86ee3 100644
--- a/Allura/allura/model/notification.py
+++ b/Allura/allura/model/notification.py
@@ -238,7 +238,7 @@ class Notification(MappedClass):
             ''' Catch any errors loading or rendering the template,
             but the notification still gets sent if there is an error
             '''
-            log.warn('Could not render notification template %s' %
+            log.warning('Could not render notification template %s' %
                      artifact.type_s, exc_info=True)
 
         assert d['reply_to_address'] is not None
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index 7e75d30e8..24cd3b470 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -1220,7 +1220,7 @@ class Project(SearchIndexable, MappedClass, ActivityNode, 
ActivityObject):
         try:
             _private = self.private
         except Exception:
-            log.warn(f'Error getting self.private on project 
{self.shortname}', exc_info=True)
+            log.warning(f'Error getting self.private on project 
{self.shortname}', exc_info=True)
             _private = False
         fields = dict(id=self.index_id(),
                       title='Project %s' % self.name,
diff --git a/Allura/allura/scripts/delete_projects.py 
b/Allura/allura/scripts/delete_projects.py
index 3f296857f..374a7237b 100644
--- a/Allura/allura/scripts/delete_projects.py
+++ b/Allura/allura/scripts/delete_projects.py
@@ -59,11 +59,11 @@ class DeleteProjects(ScriptTask):
         n, p = proj.split('/', 1)
         n = M.Neighborhood.query.get(url_prefix=f'/{n}/')
         if not n:
-            log.warn("Can't find neighborhood for %s", proj)
+            log.warning("Can't find neighborhood for %s", proj)
             return
         p = M.Project.query.get(neighborhood_id=n._id, 
shortname=n.shortname_prefix + p)
         if not p:
-            log.warn("Can't find project %s", proj)
+            log.warning("Can't find project %s", proj)
             return
         return p
 
diff --git a/Allura/allura/tasks/repo_tasks.py 
b/Allura/allura/tasks/repo_tasks.py
index e201ac799..e38ea26e7 100644
--- a/Allura/allura/tasks/repo_tasks.py
+++ b/Allura/allura/tasks/repo_tasks.py
@@ -148,7 +148,7 @@ def tarball(revision, path):
                     (c.project.shortname, c.app.config.options.mount_point, 
revision, path), exc_info=True)
                 raise
     else:
-        log.warn(
+        log.warning(
             'Skipped creation of snapshot: %s:%s because revision is not 
specified' %
             (c.project.shortname, c.app.config.options.mount_point))
 
diff --git a/Allura/allura/tests/test_webhooks.py 
b/Allura/allura/tests/test_webhooks.py
index 90523beb8..63935734d 100644
--- a/Allura/allura/tests/test_webhooks.py
+++ b/Allura/allura/tests/test_webhooks.py
@@ -549,7 +549,7 @@ class TestRepoPushWebhookSender(TestWebhookBase):
         with h.push_config(c, app=self.git):
             sender.send(dict(arg1=1, arg2=2))
         assert send_webhook.post.call_count == 0
-        log.warn.assert_called_once_with(
+        log.warning.assert_called_once_with(
             'Webhook fires too often: %s. Skipping', self.wh)
 
     @patch('allura.webhooks.send_webhook', autospec=True)
diff --git a/Allura/allura/webhooks.py b/Allura/allura/webhooks.py
index 4f9e90db4..1ca1e4381 100644
--- a/Allura/allura/webhooks.py
+++ b/Allura/allura/webhooks.py
@@ -443,7 +443,7 @@ class WebhookSender:
                     for payload in payloads:
                         send_webhook.post(webhook._id, payload)
                 else:
-                    log.warn('Webhook fires too often: %s. Skipping', webhook)
+                    log.warning('Webhook fires too often: %s. Skipping', 
webhook)
 
     def enforce_limit(self, app):
         '''
diff --git a/ForgeBlog/forgeblog/command/rssfeeds.py 
b/ForgeBlog/forgeblog/command/rssfeeds.py
index 96c410b39..2e3ed3ad7 100644
--- a/ForgeBlog/forgeblog/command/rssfeeds.py
+++ b/ForgeBlog/forgeblog/command/rssfeeds.py
@@ -108,7 +108,7 @@ class RssFeedsCommand(base.BlogCommand):
         allura_base.log.info(f"Getting {app.url} feed {feed_url}")
         f = feedparser.parse(feed_url)
         if f.bozo:
-            allura_base.log.warn(f"{app.url} feed {feed_url} errored: 
{f.bozo_exception}")
+            allura_base.log.warning(f"{app.url} feed {feed_url} errored: 
{f.bozo_exception}")
             return
         for e in f.entries:
             self.process_entry(e, appid)
diff --git a/ForgeBlog/forgeblog/main.py b/ForgeBlog/forgeblog/main.py
index 43e43f2c7..3e57cd5e9 100644
--- a/ForgeBlog/forgeblog/main.py
+++ b/ForgeBlog/forgeblog/main.py
@@ -622,7 +622,7 @@ class RootRestController(BaseController, 
AppRestControllerMixin):
         if request.method == 'POST':
             require_access(c.app, 'write')
             if BM.BlogPost.is_limit_exceeded(c.app.config, user=c.user):
-                log.warn('Create/edit rate limit exceeded. %s', 
c.app.config.url())
+                log.warning('Create/edit rate limit exceeded. %s', 
c.app.config.url())
                 raise forge_exc.HTTPTooManyRequests()
             post = BM.BlogPost.new(
                 title=title,
@@ -675,7 +675,7 @@ class PostRestController(BaseController):
     def _update_post(self, **post_data):
         require_access(self.post, 'write')
         if BM.BlogPost.is_limit_exceeded(c.app.config, user=c.user):
-            log.warn('Create/edit rate limit exceeded. %s', c.app.config.url())
+            log.warning('Create/edit rate limit exceeded. %s', 
c.app.config.url())
             raise forge_exc.HTTPTooManyRequests()
         if 'delete' in post_data:
             self.post.delete()
diff --git a/ForgeGit/forgegit/model/git_repo.py 
b/ForgeGit/forgegit/model/git_repo.py
index 022995227..148d22c24 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -589,7 +589,7 @@ class GitImplementation(M.RepositoryImplementation):
             threshold = float(threshold) if threshold else None
         except ValueError:
             threshold = None
-            log.warn('Skipping reference caching - The value for config param '
+            log.warning('Skipping reference caching - The value for config 
param '
                      '"repo_refs_cache_threshold" must be a float.')
 
         if threshold is not None and time_taken > threshold:
diff --git a/ForgeImporters/forgeimporters/github/__init__.py 
b/ForgeImporters/forgeimporters/github/__init__.py
index 9fd2cadca..2bf1b6173 100644
--- a/ForgeImporters/forgeimporters/github/__init__.py
+++ b/ForgeImporters/forgeimporters/github/__init__.py
@@ -96,7 +96,7 @@ class GitHubProjectExtractor(base.ProjectExtractor):
         limit = headers.get('X-RateLimit-Limit')
         reset = datetime.utcfromtimestamp(int(reset))
         now = datetime.utcnow()
-        log.warn('Rate limit exceeded (%s requests/hour). '
+        log.warning('Rate limit exceeded (%s requests/hour). '
                  'Sleeping until %s UTC' % (limit, reset))
         time.sleep((reset - now).total_seconds() + 2)
 
@@ -232,7 +232,7 @@ class GitHubOAuthMixin:
         client_id = config.get('github_importer.client_id')
         secret = config.get('github_importer.client_secret')
         if not client_id or not secret:
-            log.warn('github_importer.* not set up in .ini file; cannot use 
OAuth for GitHub')
+            log.warning('github_importer.* not set up in .ini file; cannot use 
OAuth for GitHub')
             return  # GitHub app is not configured
         access_token = c.user.get_tool_data('GitHubProjectImport', 'token')
         if access_token and valid_access_token(access_token, 
scopes_required=scope):
diff --git a/ForgeImporters/forgeimporters/tests/github/test_extractor.py 
b/ForgeImporters/forgeimporters/tests/github/test_extractor.py
index 3edac5eb3..4d3a022cf 100644
--- a/ForgeImporters/forgeimporters/tests/github/test_extractor.py
+++ b/ForgeImporters/forgeimporters/tests/github/test_extractor.py
@@ -169,20 +169,20 @@ class TestGitHubProjectExtractor(TestCase):
         e.get_page('http://example.com/')
         self.assertEqual(sleep.call_count, 1)
         self.assertEqual(urlopen.call_count, 2)
-        log.warn.assert_called_once_with(
+        log.warning.assert_called_once_with(
             'Rate limit exceeded (10 requests/hour). '
             'Sleeping until 2013-10-25 09:32:02 UTC'
         )
         sleep.reset_mock()
         urlopen.reset_mock()
-        log.warn.reset_mock()
+        log.warning.reset_mock()
         response_ok = BytesIO(b'{}')
         response_ok.info = lambda: {}
         urlopen.side_effect = [response_ok]
         e.get_page('http://example.com/2')
         self.assertEqual(sleep.call_count, 0)
         self.assertEqual(urlopen.call_count, 1)
-        self.assertEqual(log.warn.call_count, 0)
+        self.assertEqual(log.warning.call_count, 0)
 
     @patch('forgeimporters.base.h.urlopen')
     @patch('forgeimporters.github.time.sleep')
@@ -206,7 +206,7 @@ class TestGitHubProjectExtractor(TestCase):
         e.get_page('http://example.com/')
         self.assertEqual(sleep.call_count, 1)
         self.assertEqual(urlopen.call_count, 2)
-        log.warn.assert_called_once_with(
+        log.warning.assert_called_once_with(
             'Rate limit exceeded (10 requests/hour). '
             'Sleeping until 2013-10-25 09:32:02 UTC'
         )
diff --git a/ForgeTracker/forgetracker/tracker_main.py 
b/ForgeTracker/forgetracker/tracker_main.py
index 2bb773ef1..1a93e9166 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -1852,7 +1852,7 @@ class RootRestController(BaseController, 
AppRestControllerMixin):
         require_access(c.app, 'create')
         if TM.Ticket.is_limit_exceeded(c.app.config, user=c.user):
             msg = 'Ticket creation rate limit exceeded. '
-            log.warn(msg + c.app.config.url())
+            log.warning(msg + c.app.config.url())
             raise forge_exc.HTTPTooManyRequests()
         if c.app.globals.milestone_names is None:
             c.app.globals.milestone_names = ''
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index 5d7c1c24d..e7d44c749 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -918,7 +918,7 @@ class PageRestController(BaseController):
             if not self.page:
                 require_access(c.app, 'create')
                 if WM.Page.is_limit_exceeded(c.app.config, user=c.user):
-                    log.warn('Page create/edit rate limit exceeded. %s',
+                    log.warning('Page create/edit rate limit exceeded. %s',
                              c.app.config.url())
                     raise forge_exc.HTTPTooManyRequests()
                 self.page = WM.Page.upsert(title)
diff --git a/scripts/teamforge-import.py b/scripts/teamforge-import.py
index 02ce53f5f..903232477 100644
--- a/scripts/teamforge-import.py
+++ b/scripts/teamforge-import.py
@@ -190,7 +190,7 @@ def save_user(usernames):
             user_data = client.service.getUserData(s, username)
             users[username] = Object(user_data)
             if users[username].status != 'Active':
-                log.warn('user: %s status: %s' %
+                log.warning('user: %s status: %s' %
                          (username, users[username].status))
 
 
@@ -217,12 +217,12 @@ def get_project(project):
         project, project.id + '.json')
 
     if len(groups):
-        log.warn('Project has groups %s' % groups)
+        log.warning('Project has groups %s' % groups)
     for u in admins:
         if not u.status != 'active':
-            log.warn('inactive admin %s' % u)
+            log.warning('inactive admin %s' % u)
         if u.superUser:
-            log.warn('super user admin %s' % u)
+            log.warning('super user admin %s' % u)
 
     save_user(data.createdBy)
     save_user(u.userName for u in admins)
@@ -239,7 +239,7 @@ def get_user(orig_username):
         load_users()
         user = users[orig_username]
         if user.status != 'Active':
-            log.warn(f'Inactive user {orig_username} {user.status}')
+            log.warning(f'Inactive user {orig_username} {user.status}')
 
         if not 3 <= len(user.fullName) <= 32:
             raise Exception('invalid fullName length: %s' % user.fullName)
@@ -637,26 +637,26 @@ def check_unsupported_tools(project):
             continue
         doc_count += 1
     if doc_count:
-        log.warn('Migrating documents is not supported, but found %s docs' %
+        log.warning('Migrating documents is not supported, but found %s docs' %
                  doc_count)
 
     scm = make_client(options.api_url, 'ScmApp')
     for repo in scm.service.getRepositoryList(s, project.id).dataRows:
-        log.warn('Migrating SCM repos is not supported, but found %s' %
+        log.warning('Migrating SCM repos is not supported, but found %s' %
                  repo.repositoryPath)
 
     tasks = make_client(options.api_url, 'TaskApp')
     task_count = len(
         tasks.service.getTaskList(s, project.id, filters=None).dataRows)
     if task_count:
-        log.warn('Migrating tasks is not supported, but found %s tasks' %
+        log.warning('Migrating tasks is not supported, but found %s tasks' %
                  task_count)
 
     tracker = make_client(options.api_url, 'TrackerApp')
     tracker_count = len(
         tracker.service.getArtifactList(s, project.id, filters=None).dataRows)
     if tracker_count:
-        log.warn(
+        log.warning(
             'Migrating trackers is not supported, but found %s tracker 
artifacts' %
             task_count)
 
@@ -849,7 +849,7 @@ def get_homepage_wiki(project):
     elif 'HomePage' in pages:
         homepage = pages.pop('HomePage')
     else:
-        log.warn('did not find homepage')
+        log.warning('did not find homepage')
 
     if homepage:
         save(homepage, project, 'wiki', 'homepage_text.markdown')

Reply via email to