77import os
88import copy
99import io
10- import syslog
1110import pkg_resources
11+ import six
12+ import syslog
1213
1314from trac .core import TracError
1415from trac .env import Environment
2930
3031logtag = __name__ .split ('.' )[- 1 ]
3132logname = "user.log"
32- syslog .openlog (logtag , syslog .LOG_PID , syslog .LOG_USER )
33+ syslog .openlog (str ( logtag ) , syslog .LOG_PID , syslog .LOG_USER )
3334
3435class Command (BaseCommand ):
3536 help = "Create group wikis for WGs, RGs and Areas which don't have one."
@@ -64,9 +65,10 @@ def do_cmd(self, cmd, *args):
6465 else :
6566 self .note ("Running %s %s ..." % (os .path .basename (cmd ), " " .join (quoted_args )))
6667 command = [ cmd , ] + list (args )
68+ command = ' ' .join (command ).encode ('utf-8' )
6769 code , out , err = pipe (command )
68- out = out .decode ()
69- err = err .decode ()
70+ out = out .decode ('utf-8' )
71+ err = err .decode ('utf-8' )
7072 msg = None
7173 if code != 0 :
7274 msg = "Error %s: %s when executing '%s'" % (code , err , " " .join (command ))
@@ -88,9 +90,8 @@ def create_svn(self, svn):
8890 return msg
8991 err , out = self .svn_admin_cmd ("create" , svn )
9092 if err :
91- msg = "Error %s creating svn repository %s:\n %s" % (err , svn , out )
92- self .log (msg )
93- return msg
93+ self .log (err )
94+ return err
9495 return ""
9596
9697 # --- trac ---
@@ -137,8 +138,8 @@ def add_default_wiki_pages(self, env):
137138 name = unicode_unquote (name .encode ('utf-8' ))
138139 if os .path .isfile (filename ):
139140 self .note (" Adding page %s" % name )
140- with io .open (filename ) as file :
141- text = file .read (). decode ( 'utf-8' )
141+ with io .open (filename , encoding = 'utf-8' ) as file :
142+ text = file .read ()
142143 self .add_wiki_page (env , name , text )
143144
144145 def add_custom_wiki_pages (self , group , env ):
@@ -208,7 +209,7 @@ def create_group_trac(self, group):
208209 sect , key , val = options [i ]
209210 val = val .format (** group .__dict__ )
210211 options [i ] = sect , key , val
211- # Try to creat ethe environment, remove unwanted defaults, and add
212+ # Try to create the environment, remove unwanted defaults, and add
212213 # custom pages and settings.
213214 if self .dummy_run :
214215 self .note ("Would create Trac for group '%s' at %s" % (group .acronym , group .trac_dir ))
@@ -327,13 +328,13 @@ def handle(self, *filenames, **options):
327328 self .svn_dir_pattern = options .get ('svn_dir_pattern' , settings .TRAC_SVN_DIR_PATTERN )
328329 self .group_list = options .get ('group_list' , None )
329330 self .dummy_run = options .get ('dummy_run' , False )
330- self .wiki_dir_pattern = os .path .join (settings .BASE_DIR , '..' , self .wiki_dir_pattern )
331+ self .wiki_dir_pattern = os .path .join (str ( settings .BASE_DIR ), str ( '..' ) , self .wiki_dir_pattern )
331332 self .svn_dir_pattern = os .path .join (settings .BASE_DIR , '..' , self .svn_dir_pattern )
332333
333334 if not self .group_list is None :
334335 self .group_list = self .group_list .split ('.' )
335336
336- if isinstance (self .verbosity , ( type ( "" ), type ( "" )) ) and self .verbosity .isdigit ():
337+ if isinstance (self .verbosity , six . string_types ) and self .verbosity .isdigit ():
337338 self .verbosity = int (self .verbosity )
338339
339340 if self .dummy_run and self .verbosity < 2 :
0 commit comments