Default encoding has to be set on multiprocess instances of gam (#416)

* Default encoding has to be set on multiprocess instances of gam

* Update documentation
This commit is contained in:
Ross Scroggs
2017-02-03 10:02:31 -08:00
committed by Jay Lee
parent 9b89492d83
commit 2a1d3a1ce1
2 changed files with 14 additions and 4 deletions

View File

@@ -308,6 +308,8 @@ Named items
ipwhitelisted|
isdelegatedadmin|admin|isadmin|
ismailboxsetup|
is2svenforced|
is2svenrolled|
lastlogintime|
noneditablealiases|aliases|nicknames|
notes|note|

View File

@@ -9810,7 +9810,7 @@ def run_batch(items):
pool = Pool(processes=num_worker_threads)
sys.stderr.write(u'done with commit-batch\n')
continue
pool.apply_async(ProcessGAMCommand, [item])
pool.apply_async(ProcessGAMCommandMulti, [item])
pool.close()
pool.join()
@@ -9886,6 +9886,16 @@ def runCmdForUsers(cmd, users, default_to_batch=False, **kwargs):
else:
cmd(users, **kwargs)
def resetDefaultEncodingToUTF8():
if sys.getdefaultencoding().upper() != u'UTF-8':
reload(sys)
if hasattr(sys, u'setdefaultencoding'):
sys.setdefaultencoding(u'UTF-8')
def ProcessGAMCommandMulti(args):
resetDefaultEncodingToUTF8()
ProcessGAMCommand(args)
# Process GAM command
def ProcessGAMCommand(args):
if args != sys.argv:
@@ -10614,14 +10624,12 @@ if sys.platform.startswith('win'):
# Run from command line
if __name__ == "__main__":
resetDefaultEncodingToUTF8()
if sys.platform.startswith('win'):
freeze_support()
reload(sys)
if sys.version_info[:2] != (2, 7):
print u'ERROR: GAM requires Python 2.7. You are running %s.%s.%s. Please upgrade your Python version or use one of the binary GAM downloads.' % sys.version_info[:3]
sys.exit(5)
if hasattr(sys, u'setdefaultencoding'):
sys.setdefaultencoding(u'UTF-8')
if sys.platform.startswith('win'):
win32_unicode_argv() # cleanup sys.argv on Windows
sys.exit(ProcessGAMCommand(sys.argv))