jenkins-bot has submitted this change and it was merged.
Change subject: Code improvements for daemonize.py
......................................................................
Code improvements for daemonize.py
- Using "with" statement for opening files
- Fixing documentation
Change-Id: I1f825f58dc0931a9bff3fa107997b1d3e68742bd
---
M pywikibot/daemonize.py
1 file changed, 14 insertions(+), 10 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/daemonize.py b/pywikibot/daemonize.py
index d8c050a..918ee97 100644
--- a/pywikibot/daemonize.py
+++ b/pywikibot/daemonize.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""Module to daemonize the current process on Unix."""
#
-# (C) Pywikibot team, 2007-2013
+# (C) Pywikibot team, 2007-2015
#
# Distributed under the terms of the MIT license.
#
@@ -10,6 +10,7 @@
import os
import sys
+import codecs
is_daemon = False
@@ -19,13 +20,16 @@
Daemonize the current process.
Only works on POSIX compatible operating systems.
- The process will fork to the background and return control to the terminal.
+ The process will fork to the background and return control to 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
+ @param close_fd: Close the standard streams and replace them by /dev/null
+ @type close_fd: bool
+ @param chdir: Change the current working directory to /
+ @type chdir: bool
+ @param write_pid: Write the pid to sys.argv[0] + '.pid'
+ @type write_pid: bool
+ @param redirect_std: Filename to redirect stdout and stdin to
+ @type redirect_std: str
"""
# Fork away
if not os.fork():
@@ -54,9 +58,9 @@
return
else:
# Write out the pid
- f = open(os.path.basename(sys.argv[0]) + '.pid', 'w')
- f.write(str(pid))
- f.close()
+ path = os.path.basename(sys.argv[0]) + '.pid'
+ with codecs.open(path, 'w', 'utf-8') as f:
+ f.write(str(pid))
os._exit(0)
else:
# Exit to return control to the terminal
--
To view, visit https://gerrit.wikimedia.org/r/211029
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I1f825f58dc0931a9bff3fa107997b1d3e68742bd
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
Build Update for wikimedia/pywikibot-core
-------------------------------------
Build: #2225
Status: Errored
Duration: 44 minutes and 25 seconds
Commit: 932b5be (master)
Author: xqt
Message: Updated pywikibot/core
Project: pywikibot/i18n 096906d2c0aa6297ca7a3d954a39c415c3414fd4
[IMPROV] Additional edit summary for syntax correction
Edit summary when the bot corrects the syntax of a <references /> tag
Change-Id: Ia10f70985e9b4fb687467e7a7d906b36e202bbd8
View the changeset: https://github.com/wikimedia/pywikibot-core/compare/8f6501a726ff...932b5be1…
View the full build log and details: https://travis-ci.org/wikimedia/pywikibot-core/builds/62575367
--
You can configure recipients for build notifications in your .travis.yml file. See http://docs.travis-ci.com/user/notifications