John Vandenberg has uploaded a new change for review.
https://gerrit.wikimedia.org/r/172202
Change subject: Use envvar EDITOR if it exists
......................................................................
Use envvar EDITOR if it exists
EDITOR is usually set on Unix platforms to be a basic editor.
Use this as the default editor, if set, even on Windows.
Set EDITOR in the script tests to be a noop (like /bin/true) so
the script continues. 'editarticle' and 'upload' can now be tested.
Change-Id: I8a069960d0919c760441538c0ac0d11d1015bf01
---
M pywikibot/config2.py
M pywikibot/editor.py
M tests/script_tests.py
3 files changed, 10 insertions(+), 8 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core
refs/changes/02/172202/1
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index e24ebca..3cf1608 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -337,6 +337,7 @@
# ############# EXTERNAL EDITOR SETTINGS ##############
# The command for the editor you want to use. If set to None, a simple Tkinter
# editor will be used.
+editor = os.environ.get('EDITOR', None)
# On Windows systems, this script tries to determine the default text editor.
if sys.platform == 'win32':
try:
@@ -350,15 +351,13 @@
_key2 = _winreg.OpenKey(_winreg.HKEY_CLASSES_ROOT,
'%s\shell\open\command' % _progID)
_cmd = _winreg.QueryValueEx(_key2, None)[0]
- editor = _cmd.replace('%1', '')
+ _cmd = _cmd.replace('%1', '')
# Notepad is even worse than our Tkinter editor.
- if editor.lower().endswith('notepad.exe'):
- editor = None
+ if not _cmd.lower().endswith('notepad.exe'):
+ editor = _cmd
except WindowsError:
# Catch any key lookup errors
- editor = None
-else:
- editor = None
+ pass
# Warning: DO NOT use an editor which doesn't support Unicode to edit pages!
# You will BREAK non-ASCII symbols!
diff --git a/pywikibot/editor.py b/pywikibot/editor.py
index 440dadc..0243717 100644
--- a/pywikibot/editor.py
+++ b/pywikibot/editor.py
@@ -54,7 +54,7 @@
command += " -n%i" % (line + 1) # seems not to support columns
command += ' %s' % tempFilename
- #print command
+ pywikibot.log(u'Running editor: %s' % command)
return command
def convertLinebreaks(self, text):
diff --git a/tests/script_tests.py b/tests/script_tests.py
index d575a66..7332737 100644
--- a/tests/script_tests.py
+++ b/tests/script_tests.py
@@ -55,7 +55,6 @@
unrunnable_script_list = [
'script_wui', # depends on lua compiling
- 'editarticle', # requires a X DISPLAY
]
deadlock_script_list = [
@@ -212,6 +211,10 @@
return stream
env = os.environ.copy()
env['PYTHONPATH'] = ":".join(sys.path)
+ if sys.platform == 'win32':
+ env['EDITOR'] = 'call'
+ else:
+ env['EDITOR'] = 'true'
options = {
'stdout': subprocess.PIPE,
'stderr': subprocess.PIPE
--
To view, visit https://gerrit.wikimedia.org/r/172202
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8a069960d0919c760441538c0ac0d11d1015bf01
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits