jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/394998 )

Change subject: version.py: Print uname of Toolforge environment
......................................................................


version.py: Print uname of Toolforge environment

Add `get_toolforge_info()` in `pywikibot/version.py` that
intended to get the uname of a Wikimedia Toolforge
environment.

Print the uname of Toolforge environment if the current
environment is in Toolforge.

Bug: T113193
Change-Id: If5d390253dedfb92486a05741c3a7e773c008b2c
---
M pywikibot/version.py
M scripts/version.py
2 files changed, 19 insertions(+), 1 deletion(-)

Approvals:
  jenkins-bot: Verified
  Xqt: Looks good to me, approved
  Zoranzoki21: Looks good to me, but someone else must approve



diff --git a/pywikibot/version.py b/pywikibot/version.py
index f20209e..6c62ab5 100644
--- a/pywikibot/version.py
+++ b/pywikibot/version.py
@@ -16,6 +16,7 @@
 import datetime
 import json
 import os
+import socket
 import subprocess
 import sys
 import time
@@ -56,6 +57,18 @@
     return _program_dir
 
 
+def get_toolforge_hostname():
+    """Get hostname of the current Toolforge host.
+
+    @return: The hostname of the currently running host,
+             if it is in Wikimedia Toolforge; otherwise return None.
+    @rtype: str or None
+    """
+    if socket.getfqdn().endswith('.tools.eqiad.wmflabs'):
+        return socket.gethostname()
+    return None
+
+
 def getversion(online=True):
     """Return a pywikibot version string.
 
diff --git a/scripts/version.py b/scripts/version.py
index ad2ba84..9d7d26f 100755
--- a/scripts/version.py
+++ b/scripts/version.py
@@ -16,7 +16,7 @@
 
 import pywikibot
 
-from pywikibot.version import getversion
+from pywikibot.version import getversion, get_toolforge_hostname
 
 try:
     import requests
@@ -67,6 +67,11 @@
 
     pywikibot.output('Python: %s' % sys.version)
 
+    toolforge_env_hostname = get_toolforge_hostname()
+    if toolforge_env_hostname:
+        pywikibot.output('Toolforge hostname: {0}'.format(
+            toolforge_env_hostname))
+
     check_environ('PYWIKIBOT2_DIR')
     check_environ('PYWIKIBOT2_DIR_PWB')
     check_environ('PYWIKIBOT2_NO_USER_CONFIG')

-- 
To view, visit https://gerrit.wikimedia.org/r/394998
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: If5d390253dedfb92486a05741c3a7e773c008b2c
Gerrit-PatchSet: 5
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Rafidaslam <[email protected]>
Gerrit-Reviewer: John Vandenberg <[email protected]>
Gerrit-Reviewer: Rafidaslam <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: Zhuyifei1999 <[email protected]>
Gerrit-Reviewer: Zoranzoki21 <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to