Repository: dmwm/wmcore
Issue: MSOutput crashes initializing Rucio

**Impact of the bug**
ReqMgr2MS - MSOutput

**Describe the bug**
Once updated the ms-output configuration to:
```
data.defaultDataManSys = "Rucio"
```

the ms-output service fails to get started. Traceback will be provided below.

**How to reproduce it**
Deploy reqmgr2ms with tag HG2007h and start MSOutput.

**Expected behavior**
The service should start without any problems, nothing else ;)

**Additional context and error message**
Traceback from ms-output logs in vocms0731
```
...
2020-07-03 13:35:32,866:WARNING:MongoDB: Collection '('msOutRelValColl', <pymongo.operations.IndexModel object at 0x7feb0e6674b0>)' Already exists in database 'msOutDB'
2020-07-03 13:35:32,868:WARNING:MongoDB: Collection '('msOutNonRelValColl', <pymongo.operations.IndexModel object at 0x7feb0e6674b0>)' Already exists in database 'msOutDB'
2020-07-03 13:35:32,868:INFO:Rucio: WMCore Rucio initialization with acct: wma_test, host: None, auth: None and these extra parameters: {'auth_type': None, 'account': 'wma_test', 'timeout': 600, 'ca_cert': None, 'rucio_host': None, 'auth_
host': None, 'creds': None, 'user_agent': 'wmcore-client'}
2020-07-03 13:35:32,869:DEBUG:baseclient: no auth_type passed. Trying to get it from the environment variable RUCIO_AUTH_TYPE and config file.
2020-07-03 13:35:32,869:DEBUG:baseclient: no creds passed. Trying to get it from the config file.
2020-07-03 13:35:32,870:DEBUG:baseclient: no ca_cert passed. Trying to get it from the config file.
2020-07-03 13:35:32,870:DEBUG:baseclient: get a new token
2020-07-03 13:35:32,874:DEBUG:connectionpool: Starting new HTTPS connection (1): cmsrucio-auth-int.cern.ch:443
2020-07-03 13:35:32,988:DEBUG:connectionpool: https://cmsrucio-auth-int.cern.ch:443 "GET /auth/x509 HTTP/1.1" 401 126
Traceback (most recent call last):
  File "/data/srv/beHG2007h/sw/slc7_amd64_gcc630/cms/reqmgr2ms/0.2.6.pre6/bin/wmc-httpd", line 3, in <module>
    main()
  File "/data/srv/beHG2007h/sw/slc7_amd64_gcc630/cms/reqmgr2ms/0.2.6.pre6/lib/python2.7/site-packages/WMCore/REST/Main.py", line 596, in main
    server.start_daemon()
  File "/data/srv/beHG2007h/sw/slc7_amd64_gcc630/cms/reqmgr2ms/0.2.6.pre6/lib/python2.7/site-packages/WMCore/REST/Main.py", line 426, in start_daemon
    traceback.print_exc(file=trace)
  File "/data/srv/beHG2007h/sw/slc7_amd64_gcc630/external/python/2.7.13-comp/lib/python2.7/traceback.py", line 233, in print_exc
    print_exception(etype, value, tb, limit, file)
  File "/data/srv/beHG2007h/sw/slc7_amd64_gcc630/external/python/2.7.13-comp/lib/python2.7/traceback.py", line 124, in print_exception
    _print(file, 'Traceback (most recent call last):')
  File "/data/srv/beHG2007h/sw/slc7_amd64_gcc630/external/python/2.7.13-comp/lib/python2.7/traceback.py", line 13, in _print
    file.write(str+terminator)
TypeError: unicode argument expected, got 'str'
[03/Jul/2020:13:35:33]  WATCHDOG: server exited with exit code 1
```

Changed files:
src/python/WMCore/REST/Main.py

diff --git a/src/python/WMCore/REST/Main.py b/src/python/WMCore/REST/Main.py
index 42887d2f3..357657bb7 100644
--- a/src/python/WMCore/REST/Main.py
+++ b/src/python/WMCore/REST/Main.py
@@ -20,7 +20,7 @@ import thread
 import time
 import traceback
 from argparse import ArgumentParser
-from io import StringIO
+from io import BytesIO, StringIO
 from glob import glob
 from subprocess import Popen, PIPE
 from pprint import pformat
@@ -422,7 +422,10 @@ class RESTDaemon(RESTMain):
             self.run()
         except Exception as e:
             error = True
-            trace = StringIO()
+            if sys.version_info[0] == 2:
+                trace = BytesIO()
+            else:
+                trace = StringIO()
             traceback.print_exc(file=trace)
             cherrypy.log("ERROR: terminating due to error: %s" % trace.getvalue())