AndyTechGuy has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/264218

Change subject: Add extra test to reinforce -nolog argument
......................................................................

Add extra test to reinforce -nolog argument

Log files are sometimes created under special circumstances even when
the -nolog argument is set. For instances where 'logoutput' is called
before args are parsed, add an extra test in order to prevent log files
from being created.

Bug: T56897
Change-Id: I0277bd5019da95aa50a149b6b3ff2960c2283ef1
---
M pywikibot/bot.py
1 file changed, 17 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/18/264218/1

diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index 80905bf..03f2b9d 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -1089,22 +1089,23 @@
 
     This can be used by user later to track errors or report bugs.
     """
-    modname = calledModuleName()
-    # put quotation marks around all parameters
-    args = [modname] + [u'"%s"' % s for s in pywikibot.argvu[1:]]
-    command_log_filename = config.datafilepath('logs', 'commands.log')
-    try:
-        command_log_file = codecs.open(command_log_filename, 'a', 'utf-8')
-    except IOError:
-        command_log_file = codecs.open(command_log_filename, 'w', 'utf-8')
-    # add a timestamp in ISO 8601 formulation
-    isoDate = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
-    command_log_file.write('%s r%s Python %s '
-                           % (isoDate, version.getversiondict()['rev'],
-                              sys.version.split()[0]))
-    s = u' '.join(args)
-    command_log_file.write(s + os.linesep)
-    command_log_file.close()
+    moduleName = calledModuleName()
+    if moduleName in config.log:
+        # put quotation marks around all parameters
+        args = [moduleName] + [u'"%s"' % s for s in pywikibot.argvu[1:]]
+        command_log_filename = config.datafilepath('logs', 'commands.log')
+        try:
+            command_log_file = codecs.open(command_log_filename, 'a', 'utf-8')
+        except IOError:
+            command_log_file = codecs.open(command_log_filename, 'w', 'utf-8')
+        # add a timestamp in ISO 8601 formulation
+        isoDate = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
+        command_log_file.write('%s r%s Python %s '
+                               % (isoDate, version.getversiondict()['rev'],
+                                  sys.version.split()[0]))
+        s = u' '.join(args)
+        command_log_file.write(s + os.linesep)
+        command_log_file.close()
 
 
 def open_webbrowser(page):

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0277bd5019da95aa50a149b6b3ff2960c2283ef1
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: AndyTechGuy <andytechd...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to