jenkins-bot has submitted this change and it was merged.
Change subject: Import daemonize from compat
......................................................................
Import daemonize from compat
Minor pep changes.
Bug: T89581
Change-Id: I8daac25c55ad4961b75641b44edbd218760d9186
---
A pywikibot/daemonize.py
M tox.ini
2 files changed, 64 insertions(+), 0 deletions(-)
Approvals:
John Vandenberg: Looks good to me, but someone else must approve
Ladsgroup: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/daemonize.py b/pywikibot/daemonize.py
new file mode 100644
index 0000000..d0b5ae5
--- /dev/null
+++ b/pywikibot/daemonize.py
@@ -0,0 +1,63 @@
+# -*- coding: utf-8 -*-
+"""Module to daemonize the current process on Unix."""
+#
+# (C) Pywikibot team, 2007-2013
+#
+# Distributed under the terms of the MIT license.
+#
+__version__ = '$Id$'
+#
+
+import os
+import sys
+
+is_daemon = False
+
+
+def daemonize(close_fd=True, chdir=True, write_pid=False, redirect_std=None):
+ """
+ Daemonize the current process.
+
+ Only works on POSIX compatible operating systems.
+ The process will fork to the background and return control to the terminal.
+
+ Arguments:
+ - close_fd: Close the standard streams and replace them by /dev/null
+ - chdir: Change the current working directory to /
+ - write_pid: Write the pid to sys.argv[0] + '.pid'
+ - redirect_std: Filename to redirect stdout and stdin to
+ """
+ # Fork away
+ if not os.fork():
+ # Become session leader
+ os.setsid()
+ # Fork again to prevent the process from acquiring a
+ # controlling terminal
+ pid = os.fork()
+ if not pid:
+ global is_daemon
+ is_daemon = True
+
+ if close_fd:
+ os.close(0)
+ os.close(1)
+ os.close(2)
+ os.open('/dev/null', os.O_RDWR)
+ if redirect_std:
+ os.open(redirect_std, os.O_WRONLY | os.O_APPEND)
+ else:
+ os.dup2(0, 1)
+ os.dup2(1, 2)
+ if chdir:
+ os.chdir('/')
+ return
+ else:
+ # Write out the pid
+ f = open(os.path.basename(sys.argv[0]) + '.pid', 'w')
+ f.write(str(pid))
+ f.close()
+ os._exit(0)
+ else:
+ # Exit to return control to the terminal
+ # os._exit to prevent the cleanup to run
+ os._exit(0)
diff --git a/tox.ini b/tox.ini
index da80421..80ee993 100644
--- a/tox.ini
+++ b/tox.ini
@@ -42,6 +42,7 @@
pywikibot/comms/rcstream.py \
pywikibot/compat/ \
pywikibot/config2.py \
+ pywikibot/daemonize.py \
pywikibot/data/__init__.py \
pywikibot/data/api.py \
pywikibot/data/wikistats.py \
--
To view, visit https://gerrit.wikimedia.org/r/190696
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I8daac25c55ad4961b75641b44edbd218760d9186
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: btongminh <bryan.tongminh(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] TerminalHandler: Expect str in Python 2
......................................................................
[FIX] TerminalHandler: Expect str in Python 2
The args of a record are str in Python 2 (so basically bytes). It now
compared the str with unicode which works in Python 3 (as both are the
same there) or Python 2 if the warning message contains only ASCII
characters.
With 1e54a7d6 unicode_literals was added to the module which changed the
strings into unicode in Python 2. And Python converts the string into
unicode when it tries to do a __contains__ test. It decodes it using
ASCII which fails when there are non-ASCII characters in the string.
Bug: T98955
Change-Id: Ia421c085897e14e01a59e3c2a14822b2a7cd0ddd
---
M pywikibot/userinterfaces/terminal_interface_base.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/userinterfaces/terminal_interface_base.py b/pywikibot/userinterfaces/terminal_interface_base.py
index 968a14b..c4468e3 100755
--- a/pywikibot/userinterfaces/terminal_interface_base.py
+++ b/pywikibot/userinterfaces/terminal_interface_base.py
@@ -491,7 +491,7 @@
msg = record.args[0]
is_useless_source_output = any(
s in msg for s in
- ('warn(', 'exceptions.', 'Warning)', 'Warning,'))
+ (str('warn('), str('exceptions.'), str('Warning)'), str('Warning,')))
if is_useless_source_output:
record.args = ('\n'.join(record.args[0].splitlines()[0:-1]),)
--
To view, visit https://gerrit.wikimedia.org/r/210681
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia421c085897e14e01a59e3c2a14822b2a7cd0ddd
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [IMPROV] Fix the summary line in generate_user_files for user-fixes.py
......................................................................
[IMPROV] Fix the summary line in generate_user_files for user-fixes.py
Also update some doc strings and code parts from core.
Change-Id: Iac59759cbd08ff373879db0cddc3a333c5e4d9d2
---
M generate_user_files.py
1 file changed, 8 insertions(+), 7 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/generate_user_files.py b/generate_user_files.py
index d51f0fa..741f9fd 100644
--- a/generate_user_files.py
+++ b/generate_user_files.py
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
-""" Script to create user files (user-config.py, user-fixes.py) """
+"""Script to create user files (user-config.py, user-fixes.py)."""
#
-# (C) Pywikibot team, 2008-2013
+# (C) Pywikibot team, 2008-2015
#
-# Distributed under the terms of the MIT license
+# Distributed under the terms of the MIT license.
#
__version__ = '$Id$'
#
@@ -54,6 +54,7 @@
def file_exists(filename):
+ """Return whether the file exists and print a message if it exists."""
if os.path.exists(filename):
print("'%s' already exists." % filename)
return True
@@ -149,10 +150,11 @@
def create_user_fixes(base_dir):
+ """Create a basic user-fixes.py in base_dir."""
_fnf = os.path.join(base_dir, "user-fixes.py")
if not file_exists(_fnf):
- f = codecs.open(_fnf, "w", "utf-8")
- f.write(r"""# -*- coding: utf-8 -*-
+ with codecs.open(_fnf, "w", "utf-8") as f:
+ f.write(r"""# -*- coding: utf-8 -*-
#
# This is only an example. Don't use it.
@@ -161,7 +163,7 @@
fixes['example'] = {
'regex': True,
'msg': {
- '_default':u'no summary specified',
+ '_default': u'no summary specified',
},
'replacements': [
(ur'\bword\b', u'two words'),
@@ -169,7 +171,6 @@
}
""")
- f.close()
print("'%s' written." % _fnf)
--
To view, visit https://gerrit.wikimedia.org/r/210866
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iac59759cbd08ff373879db0cddc3a333c5e4d9d2
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/compat
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Disable cleanUpLinks in cosmetic_changes.py in Persian language wikis
......................................................................
Disable cleanUpLinks in cosmetic_changes.py in Persian language wikis
Community thinks this function has too many issues.
I do this upon request of User:Yamaha5
The discussion is here: http://bit.ly/1KMVZ7J
Change-Id: I4f40c7a89a6fd698009a6290e18948e3924f4f78
---
M cosmetic_changes.py
1 file changed, 4 insertions(+), 0 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/cosmetic_changes.py b/cosmetic_changes.py
index b15c226..4a9f528 100644
--- a/cosmetic_changes.py
+++ b/cosmetic_changes.py
@@ -377,6 +377,10 @@
def cleanUpLinks(self, text):
# helper function which works on one link and either returns it
# unmodified, or returns a replacement.
+ if self.site.sitename() != u'wikipedia:fa':
+ # Per community discussion, this one is not allowed in fa.wp
+ return
+
def handleOneLink(match):
titleWithSection = match.group('titleWithSection')
label = match.group('label')
--
To view, visit https://gerrit.wikimedia.org/r/206775
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I4f40c7a89a6fd698009a6290e18948e3924f4f78
Gerrit-PatchSet: 4
Gerrit-Project: pywikibot/compat
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>